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