Bonjour,
Je travail actuellement avec JNA afin de toucher à la wlanapi (Wifi de windows).
Struct c :
typedef struct _WLAN_INTERFACE_INFO {
GUID InterfaceGuid;
WCHAR strInterfaceDescription[WLAN_MAX_NAME_LENGTH];
WLAN_INTERFACE_STATE isState;
} WLAN_INTERFACE_INFO, *PWLAN_INTERFACE_INFO;
typedef struct _WLAN_INTERFACE_INFO_LIST {
DWORD dwNumberOfItems;
DWORD dwIndex;
#ifdef __midl
[unique, size_is(dwNumberOfItems)] WLAN_INTERFACE_INFO InterfaceInfo[*];
#else
WLAN_INTERFACE_INFO InterfaceInfo[1];
#endif
} WLAN_INTERFACE_INFO_LIST, *PWLAN_INTERFACE_INFO_LIST;
Fonction C :
DWORD WINAPI WlanEnumInterfaces(
_In_ HANDLE hClientHandle,
_Reserved_ PVOID pReserved,
_Out_ PWLAN_INTERFACE_INFO_LIST *ppInterfaceList
);
En java :
La fct :
public int WlanEnumInterfaces(Pointer hClientHandle, Pointer pReserved, PWlanInterfaceInfoList ppInterfaceList);
public class PWlanAvailableNetworkList extends Structure{
public static class ByReference extends PWlanAvailableNetworkList implements Structure.ByReference {}
public WlanAvailableNetworkList.ByReference WlanAvailableNetworkList;
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "WlanAvailableNetworkList"});
}
};
public class WlanInterfaceInfoList extends Structure {
public static class ByReference extends WlanInterfaceInfoList implements Structure.ByReference {
}
public int dwNumberOfItems;
public int dwIndex;
public WlanInterfaceInfo InterfaceInfo[] = new WlanInterfaceInfo[10];
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwNumberOfItems", "dwIndex", "InterfaceInfo" });
}
}
Le problème c'est la ligne que j'ai mi en rouge.
En effet, JNA va allouer automatiquement 10 structs de type WlanInterfaceInfo. Or, c'est la fonction WlanenumInterface qui devrait définir l'allocation à faire !
Donc je suis coincé. En plus, ses allocations peuvent me placer dans une zone mémoire interdite ce qui génère une jolie petite exception !
Quelqu'un a t'il déjà été confronté à ça ?
Ref API wlanapi : http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
Partager