[PATCH 2/2] crypt32/tests: Drop store test workarounds for Windows <= 2000

Alex Henrie alexhenrie24 at gmail.com
Tue Jan 30 12:08:15 CST 2018


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
This resolves a Coverity warning.

 dlls/crypt32/tests/store.c | 340 +++++++++++++++------------------------------
 1 file changed, 111 insertions(+), 229 deletions(-)

diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c
index 565495a29c..47cd0b38cd 100644
--- a/dlls/crypt32/tests/store.c
+++ b/dlls/crypt32/tests/store.c
@@ -117,16 +117,6 @@ static const BYTE signedCTLWithCTLInnerContent[] = {
 0x8e,0xe7,0x5f,0x76,0x2b,0xd1,0x6a,0x82,0xb3,0x30,0x25,0x61,0xf6,0x25,0x23,
 0x57,0x6c,0x0b,0x47,0xb8 };
 
-static BOOL (WINAPI *pCertControlStore)(HCERTSTORE,DWORD,DWORD,void const*);
-static PCCRL_CONTEXT (WINAPI *pCertEnumCRLsInStore)(HCERTSTORE,PCCRL_CONTEXT);
-static BOOL (WINAPI *pCertEnumSystemStore)(DWORD,void*,void*,PFN_CERT_ENUM_SYSTEM_STORE);
-static BOOL (WINAPI *pCertGetStoreProperty)(HCERTSTORE,DWORD,void*,DWORD*);
-static void (WINAPI *pCertRemoveStoreFromCollection)(HCERTSTORE,HCERTSTORE);
-static BOOL (WINAPI *pCertSetStoreProperty)(HCERTSTORE,DWORD,DWORD,const void*);
-static BOOL (WINAPI *pCertAddCertificateLinkToStore)(HCERTSTORE,PCCERT_CONTEXT,DWORD,PCCERT_CONTEXT*);
-static BOOL (WINAPI *pCertRegisterSystemStore)(const void*,DWORD,void*,void*);
-static BOOL (WINAPI *pCertUnregisterSystemStore)(const void*,DWORD);
-
 #define test_store_is_empty(store) _test_store_is_empty(__LINE__,store)
 static void _test_store_is_empty(unsigned line, HCERTSTORE store)
 {
@@ -891,32 +881,25 @@ static void testCollectionStore(void)
         ok(context == NULL, "Unexpected cert\n");
     }
 
-    if (!pCertRemoveStoreFromCollection)
-    {
-        win_skip("CertRemoveStoreFromCollection() is not available\n");
-    }
-    else
-    {
-        /* Finally, test removing stores from the collection.  No return
-         *  value, so it's a bit funny to test.
-         */
-        /* This crashes
-         * pCertRemoveStoreFromCollection(NULL, NULL);
-         */
-        /* This "succeeds," no crash, no last error set */
-        SetLastError(0xdeadbeef);
-        pCertRemoveStoreFromCollection(store2, collection);
-        ok(GetLastError() == 0xdeadbeef,
-           "Didn't expect an error to be set: %08x\n", GetLastError());
-
-        /* After removing store2, the collection should be empty */
-        SetLastError(0xdeadbeef);
-        pCertRemoveStoreFromCollection(collection, store2);
-        ok(GetLastError() == 0xdeadbeef,
-           "Didn't expect an error to be set: %08x\n", GetLastError());
-        context = CertEnumCertificatesInStore(collection, NULL);
-        ok(!context, "Unexpected cert\n");
-    }
+    /* Finally, test removing stores from the collection.  No return
+     *  value, so it's a bit funny to test.
+     */
+    /* This crashes
+     * CertRemoveStoreFromCollection(NULL, NULL);
+     */
+    /* This "succeeds," no crash, no last error set */
+    SetLastError(0xdeadbeef);
+    CertRemoveStoreFromCollection(store2, collection);
+    ok(GetLastError() == 0xdeadbeef,
+       "Didn't expect an error to be set: %08x\n", GetLastError());
+
+    /* After removing store2, the collection should be empty */
+    SetLastError(0xdeadbeef);
+    CertRemoveStoreFromCollection(collection, store2);
+    ok(GetLastError() == 0xdeadbeef,
+       "Didn't expect an error to be set: %08x\n", GetLastError());
+    context = CertEnumCertificatesInStore(collection, NULL);
+    ok(!context, "Unexpected cert\n");
 
     CertCloseStore(collection, 0);
     CertCloseStore(store2, 0);
@@ -944,16 +927,11 @@ static void testCollectionStore(void)
     CertCloseStore(store1, 0);
 
     /* Test whether a collection store can be committed */
-    if (!pCertControlStore)
-    {
-        win_skip("CertControlStore() is not available\n");
-        return;
-    }
     collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
 
     SetLastError(0xdeadbeef);
-    ret = pCertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL);
+    ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL);
     ok(ret, "CertControlStore failed: %08x\n", GetLastError());
 
     /* Adding a mem store that can't be committed prevents a successful commit.
@@ -962,10 +940,10 @@ static void testCollectionStore(void)
      CERT_STORE_CREATE_NEW_FLAG, NULL);
     CertAddStoreToCollection(collection, store1, 0, 0);
     SetLastError(0xdeadbeef);
-    ret = pCertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL);
+    ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL);
     ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
      "expected ERROR_CALL_NOT_IMPLEMENTED, got %d\n", GetLastError());
-    pCertRemoveStoreFromCollection(collection, store1);
+    CertRemoveStoreFromCollection(collection, store1);
     CertCloseStore(store1, 0);
 
     /* Test adding a cert to a collection with a file store, committing the
@@ -991,7 +969,7 @@ static void testCollectionStore(void)
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
     ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
      GetLastError());
-    ret = pCertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL);
+    ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL);
     ok(ret, "CertControlStore failed: %d\n", ret);
     compareStore(collection, "serialized store with cert",
      serializedStoreWithCert, sizeof(serializedStoreWithCert), FALSE);
@@ -1059,13 +1037,6 @@ static void testRegStore(void)
     todo_wine ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError());
     CertCloseStore(store, 0);
 
-    /* It looks like the remainder pretty much needs CertControlStore() */
-    if (!pCertControlStore)
-    {
-        win_skip("CertControlStore() is not available\n");
-        return;
-    }
-
     rc = RegCreateKeyExA(HKEY_CURRENT_USER, tempKey, 0, NULL, 0, KEY_ALL_ACCESS,
      NULL, &key, NULL);
     ok(!rc, "RegCreateKeyExA failed: %d\n", rc);
@@ -1089,7 +1060,7 @@ static void testRegStore(void)
         ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
          GetLastError());
         /* so flush the cache to force a commit.. */
-        ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
+        ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(ret, "CertControlStore failed: %08x\n", GetLastError());
         /* and check that the expected subkey was written. */
         size = sizeof(hash);
@@ -1148,7 +1119,7 @@ static void testRegStore(void)
         ok(context != NULL, "Expected a cert context\n");
         if (context)
             CertDeleteCertificateFromStore(context);
-        ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
+        ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(ret, "CertControlStore failed: %08x\n", GetLastError());
 
         /* Add a serialized cert with a bogus hash directly to the registry */
@@ -1185,7 +1156,7 @@ static void testRegStore(void)
              sizeof(buf));
             ok(!rc, "RegSetValueExA failed: %d\n", rc);
 
-            ret = pCertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL);
+            ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL);
             ok(ret, "CertControlStore failed: %08x\n", GetLastError());
 
             /* Make sure the bogus hash cert gets loaded. */
@@ -1242,7 +1213,7 @@ static void testRegStore(void)
              sizeof(buf));
             ok(!rc, "RegSetValueExA failed: %d\n", rc);
 
-            ret = pCertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL);
+            ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL);
             ok(ret, "CertControlStore failed: %08x\n", GetLastError());
 
             /* and make sure just one cert still gets loaded. */
@@ -1253,9 +1224,7 @@ static void testRegStore(void)
                 if (context)
                     certCount++;
             } while (context != NULL);
-            ok(certCount == 1 ||
-               broken(certCount == 2) /* NT4 */ ,
-               "Expected 1 certificates, got %d\n", certCount);
+            ok(certCount == 1, "Expected 1 certificate, got %d\n", certCount);
 
             /* Try again with the correct hash... */
             ptr = buf + sizeof(*hdr);
@@ -1265,7 +1234,7 @@ static void testRegStore(void)
              sizeof(buf));
             ok(!rc, "RegSetValueExA failed: %d\n", rc);
 
-            ret = pCertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL);
+            ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL);
             ok(ret, "CertControlStore failed: %08x\n", GetLastError());
 
             /* and make sure two certs get loaded. */
@@ -1304,20 +1273,10 @@ static void testRegStore(void)
         rc = RegDeleteKeyA(HKEY_CURRENT_USER, tempKey);
         if (rc)
         {
-            HMODULE shlwapi = LoadLibraryA("shlwapi");
-
             /* Use shlwapi's SHDeleteKeyA to _really_ blow away the key,
              * otherwise subsequent tests will fail.
              */
-            if (shlwapi)
-            {
-                DWORD (WINAPI *pSHDeleteKeyA)(HKEY, LPCSTR);
-
-                pSHDeleteKeyA = (void*)GetProcAddress(shlwapi, "SHDeleteKeyA");
-                if (pSHDeleteKeyA)
-                    pSHDeleteKeyA(HKEY_CURRENT_USER, tempKey);
-                FreeLibrary(shlwapi);
-            }
+            SHDeleteKeyA(HKEY_CURRENT_USER, tempKey);
         }
     }
 }
@@ -1438,7 +1397,6 @@ static void testSystemStore(void)
         if (memStore)
         {
             BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0);
-            /* FIXME: this'll fail on NT4, but what error will it give? */
             ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError());
             CertCloseStore(memStore, 0);
         }
@@ -1489,12 +1447,6 @@ static void testFileStore(void)
     PCCERT_CONTEXT cert;
     HANDLE file;
 
-    if (!pCertControlStore)
-    {
-        win_skip("CertControlStore() is not available\n");
-        return;
-    }
-
     store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, 0, NULL);
     ok(!store && GetLastError() == ERROR_INVALID_HANDLE,
      "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError());
@@ -1530,7 +1482,7 @@ static void testFileStore(void)
         /* apparently allows adding certificates.. */
         ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret);
         /* but not commits.. */
-        ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
+        ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
          "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError());
         /* It still has certs in memory.. */
@@ -1554,7 +1506,7 @@ static void testFileStore(void)
         ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
          bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
         ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret);
-        ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
+        ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
          "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError());
         CertCloseStore(store, 0);
@@ -1569,7 +1521,7 @@ static void testFileStore(void)
         ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
          bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
         ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret);
-        ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
+        ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
          "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError());
         CertCloseStore(store, 0);
@@ -1585,7 +1537,7 @@ static void testFileStore(void)
         ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
          GetLastError());
         /* with commits enabled, commit is allowed */
-        ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
+        ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(ret, "CertControlStore failed: %d\n", ret);
         compareStore(store, "serialized store with cert",
          serializedStoreWithCert, sizeof(serializedStoreWithCert), FALSE);
@@ -1701,15 +1653,11 @@ static void testFileNameStore(void)
     BOOL ret;
     DWORD GLE;
 
-    if (0)
-    {
-        /* Crashes on NT4 */
-        store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, 0, NULL);
-        GLE = GetLastError();
-        ok(!store && (GLE == ERROR_PATH_NOT_FOUND || GLE == ERROR_INVALID_PARAMETER),
-         "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08x\n",
-         GLE);
-    }
+    store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, 0, NULL);
+    GLE = GetLastError();
+    ok(!store && (GLE == ERROR_PATH_NOT_FOUND || GLE == ERROR_INVALID_PARAMETER),
+     "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08x\n",
+     GLE);
 
     if (!GetTempFileNameW(szDot, szPrefix, 0, filename))
        return;
@@ -1736,11 +1684,8 @@ static void testFileNameStore(void)
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
-        if (pCertEnumCRLsInStore)
-        {
-            crl = pCertEnumCRLsInStore(store, NULL);
-            ok(!crl, "Expected no CRLs\n");
-        }
+        crl = CertEnumCRLsInStore(store, NULL);
+        ok(!crl, "Expected no CRLs\n");
 
         CertCloseStore(store, 0);
         DeleteFileW(filename);
@@ -1760,11 +1705,8 @@ static void testFileNameStore(void)
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
-        if (pCertEnumCRLsInStore)
-        {
-            crl = pCertEnumCRLsInStore(store, NULL);
-            ok(!crl, "Expected no CRLs\n");
-        }
+        crl = CertEnumCRLsInStore(store, NULL);
+        ok(!crl, "Expected no CRLs\n");
 
         CertCloseStore(store, 0);
         DeleteFileW(filename);
@@ -1784,13 +1726,10 @@ static void testFileNameStore(void)
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
-        if (pCertEnumCRLsInStore)
-        {
-            crl = pCertEnumCRLsInStore(store, NULL);
-            ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", GetLastError());
-            crl = pCertEnumCRLsInStore(store, crl);
-            ok(!crl, "Expected only one CRL\n");
-        }
+        crl = CertEnumCRLsInStore(store, NULL);
+        ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", GetLastError());
+        crl = CertEnumCRLsInStore(store, crl);
+        ok(!crl, "Expected only one CRL\n");
 
         CertCloseStore(store, 0);
         /* Don't delete it this time, the next test uses it */
@@ -1848,11 +1787,8 @@ static void testFileNameStore(void)
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
-        if (pCertEnumCRLsInStore)
-        {
-            crl = pCertEnumCRLsInStore(store, NULL);
-            ok(!crl, "Expected no CRLs\n");
-        }
+        crl = CertEnumCRLsInStore(store, NULL);
+        ok(!crl, "Expected no CRLs\n");
 
         CertCloseStore(store, 0);
         DeleteFileW(filename);
@@ -1872,11 +1808,8 @@ static void testFileNameStore(void)
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
-        if (pCertEnumCRLsInStore)
-        {
-            crl = pCertEnumCRLsInStore(store, NULL);
-            ok(!crl, "Expected no CRLs\n");
-        }
+        crl = CertEnumCRLsInStore(store, NULL);
+        ok(!crl, "Expected no CRLs\n");
 
         CertCloseStore(store, 0);
         DeleteFileW(filename);
@@ -1966,16 +1899,13 @@ static void testMessageStore(void)
         } while (cert);
         ok(count == 0, "Expected 0 certificates, got %d\n", count);
 
-        if (pCertEnumCRLsInStore)
-        {
-            count = 0;
-            do {
-                crl = pCertEnumCRLsInStore(store, crl);
-                if (crl)
-                    count++;
-            } while (crl);
-            ok(count == 0, "Expected 0 CRLs, got %d\n", count);
-        }
+        count = 0;
+        do {
+            crl = CertEnumCRLsInStore(store, crl);
+            if (crl)
+                count++;
+        } while (crl);
+        ok(count == 0, "Expected 0 CRLs, got %d\n", count);
 
         /* Can add certs to a message store */
         ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
@@ -2017,16 +1947,14 @@ static void testMessageStore(void)
         } while (cert);
         ok(count == 1, "Expected 1 certificate, got %d\n", count);
 
-        if (pCertEnumCRLsInStore)
-        {
-            count = 0;
-            do {
-                crl = pCertEnumCRLsInStore(store, crl);
-                if (crl)
-                    count++;
-            } while (crl);
-            ok(count == 1, "Expected 1 CRL, got %d\n", count);
-        }
+        count = 0;
+        do {
+            crl = CertEnumCRLsInStore(store, crl);
+            if (crl)
+                count++;
+        } while (crl);
+        ok(count == 1, "Expected 1 CRL, got %d\n", count);
+
         CertCloseStore(store, 0);
     }
     /* Encoding appears to be ignored */
@@ -2046,9 +1974,7 @@ static void testMessageStore(void)
     blob.pbData = (LPBYTE)hashBareContent;
     SetLastError(0xdeadbeef);
     store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob);
-    ok(!store &&
-     (GetLastError() == CRYPT_E_ASN1_BADTAG ||
-      broken(GetLastError() == OSS_DATA_ERROR)), /* NT4 */
+    ok(!store && GetLastError() == CRYPT_E_ASN1_BADTAG,
      "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
 }
 
@@ -2082,11 +2008,9 @@ static void testSerializedStore(void)
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
-        if (pCertEnumCRLsInStore)
-        {
-            crl = pCertEnumCRLsInStore(store, NULL);
-            ok(!crl, "Expected no CRLs\n");
-        }
+        crl = CertEnumCRLsInStore(store, NULL);
+        ok(!crl, "Expected no CRLs\n");
+
         CertCloseStore(store, 0);
     }
     blob.cbData = sizeof(serializedStoreWithCertAndCRL);
@@ -2103,14 +2027,12 @@ static void testSerializedStore(void)
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
-        if (pCertEnumCRLsInStore)
-        {
-            crl = pCertEnumCRLsInStore(store, NULL);
-            ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n",
-             GetLastError());
-            crl = pCertEnumCRLsInStore(store, crl);
-            ok(!crl, "Expected only one CRL\n");
-        }
+        crl = CertEnumCRLsInStore(store, NULL);
+        ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n",
+         GetLastError());
+        crl = CertEnumCRLsInStore(store, crl);
+        ok(!crl, "Expected only one CRL\n");
+
         CertCloseStore(store, 0);
     }
 }
@@ -2159,15 +2081,9 @@ static void testCertRegisterSystemStore(void)
     const CERT_CONTEXT *cert, *cert2;
     unsigned int i;
 
-    if (!pCertRegisterSystemStore || !pCertUnregisterSystemStore)
-    {
-        win_skip("CertRegisterSystemStore() or CertUnregisterSystemStore() is not available\n");
-        return;
-    }
-
     for (i = 0; i < sizeof(reg_system_store_test_data) / sizeof(reg_system_store_test_data[0]); i++) {
         cur_flag = reg_system_store_test_data[i].cert_store;
-        ret = pCertRegisterSystemStore(WineTestW, cur_flag, NULL, NULL);
+        ret = CertRegisterSystemStore(WineTestW, cur_flag, NULL, NULL);
         if (!ret)
         {
             err = GetLastError();
@@ -2209,7 +2125,7 @@ static void testCertRegisterSystemStore(void)
         ret = CertCloseStore(hstore, 0);
         ok (ret, "CertCloseStore failed at %08x, last error %x\n", cur_flag, GetLastError());
 
-        ret = pCertUnregisterSystemStore(WineTestW, cur_flag );
+        ret = CertUnregisterSystemStore(WineTestW, cur_flag );
         todo_wine_if (reg_system_store_test_data[i].todo)
             ok( ret == reg_system_store_test_data[i].expected,
                 "Unregistering failed at %08x, last error %d\n", cur_flag, GetLastError());
@@ -2237,23 +2153,17 @@ static void testCertEnumSystemStore(void)
     BOOL ret;
     struct EnumSystemStoreInfo info = { FALSE, 0 };
 
-    if (!pCertEnumSystemStore)
-    {
-        win_skip("CertEnumSystemStore() is not available\n");
-        return;
-    }
-
     SetLastError(0xdeadbeef);
-    ret = pCertEnumSystemStore(0, NULL, NULL, NULL);
+    ret = CertEnumSystemStore(0, NULL, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
      "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
     /* Crashes
-    ret = pCertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, NULL,
+    ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, NULL,
      NULL);
      */
 
     SetLastError(0xdeadbeef);
-    ret = pCertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info,
+    ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info,
      enumSystemStoreCB);
     /* Callback returning FALSE stops enumeration */
     ok(!ret, "Expected CertEnumSystemStore to stop\n");
@@ -2262,7 +2172,7 @@ static void testCertEnumSystemStore(void)
 
     info.goOn = TRUE;
     info.storeCount = 0;
-    ret = pCertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info,
+    ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info,
      enumSystemStoreCB);
     ok(ret, "CertEnumSystemStore failed: %08x\n", GetLastError());
     /* There should always be at least My, Root, and CA stores */
@@ -2277,58 +2187,52 @@ static void testStoreProperty(void)
     DWORD propID, size = 0, state;
     CRYPT_DATA_BLOB blob;
 
-    if (!pCertGetStoreProperty || !pCertSetStoreProperty)
-    {
-        win_skip("CertGet/SetStoreProperty() is not available\n");
-        return;
-    }
-
     /* Crash
-    ret = pCertGetStoreProperty(NULL, 0, NULL, NULL);
-    ret = pCertGetStoreProperty(NULL, 0, NULL, &size);
-    ret = pCertGetStoreProperty(store, 0, NULL, NULL);
+    ret = CertGetStoreProperty(NULL, 0, NULL, NULL);
+    ret = CertGetStoreProperty(NULL, 0, NULL, &size);
+    ret = CertGetStoreProperty(store, 0, NULL, NULL);
      */
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
     /* Check a missing prop ID */
     SetLastError(0xdeadbeef);
-    ret = pCertGetStoreProperty(store, 0, NULL, &size);
+    ret = CertGetStoreProperty(store, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
      "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
     /* Contrary to MSDN, CERT_ACCESS_STATE_PROP_ID is supported for stores.. */
     size = sizeof(state);
-    ret = pCertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size);
+    ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size);
     ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n",
      GetLastError());
     ok(!state, "Expected a non-persisted store\n");
     /* and CERT_STORE_LOCALIZED_NAME_PROP_ID isn't supported by default. */
     size = 0;
-    ret = pCertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL,
+    ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL,
      &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
      "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
     /* Delete an arbitrary property on a store */
-    ret = pCertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL);
+    ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL);
     ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError());
     /* Set an arbitrary property on a store */
     blob.pbData = (LPBYTE)&state;
     blob.cbData = sizeof(state);
-    ret = pCertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, &blob);
+    ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, &blob);
     ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError());
     /* Get an arbitrary property that's been set */
-    ret = pCertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size);
+    ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size);
     ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError());
     ok(size == sizeof(state), "Unexpected data size %d\n", size);
-    ret = pCertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, &propID, &size);
+    ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, &propID, &size);
     ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError());
     ok(propID == state, "CertGetStoreProperty got the wrong value\n");
     /* Delete it again */
-    ret = pCertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL);
+    ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL);
     ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError());
     /* And check that it's missing */
     SetLastError(0xdeadbeef);
-    ret = pCertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size);
+    ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
      "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
     CertCloseStore(store, 0);
@@ -2336,13 +2240,13 @@ static void testStoreProperty(void)
     /* Recheck on the My store.. */
     store = CertOpenSystemStoreW(0, MyW);
     size = sizeof(state);
-    ret = pCertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size);
+    ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size);
     ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n",
      GetLastError());
     ok(state, "Expected a persisted store\n");
     SetLastError(0xdeadbeef);
     size = 0;
-    ret = pCertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL,
+    ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL,
      &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
      "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
@@ -2588,32 +2492,26 @@ static void testAddCertificateLink(void)
     WCHAR filename1[MAX_PATH], filename2[MAX_PATH];
     HANDLE file;
 
-    if (!pCertAddCertificateLinkToStore)
-    {
-        win_skip("CertAddCertificateLinkToStore not found\n");
-        return;
-    }
-
     if (0)
     {
         /* Crashes, i.e. the store is dereferenced without checking. */
-        ret = pCertAddCertificateLinkToStore(NULL, NULL, 0, NULL);
+        ret = CertAddCertificateLinkToStore(NULL, NULL, 0, NULL);
     }
 
     /* Adding a certificate link to a store requires a valid add disposition */
     store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
     SetLastError(0xdeadbeef);
-    ret = pCertAddCertificateLinkToStore(store1, NULL, 0, NULL);
+    ret = CertAddCertificateLinkToStore(store1, NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
      "expected E_INVALIDARG, got %08x\n", GetLastError());
     source = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
     SetLastError(0xdeadbeef);
-    ret = pCertAddCertificateLinkToStore(store1, source, 0, NULL);
+    ret = CertAddCertificateLinkToStore(store1, source, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
      "expected E_INVALIDARG, got %08x\n", GetLastError());
-    ret = pCertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS,
+    ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS,
      NULL);
     ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
     if (0)
@@ -2621,14 +2519,14 @@ static void testAddCertificateLink(void)
         /* Crashes, i.e. the source certificate is dereferenced without
          * checking when a valid add disposition is given.
          */
-        ret = pCertAddCertificateLinkToStore(store1, NULL, CERT_STORE_ADD_ALWAYS,
+        ret = CertAddCertificateLinkToStore(store1, NULL, CERT_STORE_ADD_ALWAYS,
          NULL);
     }
     CertCloseStore(store1, 0);
 
     store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ret = pCertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS,
+    ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS,
      &linked);
     ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
     if (ret)
@@ -2704,7 +2602,7 @@ static void testAddCertificateLink(void)
     /* Test adding a link to a memory store. */
     store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ret = pCertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
+    ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
      &linked);
     ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
     if (ret)
@@ -2766,7 +2664,7 @@ static void testAddCertificateLink(void)
     ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError());
     CloseHandle(file);
     /* Test adding a link to a file store. */
-    ret = pCertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
+    ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
      &linked);
     ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
     if (ret)
@@ -2808,7 +2706,7 @@ static void testAddCertificateLink(void)
     source = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
     SetLastError(0xdeadbeef);
-    ret = pCertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS,
+    ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS,
      &linked);
     ok(!ret && GetLastError() == E_INVALIDARG,
      "expected E_INVALIDARG, got %08x\n", GetLastError());
@@ -2835,13 +2733,13 @@ static void testAddCertificateLink(void)
     ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError());
     CloseHandle(file);
 
-    ret = pCertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
+    ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
      &linked);
     ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
     if (ret)
     {
         ok(linked->hCertStore == store2, "unexpected store\n");
-        ret = pCertControlStore(store2, 0, CERT_STORE_CTRL_COMMIT, NULL);
+        ret = CertControlStore(store2, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(ret, "CertControlStore failed: %d\n", ret);
         compareStore(store2, "file store -> system store",
          serializedStoreWithCertAndHash,
@@ -2858,7 +2756,7 @@ static void testAddCertificateLink(void)
     store2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER, WineTestW);
     ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError());
-    ret = pCertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
+    ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
      &linked);
     ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
     if (ret)
@@ -2893,7 +2791,7 @@ static DWORD countCRLsInStore(HCERTSTORE store)
     DWORD crls = 0;
 
     do {
-        crl = pCertEnumCRLsInStore(store, crl);
+        crl = CertEnumCRLsInStore(store, crl);
         if (crl)
             crls++;
     } while (crl);
@@ -3121,11 +3019,8 @@ static void test_I_UpdateStore(void)
     ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError());
     certs = countCertsInStore(store1);
     ok(certs == 1, "Expected 1 cert, got %d\n", certs);
-    if (pCertEnumCRLsInStore)
-    {
-        certs = countCRLsInStore(store1);
-        ok(certs == 1, "Expected 1 CRL, got %d\n", certs);
-    }
+    certs = countCRLsInStore(store1);
+    ok(certs == 1, "Expected 1 CRL, got %d\n", certs);
 
     CertDeleteCertificateFromStore(cert);
     /* If a context is deleted from store2, I_CertUpdateStore deletes it
@@ -3142,19 +3037,6 @@ static void test_I_UpdateStore(void)
 
 START_TEST(store)
 {
-    HMODULE hdll;
-
-    hdll = GetModuleHandleA("Crypt32.dll");
-    pCertControlStore = (void*)GetProcAddress(hdll, "CertControlStore");
-    pCertEnumCRLsInStore = (void*)GetProcAddress(hdll, "CertEnumCRLsInStore");
-    pCertEnumSystemStore = (void*)GetProcAddress(hdll, "CertEnumSystemStore");
-    pCertGetStoreProperty = (void*)GetProcAddress(hdll, "CertGetStoreProperty");
-    pCertRemoveStoreFromCollection = (void*)GetProcAddress(hdll, "CertRemoveStoreFromCollection");
-    pCertSetStoreProperty = (void*)GetProcAddress(hdll, "CertSetStoreProperty");
-    pCertAddCertificateLinkToStore = (void*)GetProcAddress(hdll, "CertAddCertificateLinkToStore");
-    pCertRegisterSystemStore = (void*)GetProcAddress(hdll, "CertRegisterSystemStore");
-    pCertUnregisterSystemStore = (void*)GetProcAddress(hdll, "CertUnregisterSystemStore");
-
     /* various combinations of CertOpenStore */
     testMemStore();
     testCollectionStore();
-- 
2.16.1




More information about the wine-devel mailing list