SOL9 Sample: CertSystemStoreDump
|
1 Screenshot
2 Source code
/*
* CertSystemStoreDump.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2009/04/08
#pragma once
#include <sol/crypt/CertSystemStore.h>
#include <sol/crypt/CertInfo.h>
#include <sol/crypt/CertSystemStoreEnum.h>
namespace SOL {
class CertSystemStoreDump : public CertSystemStoreEnum {
public:
CertSystemStoreDump()
:CertSystemStoreEnum()
{
}
protected:
/**
*/
//Override enumStore method in CertSystemStoreEnum
virtual BOOL enumStore(const void *pvSystemStore,
DWORD dwFlags,
PCERT_SYSTEM_STORE_INFO pStoreInfo)
{
const wchar_t* systemStore = (const wchar_t*)pvSystemStore;
const wchar_t* name = CryptFindLocalizedName(systemStore);
if (systemStore && wcslen(systemStore)>0 && name) {
char sysName[MAX_PATH];
size_t rsize;
wcstombs_s(&rsize, sysName, SizeOf(sysName), systemStore, sizeof(sysName));
printf("SysName=%s\n", sysName);
String string = sysName;
CertSystemStore sysStore((const TCHAR*)string);
PCCERT_CONTEXT pContext = NULL;
while ((pContext = sysStore.enumCertificate(pContext)) != NULL) {
DWORD dwData =0;
printf("============================================\n");
CertInfo certInfo(pContext->pCertInfo);
certInfo.dump();
printf("--------------------------------------------\n\n");
}
}
return TRUE;
}
};
}
void _tmain(int argc, TCHAR** argv)
{
printf("SystemStore Dump for CERT_SYSTEM_STORE_CURRENT_USER\n");
CertSystemStoreDump storeDump;
storeDump.enumerate(CERT_SYSTEM_STORE_CURRENT_USER);
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.