OaIdl$SAFEARRAYBOUND(auto-allocated@0xf41290 (16 bytes)) {
WinDef$ULONG cElements@0=10
WinDef$LONG lLbound@8=0
}
memory dump
[0a000000]
[00000000]
[00000000]
[00000000]
I changed the class like that to be absolutely conform to the MS api:
public static class SAFEARRAYBOUND extends Structure {
public static class ByReference extends SAFEARRAYBOUND implements
Structure.ByReference {
}
public ULONG cElements;
public LONG lLbound;
public SAFEARRAYBOUND() {
}
public SAFEARRAYBOUND(Pointer pointer) {
super(pointer);
this.read();
}
public SAFEARRAYBOUND(int cElements, int lLbound) {
this.cElements = new ULONG(cElements);
this.lLbound = new LONG(lLbound);
this.write();
}
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cElements", "lLbound" });
}
}
How are arrays of structures handled by JNA api?
For example I have:
SAFEARRAYBOUND[] rgsabound = new SAFEARRAYBOUND[1];
rgsabound[0] = new SAFEARRAYBOUND(size, 0);
and when I take a look to the backing memory then I see that it is not being written to memory. Please explain why!
Which methods of the Structure class needs to be overwritten to solved that?
below is the code of the structure:
public static class SAFEARRAYBOUND extends Structure {
public static class ByReference extends SAFEARRAYBOUND implements
Structure.ByReference {
}
public int cElements;
public int lLbound;
public SAFEARRAYBOUND() {
}
public SAFEARRAYBOUND(int cElements, int lLbound) {
this.cElements = cElements;
this.lLbound = lLbound;
}
public SAFEARRAYBOUND(Pointer pointer) {
super(pointer);
}
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cElements", "lLbound" });
}
}