2024-01-13 11:33:10 -08:00
|
|
|
From e6c1c1fe3fe2f4fe7d3e421b94d925c40063af22 Mon Sep 17 00:00:00 2001
|
2019-07-10 15:58:48 -07:00
|
|
|
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
|
|
|
Date: Fri, 5 Jul 2019 13:20:23 +0800
|
|
|
|
Subject: [PATCH] cryptext: Implement CryptExtOpenCER.
|
|
|
|
|
|
|
|
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
|
|
|
|
---
|
2019-07-11 16:00:06 -07:00
|
|
|
configure | 1 +
|
2019-07-10 15:58:48 -07:00
|
|
|
configure.ac | 1 +
|
|
|
|
dlls/cryptext/Makefile.in | 3 +-
|
2021-03-02 18:22:19 -08:00
|
|
|
dlls/cryptext/cryptext.spec | 4 +--
|
|
|
|
dlls/cryptext/cryptext_main.c | 64 +++++++++++++++++++++++++++++++++
|
|
|
|
dlls/cryptext/tests/Makefile.in | 4 +++
|
|
|
|
dlls/cryptext/tests/cryptext.c | 61 +++++++++++++++++++++++++++++++
|
|
|
|
7 files changed, 135 insertions(+), 3 deletions(-)
|
2019-07-10 15:58:48 -07:00
|
|
|
create mode 100644 dlls/cryptext/tests/Makefile.in
|
|
|
|
create mode 100644 dlls/cryptext/tests/cryptext.c
|
|
|
|
|
2019-07-11 16:00:06 -07:00
|
|
|
diff --git a/configure b/configure
|
2024-01-13 11:33:10 -08:00
|
|
|
index ca6e87d4740..7033499399f 100755
|
2019-07-11 16:00:06 -07:00
|
|
|
--- a/configure
|
|
|
|
+++ b/configure
|
2024-01-13 11:33:10 -08:00
|
|
|
@@ -21660,6 +21660,7 @@ wine_fn_config_makefile dlls/crypt32/tests enable_tests
|
2019-07-11 16:00:06 -07:00
|
|
|
wine_fn_config_makefile dlls/cryptdlg enable_cryptdlg
|
|
|
|
wine_fn_config_makefile dlls/cryptdll enable_cryptdll
|
|
|
|
wine_fn_config_makefile dlls/cryptext enable_cryptext
|
|
|
|
+wine_fn_config_makefile dlls/cryptext/tests enable_tests
|
|
|
|
wine_fn_config_makefile dlls/cryptnet enable_cryptnet
|
|
|
|
wine_fn_config_makefile dlls/cryptnet/tests enable_tests
|
2022-09-20 16:19:11 -07:00
|
|
|
wine_fn_config_makefile dlls/cryptowinrt enable_cryptowinrt
|
2019-07-10 15:58:48 -07:00
|
|
|
diff --git a/configure.ac b/configure.ac
|
2024-01-13 11:33:10 -08:00
|
|
|
index cba55126869..57064a05fe5 100644
|
2019-07-10 15:58:48 -07:00
|
|
|
--- a/configure.ac
|
|
|
|
+++ b/configure.ac
|
2024-01-13 11:33:10 -08:00
|
|
|
@@ -2477,6 +2477,7 @@ WINE_CONFIG_MAKEFILE(dlls/crypt32/tests)
|
2019-07-10 15:58:48 -07:00
|
|
|
WINE_CONFIG_MAKEFILE(dlls/cryptdlg)
|
|
|
|
WINE_CONFIG_MAKEFILE(dlls/cryptdll)
|
|
|
|
WINE_CONFIG_MAKEFILE(dlls/cryptext)
|
|
|
|
+WINE_CONFIG_MAKEFILE(dlls/cryptext/tests)
|
|
|
|
WINE_CONFIG_MAKEFILE(dlls/cryptnet)
|
|
|
|
WINE_CONFIG_MAKEFILE(dlls/cryptnet/tests)
|
2022-09-20 16:19:11 -07:00
|
|
|
WINE_CONFIG_MAKEFILE(dlls/cryptowinrt)
|
2019-07-10 15:58:48 -07:00
|
|
|
diff --git a/dlls/cryptext/Makefile.in b/dlls/cryptext/Makefile.in
|
2024-01-13 11:33:10 -08:00
|
|
|
index 5598bfb78e0..acda4e4ac6d 100644
|
2019-07-10 15:58:48 -07:00
|
|
|
--- a/dlls/cryptext/Makefile.in
|
|
|
|
+++ b/dlls/cryptext/Makefile.in
|
|
|
|
@@ -1,4 +1,5 @@
|
|
|
|
-MODULE = cryptext.dll
|
|
|
|
+MODULE = cryptext.dll
|
|
|
|
+IMPORTS = crypt32 cryptui user32
|
|
|
|
|
2021-09-20 16:08:59 -07:00
|
|
|
EXTRADLLFLAGS = -Wb,--prefer-native
|
2019-07-10 15:58:48 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/cryptext/cryptext.spec b/dlls/cryptext/cryptext.spec
|
2021-09-20 16:08:59 -07:00
|
|
|
index ee3e155f457..24b4794c198 100644
|
2019-07-10 15:58:48 -07:00
|
|
|
--- a/dlls/cryptext/cryptext.spec
|
|
|
|
+++ b/dlls/cryptext/cryptext.spec
|
|
|
|
@@ -12,8 +12,8 @@
|
|
|
|
@ stub CryptExtAddSPCW
|
|
|
|
@ stub CryptExtOpenCAT
|
|
|
|
@ stub CryptExtOpenCATW
|
|
|
|
-@ stub CryptExtOpenCER
|
|
|
|
-@ stub CryptExtOpenCERW
|
|
|
|
+@ stdcall CryptExtOpenCER(long ptr str long)
|
|
|
|
+@ stdcall CryptExtOpenCERW(long ptr wstr long)
|
|
|
|
@ stub CryptExtOpenCRL
|
|
|
|
@ stub CryptExtOpenCRLW
|
|
|
|
@ stub CryptExtOpenCTL
|
|
|
|
diff --git a/dlls/cryptext/cryptext_main.c b/dlls/cryptext/cryptext_main.c
|
2022-09-20 16:19:11 -07:00
|
|
|
index 537ba66cd3b..a4314518eac 100644
|
2019-07-10 15:58:48 -07:00
|
|
|
--- a/dlls/cryptext/cryptext_main.c
|
|
|
|
+++ b/dlls/cryptext/cryptext_main.c
|
2021-03-02 18:22:19 -08:00
|
|
|
@@ -22,10 +22,29 @@
|
2019-07-10 15:58:48 -07:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
+#include "winnls.h"
|
|
|
|
+#include "wincrypt.h"
|
|
|
|
+#include "winuser.h"
|
|
|
|
+#include "cryptuiapi.h"
|
|
|
|
+
|
|
|
|
+#include "wine/heap.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(cryptext);
|
|
|
|
|
|
|
|
+static WCHAR *heap_strdupAtoW(const char *str)
|
|
|
|
+{
|
|
|
|
+ WCHAR *ret;
|
|
|
|
+ INT len;
|
|
|
|
+
|
|
|
|
+ if (!str) return NULL;
|
|
|
|
+ len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
|
|
|
+ ret = heap_alloc(len * sizeof(WCHAR));
|
|
|
|
+ if (ret)
|
|
|
|
+ MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
|
|
|
+ return ret;
|
|
|
|
+}
|
2021-02-22 17:57:13 -08:00
|
|
|
+
|
|
|
|
/***********************************************************************
|
|
|
|
* CryptExtAddPFX (CRYPTEXT.@)
|
|
|
|
*/
|
2021-03-02 18:22:19 -08:00
|
|
|
@@ -43,3 +62,48 @@ HRESULT WINAPI CryptExtAddPFXW(LPCWSTR filename)
|
2019-07-10 15:58:48 -07:00
|
|
|
FIXME("stub: %s\n", debugstr_w(filename));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+/***********************************************************************
|
|
|
|
+ * CryptExtOpenCERW (CRYPTEXT.@)
|
|
|
|
+ */
|
|
|
|
+HRESULT WINAPI CryptExtOpenCERW(HWND hwnd, HINSTANCE hinst, LPCWSTR filename, DWORD showcmd)
|
|
|
|
+{
|
|
|
|
+ PCCERT_CONTEXT ctx;
|
|
|
|
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW info;
|
|
|
|
+
|
2022-03-03 16:02:37 -08:00
|
|
|
+ TRACE("(%p, %p, %s, %lu)\n", hwnd, hinst, debugstr_w(filename), showcmd);
|
2019-07-10 15:58:48 -07:00
|
|
|
+
|
|
|
|
+ if (!CryptQueryObject(CERT_QUERY_OBJECT_FILE, filename, CERT_QUERY_CONTENT_FLAG_CERT,
|
|
|
|
+ CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
+ (const void **)&ctx))
|
|
|
|
+ {
|
|
|
|
+ /* FIXME: move to the resources */
|
|
|
|
+ static const WCHAR msg[] = {'T','h','i','s',' ','i','s',' ','n','o','t',' ','a',' ','v','a','l','i','d',' ','c','e','r','t','i','f','i','c','a','t','e',0};
|
|
|
|
+ MessageBoxW(NULL, msg, filename, MB_OK | MB_ICONERROR);
|
|
|
|
+ return S_OK; /* according to the tests */
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ memset(&info, 0, sizeof(info));
|
|
|
|
+ info.dwSize = sizeof(info);
|
|
|
|
+ info.pCertContext = ctx;
|
|
|
|
+ CryptUIDlgViewCertificateW(&info, NULL);
|
|
|
|
+ CertFreeCertificateContext(ctx);
|
|
|
|
+
|
|
|
|
+ return S_OK;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/***********************************************************************
|
|
|
|
+ * CryptExtOpenCER (CRYPTEXT.@)
|
|
|
|
+ */
|
|
|
|
+HRESULT WINAPI CryptExtOpenCER(HWND hwnd, HINSTANCE hinst, LPCSTR filename, DWORD showcmd)
|
|
|
|
+{
|
|
|
|
+ HRESULT hr;
|
|
|
|
+ LPWSTR filenameW;
|
|
|
|
+
|
2022-03-03 16:02:37 -08:00
|
|
|
+ TRACE("(%p, %p, %s, %lu)\n", hwnd, hinst, debugstr_a(filename), showcmd);
|
2019-07-10 15:58:48 -07:00
|
|
|
+
|
|
|
|
+ filenameW = heap_strdupAtoW(filename);
|
|
|
|
+ hr = CryptExtOpenCERW(hwnd, hinst, filenameW, showcmd);
|
|
|
|
+ heap_free(filenameW);
|
|
|
|
+ return hr;
|
|
|
|
+}
|
|
|
|
diff --git a/dlls/cryptext/tests/Makefile.in b/dlls/cryptext/tests/Makefile.in
|
|
|
|
new file mode 100644
|
2024-01-13 11:33:10 -08:00
|
|
|
index 00000000000..c3f4551fc00
|
2019-07-10 15:58:48 -07:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/dlls/cryptext/tests/Makefile.in
|
|
|
|
@@ -0,0 +1,4 @@
|
|
|
|
+TESTDLL = cryptext.dll
|
|
|
|
+
|
2024-01-13 11:33:10 -08:00
|
|
|
+SOURCES = \
|
2019-07-10 15:58:48 -07:00
|
|
|
+ cryptext.c
|
|
|
|
diff --git a/dlls/cryptext/tests/cryptext.c b/dlls/cryptext/tests/cryptext.c
|
|
|
|
new file mode 100644
|
2022-09-20 16:19:11 -07:00
|
|
|
index 00000000000..ab1007dbd82
|
2019-07-10 15:58:48 -07:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/dlls/cryptext/tests/cryptext.c
|
|
|
|
@@ -0,0 +1,61 @@
|
|
|
|
+/*
|
|
|
|
+ * Copyright 2019 Dmitry Timoshkov
|
|
|
|
+ *
|
|
|
|
+ * This library is free software; you can redistribute it and/or
|
|
|
|
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
|
+ * License as published by the Free Software Foundation; either
|
|
|
|
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
|
+ *
|
|
|
|
+ * This library is distributed in the hope that it will be useful,
|
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
+ * Lesser General Public License for more details.
|
|
|
|
+ *
|
|
|
|
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
|
+ * License along with this library; if not, write to the Free Software
|
|
|
|
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include <stdarg.h>
|
|
|
|
+#include <assert.h>
|
|
|
|
+#include <windef.h>
|
|
|
|
+#include <winbase.h>
|
|
|
|
+#include <winuser.h>
|
|
|
|
+#include <winerror.h>
|
|
|
|
+
|
|
|
|
+#include "wine/test.h"
|
|
|
|
+
|
|
|
|
+static HRESULT (WINAPI *pCryptExtOpenCER)(HWND,HINSTANCE,LPCSTR,DWORD);
|
|
|
|
+
|
|
|
|
+static void test_CryptExtOpenCER(void)
|
|
|
|
+{
|
|
|
|
+ HRESULT hr;
|
|
|
|
+
|
|
|
|
+ if (!pCryptExtOpenCER)
|
|
|
|
+ {
|
|
|
|
+ win_skip("CryptExtOpenCER is not available on this platform\n");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!winetest_interactive)
|
|
|
|
+ {
|
|
|
|
+ skip("CryptExtOpenCER test needs user interaction\n");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SetLastError(0xdeadbeef);
|
|
|
|
+ hr = pCryptExtOpenCER(0, 0, "dead.beef", SW_HIDE);
|
2022-03-03 16:02:37 -08:00
|
|
|
+ ok(hr == S_OK, "got %#lx\n", hr);
|
2019-07-10 15:58:48 -07:00
|
|
|
+
|
|
|
|
+ hr = pCryptExtOpenCER(0, 0, "VeriSign Class 3 Public Primary Certification Authority - G4.txt", SW_SHOW);
|
2022-03-03 16:02:37 -08:00
|
|
|
+ ok(hr == S_OK, "got %#lx\n", hr);
|
2019-07-10 15:58:48 -07:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+START_TEST(cryptext)
|
|
|
|
+{
|
|
|
|
+ HMODULE hmod = LoadLibraryA("cryptext.dll");
|
|
|
|
+
|
|
|
|
+ pCryptExtOpenCER = (void *)GetProcAddress(hmod, "CryptExtOpenCER");
|
|
|
|
+
|
|
|
|
+ test_CryptExtOpenCER();
|
|
|
|
+}
|
|
|
|
--
|
2024-01-13 11:33:10 -08:00
|
|
|
2.43.0
|
2019-07-10 15:58:48 -07:00
|
|
|
|