Commit 2256a728 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

crypt32: Moved store release implementation to vtbl.

parent b3b1135d
...@@ -46,23 +46,30 @@ static void Collection_addref(WINECRYPT_CERTSTORE *store) ...@@ -46,23 +46,30 @@ static void Collection_addref(WINECRYPT_CERTSTORE *store)
TRACE("ref = %d\n", ref); TRACE("ref = %d\n", ref);
} }
static void Collection_closeStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags) static DWORD Collection_release(WINECRYPT_CERTSTORE *store, DWORD flags)
{ {
WINE_COLLECTIONSTORE *cs = (WINE_COLLECTIONSTORE*)store; WINE_COLLECTIONSTORE *cs = (WINE_COLLECTIONSTORE*)store;
WINE_STORE_LIST_ENTRY *entry, *next; WINE_STORE_LIST_ENTRY *entry, *next;
LONG ref;
TRACE("(%p, %08x)\n", store, dwFlags); if(flags)
FIXME("Unimplemented flags %x\n", flags);
LIST_FOR_EACH_ENTRY_SAFE(entry, next, &cs->stores, WINE_STORE_LIST_ENTRY, ref = InterlockedDecrement(&cs->hdr.ref);
entry) TRACE("(%p) ref=%d\n", store, ref);
if(ref)
return ERROR_SUCCESS;
LIST_FOR_EACH_ENTRY_SAFE(entry, next, &cs->stores, WINE_STORE_LIST_ENTRY, entry)
{ {
TRACE("closing %p\n", entry); TRACE("closing %p\n", entry);
CertCloseStore(entry->store, dwFlags); entry->store->vtbl->release(entry->store, flags);
CryptMemFree(entry); CryptMemFree(entry);
} }
cs->cs.DebugInfo->Spare[0] = 0; cs->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&cs->cs); DeleteCriticalSection(&cs->cs);
CRYPT_FreeStore(store); CRYPT_FreeStore(store);
return ERROR_SUCCESS;
} }
static void *CRYPT_CollectionCreateContextFromChild(WINE_COLLECTIONSTORE *store, static void *CRYPT_CollectionCreateContextFromChild(WINE_COLLECTIONSTORE *store,
...@@ -484,7 +491,7 @@ static BOOL Collection_control(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags, ...@@ -484,7 +491,7 @@ static BOOL Collection_control(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags,
static const store_vtbl_t CollectionStoreVtbl = { static const store_vtbl_t CollectionStoreVtbl = {
Collection_addref, Collection_addref,
Collection_closeStore, Collection_release,
Collection_control Collection_control
}; };
......
...@@ -247,7 +247,7 @@ typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST; ...@@ -247,7 +247,7 @@ typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
typedef struct { typedef struct {
void (*addref)(struct WINE_CRYPTCERTSTORE*); void (*addref)(struct WINE_CRYPTCERTSTORE*);
void (*closeStore)(struct WINE_CRYPTCERTSTORE*,DWORD); DWORD (*release)(struct WINE_CRYPTCERTSTORE*,DWORD);
BOOL (*control)(struct WINE_CRYPTCERTSTORE*,DWORD,DWORD,void const*); BOOL (*control)(struct WINE_CRYPTCERTSTORE*,DWORD,DWORD,void const*);
} store_vtbl_t; } store_vtbl_t;
......
...@@ -47,17 +47,26 @@ static void ProvStore_addref(WINECRYPT_CERTSTORE *store) ...@@ -47,17 +47,26 @@ static void ProvStore_addref(WINECRYPT_CERTSTORE *store)
TRACE("ref = %d\n", ref); TRACE("ref = %d\n", ref);
} }
static void ProvStore_closeStore(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags) static DWORD ProvStore_release(WINECRYPT_CERTSTORE *cert_store, DWORD flags)
{ {
WINE_PROVIDERSTORE *store = (WINE_PROVIDERSTORE*)cert_store; WINE_PROVIDERSTORE *store = (WINE_PROVIDERSTORE*)cert_store;
LONG ref;
TRACE("(%p, %08x)\n", store, dwFlags); if(flags)
FIXME("Unimplemented flags %x\n", flags);
ref = InterlockedDecrement(&store->hdr.ref);
TRACE("(%p) ref=%d\n", store, ref);
if(ref)
return ERROR_SUCCESS;
if (store->provCloseStore) if (store->provCloseStore)
store->provCloseStore(store->hStoreProv, dwFlags); store->provCloseStore(store->hStoreProv, flags);
if (!(store->dwStoreProvFlags & CERT_STORE_PROV_EXTERNAL_FLAG)) if (!(store->dwStoreProvFlags & CERT_STORE_PROV_EXTERNAL_FLAG))
CertCloseStore(store->memStore, dwFlags); store->memStore->vtbl->release(store->memStore, flags);
CRYPT_FreeStore((WINECRYPT_CERTSTORE*)store); CRYPT_FreeStore(&store->hdr);
return ERROR_SUCCESS;
} }
static BOOL CRYPT_ProvAddCert(WINECRYPT_CERTSTORE *store, void *cert, static BOOL CRYPT_ProvAddCert(WINECRYPT_CERTSTORE *store, void *cert,
...@@ -269,7 +278,7 @@ static BOOL ProvStore_control(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags, DW ...@@ -269,7 +278,7 @@ static BOOL ProvStore_control(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags, DW
static const store_vtbl_t ProvStoreVtbl = { static const store_vtbl_t ProvStoreVtbl = {
ProvStore_addref, ProvStore_addref,
ProvStore_closeStore, ProvStore_release,
ProvStore_control ProvStore_control
}; };
......
...@@ -108,6 +108,7 @@ void CRYPT_FreeStore(WINECRYPT_CERTSTORE *store) ...@@ -108,6 +108,7 @@ void CRYPT_FreeStore(WINECRYPT_CERTSTORE *store)
{ {
if (store->properties) if (store->properties)
ContextPropertyList_Free(store->properties); ContextPropertyList_Free(store->properties);
store->dwMagic = 0;
CryptMemFree(store); CryptMemFree(store);
} }
...@@ -290,18 +291,24 @@ static void MemStore_addref(WINECRYPT_CERTSTORE *store) ...@@ -290,18 +291,24 @@ static void MemStore_addref(WINECRYPT_CERTSTORE *store)
TRACE("ref = %d\n", ref); TRACE("ref = %d\n", ref);
} }
static void MemStore_closeStore(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags) static DWORD MemStore_release(WINECRYPT_CERTSTORE *cert_store, DWORD flags)
{ {
WINE_MEMSTORE *store = (WINE_MEMSTORE*)cert_store; WINE_MEMSTORE *store = (WINE_MEMSTORE*)cert_store;
LONG ref;
TRACE("(%p, %08x)\n", store, dwFlags); if(flags)
if (dwFlags) FIXME("Unimplemented flags %x\n", flags);
FIXME("Unimplemented flags: %08x\n", dwFlags);
ref = InterlockedDecrement(&store->hdr.ref);
TRACE("(%p) ref=%d\n", store, ref);
if(ref)
return ERROR_SUCCESS;
ContextList_Free(store->certs); ContextList_Free(store->certs);
ContextList_Free(store->crls); ContextList_Free(store->crls);
ContextList_Free(store->ctls); ContextList_Free(store->ctls);
CRYPT_FreeStore((WINECRYPT_CERTSTORE*)store); CRYPT_FreeStore(&store->hdr);
return ERROR_SUCCESS;
} }
static BOOL MemStore_control(WINECRYPT_CERTSTORE *store, DWORD dwFlags, static BOOL MemStore_control(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
...@@ -313,7 +320,7 @@ static BOOL MemStore_control(WINECRYPT_CERTSTORE *store, DWORD dwFlags, ...@@ -313,7 +320,7 @@ static BOOL MemStore_control(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
static const store_vtbl_t MemStoreVtbl = { static const store_vtbl_t MemStoreVtbl = {
MemStore_addref, MemStore_addref,
MemStore_closeStore, MemStore_release,
MemStore_control MemStore_control
}; };
...@@ -1227,6 +1234,7 @@ HCERTSTORE WINAPI CertDuplicateStore(HCERTSTORE hCertStore) ...@@ -1227,6 +1234,7 @@ HCERTSTORE WINAPI CertDuplicateStore(HCERTSTORE hCertStore)
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags) BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
{ {
WINECRYPT_CERTSTORE *hcs = hCertStore; WINECRYPT_CERTSTORE *hcs = hCertStore;
DWORD res;
TRACE("(%p, %08x)\n", hCertStore, dwFlags); TRACE("(%p, %08x)\n", hCertStore, dwFlags);
...@@ -1236,16 +1244,12 @@ BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags) ...@@ -1236,16 +1244,12 @@ BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
if ( hcs->dwMagic != WINE_CRYPTCERTSTORE_MAGIC ) if ( hcs->dwMagic != WINE_CRYPTCERTSTORE_MAGIC )
return FALSE; return FALSE;
if (hcs->ref <= 0) res = hcs->vtbl->release(hcs, dwFlags);
ERR("%p's ref count is %d\n", hcs, hcs->ref); if (res != ERROR_SUCCESS) {
if (InterlockedDecrement(&hcs->ref) == 0) SetLastError(res);
{ return FALSE;
TRACE("%p's ref count is 0, freeing\n", hcs);
hcs->dwMagic = 0;
hcs->vtbl->closeStore(hcs, dwFlags);
} }
else
TRACE("%p's ref count is %d\n", hcs, hcs->ref);
return TRUE; return TRUE;
} }
......
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