private void GetNDISAPs() { // Retrieve a list of NDIS_802_11_BSSID_LIST // structures from the driver. We'll parse that // list and populate ourselves based on the data // that we find there. string name = m_adapter.Name; byte[] data = NDISUIO.QueryOID(NDIS_OID.BSSID_LIST, name); if (data != null) { // Figure out how many SSIDs there are. NDIS_802_11_BSSID_LIST rawlist = new NDIS_802_11_BSSID_LIST(data, false); for (int i = 0; i < rawlist.NumberOfItems; i++) { // Get the next raw item from the list. BSSID bssid = rawlist.Item(i); // Using the raw item, create a cooked // SSID item. AccessPoint ssid = new AccessPoint(bssid); // Add the new item to this. m_aps.Add(ssid); } } else { throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), "Unable to get BSSID List"); } }
internal static List <IAccessPoint> GetAPs(string adapterName) { var apList = new List <IAccessPoint>(); INTF_ENTRY entry = new INTF_ENTRY(); entry.Guid = adapterName; INTF_FLAGS flags = 0; int result = WZCQueryInterface(null, INTF_FLAGS.INTF_ALL, ref entry, out flags); if (result != 0) { entry.Dispose(); throw new Exception("WZCQueryInterface failed for " + adapterName); } try { // Figure out how many SSIDs there are. if (entry.rdBSSIDList.cbData == 0) { // list is empty return(apList); } NDIS_802_11_BSSID_LIST rawlist = new NDIS_802_11_BSSID_LIST(entry.rdBSSIDList.lpData, true); for (int i = 0; i < rawlist.NumberOfItems; i++) { // Get the next raw item from the list. BSSID bssid = rawlist.Item(i); // Using the raw item, create a cooked // SSID item. AccessPoint ssid = new AccessPoint(bssid); // Add the new item to this. apList.Add(ssid); } return(apList); } finally { WZCDeleteIntfObj(ref entry); } }