[CRYPTEXT] Make extension localizable, and add an icon for certificate files (#1347)
authorBaruch Rutman <peterooch@gmail.com>
Sun, 10 Feb 2019 16:57:43 +0000 (18:57 +0200)
committerHermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Sun, 10 Feb 2019 16:57:43 +0000 (17:57 +0100)
- Localize error message and shell file extension description.
- Added Hebrew resources.
- Added Icon.

The icon is the Tango icon named "certificate". If anybody has a idea for more fitting icon please recommend it.

Follow up of #1343

CORE-15736

boot/bootdata/hivecls.inf
dll/shellext/cryptext/CMakeLists.txt
dll/shellext/cryptext/cryptext.c
dll/shellext/cryptext/cryptext.rc [new file with mode: 0644]
dll/shellext/cryptext/lang/en-US.rc [new file with mode: 0644]
dll/shellext/cryptext/lang/he-IL.rc [new file with mode: 0644]
dll/shellext/cryptext/precomp.h
dll/shellext/cryptext/res/cerfile.ico [new file with mode: 0644]
dll/shellext/cryptext/resource.h [new file with mode: 0644]

index 37d81fd..1b38c91 100644 (file)
@@ -78,6 +78,9 @@ HKCR,"batfile\shell\open\command","",0x00000000,"""%1"" %*"
 
 ; Certificate
 HKCR,".cer","",0x00000000,"cerfile"
+HKCR,"cerfile","",0x00000000,"Certificate File"
+HKCR,"cerfile","FriendlyTypeName",0x00020000,"@%SystemRoot%\system32\cryptext.dll,-101"
+HKCR,"cerfile\DefaultIcon","",0x00020000,"%SystemRoot%\system32\cryptext.dll,-1"
 HKCR,"cerfile\shell\open\command","",0x00020000,"%SystemRoot%\system32\rundll32.exe cryptext.dll,CryptExtOpenCER %1"
 
 ; ReactOS Command Script Files
index faa2301..8cd10f4 100644 (file)
@@ -8,6 +8,7 @@ list(APPEND SOURCE
 add_library(cryptext SHARED
     ${SOURCE}
     cryptext.spec
+    cryptext.rc
     ${CMAKE_CURRENT_BINARY_DIR}/cryptext.def)
 
 set_module_type(cryptext win32dll UNICODE)
index 8825f41..ae5e40b 100644 (file)
@@ -7,12 +7,14 @@
 
 #include "precomp.h"
 
+HINSTANCE g_hInstance;
 
 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 {
     switch (dwReason)
     {
     case DLL_PROCESS_ATTACH:
+        g_hInstance = hInstance;
         DisableThreadLibraryCalls(hInstance);
         break;
     }
@@ -29,15 +31,24 @@ VOID WINAPI CryptExtOpenCERW(HWND hWnd, HINSTANCE hInst, LPCWSTR file, DWORD nCm
         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};
+            CRYPTUI_VIEWCERTIFICATE_STRUCTW CertViewInfo = {0};
             CertViewInfo.dwSize = sizeof(CertViewInfo);
             CertViewInfo.pCertContext = pvContext;
-            CryptUIDlgViewCertificate(&CertViewInfo, NULL);
+            CryptUIDlgViewCertificateW(&CertViewInfo, NULL);
             CertFreeCertificateContext(pvContext);
         }
         else
         {
-            MessageBoxW(NULL, L"This is not a valid certificate", NULL, MB_OK);
+            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);
+            }
         }
     }
 }
diff --git a/dll/shellext/cryptext/cryptext.rc b/dll/shellext/cryptext/cryptext.rc
new file mode 100644 (file)
index 0000000..e12afbd
--- /dev/null
@@ -0,0 +1,22 @@
+#include <windef.h>
+#include <winuser.h>
+
+#include "resource.h"
+
+1 ICON "res/cerfile.ico"
+
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION  "ReactOS CryptExt Shell Extension"
+#define REACTOS_STR_INTERNAL_NAME     "cryptext"
+#define REACTOS_STR_ORIGINAL_FILENAME "cryptext.dll"
+#include <reactos/version.rc>
+
+/* UTF-8 */
+#pragma code_page(65001)
+
+#ifdef LANGUAGE_EN_US
+    #include "lang/en-US.rc"
+#endif
+#ifdef LANGUAGE_HE_IL
+    #include "lang/he-IL.rc"
+#endif
diff --git a/dll/shellext/cryptext/lang/en-US.rc b/dll/shellext/cryptext/lang/en-US.rc
new file mode 100644 (file)
index 0000000..5aeae89
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * PROJECT:     ReactOS CryptExt Shell Extension
+ * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE:     English (United States) resource translation
+ * COPYRIGHT:   Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
+ */
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+STRINGTABLE
+BEGIN
+    IDS_INVALIDFILE "This is not a valid certificate file."
+    IDS_CER_FILE "Certificate File"
+END
diff --git a/dll/shellext/cryptext/lang/he-IL.rc b/dll/shellext/cryptext/lang/he-IL.rc
new file mode 100644 (file)
index 0000000..5d821eb
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * PROJECT:     ReactOS CryptExt Shell Extension
+ * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE:     Hebrew resource translation
+ * COPYRIGHT:   Copyright 2019 Baruch Rutman (peterooch at gmail dot com)
+ */
+
+LANGUAGE LANG_HEBREW, SUBLANG_DEFAULT
+
+STRINGTABLE
+BEGIN
+    IDS_INVALIDFILE "קובץ זה הוא לא קובץ אישורי הצפנה תקין."
+    IDS_CER_FILE "קובץ אישורי הצפנה"
+END
index e9df5d3..21067f5 100644 (file)
@@ -13,6 +13,6 @@
 #include <wincrypt.h>
 #include <winuser.h>
 #include <cryptuiapi.h>
-
+#include "resource.h"
 
 #endif /* CRYPTEXT_PRECOMP_H */
diff --git a/dll/shellext/cryptext/res/cerfile.ico b/dll/shellext/cryptext/res/cerfile.ico
new file mode 100644 (file)
index 0000000..362fb40
Binary files /dev/null and b/dll/shellext/cryptext/res/cerfile.ico differ
diff --git a/dll/shellext/cryptext/resource.h b/dll/shellext/cryptext/resource.h
new file mode 100644 (file)
index 0000000..1ec6542
--- /dev/null
@@ -0,0 +1,2 @@
+#define IDS_INVALIDFILE 100
+#define IDS_CER_FILE    101