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:Timothy Wall (twal@dev.java.net)
Date:Nov 1, 2008 5:04:05 am
List:net.java.dev.jna.users

On Nov 1, 2008, at 4:46 AM, thex@email.com wrote:

Included it, now I get an return value, but all values in that structure are 0. Tried the same with C# and there the returned structure got values. So I am still doing something wrong. When I output the recieved object it looks like:

FFaceApi$INVENTORYITEM$ByValue(allocated@0x2e22690 (4 bytes)) { short id@0=0 byte index@2=0 byte count@3=0 }

To me that looks quite okay despite that id should carrry the value 17567.

What else can I try to get a properly set structure as return value?

One other thing to look at is to ensure that your inputs to GetInventoryItem are correct. What do the docs say might cause the structure to be zero-filled?

The cause of the reported access violation was not forced by calling GetInventoryItem. Before this i do a function call for:

FFACE_API void GetItemNameByID(short index, void *buffer, int *size, DWORD PID = 0 );

Strange about it is, that depending upon the mapping I do get or not get an access violation. The mapping causing it looks like this:

void GetItemNameByID(short index, PointerByReference buffer, IntByReference size, int PID);

That function returns properly the string I expect by just using buffer.getPointer().getString(0) but the next call (which likely is GetInventoryItem) crashes.

By changing the mapping to

void GetItemNameByID(short index, byte buffer[], IntByReference size, int PID);

I still get the same text but the crash does not occur anymore.

A PointerByReference is equivalent to "void **", not "void *". The latter mapping is the correct one, although you should probably be sure that your IntByReference is initialized to the size of your buffer to avoid overflow.