diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c index 14854d147e7..c37651a1b49 100644 --- a/dlls/mscoree/corruntimehost.c +++ b/dlls/mscoree/corruntimehost.c @@ -91,7 +91,7 @@ static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, MonoDomain **result) goto end; } - entry->domain = This->mono->mono_jit_init(mscorlib_path); + entry->domain = mono_jit_init(mscorlib_path); HeapFree(GetProcessHeap(), 0, mscorlib_path); @@ -102,7 +102,7 @@ static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, MonoDomain **result) goto end; } - This->mono->is_started = TRUE; + is_mono_started = TRUE; list_add_tail(&This->domains, &entry->entry); @@ -164,30 +164,30 @@ static HRESULT RuntimeHost_GetIUnknownForDomain(RuntimeHost *This, MonoDomain *d MonoObject *appdomain_object; IUnknown *unk; - This->mono->mono_thread_attach(domain); + mono_thread_attach(domain); - assembly = This->mono->mono_domain_assembly_open(domain, "mscorlib"); + assembly = mono_domain_assembly_open(domain, "mscorlib"); if (!assembly) { ERR("Cannot load mscorlib\n"); return E_FAIL; } - image = This->mono->mono_assembly_get_image(assembly); + image = mono_assembly_get_image(assembly); if (!image) { ERR("Couldn't get assembly image\n"); return E_FAIL; } - klass = This->mono->mono_class_from_name(image, "System", "AppDomain"); + klass = mono_class_from_name(image, "System", "AppDomain"); if (!klass) { ERR("Couldn't get class from image\n"); return E_FAIL; } - method = This->mono->mono_class_get_method_from_name(klass, "get_CurrentDomain", 0); + method = mono_class_get_method_from_name(klass, "get_CurrentDomain", 0); if (!method) { ERR("Couldn't get method from class\n"); @@ -195,7 +195,7 @@ static HRESULT RuntimeHost_GetIUnknownForDomain(RuntimeHost *This, MonoDomain *d } args[0] = NULL; - appdomain_object = This->mono->mono_runtime_invoke(method, NULL, args, NULL); + appdomain_object = mono_runtime_invoke(method, NULL, args, NULL); if (!appdomain_object) { ERR("Couldn't get result pointer\n"); @@ -578,17 +578,17 @@ static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain(ICLRRuntimeHost* hr = E_FAIL; - This->mono->mono_thread_attach(domain); + mono_thread_attach(domain); filenameA = WtoA(pwzAssemblyPath); - assembly = This->mono->mono_domain_assembly_open(domain, filenameA); + assembly = mono_domain_assembly_open(domain, filenameA); if (!assembly) { ERR("Cannot open assembly %s\n", filenameA); goto cleanup; } - image = This->mono->mono_assembly_get_image(assembly); + image = mono_assembly_get_image(assembly); if (!image) { ERR("Couldn't get assembly image\n"); @@ -598,7 +598,7 @@ static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain(ICLRRuntimeHost* classA = WtoA(pwzTypeName); ns = strrchr(classA, '.'); *ns = '\0'; - klass = This->mono->mono_class_from_name(image, classA, ns+1); + klass = mono_class_from_name(image, classA, ns+1); if (!klass) { ERR("Couldn't get class from image\n"); @@ -606,7 +606,7 @@ static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain(ICLRRuntimeHost* } methodA = WtoA(pwzMethodName); - method = This->mono->mono_class_get_method_from_name(klass, methodA, 1); + method = mono_class_get_method_from_name(klass, methodA, 1); if (!method) { ERR("Couldn't get method from class\n"); @@ -617,15 +617,15 @@ static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain(ICLRRuntimeHost* * public static int functionName(String param) */ argsA = WtoA(pwzArgument); - str = This->mono->mono_string_new(domain, argsA); + str = mono_string_new(domain, argsA); args[0] = str; args[1] = NULL; - result = This->mono->mono_runtime_invoke(method, NULL, args, NULL); + result = mono_runtime_invoke(method, NULL, args, NULL); if (!result) ERR("Couldn't get result pointer\n"); else { - *pReturnValue = *(DWORD*)This->mono->mono_object_unbox(result); + *pReturnValue = *(DWORD*)mono_object_unbox(result); hr = S_OK; } @@ -678,9 +678,9 @@ HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name, if (SUCCEEDED(hr)) { - This->mono->mono_thread_attach(domain); + mono_thread_attach(domain); - type = This->mono->mono_reflection_type_from_name(nameA, NULL); + type = mono_reflection_type_from_name(nameA, NULL); if (!type) { ERR("Cannot find type %s\n", debugstr_w(name)); @@ -690,7 +690,7 @@ HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name, if (SUCCEEDED(hr)) { - klass = This->mono->mono_class_from_mono_type(type); + klass = mono_class_from_mono_type(type); if (!klass) { ERR("Cannot convert type %s to a class\n", debugstr_w(name)); @@ -700,7 +700,7 @@ HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name, if (SUCCEEDED(hr)) { - obj = This->mono->mono_object_new(domain, klass); + obj = mono_object_new(domain, klass); if (!obj) { ERR("Cannot allocate object of type %s\n", debugstr_w(name)); @@ -711,7 +711,7 @@ HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name, if (SUCCEEDED(hr)) { /* FIXME: Detect exceptions from the constructor? */ - This->mono->mono_runtime_object_init(obj); + mono_runtime_object_init(obj); *result = obj; } @@ -741,30 +741,30 @@ HRESULT RuntimeHost_GetIUnknownForObject(RuntimeHost *This, MonoObject *obj, MonoObject *result; void *args[2]; - domain = This->mono->mono_object_get_domain(obj); + domain = mono_object_get_domain(obj); - assembly = This->mono->mono_domain_assembly_open(domain, "mscorlib"); + assembly = mono_domain_assembly_open(domain, "mscorlib"); if (!assembly) { ERR("Cannot load mscorlib\n"); return E_FAIL; } - image = This->mono->mono_assembly_get_image(assembly); + image = mono_assembly_get_image(assembly); if (!image) { ERR("Couldn't get assembly image\n"); return E_FAIL; } - klass = This->mono->mono_class_from_name(image, "System.Runtime.InteropServices", "Marshal"); + klass = mono_class_from_name(image, "System.Runtime.InteropServices", "Marshal"); if (!klass) { ERR("Couldn't get class from image\n"); return E_FAIL; } - method = This->mono->mono_class_get_method_from_name(klass, "GetIUnknownForObject", 1); + method = mono_class_get_method_from_name(klass, "GetIUnknownForObject", 1); if (!method) { ERR("Couldn't get method from class\n"); @@ -773,14 +773,14 @@ HRESULT RuntimeHost_GetIUnknownForObject(RuntimeHost *This, MonoObject *obj, args[0] = obj; args[1] = NULL; - result = This->mono->mono_runtime_invoke(method, NULL, args, NULL); + result = mono_runtime_invoke(method, NULL, args, NULL); if (!result) { ERR("Couldn't get result pointer\n"); return E_FAIL; } - *ppUnk = *(IUnknown**)This->mono->mono_object_unbox(result); + *ppUnk = *(IUnknown**)mono_object_unbox(result); if (!*ppUnk) { ERR("GetIUnknownForObject returned 0\n"); @@ -915,9 +915,9 @@ static void CDECL ReallyFixupVTable(struct dll_fixup *fixup) if (SUCCEEDED(hr)) { - host->mono->mono_thread_attach(domain); + mono_thread_attach(domain); - assembly = host->mono->mono_assembly_open(filenameA, &status); + assembly = mono_assembly_open(filenameA, &status); } if (assembly) @@ -925,7 +925,7 @@ static void CDECL ReallyFixupVTable(struct dll_fixup *fixup) int i; /* Mono needs an image that belongs to an assembly. */ - image = host->mono->mono_assembly_get_image(assembly); + image = mono_assembly_get_image(assembly); if (fixup->fixup->type & COR_VTABLE_32BIT) { @@ -934,7 +934,7 @@ static void CDECL ReallyFixupVTable(struct dll_fixup *fixup) for (i=0; ifixup->count; i++) { TRACE("%x\n", tokens[i]); - vtable[i] = PtrToUint(host->mono->mono_marshal_get_vtfixup_ftnptr( + vtable[i] = PtrToUint(mono_marshal_get_vtfixup_ftnptr( image, tokens[i], fixup->fixup->type)); } } @@ -1071,17 +1071,17 @@ __int32 WINAPI _CorExeMain(void) if (SUCCEEDED(hr)) { - image = host->mono->mono_image_open_from_module_handle(GetModuleHandleW(NULL), + image = mono_image_open_from_module_handle(GetModuleHandleW(NULL), filenameA, 1, &status); if (image) - assembly = host->mono->mono_assembly_load_from(image, filenameA, &status); + assembly = mono_assembly_load_from(image, filenameA, &status); if (assembly) { - host->mono->mono_trace_set_assembly(assembly); + mono_trace_set_assembly(assembly); - exit_code = host->mono->mono_jit_exec(domain, assembly, argc, argv); + exit_code = mono_jit_exec(domain, assembly, argc, argv); } else { @@ -1143,8 +1143,7 @@ void runtimehost_uninit(void) } } -HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version, - loaded_mono *loaded_mono, RuntimeHost** result) +HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version, RuntimeHost** result) { RuntimeHost *This; @@ -1157,7 +1156,6 @@ HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version, This->ref = 1; This->version = runtime_version; - This->mono = loaded_mono; list_init(&This->domains); This->default_domain = NULL; InitializeCriticalSection(&This->lock); @@ -1337,10 +1335,10 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj ) hr = CLASS_E_CLASSNOTAVAILABLE; - host->mono->mono_thread_attach(domain); + mono_thread_attach(domain); filenameA = WtoA(filename); - assembly = host->mono->mono_domain_assembly_open(domain, filenameA); + assembly = mono_domain_assembly_open(domain, filenameA); HeapFree(GetProcessHeap(), 0, filenameA); if (!assembly) { @@ -1348,7 +1346,7 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj ) goto cleanup; } - image = host->mono->mono_assembly_get_image(assembly); + image = mono_assembly_get_image(assembly); if (!image) { ERR("Couldn't get assembly image\n"); @@ -1359,7 +1357,7 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj ) ns = strrchr(classA, '.'); *ns = '\0'; - klass = host->mono->mono_class_from_name(image, classA, ns+1); + klass = mono_class_from_name(image, classA, ns+1); HeapFree(GetProcessHeap(), 0, classA); if (!klass) { @@ -1370,8 +1368,8 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj ) /* * Use the default constructor for the .NET class. */ - result = host->mono->mono_object_new(domain, klass); - host->mono->mono_runtime_object_init(result); + result = mono_object_new(domain, klass); + mono_runtime_object_init(result); hr = RuntimeHost_GetIUnknownForObject(host, result, &unk); if (SUCCEEDED(hr)) diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c index fc00522c7de..ae0e123496d 100644 --- a/dlls/mscoree/metahost.c +++ b/dlls/mscoree/metahost.c @@ -71,11 +71,47 @@ static CRITICAL_SECTION_DEBUG runtime_list_cs_debug = }; static CRITICAL_SECTION runtime_list_cs = { &runtime_list_cs_debug, -1, 0, 0, 0, 0 }; -#define NUM_ABI_VERSIONS 2 +static HMODULE mono_handle; -static loaded_mono loaded_monos[NUM_ABI_VERSIONS]; +BOOL is_mono_started; +static BOOL is_mono_shutdown; -static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path, int abi_version); +MonoImage* (CDECL *mono_assembly_get_image)(MonoAssembly *assembly); +MonoAssembly* (CDECL *mono_assembly_load_from)(MonoImage *image, const char *fname, MonoImageOpenStatus *status); +MonoAssembly* (CDECL *mono_assembly_open)(const char *filename, MonoImageOpenStatus *status); +MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type); +MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_space, const char *name); +MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count); +static void (CDECL *mono_config_parse)(const char *filename); +MonoAssembly* (CDECL *mono_domain_assembly_open)(MonoDomain *domain, const char *name); +static void (CDECL *mono_free)(void *); +static 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); +static 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[]); +MonoDomain* (CDECL *mono_jit_init)(const char *file); +static int (CDECL *mono_jit_set_trace_options)(const char* options); +void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type); +MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj); +MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass); +void* (CDECL *mono_object_unbox)(MonoObject *obj); +static void (CDECL *mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback); +MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image); +MonoObject* (CDECL *mono_runtime_invoke)(MonoMethod *method, void *obj, void **params, MonoObject **exc); +void (CDECL *mono_runtime_object_init)(MonoObject *this_obj); +static void (CDECL *mono_runtime_quit)(void); +static void (CDECL *mono_runtime_set_shutting_down)(void); +static void (CDECL *mono_set_dirs)(const char *assembly_dir, const char *config_dir); +static void (CDECL *mono_set_verbose_level)(DWORD level); +MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str); +static char* (CDECL *mono_stringify_assembly_name)(MonoAssemblyName *aname); +MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain); +static void (CDECL *mono_thread_pool_cleanup)(void); +static void (CDECL *mono_thread_suspend_all_other_threads)(void); +static void (CDECL *mono_threads_set_shutting_down)(void); +void (CDECL *mono_trace_set_assembly)(MonoAssembly *assembly); + +static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path); static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char **assemblies_path, void *user_data); @@ -100,40 +136,22 @@ 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, +static MonoImage* CDECL image_open_module_handle_dummy(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); + return mono_image_open(fname, status); } -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(void) { MESSAGE("wine: Install Mono for Windows to run .NET applications.\n"); } -static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result) +static HRESULT load_mono(CLRRuntimeInfo *This) { static const WCHAR bin[] = {'\\','b','i','n',0}; static const WCHAR lib[] = {'\\','l','i','b',0}; static const WCHAR etc[] = {'\\','e','t','c',0}; - static const WCHAR glibdll[] = {'l','i','b','g','l','i','b','-','2','.','0','-','0','.','d','l','l',0}; WCHAR mono_dll_path[MAX_PATH+16], mono_bin_path[MAX_PATH+4]; WCHAR mono_lib_path[MAX_PATH+4], mono_etc_path[MAX_PATH+4]; char mono_lib_path_a[MAX_PATH], mono_etc_path_a[MAX_PATH]; @@ -142,22 +160,13 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result) int verbose_size; char verbose_setting[256]; - if (This->mono_abi_version <= 0 || This->mono_abi_version > NUM_ABI_VERSIONS) - { - missing_runtime_message(); - return E_FAIL; - } - - *result = &loaded_monos[This->mono_abi_version-1]; - - if ((*result)->is_shutdown) + if (is_mono_shutdown) { ERR("Cannot load Mono after it has been shut down.\n"); - *result = NULL; return E_FAIL; } - if (!(*result)->mono_handle) + if (!mono_handle) { strcpyW(mono_bin_path, This->mono_path); strcatW(mono_bin_path, bin); @@ -171,15 +180,15 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result) strcatW(mono_etc_path, etc); WideCharToMultiByte(CP_UTF8, 0, mono_etc_path, -1, mono_etc_path_a, MAX_PATH, NULL, NULL); - if (!find_mono_dll(This->mono_path, mono_dll_path, This->mono_abi_version)) goto fail; + if (!find_mono_dll(This->mono_path, mono_dll_path)) goto fail; - (*result)->mono_handle = LoadLibraryW(mono_dll_path); + mono_handle = LoadLibraryW(mono_dll_path); - if (!(*result)->mono_handle) goto fail; + if (!mono_handle) goto fail; #define LOAD_MONO_FUNCTION(x) do { \ - (*result)->x = (void*)GetProcAddress((*result)->mono_handle, #x); \ - if (!(*result)->x) { \ + x = (void*)GetProcAddress(mono_handle, #x); \ + if (!x) { \ goto fail; \ } \ } while (0); @@ -192,6 +201,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_free); LOAD_MONO_FUNCTION(mono_image_open); LOAD_MONO_FUNCTION(mono_install_assembly_preload_hook); LOAD_MONO_FUNCTION(mono_jit_exec); @@ -213,30 +223,16 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result) LOAD_MONO_FUNCTION(mono_thread_attach); LOAD_MONO_FUNCTION(mono_trace_set_assembly); - /* GLib imports obsoleted by the 2.0 ABI */ - if (This->mono_abi_version == 1) - { - (*result)->glib_handle = LoadLibraryW(glibdll); - if (!(*result)->glib_handle) goto fail; - - (*result)->mono_free = (void*)GetProcAddress((*result)->glib_handle, "g_free"); - if (!(*result)->mono_free) goto fail; - } - else - { - LOAD_MONO_FUNCTION(mono_free); - } - #undef LOAD_MONO_FUNCTION #define LOAD_OPT_MONO_FUNCTION(x, default) do { \ - (*result)->x = (void*)GetProcAddress((*result)->mono_handle, #x); \ - if (!(*result)->x) { \ - (*result)->x = default; \ + x = (void*)GetProcAddress(mono_handle, #x); \ + if (!x) { \ + x = default; \ } \ } while (0); - LOAD_OPT_MONO_FUNCTION(mono_image_open_from_module_handle, image_from_handle_fn[This->mono_abi_version-1]); + LOAD_OPT_MONO_FUNCTION(mono_image_open_from_module_handle, image_open_module_handle_dummy); 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); @@ -244,26 +240,26 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result) #undef LOAD_OPT_MONO_FUNCTION - (*result)->mono_profiler_install((MonoProfiler*)*result, mono_shutdown_callback_fn); + mono_profiler_install(NULL, mono_shutdown_callback_fn); - (*result)->mono_set_dirs(mono_lib_path_a, mono_etc_path_a); + mono_set_dirs(mono_lib_path_a, mono_etc_path_a); - (*result)->mono_config_parse(NULL); + mono_config_parse(NULL); - (*result)->mono_install_assembly_preload_hook(mono_assembly_search_hook_fn, *result); + mono_install_assembly_preload_hook(mono_assembly_search_hook_fn, NULL); trace_size = GetEnvironmentVariableA("WINE_MONO_TRACE", trace_setting, sizeof(trace_setting)); if (trace_size) { - (*result)->mono_jit_set_trace_options(trace_setting); + mono_jit_set_trace_options(trace_setting); } verbose_size = GetEnvironmentVariableA("WINE_MONO_VERBOSE", verbose_setting, sizeof(verbose_setting)); if (verbose_size) { - (*result)->mono_set_verbose_level(verbose_setting[0] - '0'); + mono_set_verbose_level(verbose_setting[0] - '0'); } } @@ -271,24 +267,19 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result) fail: ERR("Could not load Mono into this process\n"); - FreeLibrary((*result)->mono_handle); - FreeLibrary((*result)->glib_handle); - (*result)->mono_handle = NULL; - (*result)->glib_handle = NULL; + FreeLibrary(mono_handle); + mono_handle = NULL; return E_FAIL; } static void mono_shutdown_callback_fn(MonoProfiler *prof) { - loaded_mono *mono = (loaded_mono*)prof; - - mono->is_shutdown = TRUE; + is_mono_shutdown = TRUE; } static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost **result) { HRESULT hr = S_OK; - loaded_mono *ploaded_mono; if (This->loaded_runtime) { @@ -298,10 +289,10 @@ static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost * EnterCriticalSection(&runtime_list_cs); - hr = load_mono(This, &ploaded_mono); + hr = load_mono(This); if (SUCCEEDED(hr)) - hr = RuntimeHost_Construct(This, ploaded_mono, &This->loaded_runtime); + hr = RuntimeHost_Construct(This, &This->loaded_runtime); LeaveCriticalSection(&runtime_list_cs); @@ -321,18 +312,14 @@ void unload_all_runtimes(void) * reference to prevent that from happening. */ GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const WCHAR *)unload_all_runtimes, &handle); - for (i=0; imono_handle && mono->is_started && !mono->is_shutdown) - { - /* Copied from Mono's ves_icall_System_Environment_Exit */ - mono->mono_threads_set_shutting_down(); - mono->mono_runtime_set_shutting_down(); - mono->mono_thread_pool_cleanup(); - mono->mono_thread_suspend_all_other_threads(); - mono->mono_runtime_quit(); - } + /* Copied from Mono's ves_icall_System_Environment_Exit */ + mono_threads_set_shutting_down(); + mono_runtime_set_shutting_down(); + mono_thread_pool_cleanup(); + mono_thread_suspend_all_other_threads(); + mono_runtime_quit(); } for (i=0; imono_handle && mono->is_started && !mono->is_shutdown) - { - ERR("Process exited with a Mono runtime loaded.\n"); - return; - } + ERR("Process exited with a Mono runtime loaded.\n"); + return; } } @@ -612,52 +593,34 @@ static const WCHAR libmono2_arch_dll[] = {'\\','b','i','n','\\','l','i','b','m', static const WCHAR libmono2_arch_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','-','2','.','0','.','d','l','l',0}; #endif -static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path, int abi_version) +static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path) { - static const WCHAR mono_dll[] = {'\\','b','i','n','\\','m','o','n','o','.','d','l','l',0}; - static const WCHAR libmono_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','.','d','l','l',0}; static const WCHAR mono2_dll[] = {'\\','b','i','n','\\','m','o','n','o','-','2','.','0','.','d','l','l',0}; static const WCHAR libmono2_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','-','2','.','0','.','d','l','l',0}; DWORD attributes=INVALID_FILE_ATTRIBUTES; - if (abi_version == 1) + strcpyW(dll_path, path); + strcatW(dll_path, libmono2_arch_dll); + attributes = GetFileAttributesW(dll_path); + + if (attributes == INVALID_FILE_ATTRIBUTES) { strcpyW(dll_path, path); - strcatW(dll_path, mono_dll); + strcatW(dll_path, mono2_dll); attributes = GetFileAttributesW(dll_path); - - if (attributes == INVALID_FILE_ATTRIBUTES) - { - strcpyW(dll_path, path); - strcatW(dll_path, libmono_dll); - attributes = GetFileAttributesW(dll_path); - } } - else if (abi_version == 2) + + if (attributes == INVALID_FILE_ATTRIBUTES) { strcpyW(dll_path, path); - strcatW(dll_path, libmono2_arch_dll); + strcatW(dll_path, libmono2_dll); attributes = GetFileAttributesW(dll_path); - - if (attributes == INVALID_FILE_ATTRIBUTES) - { - strcpyW(dll_path, path); - strcatW(dll_path, mono2_dll); - attributes = GetFileAttributesW(dll_path); - } - - if (attributes == INVALID_FILE_ATTRIBUTES) - { - strcpyW(dll_path, path); - strcatW(dll_path, libmono2_dll); - attributes = GetFileAttributesW(dll_path); - } } return (attributes != INVALID_FILE_ATTRIBUTES); } -static BOOL get_mono_path_from_registry(LPWSTR path, int abi_version) +static BOOL get_mono_path_from_registry(LPWSTR path) { static const WCHAR mono_key[] = {'S','o','f','t','w','a','r','e','\\','N','o','v','e','l','l','\\','M','o','n','o',0}; static const WCHAR defaul_clr[] = {'D','e','f','a','u','l','t','C','L','R',0}; @@ -695,29 +658,25 @@ static BOOL get_mono_path_from_registry(LPWSTR path, int abi_version) } RegCloseKey(key); - return find_mono_dll(path, dll_path, abi_version); + return find_mono_dll(path, dll_path); } -static BOOL get_mono_path_from_folder(LPCWSTR folder, LPWSTR mono_path, int abi_version) +static BOOL get_mono_path_from_folder(LPCWSTR folder, LPWSTR mono_path) { - static const WCHAR mono_one_dot_zero[] = {'\\','m','o','n','o','-','1','.','0', 0}; static const WCHAR mono_two_dot_zero[] = {'\\','m','o','n','o','-','2','.','0', 0}; WCHAR mono_dll_path[MAX_PATH]; BOOL found = FALSE; strcpyW(mono_path, folder); - if (abi_version == 1) - strcatW(mono_path, mono_one_dot_zero); - else if (abi_version == 2) - strcatW(mono_path, mono_two_dot_zero); + strcatW(mono_path, mono_two_dot_zero); - found = find_mono_dll(mono_path, mono_dll_path, abi_version); + found = find_mono_dll(mono_path, mono_dll_path); return found; } -static BOOL get_mono_path(LPWSTR path, int abi_version) +static BOOL get_mono_path(LPWSTR path) { static const WCHAR subdir_mono[] = {'\\','m','o','n','o',0}; static const WCHAR sibling_mono[] = {'\\','.','.','\\','m','o','n','o',0}; @@ -731,7 +690,7 @@ static BOOL get_mono_path(LPWSTR path, int abi_version) GetWindowsDirectoryW(base_path, MAX_PATH); strcatW(base_path, subdir_mono); - if (get_mono_path_from_folder(base_path, path, abi_version)) + if (get_mono_path_from_folder(base_path, path)) return TRUE; /* Next: /usr/share/wine/mono */ @@ -759,19 +718,19 @@ static BOOL get_mono_path(LPWSTR path, int abi_version) HeapFree(GetProcessHeap(), 0, dos_data_dir); - if (get_mono_path_from_folder(base_path, path, abi_version)) + if (get_mono_path_from_folder(base_path, path)) return TRUE; } } } /* Last: the registry */ - return get_mono_path_from_registry(path, abi_version); + return get_mono_path_from_registry(path); } static void find_runtimes(void) { - int abi_version, i; + int i; static const WCHAR libmono[] = {'\\','l','i','b','\\','m','o','n','o','\\',0}; static const WCHAR mscorlib[] = {'\\','m','s','c','o','r','l','i','b','.','d','l','l',0}; WCHAR mono_path[MAX_PATH], lib_path[MAX_PATH]; @@ -783,29 +742,23 @@ static void find_runtimes(void) if (runtimes_initialized) goto end; - for (abi_version=NUM_ABI_VERSIONS; abi_version>0; abi_version--) + if (get_mono_path(mono_path)) { - if (!get_mono_path(mono_path, abi_version)) - continue; - for (i=0; ipos].mono_abi_version) + if (runtimes[This->pos].found) { item = (IUnknown*)&runtimes[This->pos].ICLRRuntimeInfo_iface; IUnknown_AddRef(item); @@ -932,7 +885,7 @@ static HRESULT WINAPI InstalledRuntimeEnum_Skip(IEnumUnknown *iface, ULONG celt) hr = S_FALSE; break; } - if (runtimes[This->pos].mono_abi_version) + if (runtimes[This->pos].found) { num_fetched++; } @@ -1087,7 +1040,7 @@ HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface, if (runtimes[i].major == major && runtimes[i].minor == minor && runtimes[i].build == build) { - if (runtimes[i].mono_abi_version) + if (runtimes[i].found) return ICLRRuntimeInfo_QueryInterface(&runtimes[i].ICLRRuntimeInfo_iface, iid, ppRuntime); else @@ -1325,7 +1278,6 @@ HRESULT get_file_from_strongname(WCHAR* stringnameW, WCHAR* assemblies_path, int static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char **assemblies_path, void *user_data) { - loaded_mono *mono = user_data; HRESULT hr; MonoAssembly *result=NULL; char *stringname=NULL; @@ -1335,7 +1287,7 @@ static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char char *pathA; MonoImageOpenStatus stat; - stringname = mono->mono_stringify_assembly_name(aname); + stringname = mono_stringify_assembly_name(aname); TRACE("%s\n", debugstr_a(stringname)); @@ -1365,7 +1317,7 @@ static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char if (pathA) { - result = mono->mono_assembly_open(pathA, &stat); + result = mono_assembly_open(pathA, &stat); if (!result) ERR("Failed to load %s, status=%u\n", debugstr_w(path), stat); @@ -1374,7 +1326,7 @@ static MonoAssembly* mono_assembly_search_hook_fn(MonoAssemblyName *aname, char } } - mono->mono_free(stringname); + mono_free(stringname); return result; } @@ -1470,7 +1422,7 @@ HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file, while (i--) { - if (runtimes[i].mono_abi_version) + if (runtimes[i].found) { /* Must be greater or equal to the version passed in. */ if (!version || ((runtimes[i].major >= major && runtimes[i].minor >= minor && runtimes[i].build >= build) || diff --git a/dlls/mscoree/mscoree_private.h b/dlls/mscoree/mscoree_private.h index dd5b1aff522..58a5088d42b 100644 --- a/dlls/mscoree/mscoree_private.h +++ b/dlls/mscoree/mscoree_private.h @@ -55,7 +55,6 @@ typedef struct _MonoMethod MonoMethod; typedef struct _MonoProfiler MonoProfiler; typedef struct _MonoThread MonoThread; -typedef struct loaded_mono loaded_mono; typedef struct RuntimeHost RuntimeHost; typedef struct CLRRuntimeInfo @@ -65,7 +64,7 @@ typedef struct CLRRuntimeInfo DWORD major; DWORD minor; DWORD build; - int mono_abi_version; + int found; WCHAR mono_path[MAX_PATH]; WCHAR mscorlib_path[MAX_PATH]; struct RuntimeHost *loaded_runtime; @@ -76,7 +75,6 @@ struct RuntimeHost ICorRuntimeHost ICorRuntimeHost_iface; ICLRRuntimeHost ICLRRuntimeHost_iface; const CLRRuntimeInfo *version; - loaded_mono *mono; struct list domains; MonoDomain *default_domain; CRITICAL_SECTION lock; @@ -138,57 +136,35 @@ typedef MonoAssembly* (*MonoAssemblyPreLoadFunc)(MonoAssemblyName *aname, char * typedef void (*MonoProfileFunc)(MonoProfiler *prof); -struct loaded_mono -{ - HMODULE mono_handle; - HMODULE glib_handle; +extern BOOL is_mono_started; - BOOL is_started; - BOOL is_shutdown; - - MonoImage* (CDECL *mono_assembly_get_image)(MonoAssembly *assembly); - MonoAssembly* (CDECL *mono_assembly_load_from)(MonoImage *image, const char *fname, MonoImageOpenStatus *status); - MonoAssembly* (CDECL *mono_assembly_open)(const char *filename, MonoImageOpenStatus *status); - MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type); - MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_space, const char *name); - MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count); - 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[]); - MonoDomain* (CDECL *mono_jit_init)(const char *file); - int (CDECL *mono_jit_set_trace_options)(const char* options); - void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type); - MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj); - MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass); - void* (CDECL *mono_object_unbox)(MonoObject *obj); - void (CDECL *mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback); - MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image); - MonoObject* (CDECL *mono_runtime_invoke)(MonoMethod *method, void *obj, void **params, MonoObject **exc); - void (CDECL *mono_runtime_object_init)(MonoObject *this_obj); - void (CDECL *mono_runtime_quit)(void); - void (CDECL *mono_runtime_set_shutting_down)(void); - void (CDECL *mono_set_dirs)(const char *assembly_dir, const char *config_dir); - void (CDECL *mono_set_verbose_level)(DWORD level); - char* (CDECL *mono_stringify_assembly_name)(MonoAssemblyName *aname); - void (CDECL *mono_thread_pool_cleanup)(void); - void (CDECL *mono_thread_suspend_all_other_threads)(void); - void (CDECL *mono_threads_set_shutting_down)(void); - void (CDECL *mono_trace_set_assembly)(MonoAssembly *assembly); - MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str); - MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain); -}; +extern MonoImage* (CDECL *mono_assembly_get_image)(MonoAssembly *assembly); +extern MonoAssembly* (CDECL *mono_assembly_load_from)(MonoImage *image, const char *fname, MonoImageOpenStatus *status); +extern MonoAssembly* (CDECL *mono_assembly_open)(const char *filename, MonoImageOpenStatus *status); +extern MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type); +extern MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_space, const char *name); +extern MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count); +extern MonoAssembly* (CDECL *mono_domain_assembly_open)(MonoDomain *domain, const char *name); +extern int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]); +extern MonoDomain* (CDECL *mono_jit_init)(const char *file); +extern MonoImage* (CDECL *mono_image_open_from_module_handle)(HMODULE module_handle, char* fname, UINT has_entry_point, MonoImageOpenStatus* status); +extern void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type); +extern MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj); +extern MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass); +extern void* (CDECL *mono_object_unbox)(MonoObject *obj); +extern MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image); +extern MonoObject* (CDECL *mono_runtime_invoke)(MonoMethod *method, void *obj, void **params, MonoObject **exc); +extern void (CDECL *mono_runtime_object_init)(MonoObject *this_obj); +extern MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str); +extern MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain); +extern void (CDECL *mono_trace_set_assembly)(MonoAssembly *assembly); /* loaded runtime interfaces */ extern void unload_all_runtimes(void) DECLSPEC_HIDDEN; extern void expect_no_runtimes(void) DECLSPEC_HIDDEN; -extern HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version, - loaded_mono *loaded_mono, RuntimeHost** result) DECLSPEC_HIDDEN; +extern HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version, RuntimeHost** result) DECLSPEC_HIDDEN; extern HRESULT RuntimeHost_GetInterface(RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv) DECLSPEC_HIDDEN;