wintrust/tests: Use GetModuleHandleA instead of LoadLibraryA.

This commit is contained in:
Paul Vriens 2008-02-11 10:35:33 +01:00 committed by Alexandre Julliard
parent ba90a740be
commit c16830db8c
1 changed files with 25 additions and 20 deletions

View File

@ -35,30 +35,21 @@ static BOOL (WINAPI * pWintrustLoadFunctionPointers)(GUID *, CRYPT_PROVIDER_FUNC
static HMODULE hWintrust = 0;
static void InitFunctionPtrs(void)
{
hWintrust = GetModuleHandleA("wintrust.dll");
#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)
{
hWintrust = LoadLibraryA("wintrust.dll");
if(!hWintrust)
{
trace("Could not load wintrust.dll\n");
return FALSE;
}
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);
}