Juan Lang : crypt32: Allow file stores to support more than one type of file.

Alexandre Julliard julliard at winehq.org
Mon Oct 1 07:54:57 CDT 2007


Module: wine
Branch: master
Commit: 99981716b2a9a43dd14e519ede7b7f42bb88844f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=99981716b2a9a43dd14e519ede7b7f42bb88844f

Author: Juan Lang <juan.lang at gmail.com>
Date:   Fri Sep 28 08:38:12 2007 -0700

crypt32: Allow file stores to support more than one type of file.

---

 dlls/crypt32/filestore.c |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/dlls/crypt32/filestore.c b/dlls/crypt32/filestore.c
index ffd9889..9dde31c 100644
--- a/dlls/crypt32/filestore.c
+++ b/dlls/crypt32/filestore.c
@@ -30,6 +30,7 @@ typedef struct _WINE_FILESTOREINFO
     DWORD      dwOpenFlags;
     HCERTSTORE memStore;
     HANDLE     file;
+    DWORD      type;
     BOOL       dirty;
 } WINE_FILESTOREINFO, *PWINE_FILESTOREINFO;
 
@@ -40,7 +41,7 @@ static void WINAPI CRYPT_FileCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
     TRACE("(%p, %08x)\n", store, dwFlags);
     if (store->dirty)
         CertSaveStore(store->memStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
-         CERT_STORE_SAVE_AS_STORE, CERT_STORE_SAVE_TO_FILE, store->file, 0);
+         store->type, CERT_STORE_SAVE_TO_FILE, store->file, 0);
     CertCloseStore(store->memStore, dwFlags);
     CloseHandle(store->file);
     CryptMemFree(store);
@@ -100,7 +101,19 @@ static BOOL WINAPI CRYPT_FileControl(HCERTSTORE hCertStore, DWORD dwFlags,
     case CERT_STORE_CTRL_RESYNC:
         CRYPT_EmptyStore(store->memStore);
         store->dirty = FALSE;
-        ret = CRYPT_ReadSerializedStoreFromFile(store->file, store->memStore);
+        if (store->type == CERT_STORE_SAVE_AS_STORE)
+            ret = CRYPT_ReadSerializedStoreFromFile(store->file,
+             store->memStore);
+        else if (store->type == CERT_STORE_SAVE_AS_PKCS7)
+        {
+            FIXME("unimplemented for PKCS stores\n");
+            ret = FALSE;
+        }
+        else
+        {
+            WARN("unknown type %d\n", store->type);
+            ret = FALSE;
+        }
         break;
     case CERT_STORE_CTRL_COMMIT:
         if (!(store->dwOpenFlags & CERT_FILE_STORE_COMMIT_ENABLE_FLAG))
@@ -111,7 +124,7 @@ static BOOL WINAPI CRYPT_FileControl(HCERTSTORE hCertStore, DWORD dwFlags,
         else if (store->dirty)
             ret = CertSaveStore(store->memStore,
              X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
-             CERT_STORE_SAVE_AS_STORE, CERT_STORE_SAVE_TO_FILE, store->file, 0);
+             store->type, CERT_STORE_SAVE_TO_FILE, store->file, 0);
         else
             ret = TRUE;
         break;
@@ -140,7 +153,7 @@ static void *fileProvFuncs[] = {
 };
 
 static PWINECRYPT_CERTSTORE CRYPT_CreateFileStore(DWORD dwFlags,
- HCERTSTORE memStore, HANDLE file)
+ HCERTSTORE memStore, HANDLE file, DWORD type)
 {
     PWINECRYPT_CERTSTORE store = NULL;
     PWINE_FILESTOREINFO info = CryptMemAlloc(sizeof(WINE_FILESTOREINFO));
@@ -152,6 +165,7 @@ static PWINECRYPT_CERTSTORE CRYPT_CreateFileStore(DWORD dwFlags,
         info->dwOpenFlags = dwFlags;
         info->memStore = memStore;
         info->file = file;
+        info->type = type;
         info->dirty = FALSE;
         provInfo.cbSize = sizeof(provInfo);
         provInfo.cStoreProvFunc = sizeof(fileProvFuncs) /
@@ -200,7 +214,8 @@ PWINECRYPT_CERTSTORE CRYPT_FileOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
         {
             if (CRYPT_ReadSerializedStoreFromFile(file, memStore))
             {
-                store = CRYPT_CreateFileStore(dwFlags, memStore, file);
+                store = CRYPT_CreateFileStore(dwFlags, memStore, file,
+                 CERT_STORE_SAVE_AS_STORE);
                 /* File store doesn't need crypto provider, so close it */
                 if (hCryptProv &&
                  !(dwFlags & CERT_STORE_NO_CRYPT_RELEASE_FLAG))
@@ -255,7 +270,8 @@ PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
         {
             if (CRYPT_ReadSerializedStoreFromFile(file, memStore))
             {
-                store = CRYPT_CreateFileStore(dwFlags, memStore, file);
+                store = CRYPT_CreateFileStore(dwFlags, memStore, file,
+                 CERT_STORE_SAVE_AS_STORE);
                 /* File store doesn't need crypto provider, so close it */
                 if (hCryptProv &&
                  !(dwFlags & CERT_STORE_NO_CRYPT_RELEASE_FLAG))




More information about the wine-cvs mailing list