JNA中怎么模拟这个结构体,解决再加分!!急!!!!!!
typedef struct _PCI_COMMON_CONFIG {
USHORT VendorID;
USHORT DeviceID;
USHORT Command;
USHORT Status;
UCHAR RevisionID;
UCHAR ProgIf;
UCHAR SubClass;
UCHAR BaseClass;
UCHAR CacheLineSize;
UCHAR LatencyTimer;
UCHAR HeaderType;
UCHAR BIST;
union {
struct {
ULONG BaseAddresses[6];
ULONG Reserved1[2];
ULONG ROMBaseAddress;
ULONG Reserved2[2];
UCHAR InterruptLine;
UCHAR InterruptPin;
UCHAR MinimumGrant;
UCHAR MaximumLatency;
} type0;
} u;
UCHAR DeviceSpecific[192];
} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
其中
typedef unsigned short USHORT;
typedef unsigned char UCHAR;
typedef unsigned long ULONG;
这个结构体在java中怎么对应?我用的JNA,急~~~~~~~~~~~
[最优解释]
你直接把这个structure当成一个byte[]来处理吧
[其他解释]
mark,学习,帮顶
[其他解释]
先在C里面把PCI_COMMON_CONFIG sizeof一下,看看多少个byte,就在JAVA里面 new byte[size]。
你自己心里得清楚这个数组中每个字节对应的PCI_COMMON_CONFIG中的属性。
[其他解释]
谢谢帮顶的大家,我用的是JNA,直接调用dll,不用自己写dll文件了~~~
看了网上的参考资料,我对应的java部分如下:
public static class pciConfig extends Structure {
public static class ByReference extends pciConfig implements
Structure.ByReference {
}
public static class ByValue extends pciConfig implements
Structure.ByValue {
}
public short VendorID;
public short DeviceID;
public short Command;
public short Status;
public byte RevisionID;
public byte ProgIf;
public byte SubClass;
public byte BaseClass;
public byte CacheLineSize;
public byte LatencyTimer;
public byte HeaderType;
public byte BIST;
public static class type0 extends Structure {
public static class ByReference extends type0 implements
Structure.ByReference {
}
public static class ByValue extends type0 implements
Structure.ByValue {
}
public NativeLong[] BaseAddresses = new NativeLong[3];
public NativeLong[] Reserved1 = new NativeLong[2];
public NativeLong ROMBaseAddress;
public NativeLong[] Reserved2 = new NativeLong[2];
public byte InterruptLine;
public byte InterruptPin;
public byte MinimumGrant;
public byte MaximumLatency;
}
public static class union extends Union {
public static class ByReference extends union implements
Union.ByReference {
}
public static class ByValue extends union implements Union.ByValue {
}
public type0 typ;
}
public union u;
public byte[] DeviceSpecific = new byte[192];
}