[Bug 33947] Battle.net desktop app crashes after 15 seconds

wine-bugs at winehq.org wine-bugs at winehq.org
Wed Jul 10 23:49:12 CDT 2013


http://bugs.winehq.org/show_bug.cgi?id=33947

--- Comment #5 from Ben Deane <wine at elbeno.com> 2013-07-10 23:49:12 CDT ---
Comment on attachment 45185
  --> http://bugs.winehq.org/attachment.cgi?id=45185
Adds simple support for HCCE_LOCAL_MACHINE in the crypt32 dll
CertGetCertificateChain function.

>From 276ca28ff98ed69920e3ad10c012a1bd3b022dd9 Mon Sep 17 00:00:00 2001
>From: Ben Deane <wine at elbeno.com>
>Date: Wed, 10 Jul 2013 16:47:27 -0700
>Subject: crypt32: Support HCCE_LOCAL_MACHINE.
>
>Add simple support for HCCE_LOCAL_MACHINE for
>CertGetCertificateChainEngine et al.
>---
> dlls/crypt32/chain.c           | 28 ++++++++++++++++------------
> dlls/crypt32/crypt32_private.h |  2 +-
> dlls/crypt32/main.c            |  5 +++--
> 3 files changed, 20 insertions(+), 15 deletions(-)
>
>diff --git a/dlls/crypt32/chain.c b/dlls/crypt32/chain.c
>index d112673..d142b9b 100644
>--- a/dlls/crypt32/chain.c
>+++ b/dlls/crypt32/chain.c
>@@ -33,7 +33,10 @@ WINE_DECLARE_DEBUG_CHANNEL(chain);
>
> #define DEFAULT_CYCLE_MODULUS 7
>
>-static HCERTCHAINENGINE CRYPT_defaultChainEngine;
>+/* There are two default chain engines which correspond to HCCE_CURRENT_USER and
>+ * HCCE_LOCAL_MACHINE.
>+*/
>+static HCERTCHAINENGINE CRYPT_defaultChainEngine[2] = { NULL, NULL };
>
> /* This represents a subset of a certificate chain engine:  it doesn't include
>  * the "hOther" store described by MSDN, because I'm not sure how that's used.
>@@ -212,7 +215,7 @@ VOID WINAPI CertFreeCertificateChainEngine(HCERTCHAINENGINE hChainEngine)
>
>     TRACE("(%p)\n", hChainEngine);
>
>-    if (engine && InterlockedDecrement(&engine->ref) == 0)
>+    if (engine > HCCE_LOCAL_MACHINE && InterlockedDecrement(&engine->ref) == 0)
>     {
>         CertCloseStore(engine->hWorld, 0);
>         CertCloseStore(engine->hRoot, 0);
>@@ -220,26 +223,28 @@ VOID WINAPI CertFreeCertificateChainEngine(HCERTCHAINENGINE hChainEngine)
>     }
> }
>
>-static HCERTCHAINENGINE CRYPT_GetDefaultChainEngine(void)
>+static HCERTCHAINENGINE CRYPT_GetDefaultChainEngine(HCERTCHAINENGINE h)
> {
>-    if (!CRYPT_defaultChainEngine)
>+    if (!CRYPT_defaultChainEngine[(int)h])
>     {
>         CERT_CHAIN_ENGINE_CONFIG config = { 0 };
>         HCERTCHAINENGINE engine;
>
>         config.cbSize = sizeof(config);
>+        if (h == HCCE_LOCAL_MACHINE)
>+            config.dwFlags = CERT_CHAIN_USE_LOCAL_MACHINE_STORE;
>         CertCreateCertificateChainEngine(&config, &engine);
>-        InterlockedCompareExchangePointer(&CRYPT_defaultChainEngine, engine,
>+        InterlockedCompareExchangePointer(&CRYPT_defaultChainEngine[(int)h], engine,
>          NULL);
>-        if (CRYPT_defaultChainEngine != engine)
>+        if (CRYPT_defaultChainEngine[(int)h] != engine)
>             CertFreeCertificateChainEngine(engine);
>     }
>-    return CRYPT_defaultChainEngine;
>+    return CRYPT_defaultChainEngine[(int)h];
> }
>
>-void default_chain_engine_free(void)
>+void default_chain_engine_free(HCERTCHAINENGINE h)
> {
>-    CertFreeCertificateChainEngine(CRYPT_defaultChainEngine);
>+    CertFreeCertificateChainEngine(CRYPT_defaultChainEngine[(int)h]);
> }
>
> typedef struct _CertificateChain
>@@ -2819,11 +2824,10 @@ BOOL WINAPI CertGetCertificateChain(HCERTCHAINENGINE hChainEngine,
>         return FALSE;
>     }
>
>-    if (!hChainEngine)
>-        hChainEngine = CRYPT_GetDefaultChainEngine();
>+    if (hChainEngine <= HCCE_LOCAL_MACHINE)
>+        hChainEngine = CRYPT_GetDefaultChainEngine(hChainEngine);
>     if (TRACE_ON(chain))
>         dump_chain_para(pChainPara);
>-    /* FIXME: what about HCCE_LOCAL_MACHINE? */
>     ret = CRYPT_BuildCandidateChainFromCert(hChainEngine, pCertContext, pTime,
>      hAdditionalStore, &chain);
>     if (ret)
>diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h
>index ea85cbc..a07a830 100644
>--- a/dlls/crypt32/crypt32_private.h
>+++ b/dlls/crypt32/crypt32_private.h
>@@ -155,7 +155,7 @@ void crypt_oid_init(void) DECLSPEC_HIDDEN;
> void crypt_oid_free(void) DECLSPEC_HIDDEN;
> void crypt_sip_free(void) DECLSPEC_HIDDEN;
> void root_store_free(void) DECLSPEC_HIDDEN;
>-void default_chain_engine_free(void) DECLSPEC_HIDDEN;
>+void default_chain_engine_free(HCERTCHAINENGINE) DECLSPEC_HIDDEN;
>
> /* Some typedefs that make it easier to abstract which type of context we're
>  * working with.
>diff --git a/dlls/crypt32/main.c b/dlls/crypt32/main.c
>index 78f14f9..227e086 100644
>--- a/dlls/crypt32/main.c
>+++ b/dlls/crypt32/main.c
>@@ -49,8 +49,8 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved)
>             crypt_oid_free();
>             crypt_sip_free();
>             root_store_free();
>-            default_chain_engine_free();
>+            default_chain_engine_free(HCCE_CURRENT_USER);
>+            default_chain_engine_free(HCCE_LOCAL_MACHINE);
>             if (hDefProv) CryptReleaseContext(hDefProv, 0);
>             break;
>     }
>1.8.1.2

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list