Commit c16830db authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

wintrust/tests: Use GetModuleHandleA instead of LoadLibraryA.

parent ba90a740
......@@ -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);
}
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