2019-02-09 00:44:39 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS CryptExt Shell Extension
|
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
|
|
* PURPOSE: cryptext implementation
|
|
|
|
* COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
2019-02-10 16:57:43 +00:00
|
|
|
HINSTANCE g_hInstance;
|
2019-02-09 00:44:39 +00:00
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
switch (dwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2019-02-10 16:57:43 +00:00
|
|
|
g_hInstance = hInstance;
|
2019-02-09 00:44:39 +00:00
|
|
|
DisableThreadLibraryCalls(hInstance);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTERN_C
|
|
|
|
VOID WINAPI CryptExtOpenCERW(HWND hWnd, HINSTANCE hInst, LPCWSTR file, DWORD nCmdShow)
|
|
|
|
{
|
|
|
|
PCCERT_CONTEXT pvContext;
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
if (CryptQueryObject(CERT_QUERY_OBJECT_FILE, file, CERT_QUERY_CONTENT_FLAG_CERT, CERT_QUERY_FORMAT_FLAG_ALL,
|
|
|
|
0, NULL, NULL, NULL, NULL, NULL, (CONST VOID**)&pvContext))
|
|
|
|
{
|
2019-02-10 16:57:43 +00:00
|
|
|
CRYPTUI_VIEWCERTIFICATE_STRUCTW CertViewInfo = {0};
|
2019-02-09 00:44:39 +00:00
|
|
|
CertViewInfo.dwSize = sizeof(CertViewInfo);
|
|
|
|
CertViewInfo.pCertContext = pvContext;
|
2019-02-10 16:57:43 +00:00
|
|
|
CryptUIDlgViewCertificateW(&CertViewInfo, NULL);
|
2019-02-09 00:44:39 +00:00
|
|
|
CertFreeCertificateContext(pvContext);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-10 16:57:43 +00:00
|
|
|
WCHAR Message[MAX_PATH];
|
|
|
|
|
|
|
|
if (LoadStringW(g_hInstance, IDS_INVALIDFILE, Message, MAX_PATH))
|
|
|
|
{
|
|
|
|
MessageBoxW(NULL, Message, NULL, MB_OK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MessageBoxW(NULL, L"This is not a valid certificate file.", NULL, MB_OK);
|
|
|
|
}
|
2019-02-09 00:44:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTERN_C
|
|
|
|
VOID WINAPI CryptExtOpenCER(HWND hWnd, HINSTANCE hInst, LPCSTR file, DWORD nCmdShow)
|
|
|
|
{
|
|
|
|
LPWSTR fileW;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0);
|
|
|
|
fileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (fileW)
|
|
|
|
{
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, len);
|
|
|
|
CryptExtOpenCERW(hWnd, hInst, fileW, nCmdShow);
|
|
|
|
HeapFree(GetProcessHeap(), 0, fileW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|