Commit 0b0fc559 authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

wintrust: Use the return values of the registration functions.

parent 7bcec7c5
...@@ -797,8 +797,8 @@ HRESULT WINAPI DllRegisterServer(void) ...@@ -797,8 +797,8 @@ HRESULT WINAPI DllRegisterServer(void)
static const CHAR CatMemberInfoDecode[] = "WVTAsn1CatMemberInfoDecode"; static const CHAR CatMemberInfoDecode[] = "WVTAsn1CatMemberInfoDecode";
static const CHAR SpcSpOpusInfoEncode[] = "WVTAsn1SpcSpOpusInfoEncode"; static const CHAR SpcSpOpusInfoEncode[] = "WVTAsn1SpcSpOpusInfoEncode";
static const CHAR SpcSpOpusInfoDecode[] = "WVTAsn1SpcSpOpusInfoDecode"; static const CHAR SpcSpOpusInfoDecode[] = "WVTAsn1SpcSpOpusInfoDecode";
HRESULT Res = S_OK; HRESULT CryptRegisterRes = S_OK;
HKEY Key; HRESULT TrustProviderRes = S_OK;
TRACE("\n"); TRACE("\n");
...@@ -822,12 +822,12 @@ HRESULT WINAPI DllRegisterServer(void) ...@@ -822,12 +822,12 @@ HRESULT WINAPI DllRegisterServer(void)
do { \ do { \
if (!CryptRegisterOIDFunction(X509_ASN_ENCODING, CRYPT_OID_ENCODE_OBJECT_FUNC, oid, SP_POLICY_PROVIDER_DLL_NAME, encode_funcname)) \ if (!CryptRegisterOIDFunction(X509_ASN_ENCODING, CRYPT_OID_ENCODE_OBJECT_FUNC, oid, SP_POLICY_PROVIDER_DLL_NAME, encode_funcname)) \
{ \ { \
Res = HRESULT_FROM_WIN32(GetLastError()); \ CryptRegisterRes = HRESULT_FROM_WIN32(GetLastError()); \
goto add_trust_providers; \ goto add_trust_providers; \
} \ } \
if (!CryptRegisterOIDFunction(X509_ASN_ENCODING, CRYPT_OID_DECODE_OBJECT_FUNC, oid, SP_POLICY_PROVIDER_DLL_NAME, decode_funcname)) \ if (!CryptRegisterOIDFunction(X509_ASN_ENCODING, CRYPT_OID_DECODE_OBJECT_FUNC, oid, SP_POLICY_PROVIDER_DLL_NAME, decode_funcname)) \
{ \ { \
Res = HRESULT_FROM_WIN32(GetLastError()); \ CryptRegisterRes = HRESULT_FROM_WIN32(GetLastError()); \
goto add_trust_providers; \ goto add_trust_providers; \
} \ } \
} while (0) } while (0)
...@@ -864,44 +864,44 @@ HRESULT WINAPI DllRegisterServer(void) ...@@ -864,44 +864,44 @@ HRESULT WINAPI DllRegisterServer(void)
add_trust_providers: add_trust_providers:
/* Testing on W2K3 shows: /* Testing on W2K3 shows:
* If we cannot open HKLM\Software\Microsoft\Cryptography\Providers\Trust * All registry writes are tried. If one fails this part will return S_FALSE
* for writing, DllRegisterServer returns S_FALSE. If the key can be opened * but only if the first (CryptRegisterOIDFunction calls) and the third
* there is no check whether the actions can be written in the registry. * (CryptSIPAddProvider calls) part succeed.
* As the previous list shows, there are several calls after these registrations. *
* If they fail they will overwrite the returnvalue of DllRegisterServer. * Last error is set to the last error encountered, regardless if the first
* part failed or not.
*/ */
/* Check if we can open/create HKLM\Software\Microsoft\Cryptography\Providers\Trust */ /* Create the necessary action registry structures */
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, Trust, 0, NULL, 0, KEY_WRITE, NULL, &Key, NULL) != ERROR_SUCCESS) WINTRUST_InitRegStructs();
{
/* If the opening/creation of the key fails, there is no need to do the action registrations as they /* Register several Trust Provider actions */
* will fail as well. if (!WINTRUST_RegisterGenVerifyV2())
*/ TrustProviderRes = S_FALSE;
Res = S_FALSE; if (!WINTRUST_RegisterPublishedSoftware())
} TrustProviderRes = S_FALSE;
else if (!WINTRUST_RegisterPublishedSoftwareNoBadUi())
{ TrustProviderRes = S_FALSE;
RegCloseKey(Key); if (!WINTRUST_RegisterGenCertVerify())
TrustProviderRes = S_FALSE;
/* Create the necessary action registry structures */ if (!WINTRUST_RegisterTrustProviderTest())
WINTRUST_InitRegStructs(); TrustProviderRes = S_FALSE;
if (!WINTRUST_RegisterHttpsProv())
/* Register several Trust Provider actions */ TrustProviderRes = S_FALSE;
WINTRUST_RegisterGenVerifyV2(); if (!WINTRUST_RegisterOfficeSignVerify())
WINTRUST_RegisterPublishedSoftware(); TrustProviderRes = S_FALSE;
WINTRUST_RegisterPublishedSoftwareNoBadUi(); if (!WINTRUST_RegisterDriverVerify())
WINTRUST_RegisterGenCertVerify(); TrustProviderRes = S_FALSE;
WINTRUST_RegisterTrustProviderTest(); if (!WINTRUST_RegisterGenChainVerify())
WINTRUST_RegisterHttpsProv(); TrustProviderRes = S_FALSE;
WINTRUST_RegisterOfficeSignVerify();
WINTRUST_RegisterDriverVerify(); /* Free the registry structures */
WINTRUST_RegisterGenChainVerify(); WINTRUST_FreeRegStructs();
/* Free the registry structures */ if (CryptRegisterRes == S_OK)
WINTRUST_FreeRegStructs(); return TrustProviderRes;
}
return CryptRegisterRes;
return Res;
} }
/*********************************************************************** /***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment