mscoree: Keep a reference to mscoree when shutting down.

Vincent Povirk madewokherd at gmail.com
Thu Feb 28 15:52:53 CST 2013


-------------- next part --------------
From a2985095f2ec17e0e1373bf976b4bf418816a1f3 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Thu, 28 Feb 2013 15:43:25 -0600
Subject: [PATCH] mscoree: Keep a reference to mscoree when shutting down.

---
 dlls/mscoree/metahost.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c
index 143494c..6906075 100644
--- a/dlls/mscoree/metahost.c
+++ b/dlls/mscoree/metahost.c
@@ -313,6 +313,12 @@ static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost *
 void unload_all_runtimes(void)
 {
     int i;
+    HMODULE handle;
+
+    /* If the only references to mscoree are through dll's that were loaded by
+     * Mono, shutting down the Mono runtime will free mscoree, so take a
+     * reference to prevent that from happening. */
+    GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const WCHAR *)&unload_all_runtimes, &handle);
 
     for (i=0; i<NUM_ABI_VERSIONS; i++)
     {
-- 
1.8.1.2


More information about the wine-patches mailing list