Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] how to open a HANDLE with a WiFi card

From: "Joshua (Shiwei) Zhao" <swzhao@xxxxxxxxx>
Date: Thu, 18 Jun 2009 16:43:51 -0700
Hi there,
 

With Wireshark, I'm trying to modify it to send NDIS requests to a wifi card driver on windows OS. To do this I need to call CreateFile() and pass a string of device name to it.  However, what exactly a device name should I pass?

I have the following device name, e.g.

\Device\NPF_{4C2DF402-629E-4C4B-B0A9-CF5A85D1DED4}

and device description:

XXXX Wireless Network Adapter (Microsoft's Packet Scheduler)

 

In some sample code I can find I see people adding a prefix '\\\\.\\' to device name.  Is

\\.\\Device\NPF_{4C2DF402-629E-4C4B-B0A9-CF5A85D1DED4} what I should use?  I tried it but still got an invalid handle.  So what exact string I should pass in this example?

 

Here is the code I'm calling:

HANDLE hFile = CreateFile((LPCTSTR)tmp,
     GENERIC_READ,
     FILE_SHARE_READ | FILE_SHARE_WRITE,
     NULL,
     OPEN_EXISTING,
     FILE_ATTRIBUTE_READONLY,
     NULL);

 

Many thanks,

Joshua