public class CRYPT_INTEGER_BLOB extends Structure {
public int cbData;
public Pointer pbData;
public CRYPT_INTEGER_BLOB() {
super();
}
protected List<? > getFieldOrder() {
return Arrays.asList("cbData", "pbData");
}
/** @param pbData C type : BYTE* */
public CRYPT_INTEGER_BLOB(int cbData, Pointer pbData) {
super();
this.cbData = cbData;
this.pbData = pbData;
}
public CRYPT_INTEGER_BLOB(Pointer peer) {
super(peer);
}
protected ByReference newByReference() { return new ByReference(); }
protected ByValue newByValue() { return new ByValue(); }
protected CRYPT_INTEGER_BLOB newInstance() { return new CRYPT_INTEGER_BLOB(); }
//public static CRYPT_INTEGER_BLOB[] newArray(int arrayLength) {
// return Structure.newArray(CRYPT_INTEGER_BLOB.class, arrayLength);
//}
public static class ByReference extends CRYPT_INTEGER_BLOB implements Structure.ByReference {
};
public static class ByValue extends CRYPT_INTEGER_BLOB implements Structure.ByValue {
};
} int cbData@0=b4b000
Pointer pbData@8=native@0x3f394bdc111fdid newArray (see code above whitch is commented out) not exists in your JNA Structure class? it givesme the error that it does not exist? Sowhat is the up to date method?
Thanks and merry Christmas :)
public class CERT_CONTEXT extends Structure {
public int dwCertEncodingType;
public Pointer pbCertEncoded;
public int cbCertEncoded;
public CERT_INFO pCertInfo;
public HANDLE hCertStore;
public CERT_CONTEXT() {
super();
}
protected List<? > getFieldOrder() {
return Arrays.asList("dwCertEncodingType", "pbCertEncoded", "cbCertEncoded", "pCertInfo", "hCertStore");
}
/**
* @param pbCertEncoded C type : BYTE*<br>
* @param pCertInfo C type : PCERT_INFO<br>
* @param hCertStore C type : HCERTSTORE
*/
public CERT_CONTEXT(int dwCertEncodingType, Pointer pbCertEncoded, int cbCertEncoded, CERT_INFO pCertInfo, HANDLE hCertStore) {
super();
this.dwCertEncodingType = dwCertEncodingType;
this.pbCertEncoded = pbCertEncoded;
this.cbCertEncoded = cbCertEncoded;
this.pCertInfo = pCertInfo;
this.hCertStore = hCertStore;
}
public CERT_CONTEXT(Pointer peer) {
super(peer);
}
public static class ByReference extends CERT_CONTEXT implements Structure.ByReference {
};
public static class ByValue extends CERT_CONTEXT implements Structure.ByValue {
};
}public class CERT_INFO extends Structure {
public int dwVersion;
public CRYPT_INTEGER_BLOB SerialNumber;
public CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
public CRYPT_INTEGER_BLOB Issuer;
public FILETIME NotBefore;
public FILETIME NotAfter;
public CRYPT_INTEGER_BLOB Subject;
public CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo;
public CRYPT_BIT_BLOB IssuerUniqueId;
public CRYPT_BIT_BLOB SubjectUniqueId;
public int cExtension;
public int rgExtension;
public CERT_INFO() {
super();
read();
}
protected List<? > getFieldOrder() {
return Arrays.asList("dwVersion", "SerialNumber", "SignatureAlgorithm", "Issuer", "NotBefore", "NotAfter", "Subject", "SubjectPublicKeyInfo", "IssuerUniqueId", "SubjectUniqueId", "cExtension", "rgExtension");
}
public CERT_INFO(Pointer peer) {
super(peer);
read();
}
public static class ByReference extends CERT_INFO implements Structure.ByReference {};
public static class ByValue extends CERT_INFO implements Structure.ByValue {};
}public interface WindowsLibrary extends Crypt32 {
/** Opens a certificate store using a specified store provider type.
* <pre>
* HCERTSTORE WINAPI CertOpenStore(
* _In_ LPCSTR lpszStoreProvider
* _In_ DWORD dwMsgAndCertEncodingType:
* _In_ HCRYPTPROV hCryptProv
* _In_ DWORD dwFlags
* _In_ const void* pvPara
* );
* </pre>
*
* For more Details visit: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa376559%28v=vs.85%29.aspx">MSDN - CertOpenStore</a>
*/
public int CertOpenStore(
int lpszStoreProvider,
int dwMsgAndCertEncodingType,
HANDLE hCryptProv,
int dwFlags,
String pvPara
);
/** Retrieves the first or next certificate in a certificate store. Used in a loop, this function can retrieve in sequence all certificates in a certificate store.
* <pre>
* PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(
* _In_ HCERTSTORE hCertStore
* _In_ PCCERT_CONTEXT pPrevCertContext
* );
* </pre>
*
* For more Details visit: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa376050%28v=vs.85%29.aspx">MSDN - CertEnumCertificatesInStore</a>
*/
public CERT_CONTEXT CertEnumCertificatesInStore(
int certStore,
CERT_CONTEXT certContext
);
WindowsLibrary INSTANCE = (WindowsLibrary) Native.loadLibrary("crypt32", WindowsLibrary.class);
}dwVersion in CERT_INFO Class.
This is my main:
int lpszStoreProvider = 9;
int dwMsgAndCertEncodingType = 0;
HANDLE hCryptProv = null;
int dwFlags = 65536|0x00004000;
String pvPara = "MY";
CERT_CONTEXT certContext = null;
int store = WindowsLibrary.INSTANCE.CertOpenStore(lpszStoreProvider, dwMsgAndCertEncodingType, hCryptProv, dwFlags, pvPara);
certContext = WindowsLibrary.INSTANCE.CertEnumCertificatesInStore(store, certContext);
System.out.println(certContext.pCertInfo.dwVersion);
Here my output is a digital number like: 8577168. But the expected output should be 3 (because it is a Certificate with Version V3) Maybe a V2 Version, so Output should be 2. But i did not get this Output.
CERT_INFO(native@0xf9a898) (200 bytes) {
int dwVersion@0=faef70
CRYPT_INTEGER_BLOB SerialNumber@8=CRYPT_INTEGER_BLOB(native@0xf9a8a0) (16 bytes) {
int cbData@0=f96350
Pointer pbData@8=null
}
CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm@18=CRYPT_ALGORITHM_IDENTIFIER(native@0xf9a8b0) (24 bytes) {
WTypes$LPSTR pszObjId@0=null
CRYPT_INTEGER_BLOB Parameters@8=CRYPT_INTEGER_BLOB(native@0xf9a8b8) (16 bytes) {
int cbData@0=7c3016f4
Pointer pbData@8=native@0xf9a760
}
}
CRYPT_INTEGER_BLOB Issuer@30=CRYPT_INTEGER_BLOB(native@0xf9a8c8) (16 bytes) {
int cbData@0=ffffffff
Pointer pbData@8=native@0xffffffff
}
WinBase$FILETIME NotBefore@40=WinBase$FILETIME(native@0xf9a8d8) (8 bytes) {
int dwLowDateTime@0=0
int dwHighDateTime@4=0
}
WinBase$FILETIME NotAfter@48=WinBase$FILETIME(native@0xf9a8e0) (8 bytes) {
int dwLowDateTime@0=0
int dwHighDateTime@4=0
}
CRYPT_INTEGER_BLOB Subject@50=CRYPT_INTEGER_BLOB(native@0xf9a8e8) (16 bytes) {
int cbData@0=20007d0
Pointer pbData@8=null
}
CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo@60=CERT_PUBLIC_KEY_INFO(native@0xf9a8f8) (48 bytes) {
CRYPT_ALGORITHM_IDENTIFIER Algorithm@0=CRYPT_ALGORITHM_IDENTIFIER(native@0xf9a8f8) (24 bytes) {
WTypes$LPSTR pszObjId@0=null
CRYPT_INTEGER_BLOB Parameters@8=CRYPT_INTEGER_BLOB(native@0xf9a900) (16 bytes) {
int cbData@0=39c
Pointer pbData@8=native@0x44400
}
}
CRYPT_BIT_BLOB PublicKey@18=CRYPT_BIT_BLOB(native@0xf9a910) (24 bytes) {
int cbData@0=0
Pointer pbData@8=null
int cUnusedBits@10=f9a950
}
}
CRYPT_BIT_BLOB IssuerUniqueId@90=CRYPT_BIT_BLOB(native@0xf9a928) (24 bytes) {
int cbData@0=0
Pointer pbData@8=null
int cUnusedBits@10=0
}
CRYPT_BIT_BLOB SubjectUniqueId@a8=CRYPT_BIT_BLOB(native@0xf9a940) (24 bytes) {
int cbData@0=0
Pointer pbData@8=native@0xc00ba4a7c3016f4
int cUnusedBits@10=3a0043
}
int cExtension@c0=650073
int rgExtension@c4=730072
}
memory dump
[70effa00]
[00000000]
[5063f900]
[00000000]
[00000000]
[00000000]
[00000000]
[00000000]
[f416307c]
[4aba0010]
[60a7f900]
[00000000]
[ffffffff]
[ffffffff]
[ffffffff]
[00000000]
[00000000]
[00000000]
[00000000]
[00000000]
[d0070002]
[00000000]
[00000000]
[00000000]
[00000000]
[00000000]
[9c030000]
[00000000]
[00440400]
[00000000]
[00000000]
[00000000]
[00000000]
[00000000]
[50a9f900]
[00000000]
[00000000]
[00000000]
[00000000]
[00000000]
[00000000]
[00000000]
[00000000]
[00000000]
[f416307c]
[4aba000c]
[43003a00]
[5c005500]
[73006500]
[72007300]public class CRYPT_INTEGER_BLOB extends Structure {
public int cbData;
/** C type : BYTE* */
public Pointer pbData;
public CRYPT_INTEGER_BLOB() {
super();
read();
}
protected List<? > getFieldOrder() {
return Arrays.asList("cbData", "pbData");
}
/** @param pbData C type : BYTE* */
public CRYPT_INTEGER_BLOB(int cbData, Pointer pbData) {
super();
this.cbData = cbData;
this.pbData = pbData;
}
public CRYPT_INTEGER_BLOB(Pointer peer) {
super(peer);
read();
}
public static class ByReference extends CRYPT_INTEGER_BLOB implements Structure.ByReference {};
public static class ByValue extends CRYPT_INTEGER_BLOB implements Structure.ByValue {};
}