crypt32: Use context_t in addContext.

oldstable
Jacek Caban 2013-10-17 11:08:15 +02:00 committed by Alexandre Julliard
parent c75af2b9e0
commit 83026a7143
6 changed files with 89 additions and 76 deletions

View File

@ -169,7 +169,7 @@ BOOL WINAPI add_cert_to_store(WINECRYPT_CERTSTORE *store, const CERT_CONTEXT *ce
{
const CERT_CONTEXT *existing = NULL;
BOOL ret = TRUE, inherit_props = FALSE;
CERT_CONTEXT *new_context = NULL;
context_t *new_context = NULL;
switch (add_disposition)
{
@ -262,18 +262,20 @@ BOOL WINAPI add_cert_to_store(WINECRYPT_CERTSTORE *store, const CERT_CONTEXT *ce
return TRUE;
}
ret = store->vtbl->certs.addContext(store, (void*)cert, (void*)existing,
(ret_context || inherit_props) ? (const void **)&new_context : NULL, use_link);
ret = store->vtbl->certs.addContext(store, context_from_ptr(cert), existing ? context_from_ptr(existing) : NULL,
(ret_context || inherit_props) ? &new_context : NULL, use_link);
if(!ret)
return FALSE;
if(inherit_props)
Context_CopyProperties(new_context, existing);
Context_CopyProperties(context_ptr(new_context), existing);
if(ret_context)
*ret_context = CertDuplicateCertificateContext(new_context);
else if(new_context)
CertFreeCertificateContext(new_context);
if(ret_context) {
Context_AddRef(new_context);
*ret_context = context_ptr(new_context);
}else if(new_context) {
Context_Release(new_context);
}
TRACE("returning %d\n", ret);
return ret;

View File

@ -85,11 +85,11 @@ static context_t *CRYPT_CollectionCreateContextFromChild(WINE_COLLECTIONSTORE *s
}
static BOOL CRYPT_CollectionAddContext(WINE_COLLECTIONSTORE *store,
unsigned int contextFuncsOffset, void *context, void *toReplace, unsigned int contextSize,
void **pChildContext)
unsigned int contextFuncsOffset, context_t *context, context_t *toReplace, unsigned int contextSize,
context_t **pChildContext)
{
BOOL ret;
void *childContext = NULL;
context_t *childContext = NULL;
WINE_STORE_LIST_ENTRY *storeEntry = NULL;
TRACE("(%p, %d, %p, %p, %d)\n", store, contextFuncsOffset, context,
@ -98,22 +98,21 @@ static BOOL CRYPT_CollectionAddContext(WINE_COLLECTIONSTORE *store,
ret = FALSE;
if (toReplace)
{
context_t *existingLinked = context_from_ptr(toReplace)->linked;
context_t *existingLinked = toReplace->linked;
CONTEXT_FUNCS *contextFuncs;
storeEntry = context_from_ptr(toReplace)->u.ptr;
storeEntry = toReplace->u.ptr;
contextFuncs = (CONTEXT_FUNCS*)((LPBYTE)storeEntry->store->vtbl +
contextFuncsOffset);
ret = contextFuncs->addContext(storeEntry->store, context,
context_ptr(existingLinked), (const void **)&childContext, TRUE);
existingLinked, &childContext, TRUE);
}
else
{
WINE_STORE_LIST_ENTRY *entry, *next;
EnterCriticalSection(&store->cs);
LIST_FOR_EACH_ENTRY_SAFE(entry, next, &store->stores,
WINE_STORE_LIST_ENTRY, entry)
LIST_FOR_EACH_ENTRY_SAFE(entry, next, &store->stores, WINE_STORE_LIST_ENTRY, entry)
{
if (entry->dwUpdateFlags & CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG)
{
@ -121,8 +120,7 @@ static BOOL CRYPT_CollectionAddContext(WINE_COLLECTIONSTORE *store,
(LPBYTE)entry->store->vtbl + contextFuncsOffset);
storeEntry = entry;
ret = contextFuncs->addContext(entry->store, context, NULL,
(const void **)&childContext, TRUE);
ret = contextFuncs->addContext(entry->store, context, NULL, &childContext, TRUE);
break;
}
}
@ -197,24 +195,25 @@ static context_t *CRYPT_CollectionAdvanceEnum(WINE_COLLECTIONSTORE *store,
return ret;
}
static BOOL Collection_addCert(WINECRYPT_CERTSTORE *store, void *cert,
void *toReplace, const void **ppStoreContext, BOOL use_link)
static BOOL Collection_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
BOOL ret;
void *childContext = NULL;
context_t *childContext = NULL;
WINE_COLLECTIONSTORE *cs = (WINE_COLLECTIONSTORE*)store;
ret = CRYPT_CollectionAddContext(cs, offsetof(store_vtbl_t, certs),
cert, toReplace, sizeof(CERT_CONTEXT), &childContext);
if (ppStoreContext && childContext)
{
WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(childContext)->u.ptr;
WINE_STORE_LIST_ENTRY *storeEntry = childContext->u.ptr;
cert_t *context = (cert_t*)CRYPT_CollectionCreateContextFromChild(cs, storeEntry,
context_from_ptr(childContext), sizeof(CERT_CONTEXT));
childContext, sizeof(CERT_CONTEXT));
*ppStoreContext = &context->ctx;
*ppStoreContext = &context->base;
}
CertFreeCertificateContext(childContext);
if (childContext)
Context_Release(childContext);
return ret;
}
@ -270,24 +269,25 @@ static BOOL Collection_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context
return ret;
}
static BOOL Collection_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
void *toReplace, const void **ppStoreContext, BOOL use_link)
static BOOL Collection_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
BOOL ret;
void *childContext = NULL;
context_t *childContext = NULL;
WINE_COLLECTIONSTORE *cs = (WINE_COLLECTIONSTORE*)store;
ret = CRYPT_CollectionAddContext(cs, offsetof(store_vtbl_t, crls),
crl, toReplace, sizeof(CRL_CONTEXT), &childContext);
if (ppStoreContext && childContext)
{
WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(childContext)->u.ptr;
WINE_STORE_LIST_ENTRY *storeEntry = childContext->u.ptr;
crl_t *context = (crl_t*)CRYPT_CollectionCreateContextFromChild(cs, storeEntry,
context_from_ptr(childContext), sizeof(CRL_CONTEXT));
childContext, sizeof(CRL_CONTEXT));
*ppStoreContext = &context->ctx;
*ppStoreContext = &context->base;
}
CertFreeCRLContext(childContext);
if (childContext)
Context_Release(childContext);
return ret;
}
@ -341,24 +341,25 @@ static BOOL Collection_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *context)
return ret;
}
static BOOL Collection_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
void *toReplace, const void **ppStoreContext, BOOL use_link)
static BOOL Collection_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
BOOL ret;
void *childContext = NULL;
context_t *childContext = NULL;
WINE_COLLECTIONSTORE *cs = (WINE_COLLECTIONSTORE*)store;
ret = CRYPT_CollectionAddContext(cs, offsetof(store_vtbl_t, ctls),
ctl, toReplace, sizeof(CTL_CONTEXT), &childContext);
if (ppStoreContext && childContext)
{
WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(childContext)->u.ptr;
WINE_STORE_LIST_ENTRY *storeEntry = childContext->u.ptr;
ctl_t *context = (ctl_t*)CRYPT_CollectionCreateContextFromChild(cs, storeEntry,
context_from_ptr(childContext), sizeof(CTL_CONTEXT));
childContext, sizeof(CTL_CONTEXT));
*ppStoreContext = &context->ctx;
*ppStoreContext = &context->base;
}
CertFreeCTLContext(childContext);
if (childContext)
Context_Release(childContext);
return ret;
}

View File

@ -272,7 +272,7 @@ typedef struct _CONTEXT_FUNCS
* added if the store allows it. If ppStoreContext is not NULL, the added
* context should be returned in *ppStoreContext.
*/
BOOL (*addContext)(struct WINE_CRYPTCERTSTORE*,void*,void*,const void**,BOOL);
BOOL (*addContext)(struct WINE_CRYPTCERTSTORE*,context_t*,context_t*,context_t**,BOOL);
context_t *(*enumContext)(struct WINE_CRYPTCERTSTORE *store, context_t *prev);
BOOL (*delete)(struct WINE_CRYPTCERTSTORE*,context_t*);
} CONTEXT_FUNCS;

View File

@ -157,11 +157,16 @@ BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore,
if (toAdd)
{
if (store)
ret = store->vtbl->ctls.addContext(store, (void *)toAdd,
(void *)existing, (const void **)ppStoreContext, TRUE);
else if (ppStoreContext)
if (store) {
context_t *ret_ctx;
ret = store->vtbl->ctls.addContext(store, context_from_ptr(toAdd),
existing ? context_from_ptr(existing) : NULL, ppStoreContext ? &ret_ctx : NULL, TRUE);
if(ret && ppStoreContext)
*ppStoreContext = context_ptr(ret_ctx);
}else if (ppStoreContext) {
*ppStoreContext = CertDuplicateCTLContext(toAdd);
}
CertFreeCTLContext(toAdd);
}
CertFreeCTLContext(existing);

View File

@ -68,8 +68,8 @@ static DWORD ProvStore_release(WINECRYPT_CERTSTORE *cert_store, DWORD flags)
return ERROR_SUCCESS;
}
static BOOL ProvStore_addCert(WINECRYPT_CERTSTORE *store, void *cert,
void *toReplace, const void **ppStoreContext, BOOL use_link)
static BOOL ProvStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_PROVIDERSTORE *ps = (WINE_PROVIDERSTORE*)store;
BOOL ret;
@ -83,8 +83,7 @@ static BOOL ProvStore_addCert(WINECRYPT_CERTSTORE *store, void *cert,
{
ret = TRUE;
if (ps->provWriteCert)
ret = ps->provWriteCert(ps->hStoreProv, cert,
CERT_STORE_PROV_WRITE_ADD_FLAG);
ret = ps->provWriteCert(ps->hStoreProv, context_ptr(cert), CERT_STORE_PROV_WRITE_ADD_FLAG);
if (ret)
ret = ps->memStore->vtbl->certs.addContext(ps->memStore, cert, NULL,
ppStoreContext, TRUE);
@ -93,7 +92,7 @@ static BOOL ProvStore_addCert(WINECRYPT_CERTSTORE *store, void *cert,
* store.
*/
if (ret && ppStoreContext)
(*(PCERT_CONTEXT *)ppStoreContext)->hCertStore = store;
(*(cert_t**)ppStoreContext)->ctx.hCertStore = store;
return ret;
}
@ -127,8 +126,8 @@ static BOOL ProvStore_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context)
return ret;
}
static BOOL ProvStore_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
void *toReplace, const void **ppStoreContext, BOOL use_link)
static BOOL ProvStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_PROVIDERSTORE *ps = (WINE_PROVIDERSTORE*)store;
BOOL ret;
@ -149,7 +148,7 @@ static BOOL ProvStore_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
{
ret = TRUE;
if (ps->provWriteCrl)
ret = ps->provWriteCrl(ps->hStoreProv, crl,
ret = ps->provWriteCrl(ps->hStoreProv, context_ptr(crl),
CERT_STORE_PROV_WRITE_ADD_FLAG);
if (ret)
ret = ps->memStore->vtbl->crls.addContext(ps->memStore, crl, NULL,
@ -160,7 +159,7 @@ static BOOL ProvStore_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
* store.
*/
if (ret && ppStoreContext)
(*(PCRL_CONTEXT *)ppStoreContext)->hCertStore = store;
(*(crl_t**)ppStoreContext)->ctx.hCertStore = store;
return ret;
}
@ -194,8 +193,8 @@ static BOOL ProvStore_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *crl)
return ret;
}
static BOOL ProvStore_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
void *toReplace, const void **ppStoreContext, BOOL use_link)
static BOOL ProvStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_PROVIDERSTORE *ps = (WINE_PROVIDERSTORE*)store;
BOOL ret;
@ -216,7 +215,7 @@ static BOOL ProvStore_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
{
ret = TRUE;
if (ps->provWriteCtl)
ret = ps->provWriteCtl(ps->hStoreProv, ctl,
ret = ps->provWriteCtl(ps->hStoreProv, context_ptr(ctl),
CERT_STORE_PROV_WRITE_ADD_FLAG);
if (ret)
ret = ps->memStore->vtbl->ctls.addContext(ps->memStore, ctl, NULL,
@ -227,7 +226,7 @@ static BOOL ProvStore_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
* store.
*/
if (ret && ppStoreContext)
(*(PCTL_CONTEXT *)ppStoreContext)->hCertStore = store;
(*(ctl_t**)ppStoreContext)->ctx.hCertStore = store;
return ret;
}

View File

@ -142,21 +142,21 @@ BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
return TRUE;
}
static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, void *cert,
void *toReplace, const void **ppStoreContext, BOOL use_link)
static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
context = ContextList_Add(ms->certs, context_from_ptr(cert), toReplace ? context_from_ptr(toReplace) : NULL, store, use_link);
context = ContextList_Add(ms->certs, cert, toReplace, store, use_link);
if (!context)
return FALSE;
if (ppStoreContext) {
Context_AddRef(context);
*ppStoreContext = context_ptr(context);
*ppStoreContext = context;
}
return TRUE;
}
@ -186,21 +186,21 @@ static BOOL MemStore_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context)
return TRUE;
}
static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
void *toReplace, const void **ppStoreContext, BOOL use_link)
static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
context = ContextList_Add(ms->crls, context_from_ptr(crl), toReplace ? context_from_ptr(toReplace) : NULL, store, use_link);
context = ContextList_Add(ms->crls, crl, toReplace, store, use_link);
if (!context)
return FALSE;
if (ppStoreContext) {
Context_AddRef(context);
*ppStoreContext = context_ptr(context);
*ppStoreContext = context;
}
return TRUE;
}
@ -230,21 +230,21 @@ static BOOL MemStore_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *context)
return TRUE;
}
static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
void *toReplace, const void **ppStoreContext, BOOL use_link)
static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
context = ContextList_Add(ms->ctls, context_from_ptr(ctl), toReplace ? context_from_ptr(toReplace) : NULL, store, use_link);
context = ContextList_Add(ms->ctls, ctl, toReplace, store, use_link);
if (!context)
return FALSE;
if (ppStoreContext) {
Context_AddRef(context);
*ppStoreContext = context_ptr(context);
*ppStoreContext = context;
}
return TRUE;
}
@ -1026,13 +1026,19 @@ BOOL WINAPI CertAddCRLContextToStore(HCERTSTORE hCertStore,
if (toAdd)
{
if (store)
ret = store->vtbl->crls.addContext(store, (void*)toAdd, (void*)existing, (const void **)ppStoreContext, TRUE);
else if (ppStoreContext)
if (store) {
context_t *ret_context;
ret = store->vtbl->crls.addContext(store, context_from_ptr(toAdd),
existing ? context_from_ptr(existing) : NULL, ppStoreContext ? &ret_context : NULL, TRUE);
if (ret && ppStoreContext)
*ppStoreContext = context_ptr(ret_context);
}else if (ppStoreContext) {
*ppStoreContext = CertDuplicateCRLContext(toAdd);
}
CertFreeCRLContext(toAdd);
}
CertFreeCRLContext(existing);
if (existing)
CertFreeCRLContext(existing);
TRACE("returning %d\n", ret);
return ret;
@ -1358,14 +1364,14 @@ static DWORD EmptyStore_release(WINECRYPT_CERTSTORE *store, DWORD flags)
return E_UNEXPECTED;
}
static BOOL EmptyStore_add(WINECRYPT_CERTSTORE *store, void *context,
void *replace, const void **ret_context, BOOL use_link)
static BOOL EmptyStore_add(WINECRYPT_CERTSTORE *store, context_t *context,
context_t *replace, context_t **ret_context, BOOL use_link)
{
TRACE("(%p, %p, %p, %p)\n", store, context, replace, ret_context);
/* FIXME: We should clone the context */
if(ret_context) {
Context_AddRef(context_from_ptr(context));
Context_AddRef(context);
*ret_context = context;
}