crypt32: Moved store functions to vtbl.
This commit is contained in:
parent
73ca9d2d0b
commit
fa0b7b7d3d
|
@ -40,9 +40,9 @@ typedef struct _WINE_COLLECTIONSTORE
|
||||||
struct list stores;
|
struct list stores;
|
||||||
} WINE_COLLECTIONSTORE;
|
} WINE_COLLECTIONSTORE;
|
||||||
|
|
||||||
static void WINAPI CRYPT_CollectionCloseStore(HCERTSTORE store, DWORD dwFlags)
|
static void Collection_closeStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
WINE_COLLECTIONSTORE *cs = store;
|
WINE_COLLECTIONSTORE *cs = (WINE_COLLECTIONSTORE*)store;
|
||||||
WINE_STORE_LIST_ENTRY *entry, *next;
|
WINE_STORE_LIST_ENTRY *entry, *next;
|
||||||
|
|
||||||
TRACE("(%p, %08x)\n", store, dwFlags);
|
TRACE("(%p, %08x)\n", store, dwFlags);
|
||||||
|
@ -439,15 +439,14 @@ static BOOL CRYPT_CollectionDeleteCTL(WINECRYPT_CERTSTORE *store,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL WINAPI CRYPT_CollectionControl(HCERTSTORE hCertStore, DWORD dwFlags,
|
static BOOL Collection_control(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags,
|
||||||
DWORD dwCtrlType, void const *pvCtrlPara)
|
DWORD dwCtrlType, void const *pvCtrlPara)
|
||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
WINE_COLLECTIONSTORE *store = hCertStore;
|
WINE_COLLECTIONSTORE *store = (WINE_COLLECTIONSTORE*)cert_store;
|
||||||
WINE_STORE_LIST_ENTRY *entry;
|
WINE_STORE_LIST_ENTRY *entry;
|
||||||
|
|
||||||
TRACE("(%p, %08x, %d, %p)\n", hCertStore, dwFlags, dwCtrlType,
|
TRACE("(%p, %08x, %d, %p)\n", cert_store, dwFlags, dwCtrlType, pvCtrlPara);
|
||||||
pvCtrlPara);
|
|
||||||
|
|
||||||
if (!store)
|
if (!store)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -466,10 +465,9 @@ static BOOL WINAPI CRYPT_CollectionControl(HCERTSTORE hCertStore, DWORD dwFlags,
|
||||||
EnterCriticalSection(&store->cs);
|
EnterCriticalSection(&store->cs);
|
||||||
LIST_FOR_EACH_ENTRY(entry, &store->stores, WINE_STORE_LIST_ENTRY, entry)
|
LIST_FOR_EACH_ENTRY(entry, &store->stores, WINE_STORE_LIST_ENTRY, entry)
|
||||||
{
|
{
|
||||||
if (entry->store->control)
|
if (entry->store->vtbl->control)
|
||||||
{
|
{
|
||||||
ret = entry->store->control(entry->store, dwFlags, dwCtrlType,
|
ret = entry->store->vtbl->control(entry->store, dwFlags, dwCtrlType, pvCtrlPara);
|
||||||
pvCtrlPara);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -478,6 +476,11 @@ static BOOL WINAPI CRYPT_CollectionControl(HCERTSTORE hCertStore, DWORD dwFlags,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const store_vtbl_t CollectionStoreVtbl = {
|
||||||
|
Collection_closeStore,
|
||||||
|
Collection_control
|
||||||
|
};
|
||||||
|
|
||||||
WINECRYPT_CERTSTORE *CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
|
WINECRYPT_CERTSTORE *CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
|
||||||
DWORD dwFlags, const void *pvPara)
|
DWORD dwFlags, const void *pvPara)
|
||||||
{
|
{
|
||||||
|
@ -494,8 +497,7 @@ WINECRYPT_CERTSTORE *CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
|
||||||
if (store)
|
if (store)
|
||||||
{
|
{
|
||||||
memset(store, 0, sizeof(WINE_COLLECTIONSTORE));
|
memset(store, 0, sizeof(WINE_COLLECTIONSTORE));
|
||||||
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeCollection);
|
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeCollection, &CollectionStoreVtbl);
|
||||||
store->hdr.closeStore = CRYPT_CollectionCloseStore;
|
|
||||||
store->hdr.certs.addContext = CRYPT_CollectionAddCert;
|
store->hdr.certs.addContext = CRYPT_CollectionAddCert;
|
||||||
store->hdr.certs.enumContext = CRYPT_CollectionEnumCert;
|
store->hdr.certs.enumContext = CRYPT_CollectionEnumCert;
|
||||||
store->hdr.certs.deleteContext = CRYPT_CollectionDeleteCert;
|
store->hdr.certs.deleteContext = CRYPT_CollectionDeleteCert;
|
||||||
|
@ -505,7 +507,6 @@ WINECRYPT_CERTSTORE *CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
|
||||||
store->hdr.ctls.addContext = CRYPT_CollectionAddCTL;
|
store->hdr.ctls.addContext = CRYPT_CollectionAddCTL;
|
||||||
store->hdr.ctls.enumContext = CRYPT_CollectionEnumCTL;
|
store->hdr.ctls.enumContext = CRYPT_CollectionEnumCTL;
|
||||||
store->hdr.ctls.deleteContext = CRYPT_CollectionDeleteCTL;
|
store->hdr.ctls.deleteContext = CRYPT_CollectionDeleteCTL;
|
||||||
store->hdr.control = CRYPT_CollectionControl;
|
|
||||||
InitializeCriticalSection(&store->cs);
|
InitializeCriticalSection(&store->cs);
|
||||||
store->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PWINE_COLLECTIONSTORE->cs");
|
store->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PWINE_COLLECTIONSTORE->cs");
|
||||||
list_init(&store->stores);
|
list_init(&store->stores);
|
||||||
|
|
|
@ -244,22 +244,28 @@ typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
|
||||||
* - control is optional, but should be implemented by any store that supports
|
* - control is optional, but should be implemented by any store that supports
|
||||||
* persistence
|
* persistence
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void (*closeStore)(struct WINE_CRYPTCERTSTORE*,DWORD);
|
||||||
|
BOOL (*control)(struct WINE_CRYPTCERTSTORE*,DWORD,DWORD,void const*);
|
||||||
|
} store_vtbl_t;
|
||||||
|
|
||||||
typedef struct WINE_CRYPTCERTSTORE
|
typedef struct WINE_CRYPTCERTSTORE
|
||||||
{
|
{
|
||||||
DWORD dwMagic;
|
DWORD dwMagic;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
DWORD dwOpenFlags;
|
DWORD dwOpenFlags;
|
||||||
CertStoreType type;
|
CertStoreType type;
|
||||||
PFN_CERT_STORE_PROV_CLOSE closeStore;
|
const store_vtbl_t *vtbl;
|
||||||
|
/* FIXME: Move to vtbl (requires collections clean up) */
|
||||||
CONTEXT_FUNCS certs;
|
CONTEXT_FUNCS certs;
|
||||||
CONTEXT_FUNCS crls;
|
CONTEXT_FUNCS crls;
|
||||||
CONTEXT_FUNCS ctls;
|
CONTEXT_FUNCS ctls;
|
||||||
PFN_CERT_STORE_PROV_CONTROL control; /* optional */
|
|
||||||
CONTEXT_PROPERTY_LIST *properties;
|
CONTEXT_PROPERTY_LIST *properties;
|
||||||
} WINECRYPT_CERTSTORE;
|
} WINECRYPT_CERTSTORE;
|
||||||
|
|
||||||
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
|
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
|
||||||
CertStoreType type) DECLSPEC_HIDDEN;
|
CertStoreType type, const store_vtbl_t*) DECLSPEC_HIDDEN;
|
||||||
void CRYPT_FreeStore(WINECRYPT_CERTSTORE *store) DECLSPEC_HIDDEN;
|
void CRYPT_FreeStore(WINECRYPT_CERTSTORE *store) DECLSPEC_HIDDEN;
|
||||||
BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
|
BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
|
||||||
DWORD unk1) DECLSPEC_HIDDEN;
|
DWORD unk1) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -41,9 +41,9 @@ typedef struct _WINE_PROVIDERSTORE
|
||||||
PFN_CERT_STORE_PROV_CONTROL provControl;
|
PFN_CERT_STORE_PROV_CONTROL provControl;
|
||||||
} WINE_PROVIDERSTORE;
|
} WINE_PROVIDERSTORE;
|
||||||
|
|
||||||
static void WINAPI CRYPT_ProvCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
|
static void ProvStore_closeStore(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
WINE_PROVIDERSTORE *store = hCertStore;
|
WINE_PROVIDERSTORE *store = (WINE_PROVIDERSTORE*)cert_store;
|
||||||
|
|
||||||
TRACE("(%p, %08x)\n", store, dwFlags);
|
TRACE("(%p, %08x)\n", store, dwFlags);
|
||||||
|
|
||||||
|
@ -247,13 +247,12 @@ static BOOL CRYPT_ProvDeleteCTL(WINECRYPT_CERTSTORE *store, void *ctl)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL WINAPI CRYPT_ProvControl(HCERTSTORE hCertStore, DWORD dwFlags,
|
static BOOL ProvStore_control(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
|
||||||
DWORD dwCtrlType, void const *pvCtrlPara)
|
|
||||||
{
|
{
|
||||||
WINE_PROVIDERSTORE *store = hCertStore;
|
WINE_PROVIDERSTORE *store = (WINE_PROVIDERSTORE*)cert_store;
|
||||||
BOOL ret = TRUE;
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
TRACE("(%p, %08x, %d, %p)\n", hCertStore, dwFlags, dwCtrlType,
|
TRACE("(%p, %08x, %d, %p)\n", store, dwFlags, dwCtrlType,
|
||||||
pvCtrlPara);
|
pvCtrlPara);
|
||||||
|
|
||||||
if (store->provControl)
|
if (store->provControl)
|
||||||
|
@ -262,6 +261,11 @@ static BOOL WINAPI CRYPT_ProvControl(HCERTSTORE hCertStore, DWORD dwFlags,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const store_vtbl_t ProvStoreVtbl = {
|
||||||
|
ProvStore_closeStore,
|
||||||
|
ProvStore_control
|
||||||
|
};
|
||||||
|
|
||||||
WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
|
WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
|
||||||
WINECRYPT_CERTSTORE *memStore, const CERT_STORE_PROV_INFO *pProvInfo)
|
WINECRYPT_CERTSTORE *memStore, const CERT_STORE_PROV_INFO *pProvInfo)
|
||||||
{
|
{
|
||||||
|
@ -269,7 +273,7 @@ WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
CRYPT_InitStore(&ret->hdr, dwFlags, StoreTypeProvider);
|
CRYPT_InitStore(&ret->hdr, dwFlags, StoreTypeProvider, &ProvStoreVtbl);
|
||||||
ret->dwStoreProvFlags = pProvInfo->dwStoreProvFlags;
|
ret->dwStoreProvFlags = pProvInfo->dwStoreProvFlags;
|
||||||
if (ret->dwStoreProvFlags & CERT_STORE_PROV_EXTERNAL_FLAG)
|
if (ret->dwStoreProvFlags & CERT_STORE_PROV_EXTERNAL_FLAG)
|
||||||
{
|
{
|
||||||
|
@ -279,7 +283,6 @@ WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
|
||||||
else
|
else
|
||||||
ret->memStore = memStore;
|
ret->memStore = memStore;
|
||||||
ret->hStoreProv = pProvInfo->hStoreProv;
|
ret->hStoreProv = pProvInfo->hStoreProv;
|
||||||
ret->hdr.closeStore = CRYPT_ProvCloseStore;
|
|
||||||
ret->hdr.certs.addContext = CRYPT_ProvAddCert;
|
ret->hdr.certs.addContext = CRYPT_ProvAddCert;
|
||||||
ret->hdr.certs.enumContext = CRYPT_ProvEnumCert;
|
ret->hdr.certs.enumContext = CRYPT_ProvEnumCert;
|
||||||
ret->hdr.certs.deleteContext = CRYPT_ProvDeleteCert;
|
ret->hdr.certs.deleteContext = CRYPT_ProvDeleteCert;
|
||||||
|
@ -289,7 +292,6 @@ WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
|
||||||
ret->hdr.ctls.addContext = CRYPT_ProvAddCTL;
|
ret->hdr.ctls.addContext = CRYPT_ProvAddCTL;
|
||||||
ret->hdr.ctls.enumContext = CRYPT_ProvEnumCTL;
|
ret->hdr.ctls.enumContext = CRYPT_ProvEnumCTL;
|
||||||
ret->hdr.ctls.deleteContext = CRYPT_ProvDeleteCTL;
|
ret->hdr.ctls.deleteContext = CRYPT_ProvDeleteCTL;
|
||||||
ret->hdr.control = CRYPT_ProvControl;
|
|
||||||
if (pProvInfo->cStoreProvFunc > CERT_STORE_PROV_CLOSE_FUNC)
|
if (pProvInfo->cStoreProvFunc > CERT_STORE_PROV_CLOSE_FUNC)
|
||||||
ret->provCloseStore =
|
ret->provCloseStore =
|
||||||
pProvInfo->rgpvStoreProvFunc[CERT_STORE_PROV_CLOSE_FUNC];
|
pProvInfo->rgpvStoreProvFunc[CERT_STORE_PROV_CLOSE_FUNC];
|
||||||
|
|
|
@ -94,13 +94,13 @@ typedef struct _WINE_MEMSTORE
|
||||||
struct ContextList *ctls;
|
struct ContextList *ctls;
|
||||||
} WINE_MEMSTORE;
|
} WINE_MEMSTORE;
|
||||||
|
|
||||||
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
|
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags, CertStoreType type, const store_vtbl_t *vtbl)
|
||||||
CertStoreType type)
|
|
||||||
{
|
{
|
||||||
store->ref = 1;
|
store->ref = 1;
|
||||||
store->dwMagic = WINE_CRYPTCERTSTORE_MAGIC;
|
store->dwMagic = WINE_CRYPTCERTSTORE_MAGIC;
|
||||||
store->type = type;
|
store->type = type;
|
||||||
store->dwOpenFlags = dwFlags;
|
store->dwOpenFlags = dwFlags;
|
||||||
|
store->vtbl = vtbl;
|
||||||
store->properties = NULL;
|
store->properties = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,16 +284,9 @@ static BOOL CRYPT_MemDeleteCtl(WINECRYPT_CERTSTORE *store, void *pCtlContext)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL WINAPI CRYPT_MemControl(HCERTSTORE hCertStore, DWORD dwFlags,
|
static void MemStore_closeStore(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags)
|
||||||
DWORD dwCtrlType, void const *pvCtrlPara)
|
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
WINE_MEMSTORE *store = (WINE_MEMSTORE*)cert_store;
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void WINAPI CRYPT_MemCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
|
|
||||||
{
|
|
||||||
WINE_MEMSTORE *store = hCertStore;
|
|
||||||
|
|
||||||
TRACE("(%p, %08x)\n", store, dwFlags);
|
TRACE("(%p, %08x)\n", store, dwFlags);
|
||||||
if (dwFlags)
|
if (dwFlags)
|
||||||
|
@ -305,6 +298,18 @@ static void WINAPI CRYPT_MemCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
|
||||||
CRYPT_FreeStore((WINECRYPT_CERTSTORE*)store);
|
CRYPT_FreeStore((WINECRYPT_CERTSTORE*)store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL MemStore_control(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
|
||||||
|
DWORD dwCtrlType, void const *pvCtrlPara)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const store_vtbl_t MemStoreVtbl = {
|
||||||
|
MemStore_closeStore,
|
||||||
|
MemStore_control
|
||||||
|
};
|
||||||
|
|
||||||
static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
|
static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
|
||||||
DWORD dwFlags, const void *pvPara)
|
DWORD dwFlags, const void *pvPara)
|
||||||
{
|
{
|
||||||
|
@ -323,8 +328,7 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
|
||||||
if (store)
|
if (store)
|
||||||
{
|
{
|
||||||
memset(store, 0, sizeof(WINE_MEMSTORE));
|
memset(store, 0, sizeof(WINE_MEMSTORE));
|
||||||
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeMem);
|
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeMem, &MemStoreVtbl);
|
||||||
store->hdr.closeStore = CRYPT_MemCloseStore;
|
|
||||||
store->hdr.certs.addContext = CRYPT_MemAddCert;
|
store->hdr.certs.addContext = CRYPT_MemAddCert;
|
||||||
store->hdr.certs.enumContext = CRYPT_MemEnumCert;
|
store->hdr.certs.enumContext = CRYPT_MemEnumCert;
|
||||||
store->hdr.certs.deleteContext = CRYPT_MemDeleteCert;
|
store->hdr.certs.deleteContext = CRYPT_MemDeleteCert;
|
||||||
|
@ -334,7 +338,6 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
|
||||||
store->hdr.ctls.addContext = CRYPT_MemAddCtl;
|
store->hdr.ctls.addContext = CRYPT_MemAddCtl;
|
||||||
store->hdr.ctls.enumContext = CRYPT_MemEnumCtl;
|
store->hdr.ctls.enumContext = CRYPT_MemEnumCtl;
|
||||||
store->hdr.ctls.deleteContext = CRYPT_MemDeleteCtl;
|
store->hdr.ctls.deleteContext = CRYPT_MemDeleteCtl;
|
||||||
store->hdr.control = CRYPT_MemControl;
|
|
||||||
store->certs = ContextList_Create(pCertInterface,
|
store->certs = ContextList_Create(pCertInterface,
|
||||||
sizeof(CERT_CONTEXT));
|
sizeof(CERT_CONTEXT));
|
||||||
store->crls = ContextList_Create(pCRLInterface,
|
store->crls = ContextList_Create(pCRLInterface,
|
||||||
|
@ -1232,7 +1235,7 @@ BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
TRACE("%p's ref count is 0, freeing\n", hcs);
|
TRACE("%p's ref count is 0, freeing\n", hcs);
|
||||||
hcs->dwMagic = 0;
|
hcs->dwMagic = 0;
|
||||||
hcs->closeStore(hcs, dwFlags);
|
hcs->vtbl->closeStore(hcs, dwFlags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
TRACE("%p's ref count is %d\n", hcs, hcs->ref);
|
TRACE("%p's ref count is %d\n", hcs, hcs->ref);
|
||||||
|
@ -1254,8 +1257,8 @@ BOOL WINAPI CertControlStore(HCERTSTORE hCertStore, DWORD dwFlags,
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (hcs->control)
|
if (hcs->vtbl->control)
|
||||||
ret = hcs->control(hCertStore, dwFlags, dwCtrlType, pvCtrlPara);
|
ret = hcs->vtbl->control(hcs, dwFlags, dwCtrlType, pvCtrlPara);
|
||||||
else
|
else
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue