From 556b90c8ec5dacbe2d9d02ed00d4b6f0a5bcaadd Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Thu, 31 Jul 2008 10:18:30 -0700 Subject: [PATCH] More fully implement CryptSIPRetrieveSubjectGuid --- dlls/crypt32/sip.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 80 insertions(+), 9 deletions(-) diff --git a/dlls/crypt32/sip.c b/dlls/crypt32/sip.c index f60835d..a9ec3de 100644 --- a/dlls/crypt32/sip.c +++ b/dlls/crypt32/sip.c @@ -317,6 +317,9 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid static const WORD dosHdr = IMAGE_DOS_SIGNATURE; static const BYTE cabHdr[] = { 'M','S','C','F' }; BYTE hdr[SIP_MAX_MAGIC_NUMBER]; + WCHAR szFullKey[ 0x100 ]; + LONG r = ERROR_SUCCESS; + HKEY key; TRACE("(%s %p %p)\n", wine_dbgstr_w(FileName), hFileIn, pgSubject); @@ -367,16 +370,84 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid goto cleanup; } - /* FIXME - * There is a lot more to be checked: - * - Check for the keys CryptSIPDllIsMyFileType and CryptSIPDllIsMyFileType2 - * under HKLM\Software\Microsoft\Cryptography\OID\EncodingType 0. Here are - * functions listed that need check if a SIP Provider can deal with the - * given file. - */ + /* Check for supported functions using CryptSIPDllIsMyFileType */ + /* max length of szFullKey depends on our code only, so we won't overrun */ + lstrcpyW(szFullKey, szOID); + lstrcatW(szFullKey, szIsMyFile); + r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szFullKey, 0, KEY_READ, &key); + if (r == ERROR_SUCCESS) + { + DWORD index = 0, size; + WCHAR subKeyName[MAX_PATH]; + + do { + size = sizeof(subKeyName) / sizeof(subKeyName[0]); + r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL, + NULL, NULL); + if (r == ERROR_SUCCESS) + { + HKEY subKey; + + r = RegOpenKeyExW(key, subKeyName, 0, KEY_READ, &subKey); + if (r == ERROR_SUCCESS) + { + HMODULE lib; + pfnIsFileSupported isMy = CRYPT_LoadSIPFuncFromKey(subKey, + &lib); + + if (isMy) + { + bRet = isMy(hFile, pgSubject); + FreeLibrary(lib); + } + RegCloseKey(subKey); + } + } + } while (!bRet && r == ERROR_SUCCESS); + RegCloseKey(key); + } + + /* Check for supported functions using CryptSIPDllIsMyFileType2 */ + if (!bRet) + { + lstrcpyW(szFullKey, szOID); + lstrcatW(szFullKey, szIsMyFile2); + r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szFullKey, 0, KEY_READ, &key); + if (r == ERROR_SUCCESS) + { + DWORD index = 0, size; + WCHAR subKeyName[MAX_PATH]; + + do { + size = sizeof(subKeyName) / sizeof(subKeyName[0]); + r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL, + NULL, NULL); + if (r == ERROR_SUCCESS) + { + HKEY subKey; + + r = RegOpenKeyExW(key, subKeyName, 0, KEY_READ, &subKey); + if (r == ERROR_SUCCESS) + { + HMODULE lib; + pfnIsFileSupportedName isMy2 = + CRYPT_LoadSIPFuncFromKey(subKey, &lib); + + if (isMy2) + { + bRet = isMy2(FileName, pgSubject); + FreeLibrary(lib); + } + RegCloseKey(subKey); + } + } + } while (!bRet && r == ERROR_SUCCESS); + RegCloseKey(key); + } + } - /* Let's set the most common error for now */ - SetLastError(TRUST_E_SUBJECT_FORM_UNKNOWN); + if (!bRet) + SetLastError(TRUST_E_SUBJECT_FORM_UNKNOWN); cleanup: /* If we didn't open this one we shouldn't close it (hFile is a copy) */ -- 1.4.1