wintrust/tests: Use GetModuleHandleA instead of LoadLibraryA.
This commit is contained in:
parent
ba90a740be
commit
c16830db8c
|
@ -35,30 +35,21 @@ static BOOL (WINAPI * pWintrustLoadFunctionPointers)(GUID *, CRYPT_PROVIDER_FUNC
|
||||||
|
|
||||||
static HMODULE hWintrust = 0;
|
static HMODULE hWintrust = 0;
|
||||||
|
|
||||||
|
static void InitFunctionPtrs(void)
|
||||||
|
{
|
||||||
|
hWintrust = GetModuleHandleA("wintrust.dll");
|
||||||
|
|
||||||
#define WINTRUST_GET_PROC(func) \
|
#define WINTRUST_GET_PROC(func) \
|
||||||
p ## func = (void*)GetProcAddress(hWintrust, #func); \
|
p ## func = (void*)GetProcAddress(hWintrust, #func); \
|
||||||
if(!p ## func) { \
|
if(!p ## func) \
|
||||||
trace("GetProcAddress(%s) failed\n", #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;
|
|
||||||
}
|
|
||||||
|
|
||||||
WINTRUST_GET_PROC(WintrustAddActionID)
|
WINTRUST_GET_PROC(WintrustAddActionID)
|
||||||
WINTRUST_GET_PROC(WintrustAddDefaultForUsage)
|
WINTRUST_GET_PROC(WintrustAddDefaultForUsage)
|
||||||
WINTRUST_GET_PROC(WintrustRemoveActionID)
|
WINTRUST_GET_PROC(WintrustRemoveActionID)
|
||||||
WINTRUST_GET_PROC(WintrustLoadFunctionPointers)
|
WINTRUST_GET_PROC(WintrustLoadFunctionPointers)
|
||||||
|
|
||||||
return TRUE;
|
#undef WINTRUST_GET_PROC
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_AddRem_ActionID(void)
|
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 };
|
CRYPT_TRUST_REG_ENTRY DummyProvider = { sizeof(CRYPT_TRUST_REG_ENTRY), DummyDllW, DummyFunctionW };
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
|
if (!pWintrustAddActionID || !pWintrustRemoveActionID)
|
||||||
|
{
|
||||||
|
skip("WintrustAddActionID and/or WintrustRemoveActionID are not available\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* All NULL */
|
/* All NULL */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pWintrustAddActionID(NULL, 0, NULL);
|
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 const CHAR Usages[] = "SOFTWARE\\Microsoft\\Cryptography\\Providers\\Trust\\Usages\\1.2.3.4.5.6.7.8.9.10";
|
||||||
static CRYPT_PROVIDER_REGDEFUSAGE DefUsage;
|
static CRYPT_PROVIDER_REGDEFUSAGE DefUsage;
|
||||||
|
|
||||||
|
if (!pWintrustAddDefaultForUsage)
|
||||||
|
{
|
||||||
|
skip("WintrustAddDefaultForUsage is not available\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* All NULL */
|
/* All NULL */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pWintrustAddDefaultForUsage(NULL, NULL);
|
ret = pWintrustAddDefaultForUsage(NULL, NULL);
|
||||||
|
@ -264,6 +267,11 @@ static void test_LoadFunctionPointers(void)
|
||||||
CRYPT_PROVIDER_FUNCTIONS funcs;
|
CRYPT_PROVIDER_FUNCTIONS funcs;
|
||||||
GUID action = WINTRUST_ACTION_GENERIC_VERIFY_V2;
|
GUID action = WINTRUST_ACTION_GENERIC_VERIFY_V2;
|
||||||
|
|
||||||
|
if (!pWintrustLoadFunctionPointers)
|
||||||
|
{
|
||||||
|
skip("WintrustLoadFunctionPointers is not available\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pWintrustLoadFunctionPointers(NULL, NULL);
|
ret = pWintrustLoadFunctionPointers(NULL, NULL);
|
||||||
ok(!ret && GetLastError() == 0xdeadbeef, "Expected failure\n");
|
ok(!ret && GetLastError() == 0xdeadbeef, "Expected failure\n");
|
||||||
|
@ -339,13 +347,10 @@ static void test_RegPolicyFlags(void)
|
||||||
|
|
||||||
START_TEST(register)
|
START_TEST(register)
|
||||||
{
|
{
|
||||||
if(!InitFunctionPtrs())
|
InitFunctionPtrs();
|
||||||
return;
|
|
||||||
|
|
||||||
test_AddRem_ActionID();
|
test_AddRem_ActionID();
|
||||||
test_AddDefaultForUsage();
|
test_AddDefaultForUsage();
|
||||||
test_LoadFunctionPointers();
|
test_LoadFunctionPointers();
|
||||||
test_RegPolicyFlags();
|
test_RegPolicyFlags();
|
||||||
|
|
||||||
FreeLibrary(hWintrust);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue