mscoree: Add a fallback for mono_image_open_from_module_handle.

Vincent Povirk madewokherd at gmail.com
Thu May 17 09:52:40 CDT 2012


For bug 30693.
-------------- next part --------------
From 5a2eb3a6ccf7cb9b8087f9ce7ea615803427c114 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Thu, 17 May 2012 09:47:46 -0500
Subject: [PATCH] mscoree: Add a fallback for
 mono_image_open_from_module_handle.

---
 dlls/mscoree/metahost.c        |   40 ++++++++++++++++++++++++++++++++--------
 dlls/mscoree/mscoree_private.h |    1 +
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c
index 3736dc0..fa12853 100644
--- a/dlls/mscoree/metahost.c
+++ b/dlls/mscoree/metahost.c
@@ -100,6 +100,29 @@ static void CDECL do_nothing(void)
 {
 }
 
+static MonoImage* image_open_module_handle_dummy(HMODULE module_handle,
+    char* fname, UINT has_entry_point, MonoImageOpenStatus* status, int abi_version)
+{
+    return loaded_monos[abi_version-1].mono_image_open(fname, status);
+}
+
+static CDECL MonoImage* image_open_module_handle_dummy_1(HMODULE module_handle,
+    char* fname, UINT has_entry_point, MonoImageOpenStatus* status)
+{
+    return image_open_module_handle_dummy(module_handle, fname, has_entry_point, status, 1);
+}
+
+static CDECL MonoImage* image_open_module_handle_dummy_2(HMODULE module_handle,
+    char* fname, UINT has_entry_point, MonoImageOpenStatus* status)
+{
+    return image_open_module_handle_dummy(module_handle, fname, has_entry_point, status, 2);
+}
+
+MonoImage* (CDECL * const image_from_handle_fn[NUM_ABI_VERSIONS])(HMODULE module_handle, char* fname, UINT has_entry_point, MonoImageOpenStatus* status) = {
+    image_open_module_handle_dummy_1,
+    image_open_module_handle_dummy_2
+};
+
 static void missing_runtime_message(const CLRRuntimeInfo *This)
 {
     if (This->major == 1)
@@ -172,7 +195,7 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result)
         LOAD_MONO_FUNCTION(mono_class_from_name);
         LOAD_MONO_FUNCTION(mono_class_get_method_from_name);
         LOAD_MONO_FUNCTION(mono_domain_assembly_open);
-        LOAD_MONO_FUNCTION(mono_image_open_from_module_handle);
+        LOAD_MONO_FUNCTION(mono_image_open);
         LOAD_MONO_FUNCTION(mono_install_assembly_preload_hook);
         LOAD_MONO_FUNCTION(mono_jit_exec);
         LOAD_MONO_FUNCTION(mono_jit_init);
@@ -207,19 +230,20 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result)
 
 #undef LOAD_MONO_FUNCTION
 
-#define LOAD_OPT_VOID_MONO_FUNCTION(x) do { \
+#define LOAD_OPT_MONO_FUNCTION(x, default) do { \
     (*result)->x = (void*)GetProcAddress((*result)->mono_handle, #x); \
     if (!(*result)->x) { \
-        (*result)->x = do_nothing; \
+        (*result)->x = default; \
     } \
 } while (0);
 
-        LOAD_OPT_VOID_MONO_FUNCTION(mono_runtime_set_shutting_down);
-        LOAD_OPT_VOID_MONO_FUNCTION(mono_thread_pool_cleanup);
-        LOAD_OPT_VOID_MONO_FUNCTION(mono_thread_suspend_all_other_threads);
-        LOAD_OPT_VOID_MONO_FUNCTION(mono_threads_set_shutting_down);
+        LOAD_OPT_MONO_FUNCTION(mono_image_open_from_module_handle, image_from_handle_fn[This->mono_abi_version-1]);
+        LOAD_OPT_MONO_FUNCTION(mono_runtime_set_shutting_down, do_nothing);
+        LOAD_OPT_MONO_FUNCTION(mono_thread_pool_cleanup, do_nothing);
+        LOAD_OPT_MONO_FUNCTION(mono_thread_suspend_all_other_threads, do_nothing);
+        LOAD_OPT_MONO_FUNCTION(mono_threads_set_shutting_down, do_nothing);
 
-#undef LOAD_OPT_VOID_MONO_FUNCTION
+#undef LOAD_OPT_MONO_FUNCTION
 
         (*result)->mono_profiler_install((MonoProfiler*)*result, mono_shutdown_callback_fn);
 
diff --git a/dlls/mscoree/mscoree_private.h b/dlls/mscoree/mscoree_private.h
index ef9079e..7266687 100644
--- a/dlls/mscoree/mscoree_private.h
+++ b/dlls/mscoree/mscoree_private.h
@@ -154,6 +154,7 @@ struct loaded_mono
     void (CDECL *mono_config_parse)(const char *filename);
     MonoAssembly* (CDECL *mono_domain_assembly_open) (MonoDomain *domain, const char *name);
     void (CDECL *mono_free)(void *);
+    MonoImage* (CDECL *mono_image_open)(const char *fname, MonoImageOpenStatus *status);
     MonoImage* (CDECL *mono_image_open_from_module_handle)(HMODULE module_handle, char* fname, UINT has_entry_point, MonoImageOpenStatus* status);
     void (CDECL *mono_install_assembly_preload_hook)(MonoAssemblyPreLoadFunc func, void *user_data);
     int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
-- 
1.7.9.5


More information about the wine-patches mailing list