2 messages in net.java.dev.jna.usersRe: [jna-users] Windows BOOL, BYTE ar...
FromSent OnAttachments
bb...@cox.netAug 3, 2007 8:15 am 
Timothy WallAug 3, 2007 8:27 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Windows BOOL, BYTE are what?Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Aug 3, 2007 8:27:13 am
List:net.java.dev.jna.users

On Aug 3, 2007, at 11:16 AM, bbc2 wrote:

So, how would I write the JNA for this C function out of a Windows .dll? BOOL DLLEXPORT f( BYTE *a, short b, long c, BYTE d, BOOL e);

I tried int f( byte[] a, short b, int c, byte d, int e); but that crashed HotSpot.

DLLEXPORT is apparently either __declspec(dllexport) or __declspec (dllimport) I'm not sure what BOOL and BYTE are, but guess they are some standard Windows thing. I guess that's my first problem. Anybody know?

Look up their definitions on MSDN or the visual C header files. BOOL is an int (java int), BYTE is a signed char (java byte). If you look at W32TypeMapper you can see how to automatically translate a Java boolean into its native equivalent (Integer), so you can use boolean instead of int.

However, what you've mapped should work and not crash the VM; are you using StdCallLibrary if the dll uses the __stdcall calling convention (usually this shows up as some macro like "WINAPI" or "WINUSERAPI" or some such cruft)?

Also make sure that the native code doesn't run off the end of your byte array.