Skip to content

Instantly share code, notes, and snippets.

@netmindz
Created March 3, 2011 18:49
Show Gist options
  • Save netmindz/853267 to your computer and use it in GitHub Desktop.
Save netmindz/853267 to your computer and use it in GitHub Desktop.
Buffer JNA issue
// C++ header
extern "C" __declspec(dllexport) int __stdcall API_USBMF_Request(
HANDLE commHandle, int DeviceAddress,
unsigned char inf_mode, unsigned char *Buffer);
// Java - Returns a single byte, which I think is a valid result
public int API_USBMF_Request(HANDLE commHandle, int DeviceAddress, char inf_mode, ByteByReference Buffer);
// Java - No change to byte array
public int API_USBMF_Request(HANDLE commHandle, int DeviceAddress, char inf_mode, byte[] Buffer);
@netmindz
Copy link
Author

netmindz commented Mar 3, 2011

Not sure what the jna ByReference does, but byte[] definitely doesn't work

@netmindz
Copy link
Author

netmindz commented Mar 3, 2011

Any ideas why using Pointer.getString() failed with access exception, weridly using IntByReferernce returns values, though quite what this number is when what I want is a String I'm not sure. Some native thing ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment