[Wine-patches] [eter-1.0.12 2/2] crypt32: Implement CryptRegisterOIDInfo (eterbug #5528).

Alexander Morozov amorozov на etersoft.ru
Пн Апр 26 19:55:26 MSD 2010


----------- следующая часть -----------
From cd35629b98a08011015505466c2d8caab7b4f83c Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Mon, 26 Apr 2010 19:37:05 +0400
Subject: [eter-1.0.12 2/2] crypt32: Implement CryptRegisterOIDInfo (eterbug #5528).

---
 dlls/crypt32/oid.c |   95 +++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 83 insertions(+), 12 deletions(-)

diff --git a/dlls/crypt32/oid.c b/dlls/crypt32/oid.c
index 96bc4fb..7cb98f9 100644
--- a/dlls/crypt32/oid.c
+++ b/dlls/crypt32/oid.c
@@ -29,14 +29,24 @@
 #include "wincrypt.h"
 #include "winreg.h"
 #include "winuser.h"
+#include "winnls.h"
 #include "wine/debug.h"
 #include "wine/list.h"
 #include "crypt32_private.h"
 #include "cryptres.h"
+#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(crypt);
 
 static const WCHAR DllW[] = { 'D','l','l',0 };
+static const WCHAR wszCryptDllFindOIDInfoKey[] =
+ { 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
+ 'C','r','y','p','t','o','g','r','a','p','h','y','\\',
+ 'O','I','D','\\','E','n','c','o','d','i','n','g','T','y','p','e',' ','0','\\',
+ 'C','r','y','p','t','D','l','l','F','i','n','d','O','I','D','I','n','f','o',0 };
+static const WCHAR wszAlgid[] = { 'A','l','g','i','d',0 };
+static const WCHAR wszExtraInfo[] = { 'E','x','t','r','a','I','n','f','o',0 };
+static const WCHAR wszName[] = { 'N','a','m','e',0 };
 
 static void init_oid_info(void);
 static void free_function_sets(void);
@@ -672,9 +682,79 @@ error_close_key:
  */
 BOOL WINAPI CryptRegisterOIDInfo(PCCRYPT_OID_INFO pInfo, DWORD dwFlags)
 {
-    FIXME("(%p, %x): stub\n", pInfo, dwFlags );
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
+    WCHAR bufW[MAX_PATH];
+    char buf[MAX_PATH];
+    HKEY hKey, hSubKey;
+    BOOL ret = FALSE;
+    LONG r;
+
+    TRACE("(%p, %x)\n", pInfo, dwFlags);
+
+    if (dwFlags)
+        FIXME("flags not supported\n");
+
+    if (!pInfo || pInfo->cbSize < sizeof(CRYPT_OID_INFO) || !pInfo->pszOID)
+    {
+        SetLastError(E_INVALIDARG);
+        return FALSE;
+    }
+
+    r = RegCreateKeyW(HKEY_LOCAL_MACHINE, wszCryptDllFindOIDInfoKey, &hKey);
+    if (r != ERROR_SUCCESS)
+    {
+        SetLastError(r);
+        return FALSE;
+    }
+
+    snprintf(buf, sizeof(buf), "%s!%u", pInfo->pszOID, pInfo->dwGroupId);
+    if (!MultiByteToWideChar(CP_ACP, 0, buf, -1, bufW, sizeof(bufW)))
+    {
+        RegCloseKey(hKey);
+        return FALSE;
+    }
+
+    r = RegCreateKeyW(hKey, bufW, &hSubKey);
+    if (r == ERROR_SUCCESS)
+    {
+        if (pInfo->pwszName)
+        {
+            r = RegSetValueExW(hSubKey, wszName, 0, REG_SZ,
+             (LPBYTE)pInfo->pwszName,
+             (strlenW(pInfo->pwszName) + 1) * sizeof(WCHAR));
+            if (r != ERROR_SUCCESS)
+            {
+                SetLastError(r);
+                goto close_key;
+            }
+        }
+        if (pInfo->u.Algid)
+        {
+            r = RegSetValueExW(hSubKey, wszAlgid, 0, REG_DWORD,
+             (LPBYTE)&pInfo->u.Algid, sizeof(pInfo->u.Algid));
+            if (r != ERROR_SUCCESS)
+            {
+                SetLastError(r);
+                goto close_key;
+            }
+        }
+        if (pInfo->ExtraInfo.cbData)
+        {
+            r = RegSetValueExW(hSubKey, wszExtraInfo, 0, REG_BINARY,
+             pInfo->ExtraInfo.pbData, pInfo->ExtraInfo.cbData);
+            if (r != ERROR_SUCCESS)
+            {
+                SetLastError(r);
+                goto close_key;
+            }
+        }
+        ret = TRUE;
+close_key:
+        RegCloseKey(hSubKey);
+    }
+    else SetLastError(r);
+
+    RegCloseKey(hKey);
+    return ret;
 }
 
 /***********************************************************************
@@ -1462,15 +1542,6 @@ static void free_oid_info(void)
 
 static void update_oid_info(void)
 {
-    static const WCHAR wszCryptDllFindOIDInfoKey[] = {'S','o','f','t','w','a','r','e','\\',
-     'M','i','c','r','o','s','o','f','t','\\',
-     'C','r','y','p','t','o','g','r','a','p','h','y','\\',
-     'O','I','D','\\','E','n','c','o','d','i','n','g','T','y','p','e',' ','0','\\',
-     'C','r','y','p','t','D','l','l','F','i','n','d','O','I','D','I','n','f','o',0};
-    static const WCHAR wszAlgid[] = {'A','l','g','i','d',0};
-    static const WCHAR wszExtraInfo[] = {'E','x','t','r','a','I','n','f','o',0};
-    static const WCHAR wszName[] = {'N','a','m','e',0};
-
     struct OIDInfo *info;
     HKEY hKey, hSubKey;
     char buf[MAX_PATH], *ptr, *endptr;
-- 
1.6.5.8



Подробная информация о списке рассылки Wine-patches