mscoree: Use mono_get_corlib to get mscorlib image.

Apparently, mono_domain_assembly_open is intended for the entry
point assembly only, and no longer works when mscorlib is passed
in.

Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Vincent Povirk 2020-04-18 22:01:15 -05:00 committed by Alexandre Julliard
parent e13d546657
commit 049e50bcaa
3 changed files with 26 additions and 16 deletions

View File

@ -200,18 +200,25 @@ static BOOL RuntimeHost_GetMethod(MonoDomain *domain, const char *assemblyname,
MonoImage *image;
MonoClass *klass;
assembly = mono_domain_assembly_open(domain, assemblyname);
if (!assembly)
if (!assemblyname)
{
ERR("Cannot load assembly %s\n", assemblyname);
return FALSE;
image = mono_get_corlib();
}
image = mono_assembly_get_image(assembly);
if (!image)
else
{
ERR("Couldn't get assembly image for %s\n", assemblyname);
return FALSE;
assembly = mono_domain_assembly_open(domain, assemblyname);
if (!assembly)
{
ERR("Cannot load assembly %s\n", assemblyname);
return FALSE;
}
image = mono_assembly_get_image(assembly);
if (!image)
{
ERR("Couldn't get assembly image for %s\n", assemblyname);
return FALSE;
}
}
klass = mono_class_from_name(image, namespace, typename);
@ -250,7 +257,7 @@ static HRESULT RuntimeHost_DoInvoke(RuntimeHost *This, MonoDomain *domain,
if (methodname != get_hresult)
{
/* Map the exception to an HRESULT. */
hr = RuntimeHost_Invoke(This, domain, "mscorlib", "System", "Exception", get_hresult,
hr = RuntimeHost_Invoke(This, domain, NULL, "System", "Exception", get_hresult,
exc, NULL, 0, &hr_object);
if (SUCCEEDED(hr))
hr = *(HRESULT*)mono_object_unbox(hr_object);
@ -348,7 +355,7 @@ static HRESULT RuntimeHost_GetObjectForIUnknown(RuntimeHost *This, MonoDomain *d
MonoObject *result;
args[0] = &unk;
hr = RuntimeHost_Invoke(This, domain, "mscorlib", "System.Runtime.InteropServices", "Marshal", "GetObjectForIUnknown",
hr = RuntimeHost_Invoke(This, domain, NULL, "System.Runtime.InteropServices", "Marshal", "GetObjectForIUnknown",
NULL, args, 1, &result);
if (SUCCEEDED(hr))
@ -413,7 +420,7 @@ static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, const WCHAR *name, IUnkn
args[2] = NULL;
}
res = RuntimeHost_Invoke(This, domain, "mscorlib", "System", "AppDomain", "CreateDomain",
res = RuntimeHost_Invoke(This, domain, NULL, "System", "AppDomain", "CreateDomain",
NULL, args, 3, &new_domain);
if (FAILED(res))
@ -427,7 +434,7 @@ static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, const WCHAR *name, IUnkn
* Instead, do a vcall.
*/
res = RuntimeHost_VirtualInvoke(This, domain, "mscorlib", "System", "AppDomain", "get_Id",
res = RuntimeHost_VirtualInvoke(This, domain, NULL, "System", "AppDomain", "get_Id",
new_domain, NULL, 0, &id);
if (FAILED(res))
@ -448,7 +455,7 @@ static HRESULT RuntimeHost_GetIUnknownForDomain(RuntimeHost *This, MonoDomain *d
MonoObject *appdomain_object;
IUnknown *unk;
hr = RuntimeHost_Invoke(This, domain, "mscorlib", "System", "AppDomain", "get_CurrentDomain",
hr = RuntimeHost_Invoke(This, domain, NULL, "System", "AppDomain", "get_CurrentDomain",
NULL, NULL, 0, &appdomain_object);
if (SUCCEEDED(hr))
@ -480,7 +487,7 @@ void RuntimeHost_ExitProcess(RuntimeHost *This, INT exitcode)
args[0] = &exitcode;
args[1] = NULL;
RuntimeHost_Invoke(This, domain, "mscorlib", "System", "Environment", "Exit",
RuntimeHost_Invoke(This, domain, NULL, "System", "Environment", "Exit",
NULL, args, 1, &dummy);
ERR("Process should have exited\n");
@ -1048,7 +1055,7 @@ HRESULT RuntimeHost_GetIUnknownForObject(RuntimeHost *This, MonoObject *obj,
domain = mono_object_get_domain(obj);
hr = RuntimeHost_Invoke(This, domain, "mscorlib", "System.Runtime.InteropServices", "Marshal", "GetIUnknownForObject",
hr = RuntimeHost_Invoke(This, domain, NULL, "System.Runtime.InteropServices", "Marshal", "GetIUnknownForObject",
NULL, (void**)&obj, 1, &result);
if (SUCCEEDED(hr))

View File

@ -99,6 +99,7 @@ MonoDomain* (CDECL *mono_domain_get_by_id)(int id);
BOOL (CDECL *mono_domain_set)(MonoDomain *domain,BOOL force);
void (CDECL *mono_domain_set_config)(MonoDomain *domain,const char *base_dir,const char *config_file_name);
static void (CDECL *mono_free)(void *);
MonoImage* (CDECL *mono_get_corlib)(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);
@ -204,6 +205,7 @@ static HRESULT load_mono(LPCWSTR mono_path)
LOAD_MONO_FUNCTION(mono_domain_set);
LOAD_MONO_FUNCTION(mono_domain_set_config);
LOAD_MONO_FUNCTION(mono_free);
LOAD_MONO_FUNCTION(mono_get_corlib);
LOAD_MONO_FUNCTION(mono_image_open);
LOAD_MONO_FUNCTION(mono_install_assembly_preload_hook);
LOAD_MONO_FUNCTION(mono_jit_exec);

View File

@ -162,6 +162,7 @@ extern MonoDomain* (CDECL *mono_domain_get)(void) DECLSPEC_HIDDEN;
extern MonoDomain* (CDECL *mono_domain_get_by_id)(int id) DECLSPEC_HIDDEN;
extern BOOL (CDECL *mono_domain_set)(MonoDomain *domain, BOOL force) DECLSPEC_HIDDEN;
extern void (CDECL *mono_domain_set_config)(MonoDomain *domain,const char *base_dir,const char *config_file_name) DECLSPEC_HIDDEN;
extern MonoImage* (CDECL *mono_get_corlib)(void) DECLSPEC_HIDDEN;
extern int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]) DECLSPEC_HIDDEN;
extern MonoDomain* (CDECL *mono_jit_init_version)(const char *domain_name, const char *runtime_version) DECLSPEC_HIDDEN;
extern MonoImage* (CDECL *mono_image_open_from_module_handle)(HMODULE module_handle, char* fname, UINT has_entry_point, MonoImageOpenStatus* status) DECLSPEC_HIDDEN;