Wifi Intermediate Driver DLL for Windows Mobile

For what it's worth, I have packaged a small "Wifi Intermediate Driver" into a DLL for Windows Mobile 5 (both PocketPC and Smartphone are supported) and 6 (Standard and Professional editions are both supported).

The library allows you to scan for nearby Wifi access points using the provided WifiOpen(), WifiClose() and WifiEnumerate() easy-to-use functions instead of zillions of fastidious and bug-prone DeviceIOControl() calls on a network adapter driver.

It was modeled after the GPS intermediate driver provided by Microsoft, and shares the same KISS approach but applies it to Wifi discovery.

The archive contains the header and source files of the DLL in unmanaged C++, as well as a small managed class in C# for using it from a .Net application.

It is not complete in anyway, as it does only what I need it to do, ie retrieving the HMAC address and the signal strength of currently available infrastructure 802.1x access points. The SSID is not retrieved but that's easy to implement once you understand the rest of the code.

1 comment

jcayzac said...

I just noticed a small bug in my managed C# sample code available under the csharp directory in the archive.
It's a potential leak problem here:

IntPtr buffer = Utils.LocalAlloc(800);
...Call to WifiEnumerate() and Enqueue() loop...
Utils.LocalFree(buffer);

If either WifiEnumerate() or Enqueue() call throws an exception, the unmanaged buffer won't be freed, and our app will leak 800 bytes!

The fix is quite easy:

IntPtr buffer = Utils.LocalAlloc(800);
try
{
...Call to WifiEnumerate() and Enqueue() loop...
}
finally
{
Utils.LocalFree(buffer);
}

Powered by Blogger.