Using BridJ in 32 bit mode in 64 bit application

15 views
Skip to first unread message

Jens Lideström

unread,
Apr 12, 2018, 7:22:32 PM4/12/18
to NativeLibs4Java
I'm trying to use BridJ in a way that I'm not sure whether it is supported:

I have a 64 bit application. I get a byte array containing the memory of a 32 bit application through a debugger interface.

I'd like to use BridJ to parse the content of this byte array as C datatypes. I do this by using Pointer.pointerToBytes().as(my_struct.class).get()
. This technique works in a 32 bit application. But in a 64 bit application it does not, because BridJ uses the word size of the host application (64 bit) and I want to use the word size of the byte array (32 bit).

Can that be done? Is it possible to somehow switch the word size of BridJ manually, so that BridJ uses 32 bit words, even if it is run in a 64 bit application?

Longer example of what I'm trying to do

    byte[] objData = debugger.readMemory(remoteStructAddr, BridJ.sizeOf(c_struct.class));
    c_struct s
= Pointer.pointerToBytes(objData).as(c_struct.class).get();
   
int structMem = s.member();

   
byte[] namePtr = debugger.readMemory(removePtr + StructObject.offsetOfField(new c_struct(), "name"), 4);
   
String name = debugger.readString(namePtr);

Some More Details

* I use JNAerator to generate the BridJ classes
* I've tied to use the JNAerator -arch flag, but it doesn't seem to do what I want.
* I don't use a native library together with BridJ, I just use BridJ to read byte arrays that I get with the debugger API.
Reply all
Reply to author
Forward
0 new messages