24 messages in net.java.dev.jna.usersRe: [jna-users] Re: Mapping Struct to...
FromSent OnAttachments
thex...@email.comNov 1, 2008 1:46 am 
Timothy WallNov 1, 2008 5:04 am 
thex...@email.comNov 1, 2008 8:40 am 
Timothy WallNov 1, 2008 11:14 am 
Timothy WallNov 1, 2008 11:17 am 
thex...@email.comNov 2, 2008 12:30 am 
Timothy WallNov 2, 2008 7:42 am 
thex...@email.comNov 3, 2008 2:02 am 
Timothy WallNov 3, 2008 3:49 am 
thex...@email.comNov 3, 2008 4:51 am 
Timothy WallNov 3, 2008 6:22 am 
thex...@email.comNov 3, 2008 7:47 am 
Timothy WallNov 3, 2008 8:21 am 
thex...@email.comNov 3, 2008 11:19 pm 
Timothy WallNov 4, 2008 5:33 am 
Timothy WallNov 4, 2008 5:34 am 
thex...@email.comNov 4, 2008 2:33 pm 
Timothy WallNov 5, 2008 5:44 am 
thex...@email.comNov 5, 2008 8:15 am 
Timothy WallNov 5, 2008 9:19 am 
thex...@email.comNov 5, 2008 3:22 pm 
Timothy WallNov 5, 2008 7:00 pm 
thex...@email.comNov 6, 2008 3:36 am 
thex...@email.comNov 6, 2008 10:55 pm 
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] Re: Mapping Struct to JavaActions...
From:thex...@email.com (thex@email.com)
Date:Nov 3, 2008 2:02:06 am
List:net.java.dev.jna.users

Hi

Another week, another run. =)

The information should be in the C# file. You can also use the "depends.exe" tool, which shows you function names and dll dependencies.

Yeah, the C# was quite readable. Used depends to verify what i read in C#
before. Thanx for the hint. I love depends out of the box.

You can't compile a struct-by-value return without the full structure definition -- the compiler implicitly copies the return value (usually by passing the called function the address of the struct memory to which to write).

Sorry, I didn't get that. It sounds to me that the struct definition must be
exported to dll aswell. Which infact depends shows its not. But with my poor knowledge of
things going on really way down I guess I just missed the point.

There may be a bug in returning struct values of small size; you can verify this by making your own DLL function with identical signature to the original, but which returns known values in the struct. Alternatively you could declare the function as returning "int" and extracting the fields manually (if this works, it would suggest a bug in libffi's handling of small structs on w32).

With a huge effort I managed to write a VC++ dll that exactly does like you suggested. Calling that dll from C# and VC itself returns the expected values. With JNA I get a Access Violation, with Native.setProtected(true) I get an Invalid memory access at at com.sun.jna.Pointer._getShort(). Changing the JNA definition to return an int instead of the structure returns an int consisting of the right values. I will have to verify this behaviour with the real dll still, but it looks promising and shows off the troubles I encountered quite well.

Can you verify JNA accordingly and report any bug to libffi?

If a memory fault occurs with setProtected(true), you should be getting an exception rather than having the function return.

Not sure on why it is behaving differently. I am still using the PointerByReference instead of byte[] for string buffers. Gonna remove that and check it once more.

Regards, Armin