Commit 16d91233 authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

crypt32/tests: Use GetModuleHandle and skip.

parent 714a3731
......@@ -225,8 +225,6 @@ static void test_cryptTls(void)
DWORD index;
BOOL ret;
if (!hCrypt) return;
pI_CryptAllocTls = (I_CryptAllocTlsFunc)GetProcAddress(hCrypt,
"I_CryptAllocTls");
pI_CryptDetachTls = (I_CryptDetachTlsFunc)GetProcAddress(hCrypt,
......@@ -290,8 +288,6 @@ static void test_readTrustedPublisherDWORD(void)
{
I_CryptReadTrustedPublisherDWORDValueFromRegistryFunc pReadDWORD;
if (!hCrypt) return;
pReadDWORD =
(I_CryptReadTrustedPublisherDWORDValueFromRegistryFunc)GetProcAddress(
hCrypt, "I_CryptReadTrustedPublisherDWORDValueFromRegistry");
......@@ -335,8 +331,6 @@ static void test_getDefaultCryptProv(void)
I_CryptGetDefaultCryptProvFunc pI_CryptGetDefaultCryptProv;
HCRYPTPROV prov;
if (!hCrypt) return;
pI_CryptGetDefaultCryptProv = (I_CryptGetDefaultCryptProvFunc)
GetProcAddress(hCrypt, "I_CryptGetDefaultCryptProv");
if (!pI_CryptGetDefaultCryptProv) return;
......@@ -362,8 +356,6 @@ static void test_CryptInstallOssGlobal(void)
int ret,i;
I_CryptInstallOssGlobal pI_CryptInstallOssGlobal;
if (!hCrypt) return;
pI_CryptInstallOssGlobal= (I_CryptInstallOssGlobal)GetProcAddress(hCrypt,"I_CryptInstallOssGlobal");
/* passing in some random values to I_CryptInstallOssGlobal, it always returns 9 the first time, then 10, 11 etc.*/
for(i=0;i<30;i++)
......@@ -375,7 +367,8 @@ static void test_CryptInstallOssGlobal(void)
START_TEST(main)
{
hCrypt = LoadLibraryA("crypt32.dll");
hCrypt = GetModuleHandleA("crypt32.dll");
test_findAttribute();
test_findExtension();
test_findRDNAttr();
......
......@@ -295,17 +295,12 @@ static void test_SIPLoad(void)
"Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
hCrypt = LoadLibraryA("crypt32.dll");
if (hCrypt)
{
funcCryptSIPGetSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPGetSignedDataMsg");
funcCryptSIPPutSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPPutSignedDataMsg");
funcCryptSIPCreateIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPCreateIndirectData");
funcCryptSIPVerifyIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPVerifyIndirectData");
funcCryptSIPRemoveSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPRemoveSignedDataMsg");
}
/* We're not going to use the functions, so we can free already here */
FreeLibrary(hCrypt);
hCrypt = GetModuleHandleA("crypt32.dll");
funcCryptSIPGetSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPGetSignedDataMsg");
funcCryptSIPPutSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPPutSignedDataMsg");
funcCryptSIPCreateIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPCreateIndirectData");
funcCryptSIPVerifyIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPVerifyIndirectData");
funcCryptSIPRemoveSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPRemoveSignedDataMsg");
/* All OK */
SetLastError(0xdeadbeef);
......
......@@ -271,7 +271,11 @@ static void test_CertRDNValueToStrW(void)
WCHAR buffer[2000];
CERT_RDN_VALUE_BLOB blob = { 0, NULL };
if (!pCertRDNValueToStrW) return;
if (!pCertRDNValueToStrW)
{
skip("CertRDNValueToStrW is not available\n");
return;
}
/* This crashes
ret = pCertRDNValueToStrW(0, NULL, NULL, 0);
......@@ -319,7 +323,11 @@ static void test_CertNameToStrA(void)
{
PCCERT_CONTEXT context;
if (!pCertNameToStrA) return;
if (!pCertNameToStrA)
{
skip("CertNameToStrA is not available\n");
return;
}
context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
sizeof(cert));
......@@ -392,7 +400,11 @@ static void test_CertNameToStrW(void)
{
PCCERT_CONTEXT context;
if (!pCertNameToStrW) return;
if (!pCertNameToStrW)
{
skip("CertNameToStrW is not available\n");
return;
}
context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
sizeof(cert));
......@@ -473,7 +485,11 @@ static void test_CertStrToNameA(void)
DWORD size, i;
BYTE buf[100];
if (!pCertStrToNameA) return;
if (!pCertStrToNameA)
{
skip("CertStrToNameA is not available\n");
return;
}
/* Crash
ret = pCertStrToNameA(0, NULL, 0, NULL, NULL, NULL, NULL);
......@@ -554,7 +570,11 @@ static void test_CertStrToNameW(void)
LPCWSTR errorPtr;
BYTE buf[100];
if (!pCertStrToNameW) return;
if (!pCertStrToNameW)
{
skip("CertStrToNameW is not available\n");
return;
}
/* Crash
ret = pCertStrToNameW(0, NULL, 0, NULL, NULL, NULL, NULL);
......@@ -600,7 +620,7 @@ static void test_CertStrToNameW(void)
START_TEST(str)
{
dll = LoadLibrary("Crypt32.dll");
dll = GetModuleHandleA("Crypt32.dll");
pCertNameToStrA = (CertNameToStrAFunc)GetProcAddress(dll,"CertNameToStrA");
pCertNameToStrW = (CertNameToStrWFunc)GetProcAddress(dll,"CertNameToStrW");
......@@ -619,6 +639,4 @@ START_TEST(str)
test_CertNameToStrW();
test_CertStrToNameA();
test_CertStrToNameW();
FreeLibrary(dll);
}
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