

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
3 messages in net.java.dev.jna.usersRe: [jna-users] Mapping Struct to Java| From | Sent On | Attachments |
|---|---|---|
| thex...@email.com | Oct 31, 2008 5:48 am | |
| Timothy Wall | Oct 31, 2008 6:26 am | |
| thex...@email.com | Oct 31, 2008 6:29 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] Mapping Struct to Java | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Oct 31, 2008 6:26:38 am | |
| List: | net.java.dev.jna.users | |
Your C function is returning a structure by value, therefore you need to declare a ByValue version of your structure.
class MyStructure extends Structure { public static ByValue extends MyStructure implements Structure.ByValue { } }
Then your function should return MyStructure.ByValue instead of MyStructure.
On Oct 31, 2008, at 8:48 AM, thex...@email.com wrote:
Hi
Currently doing my very first steps between the worlds of C and Java. I got a header file that features structs and function calls of a specific dll I would like to access from within Java. Due to my lacking knowledge of C I decided to use JNA for integration purposes.
The standard calls work by now, I even managed to figure out the special way that strings get treaten in C. But now I am stuck on this call and its corresponding struct:
FFACE_API INVENTORYITEM GetInventoryItem(int index, DWORD PID = 0);
struct INVENTORYITEM { short id; unsigned char index; unsigned char count; };
My java mapping looks like this:
public interface FFaceApix extends Library { FFaceApix INSTANCE = (FFaceApix) Native.loadLibrary("FFACE", FFaceApix.class);
INVENTORYITEM GetInventoryItem(int index, int PID); } public static class INVENTORYITEM extends com.sun.jna.Structure { public short id; public byte index; public byte count; }
When accessing the mapped function I get an 'EXCEPTION_ACCESS_VIOLATION'. After having read lots of posts and checking out the JNA api aswell as the other documentation I still can't manage to make this work.
What did I not take care of with my mapping?
Regards, Armin
-- See Exclusive Video: Hollywood Life's 5th Annual Style Awards http://www.hollywoodlife.net/Awards.aspx?AwardsID=style2008







