[Wine-patches] [1/2] crypt32: Update oidInfo using a registry (eterbug #5348).
Alexander Morozov
amorozov на etersoft.ru
Вт Апр 20 17:52:49 MSD 2010
----------- следующая часть -----------
From 2caf4b73e61d5831b3ed65d4a164410883a1ddb6 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Tue, 30 Mar 2010 19:24:43 +0400
Subject: [PATCH 1/2] crypt32: Update oidInfo using a registry (eterbug #5348).
---
dlls/crypt32/oid.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 105 insertions(+), 0 deletions(-)
diff --git a/dlls/crypt32/oid.c b/dlls/crypt32/oid.c
index 0f36fd7..1cdb86d 100644
--- a/dlls/crypt32/oid.c
+++ b/dlls/crypt32/oid.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdarg.h>
+#include <stdlib.h>
#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
@@ -40,10 +41,12 @@ static const WCHAR DllW[] = { 'D','l','l',0 };
static void init_oid_info(void);
static void free_function_sets(void);
static void free_oid_info(void);
+static void update_oid_info(void);
void crypt_oid_init(void)
{
init_oid_info();
+ update_oid_info();
}
void crypt_oid_free(void)
@@ -1447,6 +1450,103 @@ 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;
+ DWORD size, id, i = 0;
+ LONG ret, oid_size, name_size, extra_size;
+ int found = 0, err = 0;
+
+ if (RegOpenKeyW(HKEY_LOCAL_MACHINE, wszCryptDllFindOIDInfoKey, &hKey))
+ return;
+ for (;;)
+ {
+ if (RegEnumKeyA(hKey, i++, buf, MAX_PATH))
+ break;
+
+ ptr = strchr(buf, '!');
+ if (!ptr)
+ continue;
+ *ptr = 0;
+ id = strtol(ptr + 1, &endptr, 10);
+ if (*endptr != 0)
+ continue;
+
+ LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry)
+ {
+ if (!lstrcmpA(info->info.pszOID, buf) &&
+ (info->info.dwGroupId == id))
+ {
+ found = 1;
+ break;
+ }
+ }
+ if (found)
+ {
+ found = 0;
+ continue;
+ }
+
+ *ptr = '!';
+ if (RegOpenKeyA(hKey, buf, &hSubKey))
+ continue;
+ *ptr = 0;
+ name_size = 0;
+ RegQueryValueW(hSubKey, wszName, NULL, &name_size);
+ extra_size = 0;
+ RegQueryValueW(hSubKey, wszExtraInfo, NULL, &extra_size);
+ oid_size = strlen(buf) + 1;
+
+ info = CryptMemAlloc(sizeof(*info) + oid_size + name_size + extra_size);
+ if (info)
+ {
+ memset(info, 0, sizeof(*info));
+ info->info.cbSize = sizeof(CRYPT_OID_INFO);
+ memcpy(info + 1, buf, oid_size);
+ info->info.pszOID = (LPSTR)(info + 1);
+ info->info.dwGroupId = id;
+ size = sizeof(DWORD);
+ ret = RegQueryValueExW(hSubKey, wszAlgid, NULL, NULL,
+ (LPBYTE)&info->info.u.Algid, &size);
+ if (ret != ERROR_SUCCESS && ret != ERROR_FILE_NOT_FOUND)
+ err = 1;
+ if (name_size)
+ {
+ info->info.pwszName = (LPWSTR)((char *)(info + 1) + oid_size);
+ if (RegQueryValueW(hSubKey, wszName, (LPWSTR)info->info.pwszName,
+ &name_size))
+ err = 1;
+ }
+ if (extra_size)
+ {
+ info->info.ExtraInfo.pbData =
+ (BYTE *)((char *)(info + 1) + oid_size + name_size);
+ if (RegQueryValueW(hSubKey, wszExtraInfo,
+ (LPWSTR)info->info.ExtraInfo.pbData, &extra_size))
+ err = 1;
+ }
+ if (!err)
+ list_add_tail(&oidInfo, &info->entry);
+ else
+ CryptMemFree(info);
+ }
+
+ RegCloseKey(hSubKey);
+ }
+ RegCloseKey(hKey);
+}
+
/***********************************************************************
* CryptEnumOIDInfo (CRYPT32.@)
*/
@@ -1460,6 +1560,7 @@ BOOL WINAPI CryptEnumOIDInfo(DWORD dwGroupId, DWORD dwFlags, void *pvArg,
pfnEnumOIDInfo);
EnterCriticalSection(&oidInfoCS);
+ update_oid_info();
LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry)
{
if (!dwGroupId || dwGroupId == info->info.dwGroupId)
@@ -1488,6 +1589,7 @@ PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey,
TRACE("CRYPT_OID_INFO_ALGID_KEY: %d\n", *(DWORD *)pvKey);
EnterCriticalSection(&oidInfoCS);
+ update_oid_info();
LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry)
{
if (info->info.u.Algid == *(DWORD *)pvKey &&
@@ -1506,6 +1608,7 @@ PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey,
TRACE("CRYPT_OID_INFO_NAME_KEY: %s\n", debugstr_w(pvKey));
EnterCriticalSection(&oidInfoCS);
+ update_oid_info();
LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry)
{
if (!lstrcmpW(info->info.pwszName, pvKey) &&
@@ -1525,6 +1628,7 @@ PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey,
TRACE("CRYPT_OID_INFO_OID_KEY: %s\n", debugstr_a(oid));
EnterCriticalSection(&oidInfoCS);
+ update_oid_info();
LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry)
{
if (!lstrcmpA(info->info.pszOID, oid) &&
@@ -1543,6 +1647,7 @@ PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey,
TRACE("CRYPT_OID_INFO_SIGN_KEY: %d\n", *(DWORD *)pvKey);
EnterCriticalSection(&oidInfoCS);
+ update_oid_info();
LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry)
{
if (info->info.u.Algid == *(DWORD *)pvKey &&
--
1.6.5.8
Подробная информация о списке рассылки Wine-patches