Module: wine Branch: master Commit: 6ab429363a904529f5de0f4952a98257383723c7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6ab429363a904529f5de0f4952...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Oct 15 16:53:54 2013 +0200
crypt32: Added cloning logic to context's vtbl.
---
dlls/crypt32/cert.c | 15 ++++++++++++- dlls/crypt32/collectionstore.c | 8 +------ dlls/crypt32/context.c | 4 +- dlls/crypt32/crl.c | 15 ++++++++++++- dlls/crypt32/crypt32_private.h | 9 ++++--- dlls/crypt32/ctl.c | 15 ++++++++++++- dlls/crypt32/store.c | 46 ++++++++++++++++++--------------------- 7 files changed, 71 insertions(+), 41 deletions(-)
diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index 2c96419..60cff2d 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -117,8 +117,21 @@ static void Cert_free(context_t *context) LocalFree(cert->ctx.pCertInfo); }
+static context_t *Cert_clone(context_t *context, WINECRYPT_CERTSTORE *store) +{ + cert_t *cert; + + cert = (cert_t*)Context_CreateLinkContext(sizeof(CERT_CONTEXT), context); + if(!cert) + return NULL; + + cert->ctx.hCertStore = store; + return &cert->base; +} + static const context_vtbl_t cert_vtbl = { - Cert_free + Cert_free, + Cert_clone };
BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore, diff --git a/dlls/crypt32/collectionstore.c b/dlls/crypt32/collectionstore.c index 9fa1f05..855365a 100644 --- a/dlls/crypt32/collectionstore.c +++ b/dlls/crypt32/collectionstore.c @@ -76,7 +76,7 @@ static void *CRYPT_CollectionCreateContextFromChild(WINE_COLLECTIONSTORE *store, { context_t *ret;
- ret = Context_CreateLinkContext(contextSize, child); + ret = child->vtbl->clone(child, &store->hdr); if (!ret) return NULL;
@@ -210,8 +210,6 @@ static BOOL Collection_addCert(WINECRYPT_CERTSTORE *store, void *cert, PCERT_CONTEXT context = CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CERT_CONTEXT));
- if (context) - context->hCertStore = store; *ppStoreContext = context; } CertFreeCertificateContext(childContext); @@ -287,8 +285,6 @@ static BOOL Collection_addCRL(WINECRYPT_CERTSTORE *store, void *crl, PCRL_CONTEXT context = CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CRL_CONTEXT));
- if (context) - context->hCertStore = store; *ppStoreContext = context; } CertFreeCRLContext(childContext); @@ -363,8 +359,6 @@ static BOOL Collection_addCTL(WINECRYPT_CERTSTORE *store, void *ctl, PCTL_CONTEXT context = CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CTL_CONTEXT));
- if (context) - context->hCertStore = store; *ppStoreContext = context; } CertFreeCTLContext(childContext); diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index 05e5d79..bb919f2 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -162,13 +162,13 @@ struct ContextList *ContextList_Create( return list; }
-void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) +void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace, struct WINE_CRYPTCERTSTORE *store) { context_t *context;
TRACE("(%p, %p, %p)\n", list, toLink, toReplace);
- context = Context_CreateLinkContext(list->contextSize, context_from_ptr(toLink)); + context = context_from_ptr(toLink)->vtbl->clone(BASE_CONTEXT_FROM_CONTEXT(toLink), store); if (context) { TRACE("adding %p\n", context); diff --git a/dlls/crypt32/crl.c b/dlls/crypt32/crl.c index 2e3a58f..75fdc8e 100644 --- a/dlls/crypt32/crl.c +++ b/dlls/crypt32/crl.c @@ -37,8 +37,21 @@ static void CRL_free(context_t *context) LocalFree(crl->ctx.pCrlInfo); }
+static context_t *CRL_clone(context_t *context, WINECRYPT_CERTSTORE *store) +{ + crl_t *crl; + + crl = (crl_t*)Context_CreateLinkContext(sizeof(CRL_CONTEXT), context); + if(!crl) + return NULL; + + crl->ctx.hCertStore = store; + return &crl->base; +} + static const context_vtbl_t crl_vtbl = { - CRL_free + CRL_free, + CRL_clone };
PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType, diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index fc1e122..9382841 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -159,12 +159,16 @@ void crypt_sip_free(void) DECLSPEC_HIDDEN; void root_store_free(void) DECLSPEC_HIDDEN; void default_chain_engine_free(void) DECLSPEC_HIDDEN;
+/* (Internal) certificate store types and functions */ +struct WINE_CRYPTCERTSTORE; + typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
typedef struct _context_t context_t;
typedef struct { void (*free)(context_t*); + struct _context_t *(*clone)(context_t*,struct WINE_CRYPTCERTSTORE*); } context_vtbl_t;
typedef struct _context_t { @@ -257,9 +261,6 @@ extern const WINE_CONTEXT_INTERFACE *pCertInterface DECLSPEC_HIDDEN; extern const WINE_CONTEXT_INTERFACE *pCRLInterface DECLSPEC_HIDDEN; extern const WINE_CONTEXT_INTERFACE *pCTLInterface DECLSPEC_HIDDEN;
-/* (Internal) certificate store types and functions */ -struct WINE_CRYPTCERTSTORE; - typedef struct WINE_CRYPTCERTSTORE * (*StoreOpenFunc)(HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara);
@@ -454,7 +455,7 @@ struct ContextList; struct ContextList *ContextList_Create( const WINE_CONTEXT_INTERFACE *contextInterface, size_t contextSize) DECLSPEC_HIDDEN;
-void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) DECLSPEC_HIDDEN; +void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace, struct WINE_CRYPTCERTSTORE *store) DECLSPEC_HIDDEN;
void *ContextList_Enum(struct ContextList *list, void *pPrev) DECLSPEC_HIDDEN;
diff --git a/dlls/crypt32/ctl.c b/dlls/crypt32/ctl.c index 26072ab..ed92f90 100644 --- a/dlls/crypt32/ctl.c +++ b/dlls/crypt32/ctl.c @@ -39,8 +39,21 @@ static void CTL_free(context_t *context) LocalFree(ctl->ctx.pCtlInfo); }
+static context_t *CTL_clone(context_t *context, WINECRYPT_CERTSTORE *store) +{ + ctl_t *ctl; + + ctl = (ctl_t*)Context_CreateLinkContext(sizeof(CTL_CONTEXT), context); + if(!ctl) + return NULL; + + ctl->ctx.hCertStore = store; + return &ctl->base; +} + static const context_vtbl_t ctl_vtbl = { - CTL_free + CTL_free, + CTL_clone };
BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore, diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 1ba81c9..4f27e62 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -150,15 +150,13 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, void *cert,
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
- context = ContextList_Add(ms->certs, cert, toReplace); - if (context) - { - context->hCertStore = store; - if (ppStoreContext) { - *ppStoreContext = CertDuplicateCertificateContext(context); - } - } - return context != 0; + context = ContextList_Add(ms->certs, cert, toReplace, store); + if (!context) + return FALSE; + + if (ppStoreContext) + *ppStoreContext = CertDuplicateCertificateContext(context); + return TRUE; }
static void *MemStore_enumCert(WINECRYPT_CERTSTORE *store, void *pPrev) @@ -194,14 +192,13 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
- context = ContextList_Add(ms->crls, crl, toReplace); - if (context) - { - context->hCertStore = store; - if (ppStoreContext) - *ppStoreContext = CertDuplicateCRLContext(context); - } - return context != 0; + context = ContextList_Add(ms->crls, crl, toReplace, store); + if (!context) + return FALSE; + + if (ppStoreContext) + *ppStoreContext = CertDuplicateCRLContext(context); + return TRUE; }
static void *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, void *pPrev) @@ -237,14 +234,13 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
- context = ContextList_Add(ms->ctls, ctl, toReplace); - if (context) - { - context->hCertStore = store; - if (ppStoreContext) - *ppStoreContext = CertDuplicateCTLContext(context); - } - return context != 0; + context = ContextList_Add(ms->ctls, ctl, toReplace, store); + if (!context) + return FALSE; + + if (ppStoreContext) + *ppStoreContext = CertDuplicateCTLContext(context); + return TRUE; }
static void *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, void *pPrev)