

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

![]() | 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] Re: Mapping Struct to Java | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Nov 5, 2008 7:00:34 pm | |
| List: | net.java.dev.jna.users | |
On Nov 5, 2008, at 6:22 PM, thex...@email.com wrote:
Hi Tim
Just trying to eliminate variables.
Thats one of the best approaches. ^^
You should be able to target either dll simply by changing the name passed to the loadLibrary call, and pass the dll name as an argument to main. That ensures that the java environment is identical in both cases.
Used this construct:
FFaceApi fface = null; Native.setProtected(true); for (int j=0; j < 7; j++) { fface = (FFaceApi) Native.loadLibrary( flipFlop ? "Test2" : "FFACE", FFaceApi.class); System.out.println(">>> "+(flipFlop ? "Test2" : "FFACE") +" "+fface.GetInventoryItem(1, 0)); }
When GetInventoryItem() returns a struct, the test2.dll returns steadily a properly filled structure while fface.dll returns random values. Changing GetInventoryItem()'s signature to return int's both dll deliver steadily the right value.
If one works and the other doesn't, then there must be something peculiar about the fface dll.
So, given these test results your conclusion is that there is something wrong with FFACE.dll?
*something* is different between the DLLs.
Dumb question: Does the evaluation of structure contents work aswell if the data is coming from another process? Saying process A is producing data, fface.dll is accessing that process and delivering data from there to Process B. No idea why it should work with int then, but just asking.
Well, a stack-allocated struct passed by address could go out of scope, while an integer value would just be copied around. But you'd need to be a bit more descriptive of your data paths and players; I can't guess from what you've said so far.
Normally, the function call will copy its struct return value into an address provided by the caller as a hidden argument (often just the first thing pushed on the stack). For structs that fit within a register, the caller may just copy from the normal return value register. Or both things might happen. There might be flags to the VC ++ compiler that alter what it does with small structs, and maybe your test and real dlls are compiled with different options.
Other than that, the difference between JNA and your C code is the dynamic linkage. The function is looked up by name and invoked via function pointer. If invoked with a cast to the function pointer, the compiler will figure out what convention it needs to use to capture the struct return value. JNA uses libffi, which uses custom assembly to configure the stack and extract the return value.







