

![]() | 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: |
1 message in net.java.dev.jna.users[jna-users] Re: [jna-dev] Structure a...| From | Sent On | Attachments |
|---|---|---|
| Timothy Wall | Jun 12, 2009 5:25 am |

![]() | 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: | [jna-users] Re: [jna-dev] Structure array in structure again | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Jun 12, 2009 5:25:42 am | |
| List: | net.java.dev.jna.users | |
On Jun 12, 2009, at 3:22 AM, Мария Попова wrote:
Hello, thanks for the help you've given. Now i cannot exactly understand how to map structure with array of structures.
Example:
WinApi function returns to me CRL_INFO structure: typedef struct _CRL_INFO { DWORD dwVersion; CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm; CERT_NAME_BLOB Issuer; FILETIME ThisUpdate; FILETIME NextUpdate; DWORD cCRLEntry; PCRL_ENTRY rgCRLEntry; DWORD cExtension; PCERT_EXTENSION rgExtension; }CRL_INFO, *PCRL_INFO;
where PCRL_ENTRY rgCRLEntry is "Array of pointers to CRL_ENTRY structures. Each of these structures represents a revoked certificate"
Your documentation doesn't match your type declaration. An array of pointers to CRL_ENTRY would be
PCRL_ENTRY rgCRLEntry[]; // alternatively CRL_ENTRY *rgCRLEntry[];
A pointer to an array of pointers would be declared like this:
PCRL_ENTRY *rgCRLEntry;
Your existing declaration is either a pointer to a single structure, or a pointer to a block of them. In either case, your field would need to be of Structure.ByReference type, assigned with the first element in the array returned by Structure.toArray().
My mapping is:
public class CRL_INFO extends Structure { public DWORD dwVersion; public CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm; public CRYPT_BIT_BLOB Issuer; public Pointer ThisUpdate; public Pointer NextUpdate; public DWORD cCrlEntry; public CRL_ENTRY rgCRLEntry; public DWORD cExtension; public Pointer rgExtension; }
public class CRL_ENTRY extends Structure implements Structure.ByReference { public CRYPT_BIT_BLOB SerialNumber; public Pointer RevocationDate; public DWORD cExtension; public Pointer rgExtension; }
But when function returns me CRL_INFO the CRL_ENTRY field is null. You said to use Structure.toArray but i cannot understand how to use it.
Thanks
If your native function is filling in the data, then you don't need to worry about populating it. If rgCRLEntry is null, that means the native function gave you a NULL pointer in place of the array, which probably means there are no CRL entries.
When you *do* get something there, you can access additional entries (assuming they're allocated in a block) by invoking toArray(cCrlEntry) on the rgCrlEntry field.







