So as an overview, I am working with the Wlanapi and I am fairly new to it (native apis in general). I am running into a problem converting a structure from c++ to c#. Right now I have:
Original:
typedef struct _WLAN_BSS_LIST {
DWORD dwTotalSize;
DWORD dwNumberOfItems;
WLAN_BSS_ENTRY wlanBssEntries[1];
} WLAN_BSS_LIST, *PWLAN_BSS_LIST;
Conversion:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
struct WLAN_BSS_LIST
{
internal uint dwTotalSize;
internal uint dwNumberOfItems;
internal WLAN_BSS_ENTRY[] wlanBssEntries;
internal WLAN_BSS_LIST(IntPtr ppBssList)
{
dwNumberOfItems = (uint)Marshal.ReadInt32(ppBssList);
//I need to set the value of dwTotalSize but I dunno how
wlanBssEntries = new WLAN_BSS_ENTRY[dwNumberOfItems];
for (int i = 0; i < dwNumberOfItems; i++)
{
IntPtr pWlanBssEntry = new IntPtr(ppBssList.ToInt32() + i *
Marshal.SizeOf(typeof(WLAN_BSS_ENTRY)) + 8);
wlanBssEntries[i] = (WLAN_BSS_ENTRY)Marshal.
PtrToStructure(pWlanBssEntry,
typeof(WLAN_BSS_ENTRY));
}
}
}
I just don't know how to get the total size of the array referenced by ppBssList
:(
As an fyi, I will be extremely disappointed if someone points me to an existing library.
Edited to add original struct