| From | Sent On | Attachments |
|---|---|---|
| Мария Попова | Jun 10, 2009 3:09 am | |
| Timothy Wall | Jun 10, 2009 3:46 am |
| Subject: | Re: [jna-dev] Structure array in Structure | |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Jun 10, 2009 3:46:03 am | |
| List: | net.java.dev.jna.dev | |
On Jun 10, 2009, at 6:10 AM, Мария Попова wrote:
Hello, i have a problem: I have WinApi Structure:
typedef struct _CERT_CHAIN_CONTEXT {
DWORD cbSize; CERT_TRUST_STATUS TrustStatus; DWORD cChain; PCERT_SIMPLE_CHAIN * rgpChain; DWORD cLowerQualityChainContext; PCCERT_CHAIN_CONTEXT *rgpLowerQualityChainContext;
BOOL fHasRevocationFreshnessTime; DWORD dwRevocationFreshnessTime; }CERT_CHAIN_CONTEXT, *PCERT_CHAIN_CONTEXT;
And msdn tells that PCERT_SIMPLECHAIN* is "An array of pointers to simple chain structures" How to map it correctly? I've tried this way:
public class CERT_CHAIN_CONTEXT extends Structure implements Structure.ByReference { public DWORD cbSize; public CERT_TRUST_STATUS TrustStatus; public DWORD cChain; public CERT_SIMPLE_CHAIN[] rgpChain; public DWORD cLowerQualityChainContext; public CERT_CHAIN_CONTEXT rgpLowerQualityChainContext; public boolean fHasRevocationFreshnessTime; public DWORD dwRevocationFreshnessTime; }
but it doesn't work. Does CERT_SIMPLE_CHAIN must be Structure.BeReference?
Must be Structure.ByReference or Pointer from Structure.getPointer(). Use Structure.toArray() to obtain the contiguously allocated array. Note that you will need to manually call Structure.write() after making changes to any elements after the first one, and Structure.read() in order to pick up any changes made by the native code.





