Enumerating Wifi access points on Windows Mobile

The other day, I wanted to get the list of all the nearby wireless access points in C++ on a Windows Mobile 6 terminal. After a few hours spent digging on Google, I realized that was trickier that it seemed and not as easy as on other platforms.

Here is what I had to do:

  1. Enumerate all network adapters with GetAdaptersInfo(),
  2. For each adapter, consider only the ones with a MIB_IF_TYPE_ETHERNET type,
  3. Open the NDIS device (UIO1:) and issue a IOCTL_NDISUIO_NIC_STATISTICS ioctl on it, in order to get the physical medium type of the adapter, and consider anly those with a NdisPhysicalMediumWirelessLan medium,
  4. Each time I want to initiate a scan, issue OID_802_11_BSSID_LIST_SCAN and OID_802_11_BSSID_LIST_SCAN ioctls on the UIO1: device.

Here is the code, packaged into a CWifi class:

  • wifi.h header file
  • wifi.cpp source file
  • wifi.txt, with md5, sha1 and sha256 signatures for the above two files.
Powered by Blogger.