#include #include #include int IFilter = 0; BOOL FILTER(PCCERT_CONTEXT pccert, long, DWORD, DWORD) { switch (IFilter) { case 1: return TRUE; case 2: return (pccert->pCertInfo->dwVersion == 0); } return TRUE; } void PrintUsage() { printf("test options are:\n"); printf(" -h print help\n"); printf(" -A open AddressBook cert store\n"); printf(" -C open CA cert store\n"); printf(" -M open My cert store\n"); printf(" -R open ROOT cert store\n"); printf(" -F# filter number to apply\n"); printf(" 1 - view all certs\n"); printf(" 2 - view V1 certs only\n"); printf(" -S open cert store\n"); } int __cdecl main(int argc, char * argv[]) { BOOL fWide = FALSE; HCERTSTORE hcertstor = NULL; int i; PCCERT_CONTEXT pccert = NULL; char * szPurposeOid = "1.3.6.1.5.5.7.3.4"; for (i=1; i 0) { css.pfnFilter = FILTER; } else { css.pfnFilter = NULL; } css.szHelpFileName = L"Help File"; css.dwHelpId = 100; if (CertSelectCertificateW(&css)) { CERT_VIEWPROPERTIES_STRUCT_W cvp; memset(&cvp, 0, sizeof(cvp)); cvp.dwSize = sizeof(cvp); cvp.pCertContext = pccert; cvp.dwFlags |= CM_SHOW_HELP; cvp.cArrayPurposes = 1; cvp.arrayPurposes = (LPSTR *) &css.szPurposeOid; cvp.szHelpFileName = L"Help File"; cvp.dwHelpId = 100; CertViewPropertiesW(&cvp); } } else { CERT_SELECT_STRUCT_A css = {0}; css.dwSize = sizeof(css); css.szPurposeOid = szPurposeOid; css.hwndParent = NULL; css.hInstance = NULL; css.pTemplateName = NULL; css.dwFlags = CSS_SHOW_HELP; css.szTitle = NULL; css.cCertStore = 1; css.arrayCertStore = &hcertstor; css.cCertContext = 0; css.arrayCertContext = &pccert; css.lCustData = 0; css.pfnHook = NULL; if (IFilter > 0) { css.pfnFilter = FILTER; } else { css.pfnFilter = NULL; } css.szHelpFileName = "Help File"; css.dwHelpId = 100; if (CertSelectCertificateA(&css)) { CERT_VIEWPROPERTIES_STRUCT_A cvp; memset(&cvp, 0, sizeof(cvp)); cvp.dwSize = sizeof(cvp); cvp.pCertContext = pccert; cvp.dwFlags |= CM_SHOW_HELP; cvp.cArrayPurposes = 1; cvp.arrayPurposes = (LPSTR *) &css.szPurposeOid; cvp.szHelpFileName = "Help File"; cvp.dwHelpId = 100; CertViewPropertiesA(&cvp); } } return 0; }