mscoree: Avoid calling mono_image_open_from_module_handle for libraries.

Vincent Povirk madewokherd at gmail.com
Mon Aug 20 13:08:43 CDT 2012


-------------- next part --------------
From f94d628cd586152265e9f3a6a35908eddfeaa6ea Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Mon, 20 Aug 2012 11:15:33 -0500
Subject: [PATCH] mscoree: Avoid calling mono_image_open_from_module_handle
 for libraries.

It turns out that this function takes ownership of the module handle and
filename. We can duplicate the module handle, but the filename will be freed
with mono_free, and mono doesn't export a corresponding malloc function
(though in theory it just uses MSVCRT_malloc so allocating on the process heap
would be fine). For dll's, the normal loading process will do a LoadLibrary
anyway, so we can don't have to supply the HMODULE. For the main exe, we can
use mono_image_open_from_module_handle in _CorExeMain, and afterwards that
cached image will be used (and should never be freed).
---
 dlls/mscoree/corruntimehost.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c
index 0262757..604f430 100644
--- a/dlls/mscoree/corruntimehost.c
+++ b/dlls/mscoree/corruntimehost.c
@@ -911,13 +911,9 @@ static void CDECL ReallyFixupVTable(struct dll_fixup *fixup)
     {
         host->mono->mono_thread_attach(domain);
 
-        image = host->mono->mono_image_open_from_module_handle(fixup->dll,
-            filenameA, 1, &status);
+        assembly = host->mono->mono_assembly_open(filenameA, &status);
     }
 
-    if (image)
-        assembly = host->mono->mono_assembly_load_from(image, filenameA, &status);
-
     if (assembly)
     {
         int i;
-- 
1.7.9.5


More information about the wine-patches mailing list