mscoree: Add a fallback for mono_image_open_from_module_handle.

This commit is contained in:
Vincent Povirk 2012-05-17 09:47:46 -05:00 committed by Alexandre Julliard
parent ad7279a5a6
commit 56484cc037
2 changed files with 33 additions and 8 deletions

View File

@ -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);

View File

@ -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[]);