I’m trying to convert this function to JNA:
DWORD WINAPI WlanHostedNetworkSetProperty(
__in HANDLE hClientHandle,
__in WLAN_HOSTED_NETWORK_OPCODE OpCode,
__in DWORD dwDataSize,
__in PVOID pvData,
__out_opt PWLAN_HOSTED_NETWORK_REASON pFailReason,
__reserved PVOID pvReserved
);
As I have now:
int WlanHostedNetworpSetProperty(HANDLE hClientHandle, IntByReference OpCode,int dwDataSize, Pointer pvData, IntByReference pFailReason, Pointer pvReserved);
Which should be right.
However when OpCode is wlan_hosted_network_opcode_enable, aka 3, it wants the pvData to be BOOL. I read that BOOL is an integer, but doing pvData.setInteger(1) will crash the application. Any help would be great.
The crash is an EXCEPTION_ACCESS_VIOLATION.
According to MSDN, when the
OpCodeiswlan_hosted_network_opcode_enable:Note that it’s a pointer to
BOOL, not an actualBOOLvalue, that is needed.As you found, changing to an
IntByReferencesolved the problem, likely because anintandBOOLare the same size on your platform, and because now you’re passing a valid pointer.