From c16830db8cc45bae1bd9da4729a6a3d5f8f6babb Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Mon, 11 Feb 2008 10:35:33 +0100 Subject: [PATCH] wintrust/tests: Use GetModuleHandleA instead of LoadLibraryA. --- dlls/wintrust/tests/register.c | 45 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/dlls/wintrust/tests/register.c b/dlls/wintrust/tests/register.c index f4aef92478e..bd277c55e31 100644 --- a/dlls/wintrust/tests/register.c +++ b/dlls/wintrust/tests/register.c @@ -35,30 +35,21 @@ static BOOL (WINAPI * pWintrustLoadFunctionPointers)(GUID *, CRYPT_PROVIDER_FUNC static HMODULE hWintrust = 0; -#define WINTRUST_GET_PROC(func) \ - p ## func = (void*)GetProcAddress(hWintrust, #func); \ - if(!p ## func) { \ - trace("GetProcAddress(%s) failed\n", #func); \ - FreeLibrary(hWintrust); \ - return FALSE; \ - } - -static BOOL InitFunctionPtrs(void) +static void InitFunctionPtrs(void) { - hWintrust = LoadLibraryA("wintrust.dll"); + hWintrust = GetModuleHandleA("wintrust.dll"); - if(!hWintrust) - { - trace("Could not load wintrust.dll\n"); - return FALSE; - } +#define WINTRUST_GET_PROC(func) \ + p ## func = (void*)GetProcAddress(hWintrust, #func); \ + if(!p ## func) \ + trace("GetProcAddress(%s) failed\n", #func); WINTRUST_GET_PROC(WintrustAddActionID) WINTRUST_GET_PROC(WintrustAddDefaultForUsage) WINTRUST_GET_PROC(WintrustRemoveActionID) WINTRUST_GET_PROC(WintrustLoadFunctionPointers) - return TRUE; +#undef WINTRUST_GET_PROC } static void test_AddRem_ActionID(void) @@ -71,6 +62,12 @@ static void test_AddRem_ActionID(void) CRYPT_TRUST_REG_ENTRY DummyProvider = { sizeof(CRYPT_TRUST_REG_ENTRY), DummyDllW, DummyFunctionW }; BOOL ret; + if (!pWintrustAddActionID || !pWintrustRemoveActionID) + { + skip("WintrustAddActionID and/or WintrustRemoveActionID are not available\n"); + return; + } + /* All NULL */ SetLastError(0xdeadbeef); ret = pWintrustAddActionID(NULL, 0, NULL); @@ -174,6 +171,12 @@ static void test_AddDefaultForUsage(void) static const CHAR Usages[] = "SOFTWARE\\Microsoft\\Cryptography\\Providers\\Trust\\Usages\\1.2.3.4.5.6.7.8.9.10"; static CRYPT_PROVIDER_REGDEFUSAGE DefUsage; + if (!pWintrustAddDefaultForUsage) + { + skip("WintrustAddDefaultForUsage is not available\n"); + return; + } + /* All NULL */ SetLastError(0xdeadbeef); ret = pWintrustAddDefaultForUsage(NULL, NULL); @@ -264,6 +267,11 @@ static void test_LoadFunctionPointers(void) CRYPT_PROVIDER_FUNCTIONS funcs; GUID action = WINTRUST_ACTION_GENERIC_VERIFY_V2; + if (!pWintrustLoadFunctionPointers) + { + skip("WintrustLoadFunctionPointers is not available\n"); + return; + } SetLastError(0xdeadbeef); ret = pWintrustLoadFunctionPointers(NULL, NULL); ok(!ret && GetLastError() == 0xdeadbeef, "Expected failure\n"); @@ -339,13 +347,10 @@ static void test_RegPolicyFlags(void) START_TEST(register) { - if(!InitFunctionPtrs()) - return; + InitFunctionPtrs(); test_AddRem_ActionID(); test_AddDefaultForUsage(); test_LoadFunctionPointers(); test_RegPolicyFlags(); - - FreeLibrary(hWintrust); } -- 2.11.4.GIT