winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
October 2013
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
757 discussions
Start a n
N
ew thread
Jacek Caban : crypt32: Use context_t in Context_CreateLinkContext.
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: 2553b4602bda7d917f17ec80164d51545d507936 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=2553b4602bda7d917f17ec801…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:48:06 2013 +0200 crypt32: Use context_t in Context_CreateLinkContext. --- dlls/crypt32/collectionstore.c | 28 ++++++++++++---------------- dlls/crypt32/context.c | 25 +++++++++++-------------- dlls/crypt32/crypt32_private.h | 8 ++++++-- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/dlls/crypt32/collectionstore.c b/dlls/crypt32/collectionstore.c index af209cd..dbcf21b 100644 --- a/dlls/crypt32/collectionstore.c +++ b/dlls/crypt32/collectionstore.c @@ -73,17 +73,15 @@ static DWORD Collection_release(WINECRYPT_CERTSTORE *store, DWORD flags) } static void *CRYPT_CollectionCreateContextFromChild(WINE_COLLECTIONSTORE *store, - WINE_STORE_LIST_ENTRY *storeEntry, void *child, size_t contextSize, - BOOL addRef) + WINE_STORE_LIST_ENTRY *storeEntry, void *child, size_t contextSize) { - void *ret = Context_CreateLinkContext(contextSize, child, - sizeof(WINE_STORE_LIST_ENTRY*), addRef); + context_t *ret = Context_CreateLinkContext(contextSize, context_from_ptr(child), + sizeof(WINE_STORE_LIST_ENTRY*)); if (ret) - *(WINE_STORE_LIST_ENTRY **)Context_GetExtra(ret, contextSize) - = storeEntry; + *(WINE_STORE_LIST_ENTRY **)Context_GetExtra(context_ptr(ret), contextSize) = storeEntry; - return ret; + return context_ptr(ret); } static BOOL CRYPT_CollectionAddContext(WINE_COLLECTIONSTORE *store, @@ -168,9 +166,10 @@ static void *CRYPT_CollectionAdvanceEnum(WINE_COLLECTIONSTORE *store, } else child = contextFuncs->enumContext(storeEntry->store, NULL); - if (child) - ret = CRYPT_CollectionCreateContextFromChild(store, storeEntry, child, - contextSize, FALSE); + if (child) { + ret = CRYPT_CollectionCreateContextFromChild(store, storeEntry, child, contextSize); + Context_Release(context_from_ptr(child)); + } else { if (storeNext) @@ -211,8 +210,7 @@ static BOOL Collection_addCert(WINECRYPT_CERTSTORE *store, void *cert, WINE_STORE_LIST_ENTRY *storeEntry = *(WINE_STORE_LIST_ENTRY **) Context_GetExtra(childContext, sizeof(CERT_CONTEXT)); PCERT_CONTEXT context = - CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, - sizeof(CERT_CONTEXT), TRUE); + CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, sizeof(CERT_CONTEXT)); if (context) context->hCertStore = store; @@ -291,8 +289,7 @@ static BOOL Collection_addCRL(WINECRYPT_CERTSTORE *store, void *crl, WINE_STORE_LIST_ENTRY *storeEntry = *(WINE_STORE_LIST_ENTRY **) Context_GetExtra(childContext, sizeof(CRL_CONTEXT)); PCRL_CONTEXT context = - CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, - sizeof(CRL_CONTEXT), TRUE); + CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, sizeof(CRL_CONTEXT)); if (context) context->hCertStore = store; @@ -370,8 +367,7 @@ static BOOL Collection_addCTL(WINECRYPT_CERTSTORE *store, void *ctl, WINE_STORE_LIST_ENTRY *storeEntry = *(WINE_STORE_LIST_ENTRY **) Context_GetExtra(childContext, sizeof(CTL_CONTEXT)); PCTL_CONTEXT context = - CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, - sizeof(CTL_CONTEXT), TRUE); + CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, sizeof(CTL_CONTEXT)); if (context) context->hCertStore = store; diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index ff1c440..b2b2282 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -51,10 +51,9 @@ void *Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl) return CONTEXT_FROM_BASE_CONTEXT(context); } -void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned int extra, - BOOL addRef) +context_t *Context_CreateLinkContext(unsigned int contextSize, context_t *linked, unsigned int extra) { - BASE_CONTEXT *context; + context_t *context; TRACE("(%d, %p, %d)\n", contextSize, linked, extra); @@ -62,15 +61,14 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned if (!context) return NULL; - memcpy(CONTEXT_FROM_BASE_CONTEXT(context), linked, contextSize); - context->vtbl = BASE_CONTEXT_FROM_CONTEXT(linked)->vtbl; + memcpy(context_ptr(context), context_ptr(linked), contextSize); + context->vtbl = linked->vtbl; context->ref = 1; - context->linked = BASE_CONTEXT_FROM_CONTEXT(linked); - if (addRef) - Context_AddRef(BASE_CONTEXT_FROM_CONTEXT(linked)); + context->linked = linked; + Context_AddRef(linked); TRACE("returning %p\n", context); - return CONTEXT_FROM_BASE_CONTEXT(context); + return context; } void Context_AddRef(context_t *context) @@ -185,15 +183,14 @@ static inline void *ContextList_EntryToContext(const struct ContextList *list, void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) { - void *context; + context_t *context; TRACE("(%p, %p, %p)\n", list, toLink, toReplace); - context = Context_CreateLinkContext(list->contextSize, toLink, - sizeof(struct list), TRUE); + context = Context_CreateLinkContext(list->contextSize, context_from_ptr(toLink), sizeof(struct list)); if (context) { - struct list *entry = ContextList_ContextToEntry(list, context); + struct list *entry = ContextList_ContextToEntry(list, CONTEXT_FROM_BASE_CONTEXT(context)); TRACE("adding %p\n", context); EnterCriticalSection(&list->cs); @@ -212,7 +209,7 @@ void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) list_add_head(&list->contexts, entry); LeaveCriticalSection(&list->cs); } - return context; + return CONTEXT_FROM_BASE_CONTEXT(context); } void *ContextList_Enum(struct ContextList *list, void *pPrev) diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index bcb4808..287e0c2 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -177,6 +177,11 @@ static inline context_t *context_from_ptr(const void *ptr) return (context_t*)ptr-1; } +static inline void *context_ptr(context_t *context) +{ + return context+1; +} + typedef struct { context_t base; CERT_CONTEXT ctx; @@ -390,8 +395,7 @@ void *Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl) * it should be) linked is addref'd. * Free with Context_Release. */ -void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned int extra, - BOOL addRef) DECLSPEC_HIDDEN; +context_t *Context_CreateLinkContext(unsigned contextSize, context_t *linked, unsigned extra) DECLSPEC_HIDDEN; /* Returns a pointer to the extra bytes allocated with context, which must be * a link context.
1
0
0
0
Jacek Caban : crypt32: Use Context_Release instead of WINE_CONTEXT_INTERFACE.
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: c72570ce52dcb78668c291c0bd35f387e79766e2 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c72570ce52dcb78668c291c0b…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:47:50 2013 +0200 crypt32: Use Context_Release instead of WINE_CONTEXT_INTERFACE. --- dlls/crypt32/collectionstore.c | 2 +- dlls/crypt32/context.c | 6 +++--- dlls/crypt32/crypt32_private.h | 2 -- dlls/crypt32/object.c | 2 +- dlls/crypt32/regstore.c | 4 ++-- dlls/crypt32/serialize.c | 10 +++++----- dlls/crypt32/store.c | 3 --- 7 files changed, 12 insertions(+), 17 deletions(-) diff --git a/dlls/crypt32/collectionstore.c b/dlls/crypt32/collectionstore.c index 7f494c5..af209cd 100644 --- a/dlls/crypt32/collectionstore.c +++ b/dlls/crypt32/collectionstore.c @@ -163,7 +163,7 @@ static void *CRYPT_CollectionAdvanceEnum(WINE_COLLECTIONSTORE *store, child = Context_GetLinkedContext(pPrev); Context_AddRef(context_from_ptr(child)); child = contextFuncs->enumContext(storeEntry->store, child); - contextInterface->free(pPrev); + Context_Release(context_from_ptr(pPrev)); pPrev = NULL; } else diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index 7f6f00d..ff1c440 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -206,7 +206,7 @@ void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) entry->prev->next = entry; entry->next->prev = entry; existing->prev = existing->next = existing; - list->contextInterface->free(toReplace); + Context_Release(context_from_ptr(toReplace)); } else list_add_head(&list->contexts, entry); @@ -226,7 +226,7 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev) struct list *prevEntry = ContextList_ContextToEntry(list, pPrev); listNext = list_next(&list->contexts, prevEntry); - list->contextInterface->free(pPrev); + Context_Release(context_from_ptr(pPrev)); } else listNext = list_next(&list->contexts, &list->contexts); @@ -270,7 +270,7 @@ static void ContextList_Empty(struct ContextList *list) TRACE("removing %p\n", context); list_remove(entry); - list->contextInterface->free(context); + Context_Release(context_from_ptr(context)); } LeaveCriticalSection(&list->cs); } diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index 08f5563..bcb4808 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -226,7 +226,6 @@ typedef BOOL (WINAPI *SetContextPropertyFunc)(const void *context, DWORD dwPropID, DWORD dwFlags, const void *pvData); typedef BOOL (WINAPI *SerializeElementFunc)(const void *context, DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement); -typedef BOOL (WINAPI *FreeContextFunc)(const void *context); typedef BOOL (WINAPI *DeleteContextFunc)(const void *contex); /* An abstract context (certificate, CRL, or CTL) interface */ @@ -240,7 +239,6 @@ typedef struct _WINE_CONTEXT_INTERFACE GetContextPropertyFunc getProp; SetContextPropertyFunc setProp; SerializeElementFunc serialize; - FreeContextFunc free; DeleteContextFunc deleteFromStore; } WINE_CONTEXT_INTERFACE; diff --git a/dlls/crypt32/object.c b/dlls/crypt32/object.c index 074bdd8..0ff1bfd 100644 --- a/dlls/crypt32/object.c +++ b/dlls/crypt32/object.c @@ -279,7 +279,7 @@ static BOOL CRYPT_QuerySerializedContextObject(DWORD dwObjectType, end: if (contextInterface && context) - contextInterface->free(context); + Context_Release(context_from_ptr(context)); if (blob == &fileBlob) CryptMemFree(blob->pbData); TRACE("returning %d\n", ret); diff --git a/dlls/crypt32/regstore.c b/dlls/crypt32/regstore.c index a5d69a1..8fb7eeb 100644 --- a/dlls/crypt32/regstore.c +++ b/dlls/crypt32/regstore.c @@ -143,7 +143,7 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType, else TRACE("hash doesn't match, ignoring\n"); } - contextInterface->free(context); + Context_Release(context_from_ptr(context)); } } } @@ -242,7 +242,7 @@ static BOOL CRYPT_SerializeContextsToReg(HKEY key, ret = TRUE; } while (ret && context != NULL); if (context) - contextInterface->free(context); + Context_Release(context_from_ptr(context)); return ret; } diff --git a/dlls/crypt32/serialize.c b/dlls/crypt32/serialize.c index d8027c1..e8ccc4a 100644 --- a/dlls/crypt32/serialize.c +++ b/dlls/crypt32/serialize.c @@ -409,7 +409,7 @@ const void *CRYPT_ReadSerializedElement(const BYTE *pbElement, DWORD cbElement, } else { - contextInterface->free(context); + Context_Release(context_from_ptr(context)); context = NULL; } } @@ -461,7 +461,7 @@ static BOOL CRYPT_ReadSerializedStore(void *handle, propHdr.propID == CERT_CTL_PROP_ID)) { /* We have a new context, so free the existing one */ - contextInterface->free(context); + Context_Release(context_from_ptr(context)); } if (propHdr.cb > bufSize) { @@ -522,7 +522,7 @@ static BOOL CRYPT_ReadSerializedStore(void *handle, if (contextInterface && context) { /* Free the last context added */ - contextInterface->free(context); + Context_Release(context_from_ptr(context)); } CryptMemFree(buf); ret = TRUE; @@ -638,7 +638,7 @@ static BOOL CRYPT_SerializeContextsToStream(SerializedOutputFunc output, ret = TRUE; } while (ret && context != NULL); if (context) - contextInterface->free(context); + Context_Release(context_from_ptr(context)); return ret; } @@ -996,7 +996,7 @@ BOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore, *pdwContentType = type; ret = contextInterface->addContextToStore(hCertStore, context, dwAddDisposition, ppvContext); - contextInterface->free(context); + Context_Release(context_from_ptr(context)); } else ret = FALSE; diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index e3c6cfd..f11279c 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -50,7 +50,6 @@ static const WINE_CONTEXT_INTERFACE gCertInterface = { (GetContextPropertyFunc)CertGetCertificateContextProperty, (SetContextPropertyFunc)CertSetCertificateContextProperty, (SerializeElementFunc)CertSerializeCertificateStoreElement, - (FreeContextFunc)CertFreeCertificateContext, (DeleteContextFunc)CertDeleteCertificateFromStore, }; const WINE_CONTEXT_INTERFACE *pCertInterface = &gCertInterface; @@ -64,7 +63,6 @@ static const WINE_CONTEXT_INTERFACE gCRLInterface = { (GetContextPropertyFunc)CertGetCRLContextProperty, (SetContextPropertyFunc)CertSetCRLContextProperty, (SerializeElementFunc)CertSerializeCRLStoreElement, - (FreeContextFunc)CertFreeCRLContext, (DeleteContextFunc)CertDeleteCRLFromStore, }; const WINE_CONTEXT_INTERFACE *pCRLInterface = &gCRLInterface; @@ -78,7 +76,6 @@ static const WINE_CONTEXT_INTERFACE gCTLInterface = { (GetContextPropertyFunc)CertGetCTLContextProperty, (SetContextPropertyFunc)CertSetCTLContextProperty, (SerializeElementFunc)CertSerializeCTLStoreElement, - (FreeContextFunc)CertFreeCTLContext, (DeleteContextFunc)CertDeleteCTLFromStore, }; const WINE_CONTEXT_INTERFACE *pCTLInterface = &gCTLInterface;
1
0
0
0
Jacek Caban : crypt32: Use Context_AddRef instead of WINE_CONTEXT_INTERFACE .
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: 76066d1cfe28a9aa285705a91c8801a02efbd19c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=76066d1cfe28a9aa285705a91…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:47:40 2013 +0200 crypt32: Use Context_AddRef instead of WINE_CONTEXT_INTERFACE. --- dlls/crypt32/collectionstore.c | 2 +- dlls/crypt32/context.c | 2 +- dlls/crypt32/crypt32_private.h | 2 -- dlls/crypt32/object.c | 5 ++++- dlls/crypt32/store.c | 3 --- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dlls/crypt32/collectionstore.c b/dlls/crypt32/collectionstore.c index f8dbf6e..7f494c5 100644 --- a/dlls/crypt32/collectionstore.c +++ b/dlls/crypt32/collectionstore.c @@ -161,7 +161,7 @@ static void *CRYPT_CollectionAdvanceEnum(WINE_COLLECTIONSTORE *store, * the free(pPrev) below can cause the ref count to become negative. */ child = Context_GetLinkedContext(pPrev); - contextInterface->duplicate(child); + Context_AddRef(context_from_ptr(child)); child = contextFuncs->enumContext(storeEntry->store, child); contextInterface->free(pPrev); pPrev = NULL; diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index 2a44e9a..7f6f00d 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -235,7 +235,7 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev) if (listNext) { ret = ContextList_EntryToContext(list, listNext); - list->contextInterface->duplicate(ret); + Context_AddRef(context_from_ptr(ret)); } else ret = NULL; diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index 7b64dba..08f5563 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -217,7 +217,6 @@ typedef BOOL (WINAPI *AddContextToStoreFunc)(HCERTSTORE hCertStore, typedef BOOL (WINAPI *AddEncodedContextToStoreFunc)(HCERTSTORE hCertStore, DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwAddDisposition, const void **ppContext); -typedef const void *(WINAPI *DuplicateContextFunc)(const void *context); typedef const void *(WINAPI *EnumContextsInStoreFunc)(HCERTSTORE hCertStore, const void *pPrevContext); typedef DWORD (WINAPI *EnumPropertiesFunc)(const void *context, DWORD dwPropId); @@ -236,7 +235,6 @@ typedef struct _WINE_CONTEXT_INTERFACE CreateContextFunc create; AddContextToStoreFunc addContextToStore; AddEncodedContextToStoreFunc addEncodedToStore; - DuplicateContextFunc duplicate; EnumContextsInStoreFunc enumContextsInStore; EnumPropertiesFunc enumProps; GetContextPropertyFunc getProp; diff --git a/dlls/crypt32/object.c b/dlls/crypt32/object.c index 5f45d81..074bdd8 100644 --- a/dlls/crypt32/object.c +++ b/dlls/crypt32/object.c @@ -271,7 +271,10 @@ static BOOL CRYPT_QuerySerializedContextObject(DWORD dwObjectType, *phCertStore = CertDuplicateStore( *(HCERTSTORE *)((const BYTE *)context + certStoreOffset)); if (ppvContext) - *ppvContext = contextInterface->duplicate(context); + { + *ppvContext = context; + Context_AddRef(context_from_ptr(context)); + } } end: diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 506a33c..e3c6cfd 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -45,7 +45,6 @@ static const WINE_CONTEXT_INTERFACE gCertInterface = { (CreateContextFunc)CertCreateCertificateContext, (AddContextToStoreFunc)CertAddCertificateContextToStore, (AddEncodedContextToStoreFunc)CertAddEncodedCertificateToStore, - (DuplicateContextFunc)CertDuplicateCertificateContext, (EnumContextsInStoreFunc)CertEnumCertificatesInStore, (EnumPropertiesFunc)CertEnumCertificateContextProperties, (GetContextPropertyFunc)CertGetCertificateContextProperty, @@ -60,7 +59,6 @@ static const WINE_CONTEXT_INTERFACE gCRLInterface = { (CreateContextFunc)CertCreateCRLContext, (AddContextToStoreFunc)CertAddCRLContextToStore, (AddEncodedContextToStoreFunc)CertAddEncodedCRLToStore, - (DuplicateContextFunc)CertDuplicateCRLContext, (EnumContextsInStoreFunc)CertEnumCRLsInStore, (EnumPropertiesFunc)CertEnumCRLContextProperties, (GetContextPropertyFunc)CertGetCRLContextProperty, @@ -75,7 +73,6 @@ static const WINE_CONTEXT_INTERFACE gCTLInterface = { (CreateContextFunc)CertCreateCTLContext, (AddContextToStoreFunc)CertAddCTLContextToStore, (AddEncodedContextToStoreFunc)CertAddEncodedCTLToStore, - (DuplicateContextFunc)CertDuplicateCTLContext, (EnumContextsInStoreFunc)CertEnumCTLsInStore, (EnumPropertiesFunc)CertEnumCTLContextProperties, (GetContextPropertyFunc)CertGetCTLContextProperty,
1
0
0
0
Jacek Caban : crypt32: Moved context desatructor to vtbl.
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: 993691bef556092d8def4a670f23da58282e3935 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=993691bef556092d8def4a670…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:47:30 2013 +0200 crypt32: Moved context desatructor to vtbl. --- dlls/crypt32/cert.c | 24 ++++++++++++++---------- dlls/crypt32/context.c | 10 ++++++---- dlls/crypt32/crl.c | 24 ++++++++++++++---------- dlls/crypt32/crypt32_private.h | 17 +++++++++++------ dlls/crypt32/ctl.c | 28 ++++++++++++++++------------ 5 files changed, 61 insertions(+), 42 deletions(-) diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index 678a44b..9016d8c 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -109,6 +109,18 @@ BOOL WINAPI CertAddEncodedCertificateToSystemStoreW(LPCWSTR pszCertStoreName, return ret; } +static void Cert_free(context_t *context) +{ + cert_t *cert = (cert_t*)context; + + CryptMemFree(cert->ctx.pbCertEncoded); + LocalFree(cert->ctx.pCertInfo); +} + +static const context_vtbl_t cert_vtbl = { + Cert_free +}; + BOOL WINAPI CertAddCertificateLinkToStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext) @@ -154,7 +166,7 @@ PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType, { BYTE *data = NULL; - cert = Context_CreateDataContext(sizeof(CERT_CONTEXT)); + cert = Context_CreateDataContext(sizeof(CERT_CONTEXT), &cert_vtbl); if (!cert) goto end; data = CryptMemAlloc(cbCertEncoded); @@ -187,14 +199,6 @@ PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContex return pCertContext; } -static void CertDataContext_Free(void *context) -{ - PCERT_CONTEXT certContext = context; - - CryptMemFree(certContext->pbCertEncoded); - LocalFree(certContext->pCertInfo); -} - BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext) { BOOL ret = TRUE; @@ -202,7 +206,7 @@ BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext) TRACE("(%p)\n", pCertContext); if (pCertContext) - ret = Context_Release(&cert_from_ptr(pCertContext)->base, CertDataContext_Free); + ret = Context_Release(&cert_from_ptr(pCertContext)->base); return ret; } diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index 2f71c5b..2a44e9a 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -29,7 +29,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(context); #define CONTEXT_FROM_BASE_CONTEXT(p) (void*)(p+1) #define BASE_CONTEXT_FROM_CONTEXT(p) ((BASE_CONTEXT*)(p)-1) -void *Context_CreateDataContext(size_t contextSize) +void *Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl) { BASE_CONTEXT *context; @@ -37,6 +37,7 @@ void *Context_CreateDataContext(size_t contextSize) if (!context) return NULL; + context->vtbl = vtbl; context->ref = 1; context->linked = NULL; context->properties = ContextPropertyList_Create(); @@ -62,6 +63,7 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned return NULL; memcpy(CONTEXT_FROM_BASE_CONTEXT(context), linked, contextSize); + context->vtbl = BASE_CONTEXT_FROM_CONTEXT(linked)->vtbl; context->ref = 1; context->linked = BASE_CONTEXT_FROM_CONTEXT(linked); if (addRef) @@ -103,7 +105,7 @@ CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context) return ptr->properties; } -BOOL Context_Release(context_t *context, ContextFreeFunc dataContextFree) +BOOL Context_Release(context_t *context) { BOOL ret = TRUE; @@ -118,9 +120,9 @@ BOOL Context_Release(context_t *context, ContextFreeFunc dataContextFree) if (!context->linked) { ContextPropertyList_Free(context->properties); - dataContextFree(CONTEXT_FROM_BASE_CONTEXT(context)); + context->vtbl->free(context); } else { - Context_Release(context->linked, dataContextFree); + Context_Release(context->linked); } CryptMemFree(context); } diff --git a/dlls/crypt32/crl.c b/dlls/crypt32/crl.c index fcdec5b..9ecc23f 100644 --- a/dlls/crypt32/crl.c +++ b/dlls/crypt32/crl.c @@ -29,6 +29,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt); +static void CRL_free(context_t *context) +{ + crl_t *crl = (crl_t*)context; + + CryptMemFree(crl->ctx.pbCrlEncoded); + LocalFree(crl->ctx.pCrlInfo); +} + +static const context_vtbl_t crl_vtbl = { + CRL_free +}; + PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType, const BYTE* pbCrlEncoded, DWORD cbCrlEncoded) { @@ -52,7 +64,7 @@ PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType, { BYTE *data = NULL; - crl = Context_CreateDataContext(sizeof(CRL_CONTEXT)); + crl = Context_CreateDataContext(sizeof(CRL_CONTEXT), &crl_vtbl); if (!crl) goto end; data = CryptMemAlloc(cbCrlEncoded); @@ -331,14 +343,6 @@ PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext) return pCrlContext; } -static void CrlDataContext_Free(void *context) -{ - PCRL_CONTEXT crlContext = context; - - CryptMemFree(crlContext->pbCrlEncoded); - LocalFree(crlContext->pCrlInfo); -} - BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext) { BOOL ret = TRUE; @@ -346,7 +350,7 @@ BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext) TRACE("(%p)\n", pCrlContext); if (pCrlContext) - ret = Context_Release(&crl_from_ptr(pCrlContext)->base, CrlDataContext_Free); + ret = Context_Release(&crl_from_ptr(pCrlContext)->base); return ret; } diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index 4a4a614..7b64dba 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -159,11 +159,18 @@ void default_chain_engine_free(void) DECLSPEC_HIDDEN; typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST; +typedef struct _context_t context_t; + +typedef struct { + void (*free)(context_t*); +} context_vtbl_t; + typedef struct _context_t { + const context_vtbl_t *vtbl; LONG ref; struct _context_t *linked; CONTEXT_PROPERTY_LIST *properties; -} BASE_CONTEXT, context_t; +} BASE_CONTEXT; static inline context_t *context_from_ptr(const void *ptr) { @@ -380,7 +387,7 @@ DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indent, * which should be one of CERT_CONTEXT, CRL_CONTEXT, or CTL_CONTEXT. * Free with Context_Release. */ -void *Context_CreateDataContext(size_t contextSize) DECLSPEC_HIDDEN; +void *Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl) DECLSPEC_HIDDEN; /* Creates a new link context with extra bytes. The context refers to linked * rather than owning its own properties. If addRef is TRUE (which ordinarily @@ -396,7 +403,7 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned void *Context_GetExtra(const void *context, size_t contextSize) DECLSPEC_HIDDEN; /* Gets the context linked to by context, which must be a link context. */ -void *Context_GetLinkedContext(void *context) DECLSPEC_HIDDEN; +void *Context_GetLinkedContext(void*) DECLSPEC_HIDDEN; /* Copies properties from fromContext to toContext. */ void Context_CopyProperties(const void *to, const void *from) DECLSPEC_HIDDEN; @@ -408,14 +415,12 @@ CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context) DECLSPEC_HIDDE void Context_AddRef(context_t*) DECLSPEC_HIDDEN; -typedef void (*ContextFreeFunc)(void *context); - /* Decrements context's ref count. If context is a link context, releases its * linked context as well. * If a data context has its ref count reach 0, calls dataContextFree on it. * Returns FALSE if the reference count is <= 0 when called. */ -BOOL Context_Release(context_t *context, ContextFreeFunc dataContextFree) DECLSPEC_HIDDEN; +BOOL Context_Release(context_t *context) DECLSPEC_HIDDEN; /** * Context property list functions diff --git a/dlls/crypt32/ctl.c b/dlls/crypt32/ctl.c index 9b5837a..fb976b4 100644 --- a/dlls/crypt32/ctl.c +++ b/dlls/crypt32/ctl.c @@ -29,6 +29,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt); +static void CTL_free(context_t *context) +{ + ctl_t *ctl = (ctl_t*)context; + + CryptMsgClose(ctl->ctx.hCryptMsg); + CryptMemFree(ctl->ctx.pbCtlEncoded); + CryptMemFree(ctl->ctx.pbCtlContext); + LocalFree(ctl->ctx.pCtlInfo); +} + +static const context_vtbl_t ctl_vtbl = { + CTL_free +}; + BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore, PCCTL_CONTEXT pCtlContext, DWORD dwAddDisposition, PCCTL_CONTEXT* ppStoreContext) @@ -403,7 +417,7 @@ PCCTL_CONTEXT WINAPI CertCreateCTLContext(DWORD dwMsgAndCertEncodingType, &ctlInfo, &size); if (ret) { - ctl = Context_CreateDataContext(sizeof(CTL_CONTEXT)); + ctl = Context_CreateDataContext(sizeof(CTL_CONTEXT), &ctl_vtbl); if (ctl) { BYTE *data = CryptMemAlloc(cbCtlEncoded); @@ -461,16 +475,6 @@ PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext) return pCtlContext; } -static void CTLDataContext_Free(void *context) -{ - PCTL_CONTEXT ctlContext = context; - - CryptMsgClose(ctlContext->hCryptMsg); - CryptMemFree(ctlContext->pbCtlEncoded); - CryptMemFree(ctlContext->pbCtlContext); - LocalFree(ctlContext->pCtlInfo); -} - BOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCTLContext) { BOOL ret = TRUE; @@ -478,7 +482,7 @@ BOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCTLContext) TRACE("(%p)\n", pCTLContext); if (pCTLContext) - ret = Context_Release(&ctl_from_ptr(pCTLContext)->base, CTLDataContext_Free); + ret = Context_Release(&ctl_from_ptr(pCTLContext)->base); return ret; }
1
0
0
0
Jacek Caban : crypt32: Pass context as context_t to Context_Release.
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: 17e1dfef9beb29b418e9cf94f7ecbf11de000bdd URL:
http://source.winehq.org/git/wine.git/?a=commit;h=17e1dfef9beb29b418e9cf94f…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:47:17 2013 +0200 crypt32: Pass context as context_t to Context_Release. --- dlls/crypt32/cert.c | 2 +- dlls/crypt32/context.c | 21 ++++++++++----------- dlls/crypt32/crl.c | 2 +- dlls/crypt32/crypt32_private.h | 2 +- dlls/crypt32/ctl.c | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index 9e47847..678a44b 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -202,7 +202,7 @@ BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext) TRACE("(%p)\n", pCertContext); if (pCertContext) - ret = Context_Release((void *)pCertContext, CertDataContext_Free); + ret = Context_Release(&cert_from_ptr(pCertContext)->base, CertDataContext_Free); return ret; } diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index a91b63b..2f71c5b 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -103,30 +103,29 @@ CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context) return ptr->properties; } -BOOL Context_Release(void *context, ContextFreeFunc dataContextFree) +BOOL Context_Release(context_t *context, ContextFreeFunc dataContextFree) { - BASE_CONTEXT *base = BASE_CONTEXT_FROM_CONTEXT(context); BOOL ret = TRUE; - if (base->ref <= 0) + if (context->ref <= 0) { - ERR("%p's ref count is %d\n", context, base->ref); + ERR("%p's ref count is %d\n", context, context->ref); return FALSE; } - if (InterlockedDecrement(&base->ref) == 0) + if (InterlockedDecrement(&context->ref) == 0) { TRACE("freeing %p\n", context); - if (!base->linked) + if (!context->linked) { - ContextPropertyList_Free(base->properties); - dataContextFree(context); + ContextPropertyList_Free(context->properties); + dataContextFree(CONTEXT_FROM_BASE_CONTEXT(context)); } else { - Context_Release(CONTEXT_FROM_BASE_CONTEXT(base->linked), dataContextFree); + Context_Release(context->linked, dataContextFree); } - CryptMemFree(base); + CryptMemFree(context); } else - TRACE("%p's ref count is %d\n", context, base->ref); + TRACE("%p's ref count is %d\n", context, context->ref); return ret; } diff --git a/dlls/crypt32/crl.c b/dlls/crypt32/crl.c index 5f127cb..fcdec5b 100644 --- a/dlls/crypt32/crl.c +++ b/dlls/crypt32/crl.c @@ -346,7 +346,7 @@ BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext) TRACE("(%p)\n", pCrlContext); if (pCrlContext) - ret = Context_Release((void *)pCrlContext, CrlDataContext_Free); + ret = Context_Release(&crl_from_ptr(pCrlContext)->base, CrlDataContext_Free); return ret; } diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index 18a3523..4a4a614 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -415,7 +415,7 @@ typedef void (*ContextFreeFunc)(void *context); * If a data context has its ref count reach 0, calls dataContextFree on it. * Returns FALSE if the reference count is <= 0 when called. */ -BOOL Context_Release(void *context, ContextFreeFunc dataContextFree) DECLSPEC_HIDDEN; +BOOL Context_Release(context_t *context, ContextFreeFunc dataContextFree) DECLSPEC_HIDDEN; /** * Context property list functions diff --git a/dlls/crypt32/ctl.c b/dlls/crypt32/ctl.c index 2ee94ab..9b5837a 100644 --- a/dlls/crypt32/ctl.c +++ b/dlls/crypt32/ctl.c @@ -478,7 +478,7 @@ BOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCTLContext) TRACE("(%p)\n", pCTLContext); if (pCTLContext) - ret = Context_Release((void *)pCTLContext, CTLDataContext_Free); + ret = Context_Release(&ctl_from_ptr(pCTLContext)->base, CTLDataContext_Free); return ret; }
1
0
0
0
Jacek Caban : crypt32: Pass context as BASE_CONTEXT to Context_AddRef and added structs describing memory layout behind context structs .
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: 802a6bc1bb93b4c6397a7c4100a1c86dd893b485 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=802a6bc1bb93b4c6397a7c410…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:47:07 2013 +0200 crypt32: Pass context as BASE_CONTEXT to Context_AddRef and added structs describing memory layout behind context structs. --- dlls/crypt32/cert.c | 5 +-- dlls/crypt32/context.c | 17 +++----------- dlls/crypt32/crl.c | 2 +- dlls/crypt32/crypt32_private.h | 47 +++++++++++++++++++++++++++++++++++++-- dlls/crypt32/ctl.c | 2 +- dlls/crypt32/store.c | 2 +- 6 files changed, 53 insertions(+), 22 deletions(-) diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index 561fd59..9e47847 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -176,15 +176,14 @@ end: return cert; } -PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext( - PCCERT_CONTEXT pCertContext) +PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext) { TRACE("(%p)\n", pCertContext); if (!pCertContext) return NULL; - Context_AddRef((void *)pCertContext); + Context_AddRef(&cert_from_ptr(pCertContext)->base); return pCertContext; } diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index cdc8c01..a91b63b 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -26,13 +26,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(context); -typedef struct _BASE_CONTEXT -{ - LONG ref; - struct _BASE_CONTEXT *linked; - CONTEXT_PROPERTY_LIST *properties; -} BASE_CONTEXT; - #define CONTEXT_FROM_BASE_CONTEXT(p) (void*)(p+1) #define BASE_CONTEXT_FROM_CONTEXT(p) ((BASE_CONTEXT*)(p)-1) @@ -72,18 +65,16 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned context->ref = 1; context->linked = BASE_CONTEXT_FROM_CONTEXT(linked); if (addRef) - Context_AddRef(linked); + Context_AddRef(BASE_CONTEXT_FROM_CONTEXT(linked)); TRACE("returning %p\n", context); return CONTEXT_FROM_BASE_CONTEXT(context); } -void Context_AddRef(void *context) +void Context_AddRef(context_t *context) { - BASE_CONTEXT *baseContext = BASE_CONTEXT_FROM_CONTEXT(context); - - InterlockedIncrement(&baseContext->ref); - TRACE("%p's ref count is %d\n", context, baseContext->ref); + InterlockedIncrement(&context->ref); + TRACE("(%p) ref=%d\n", context, context->ref); } void *Context_GetExtra(const void *context, size_t contextSize) diff --git a/dlls/crypt32/crl.c b/dlls/crypt32/crl.c index 6ed27f7..5f127cb 100644 --- a/dlls/crypt32/crl.c +++ b/dlls/crypt32/crl.c @@ -327,7 +327,7 @@ PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext) { TRACE("(%p)\n", pCrlContext); if (pCrlContext) - Context_AddRef((void *)pCrlContext); + Context_AddRef(&crl_from_ptr(pCrlContext)->base); return pCrlContext; } diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index cc1477c..18a3523 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -157,6 +157,49 @@ void crypt_sip_free(void) DECLSPEC_HIDDEN; void root_store_free(void) DECLSPEC_HIDDEN; void default_chain_engine_free(void) DECLSPEC_HIDDEN; +typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST; + +typedef struct _context_t { + LONG ref; + struct _context_t *linked; + CONTEXT_PROPERTY_LIST *properties; +} BASE_CONTEXT, context_t; + +static inline context_t *context_from_ptr(const void *ptr) +{ + return (context_t*)ptr-1; +} + +typedef struct { + context_t base; + CERT_CONTEXT ctx; +} cert_t; + +static inline cert_t *cert_from_ptr(const CERT_CONTEXT *ptr) +{ + return CONTAINING_RECORD(ptr, cert_t, ctx); +} + +typedef struct { + context_t base; + CRL_CONTEXT ctx; +} crl_t; + +static inline crl_t *crl_from_ptr(const CRL_CONTEXT *ptr) +{ + return CONTAINING_RECORD(ptr, crl_t, ctx); +} + +typedef struct { + context_t base; + CTL_CONTEXT ctx; +} ctl_t; + +static inline ctl_t *ctl_from_ptr(const CTL_CONTEXT *ptr) +{ + return CONTAINING_RECORD(ptr, ctl_t, ctx); +} + /* Some typedefs that make it easier to abstract which type of context we're * working with. */ @@ -234,8 +277,6 @@ typedef enum _CertStoreType { StoreTypeEmpty } CertStoreType; -typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST; - #define WINE_CRYPTCERTSTORE_MAGIC 0x74726563 /* A cert store is polymorphic through the use of function pointers. A type @@ -365,7 +406,7 @@ void Context_CopyProperties(const void *to, const void *from) DECLSPEC_HIDDEN; */ CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context) DECLSPEC_HIDDEN; -void Context_AddRef(void *context) DECLSPEC_HIDDEN; +void Context_AddRef(context_t*) DECLSPEC_HIDDEN; typedef void (*ContextFreeFunc)(void *context); diff --git a/dlls/crypt32/ctl.c b/dlls/crypt32/ctl.c index a484f85..2ee94ab 100644 --- a/dlls/crypt32/ctl.c +++ b/dlls/crypt32/ctl.c @@ -457,7 +457,7 @@ PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext) { TRACE("(%p)\n", pCtlContext); if (pCtlContext) - Context_AddRef((void *)pCtlContext); + Context_AddRef(&ctl_from_ptr(pCtlContext)->base); return pCtlContext; } diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 521fd4f..506a33c 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -1507,7 +1507,7 @@ static BOOL EmptyStore_add(WINECRYPT_CERTSTORE *store, void *context, /* FIXME: We should clone the context */ if(ret_context) { - Context_AddRef(context); + Context_AddRef(context_from_ptr(context)); *ret_context = context; }
1
0
0
0
Jacek Caban : crypt32: Use linked pointer instead of context type to test for linked contexts.
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: b2b71c20855611bf0f2bfd3a0bd1eddb3531f41e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b2b71c20855611bf0f2bfd3a0…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:46:52 2013 +0200 crypt32: Use linked pointer instead of context type to test for linked contexts. --- dlls/crypt32/context.c | 39 +++++++++++++++------------------------ 1 files changed, 15 insertions(+), 24 deletions(-) diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index 915ad5e..cdc8c01 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -26,19 +26,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(context); -typedef enum _ContextType { - ContextTypeData, - ContextTypeLink, -} ContextType; - typedef struct _BASE_CONTEXT { LONG ref; - ContextType type; - union { - CONTEXT_PROPERTY_LIST *properties; - struct _BASE_CONTEXT *linked; - } u; + struct _BASE_CONTEXT *linked; + CONTEXT_PROPERTY_LIST *properties; } BASE_CONTEXT; #define CONTEXT_FROM_BASE_CONTEXT(p) (void*)(p+1) @@ -53,9 +45,9 @@ void *Context_CreateDataContext(size_t contextSize) return NULL; context->ref = 1; - context->type = ContextTypeData; - context->u.properties = ContextPropertyList_Create(); - if (!context->u.properties) + context->linked = NULL; + context->properties = ContextPropertyList_Create(); + if (!context->properties) { CryptMemFree(context); return NULL; @@ -78,8 +70,7 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned memcpy(CONTEXT_FROM_BASE_CONTEXT(context), linked, contextSize); context->ref = 1; - context->type = ContextTypeLink; - context->u.linked = BASE_CONTEXT_FROM_CONTEXT(linked); + context->linked = BASE_CONTEXT_FROM_CONTEXT(linked); if (addRef) Context_AddRef(linked); @@ -99,7 +90,7 @@ void *Context_GetExtra(const void *context, size_t contextSize) { BASE_CONTEXT *baseContext = BASE_CONTEXT_FROM_CONTEXT(context); - assert(baseContext->type == ContextTypeLink); + assert(baseContext->linked != NULL); return (LPBYTE)CONTEXT_FROM_BASE_CONTEXT(baseContext) + contextSize; } @@ -107,18 +98,18 @@ void *Context_GetLinkedContext(void *context) { BASE_CONTEXT *baseContext = BASE_CONTEXT_FROM_CONTEXT(context); - assert(baseContext->type == ContextTypeLink); - return CONTEXT_FROM_BASE_CONTEXT(baseContext->u.linked); + assert(baseContext->linked != NULL); + return CONTEXT_FROM_BASE_CONTEXT(baseContext->linked); } CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context) { BASE_CONTEXT *ptr = BASE_CONTEXT_FROM_CONTEXT(context); - while (ptr && ptr->type == ContextTypeLink) - ptr = ptr->u.linked; + while (ptr && ptr->linked) + ptr = ptr->linked; - return (ptr && ptr->type == ContextTypeData) ? ptr->u.properties : NULL; + return ptr->properties; } BOOL Context_Release(void *context, ContextFreeFunc dataContextFree) @@ -134,12 +125,12 @@ BOOL Context_Release(void *context, ContextFreeFunc dataContextFree) if (InterlockedDecrement(&base->ref) == 0) { TRACE("freeing %p\n", context); - if (base->type == ContextTypeData) + if (!base->linked) { - ContextPropertyList_Free(base->u.properties); + ContextPropertyList_Free(base->properties); dataContextFree(context); } else { - Context_Release(CONTEXT_FROM_BASE_CONTEXT(base->u.linked), dataContextFree); + Context_Release(CONTEXT_FROM_BASE_CONTEXT(base->linked), dataContextFree); } CryptMemFree(base); }
1
0
0
0
Jacek Caban : crypt32: Added new empty store type and use it for creating certificates with no store .
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: c7d1082b4f0b6db5eea5e99e68ffb42108d6c507 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c7d1082b4f0b6db5eea5e99e6…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:46:40 2013 +0200 crypt32: Added new empty store type and use it for creating certificates with no store. --- dlls/crypt32/cert.c | 2 +- dlls/crypt32/crypt32_private.h | 4 ++ dlls/crypt32/main.c | 1 + dlls/crypt32/store.c | 72 ++++++++++++++++++++++++++++++++++++++++ dlls/crypt32/tests/cert.c | 1 - dlls/crypt32/tests/store.c | 4 ++- 6 files changed, 81 insertions(+), 3 deletions(-) diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index e9d8717..561fd59 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -169,7 +169,7 @@ PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType, cert->pbCertEncoded = data; cert->cbCertEncoded = cbCertEncoded; cert->pCertInfo = certInfo; - cert->hCertStore = 0; + cert->hCertStore = &empty_store; } end: diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index d9f5c23..cc1477c 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -231,6 +231,7 @@ typedef enum _CertStoreType { StoreTypeMem, StoreTypeCollection, StoreTypeProvider, + StoreTypeEmpty } CertStoreType; typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST; @@ -420,6 +421,9 @@ BOOL ContextList_Remove(struct ContextList *list, void *context) DECLSPEC_HIDDEN void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN; +extern WINECRYPT_CERTSTORE empty_store; +void init_empty_store(void) DECLSPEC_HIDDEN; + /** * Utilities. */ diff --git a/dlls/crypt32/main.c b/dlls/crypt32/main.c index 78f14f9..c4f6c78 100644 --- a/dlls/crypt32/main.c +++ b/dlls/crypt32/main.c @@ -42,6 +42,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved) case DLL_PROCESS_ATTACH: hInstance = hInst; DisableThreadLibraryCalls(hInst); + init_empty_store(); crypt_oid_init(); break; case DLL_PROCESS_DETACH: diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 1054b04..521fd4f 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -1488,3 +1488,75 @@ BOOL WINAPI CertRegisterPhysicalStore(const void *pvSystemStore, DWORD dwFlags, dwFlags, debugstr_w(pwszStoreName), pStoreInfo, pvReserved); return FALSE; } + +static void EmptyStore_addref(WINECRYPT_CERTSTORE *store) +{ + TRACE("(%p)\n", store); +} + +static DWORD EmptyStore_release(WINECRYPT_CERTSTORE *store, DWORD flags) +{ + TRACE("(%p)\n", store); + return E_UNEXPECTED; +} + +static BOOL EmptyStore_add(WINECRYPT_CERTSTORE *store, void *context, + void *replace, const void **ret_context) +{ + TRACE("(%p, %p, %p, %p)\n", store, context, replace, ret_context); + + /* FIXME: We should clone the context */ + if(ret_context) { + Context_AddRef(context); + *ret_context = context; + } + + return TRUE; +} + +static void *EmptyStore_enum(WINECRYPT_CERTSTORE *store, void *prev) +{ + TRACE("(%p, %p)\n", store, prev); + + SetLastError(CRYPT_E_NOT_FOUND); + return FALSE; +} + +static BOOL EmptyStore_delete(WINECRYPT_CERTSTORE *store, void *context) +{ + return TRUE; +} + +static BOOL EmptyStore_control(WINECRYPT_CERTSTORE *store, DWORD flags, DWORD ctrl_type, void const *ctrl_para) +{ + TRACE("()\n"); + + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +static const store_vtbl_t EmptyStoreVtbl = { + EmptyStore_addref, + EmptyStore_release, + EmptyStore_control, + { + EmptyStore_add, + EmptyStore_enum, + EmptyStore_delete + }, { + EmptyStore_add, + EmptyStore_enum, + EmptyStore_delete + }, { + EmptyStore_add, + EmptyStore_enum, + EmptyStore_delete + } +}; + +WINECRYPT_CERTSTORE empty_store; + +void init_empty_store(void) +{ + CRYPT_InitStore(&empty_store, CERT_STORE_READONLY_FLAG, StoreTypeEmpty, &EmptyStoreVtbl); +} diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index f31236a..dfb6921 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -660,7 +660,6 @@ static void testCreateCert(void) selfSignedCert, sizeof(selfSignedCert)); ok(cert != NULL, "creating cert failed: %08x\n", GetLastError()); /* Even in-memory certs are expected to have a store associated with them */ - todo_wine ok(cert->hCertStore != NULL, "expected created cert to have a store\n"); /* The cert doesn't have the archived property set (which would imply it * doesn't show up in enumerations.) diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c index 25dd5f6..2e852fb 100644 --- a/dlls/crypt32/tests/store.c +++ b/dlls/crypt32/tests/store.c @@ -2515,7 +2515,7 @@ static void testEmptyStore(void) cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); ok(cert != NULL, "CertCreateCertificateContext failed\n"); - todo_wine ok(cert->hCertStore != NULL, "cert->hCertStore == NULL\n"); + ok(cert->hCertStore != NULL, "cert->hCertStore == NULL\n"); if(!cert->hCertStore) { CertFreeCertificateContext(cert); return; @@ -2555,6 +2555,8 @@ static void testEmptyStore(void) ok(res, "CertDeleteCertificateContextFromStore failed\n"); ok(cert3->hCertStore == store, "Unexpected hCertStore\n"); + CertFreeCertificateContext(cert3); + CertCloseStore(store, 0); res = CertCloseStore(cert->hCertStore, CERT_CLOSE_STORE_CHECK_FLAG);
1
0
0
0
Jacek Caban : crypt32: Don' t call CertFreeCertificateContext in CertDeleteCertificateContext, leave it to store-specific functions.
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: fe9e23998ac79239a1f89f22c9aa3295985ff55d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fe9e23998ac79239a1f89f22c…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:46:27 2013 +0200 crypt32: Don't call CertFreeCertificateContext in CertDeleteCertificateContext, leave it to store-specific functions. --- dlls/crypt32/collectionstore.c | 25 ++++--------------------- dlls/crypt32/store.c | 5 ----- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/dlls/crypt32/collectionstore.c b/dlls/crypt32/collectionstore.c index 10dd6c1..f8dbf6e 100644 --- a/dlls/crypt32/collectionstore.c +++ b/dlls/crypt32/collectionstore.c @@ -271,15 +271,9 @@ static BOOL Collection_deleteCert(WINECRYPT_CERTSTORE *store, void *pCertContext TRACE("(%p, %p)\n", store, pCertContext); - /* Deleting the linked context results in its ref count getting - * decreased, but the caller of this (CertDeleteCertificateFromStore) also - * decreases pCertContext's ref count, by calling - * CertFreeCertificateContext. Increase ref count of linked context to - * compensate. - */ linked = Context_GetLinkedContext(pCertContext); - CertDuplicateCertificateContext(linked); ret = CertDeleteCertificateFromStore(linked); + CertFreeCertificateContext(pCertContext); return ret; } @@ -356,14 +350,9 @@ static BOOL Collection_deleteCRL(WINECRYPT_CERTSTORE *store, void *pCrlContext) TRACE("(%p, %p)\n", store, pCrlContext); - /* Deleting the linked context results in its ref count getting - * decreased, but the caller of this (CertDeleteCRLFromStore) also - * decreases pCrlContext's ref count, by calling CertFreeCRLContext. - * Increase ref count of linked context to compensate. - */ linked = Context_GetLinkedContext(pCrlContext); - CertDuplicateCRLContext(linked); ret = CertDeleteCRLFromStore(linked); + CertFreeCRLContext(pCrlContext); return ret; } @@ -432,22 +421,16 @@ static void *Collection_enumCTL(WINECRYPT_CERTSTORE *store, void *pPrev) return ret; } -static BOOL Collection_deleteCTL(WINECRYPT_CERTSTORE *store, - void *pCtlContext) +static BOOL Collection_deleteCTL(WINECRYPT_CERTSTORE *store, void *pCtlContext) { BOOL ret; PCCTL_CONTEXT linked; TRACE("(%p, %p)\n", store, pCtlContext); - /* Deleting the linked context results in its ref count getting - * decreased, but the caller of this (CertDeleteCTLFromStore) also - * decreases pCtlContext's ref count, by calling CertFreeCTLContext. - * Increase ref count of linked context to compensate. - */ linked = Context_GetLinkedContext(pCtlContext); - CertDuplicateCTLContext(linked); ret = CertDeleteCTLFromStore(linked); + CertFreeCTLContext(pCtlContext); return ret; } diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 496c7a8..1054b04 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -1060,15 +1060,10 @@ BOOL WINAPI CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext) ret = FALSE; else ret = hcs->vtbl->certs.deleteContext(hcs, (void *)pCertContext); - if (ret) - ret = CertFreeCertificateContext(pCertContext); } return ret; } -#define CrlContext_CopyProperties(to, from) \ - Context_CopyProperties((to), (from), sizeof(CRL_CONTEXT)) - BOOL WINAPI CertAddCRLContextToStore(HCERTSTORE hCertStore, PCCRL_CONTEXT pCrlContext, DWORD dwAddDisposition, PCCRL_CONTEXT* ppStoreContext)
1
0
0
0
Jacek Caban : crypt32: Moved store context functions to vtbl.
by Alexandre Julliard
14 Oct '13
14 Oct '13
Module: wine Branch: master Commit: 52b2add3957aeee0576a15c422bf5a4daa6d1aee URL:
http://source.winehq.org/git/wine.git/?a=commit;h=52b2add3957aeee0576a15c42…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Oct 14 14:46:16 2013 +0200 crypt32: Moved store context functions to vtbl. --- dlls/crypt32/collectionstore.c | 69 +++++++++++++++++++++------------------- dlls/crypt32/crypt32_private.h | 7 ++-- dlls/crypt32/ctl.c | 6 ++-- dlls/crypt32/provstore.c | 66 ++++++++++++++++++++------------------ dlls/crypt32/store.c | 54 +++++++++++++++++-------------- 5 files changed, 106 insertions(+), 96 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=52b2add3957aeee0576a1…
1
0
0
0
← Newer
1
...
43
44
45
46
47
48
49
...
76
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Results per page:
10
25
50
100
200