[CRYPTEXT] Add a minimal shell extension that will show the certificate dialog

This commit is contained in:
Mark Jansen 2019-02-09 01:44:39 +01:00
parent 27cc4c6a08
commit fb7a0344cd
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
6 changed files with 105 additions and 0 deletions

View file

@ -76,6 +76,10 @@ HKCR,"batfile\DefaultIcon","",0x00020000,"%SystemRoot%\system32\shell32.dll,-153
HKCR,"batfile\shell\edit\command","",0x00020000,"%SystemRoot%\system32\notepad.exe ""%1"""
HKCR,"batfile\shell\open\command","",0x00000000,"""%1"" %*"
; Certificate
HKCR,".cer","",0x00000000,"cerfile"
HKCR,"cerfile\shell\open\command","",0x00020000,"%SystemRoot%\system32\rundll32.exe cryptext.dll,CryptExtOpenCER %1"
; ReactOS Command Script Files
HKCR,".cmd","",0x00000000,"cmdfile"
HKCR,"cmdfile","",0x00000000,"ReactOS Command Script"

View file

@ -1,5 +1,6 @@
add_subdirectory(acppage)
add_subdirectory(cryptext)
add_subdirectory(deskadp)
add_subdirectory(deskmon)
add_subdirectory(devcpux)

View file

@ -0,0 +1,17 @@
spec2def(cryptext.dll cryptext.spec)
list(APPEND SOURCE
cryptext.c
precomp.h)
add_library(cryptext SHARED
${SOURCE}
cryptext.spec
${CMAKE_CURRENT_BINARY_DIR}/cryptext.def)
set_module_type(cryptext win32dll UNICODE)
target_link_libraries(cryptext uuid)
add_importlibs(cryptext cryptui crypt32 user32 msvcrt kernel32 ntdll)
add_pch(cryptext precomp.h SOURCE)
add_cd_file(TARGET cryptext DESTINATION reactos/system32 FOR all)

View file

@ -0,0 +1,63 @@
/*
* 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"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
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))
{
CRYPTUI_VIEWCERTIFICATE_STRUCT CertViewInfo = {0};
CertViewInfo.dwSize = sizeof(CertViewInfo);
CertViewInfo.pCertContext = pvContext;
CryptUIDlgViewCertificate(&CertViewInfo, NULL);
CertFreeCertificateContext(pvContext);
}
else
{
MessageBoxW(NULL, L"This is not a valid certificate", NULL, MB_OK);
}
}
}
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);
}
}
}

View file

@ -0,0 +1,2 @@
@ stdcall CryptExtOpenCER(ptr ptr str long)
@ stdcall CryptExtOpenCERW(ptr ptr wstr long)

View file

@ -0,0 +1,18 @@
#ifndef CRYPTEXT_PRECOMP_H
#define CRYPTEXT_PRECOMP_H
#define COBJMACROS
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#define NTOS_MODE_USER
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#include <wincrypt.h>
#include <winuser.h>
#include <cryptuiapi.h>
#endif /* CRYPTEXT_PRECOMP_H */