Commit 5cd6db03 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

mscoree: Remove the runtime version selection logic and just use 4.0.

Mono has removed support for the .NET 2.0 profile, so we'll have to be using 4.0 for everything next time we want to update.
parent dfd25067
...@@ -71,7 +71,6 @@ struct dll_fixup ...@@ -71,7 +71,6 @@ struct dll_fixup
static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, MonoDomain **result) static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, MonoDomain **result)
{ {
struct DomainEntry *entry; struct DomainEntry *entry;
char *mscorlib_path;
HRESULT res=S_OK; HRESULT res=S_OK;
EnterCriticalSection(&This->lock); EnterCriticalSection(&This->lock);
...@@ -83,17 +82,8 @@ static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, MonoDomain **result) ...@@ -83,17 +82,8 @@ static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, MonoDomain **result)
goto end; goto end;
} }
mscorlib_path = WtoA(This->version->mscorlib_path); /* FIXME: Use exe filename to name the domain? */
if (!mscorlib_path) entry->domain = mono_jit_init_version("mscorlib.dll", "v4.0.30319");
{
HeapFree(GetProcessHeap(), 0, entry);
res = E_OUTOFMEMORY;
goto end;
}
entry->domain = mono_jit_init(mscorlib_path);
HeapFree(GetProcessHeap(), 0, mscorlib_path);
if (!entry->domain) if (!entry->domain)
{ {
......
...@@ -45,22 +45,17 @@ ...@@ -45,22 +45,17 @@
WINE_DEFAULT_DEBUG_CHANNEL( mscoree ); WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
static const WCHAR net_20_subdir[] = {'2','.','0',0};
static const WCHAR net_40_subdir[] = {'4','.','0',0};
static const struct ICLRRuntimeInfoVtbl CLRRuntimeInfoVtbl; static const struct ICLRRuntimeInfoVtbl CLRRuntimeInfoVtbl;
#define NUM_RUNTIMES 4 #define NUM_RUNTIMES 4
static struct CLRRuntimeInfo runtimes[NUM_RUNTIMES] = { static struct CLRRuntimeInfo runtimes[NUM_RUNTIMES] = {
{{&CLRRuntimeInfoVtbl}, net_20_subdir, 1, 0, 3705, 0}, {{&CLRRuntimeInfoVtbl}, 1, 0, 3705, 0},
{{&CLRRuntimeInfoVtbl}, net_20_subdir, 1, 1, 4322, 0}, {{&CLRRuntimeInfoVtbl}, 1, 1, 4322, 0},
{{&CLRRuntimeInfoVtbl}, net_20_subdir, 2, 0, 50727, 0}, {{&CLRRuntimeInfoVtbl}, 2, 0, 50727, 0},
{{&CLRRuntimeInfoVtbl}, net_40_subdir, 4, 0, 30319, 0} {{&CLRRuntimeInfoVtbl}, 4, 0, 30319, 0}
}; };
static BOOL runtimes_initialized = FALSE;
static CRITICAL_SECTION runtime_list_cs; static CRITICAL_SECTION runtime_list_cs;
static CRITICAL_SECTION_DEBUG runtime_list_cs_debug = static CRITICAL_SECTION_DEBUG runtime_list_cs_debug =
{ {
...@@ -89,7 +84,7 @@ static MonoImage* (CDECL *mono_image_open)(const char *fname, MonoImageOpenStatu ...@@ -89,7 +84,7 @@ static MonoImage* (CDECL *mono_image_open)(const char *fname, MonoImageOpenStatu
MonoImage* (CDECL *mono_image_open_from_module_handle)(HMODULE module_handle, char* fname, UINT has_entry_point, 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); 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[]); int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
MonoDomain* (CDECL *mono_jit_init)(const char *file); MonoDomain* (CDECL *mono_jit_init_version)(const char *domain_name, const char *runtime_version);
static int (CDECL *mono_jit_set_trace_options)(const char* options); static int (CDECL *mono_jit_set_trace_options)(const char* options);
void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type); void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type);
MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj); MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj);
...@@ -108,6 +103,8 @@ MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain); ...@@ -108,6 +103,8 @@ MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain);
void (CDECL *mono_thread_manage)(void); void (CDECL *mono_thread_manage)(void);
void (CDECL *mono_trace_set_assembly)(MonoAssembly *assembly); void (CDECL *mono_trace_set_assembly)(MonoAssembly *assembly);
static BOOL get_mono_path(LPWSTR path);
static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path); static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path);
static MonoAssembly* mono_assembly_preload_hook_fn(MonoAssemblyName *aname, char **assemblies_path, void *user_data); static MonoAssembly* mono_assembly_preload_hook_fn(MonoAssemblyName *aname, char **assemblies_path, void *user_data);
...@@ -140,7 +137,7 @@ static void missing_runtime_message(void) ...@@ -140,7 +137,7 @@ static void missing_runtime_message(void)
MESSAGE("wine: Install Mono for Windows to run .NET applications.\n"); MESSAGE("wine: Install Mono for Windows to run .NET applications.\n");
} }
static HRESULT load_mono(CLRRuntimeInfo *This) static HRESULT load_mono(LPCWSTR mono_path)
{ {
static const WCHAR bin[] = {'\\','b','i','n',0}; static const WCHAR bin[] = {'\\','b','i','n',0};
static const WCHAR lib[] = {'\\','l','i','b',0}; static const WCHAR lib[] = {'\\','l','i','b',0};
...@@ -161,19 +158,19 @@ static HRESULT load_mono(CLRRuntimeInfo *This) ...@@ -161,19 +158,19 @@ static HRESULT load_mono(CLRRuntimeInfo *This)
if (!mono_handle) if (!mono_handle)
{ {
strcpyW(mono_bin_path, This->mono_path); strcpyW(mono_bin_path, mono_path);
strcatW(mono_bin_path, bin); strcatW(mono_bin_path, bin);
set_environment(mono_bin_path); set_environment(mono_bin_path);
strcpyW(mono_lib_path, This->mono_path); strcpyW(mono_lib_path, mono_path);
strcatW(mono_lib_path, lib); strcatW(mono_lib_path, lib);
WideCharToMultiByte(CP_UTF8, 0, mono_lib_path, -1, mono_lib_path_a, MAX_PATH, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, mono_lib_path, -1, mono_lib_path_a, MAX_PATH, NULL, NULL);
strcpyW(mono_etc_path, This->mono_path); strcpyW(mono_etc_path, mono_path);
strcatW(mono_etc_path, etc); strcatW(mono_etc_path, etc);
WideCharToMultiByte(CP_UTF8, 0, mono_etc_path, -1, mono_etc_path_a, MAX_PATH, NULL, NULL); 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)) goto fail; if (!find_mono_dll(mono_path, mono_dll_path)) goto fail;
mono_handle = LoadLibraryW(mono_dll_path); mono_handle = LoadLibraryW(mono_dll_path);
...@@ -198,7 +195,7 @@ static HRESULT load_mono(CLRRuntimeInfo *This) ...@@ -198,7 +195,7 @@ static HRESULT load_mono(CLRRuntimeInfo *This)
LOAD_MONO_FUNCTION(mono_image_open); LOAD_MONO_FUNCTION(mono_image_open);
LOAD_MONO_FUNCTION(mono_install_assembly_preload_hook); LOAD_MONO_FUNCTION(mono_install_assembly_preload_hook);
LOAD_MONO_FUNCTION(mono_jit_exec); LOAD_MONO_FUNCTION(mono_jit_exec);
LOAD_MONO_FUNCTION(mono_jit_init); LOAD_MONO_FUNCTION(mono_jit_init_version);
LOAD_MONO_FUNCTION(mono_jit_set_trace_options); LOAD_MONO_FUNCTION(mono_jit_set_trace_options);
LOAD_MONO_FUNCTION(mono_marshal_get_vtfixup_ftnptr); LOAD_MONO_FUNCTION(mono_marshal_get_vtfixup_ftnptr);
LOAD_MONO_FUNCTION(mono_object_get_domain); LOAD_MONO_FUNCTION(mono_object_get_domain);
...@@ -270,6 +267,7 @@ static void mono_shutdown_callback_fn(MonoProfiler *prof) ...@@ -270,6 +267,7 @@ static void mono_shutdown_callback_fn(MonoProfiler *prof)
static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost **result) static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost **result)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
WCHAR mono_path[MAX_PATH];
if (This->loaded_runtime) if (This->loaded_runtime)
{ {
...@@ -277,9 +275,15 @@ static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost * ...@@ -277,9 +275,15 @@ static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost *
return hr; return hr;
} }
if (!get_mono_path(mono_path))
{
missing_runtime_message();
return CLR_E_SHIM_RUNTIME;
}
EnterCriticalSection(&runtime_list_cs); EnterCriticalSection(&runtime_list_cs);
hr = load_mono(This); hr = load_mono(mono_path);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = RuntimeHost_Construct(This, &This->loaded_runtime); hr = RuntimeHost_Construct(This, &This->loaded_runtime);
...@@ -693,55 +697,6 @@ static BOOL get_mono_path(LPWSTR path) ...@@ -693,55 +697,6 @@ static BOOL get_mono_path(LPWSTR path)
return get_mono_path_from_registry(path); return get_mono_path_from_registry(path);
} }
static void find_runtimes(void)
{
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];
BOOL any_runtimes_found = FALSE;
if (runtimes_initialized) return;
EnterCriticalSection(&runtime_list_cs);
if (runtimes_initialized) goto end;
if (get_mono_path(mono_path))
{
for (i=0; i<NUM_RUNTIMES; i++)
{
strcpyW(lib_path, mono_path);
strcatW(lib_path, libmono);
strcatW(lib_path, runtimes[i].mono_libdir);
strcatW(lib_path, mscorlib);
if (GetFileAttributesW(lib_path) != INVALID_FILE_ATTRIBUTES)
{
runtimes[i].found = TRUE;
strcpyW(runtimes[i].mono_path, mono_path);
strcpyW(runtimes[i].mscorlib_path, lib_path);
any_runtimes_found = TRUE;
}
}
}
if (!any_runtimes_found)
{
/* Report all runtimes are available if Mono isn't installed.
* FIXME: Remove this when Mono is properly packaged. */
for (i=0; i<NUM_RUNTIMES; i++)
runtimes[i].found = TRUE;
}
runtimes_initialized = TRUE;
end:
LeaveCriticalSection(&runtime_list_cs);
}
struct InstalledRuntimeEnum struct InstalledRuntimeEnum
{ {
IEnumUnknown IEnumUnknown_iface; IEnumUnknown IEnumUnknown_iface;
...@@ -819,13 +774,10 @@ static HRESULT WINAPI InstalledRuntimeEnum_Next(IEnumUnknown *iface, ULONG celt, ...@@ -819,13 +774,10 @@ static HRESULT WINAPI InstalledRuntimeEnum_Next(IEnumUnknown *iface, ULONG celt,
hr = S_FALSE; hr = S_FALSE;
break; break;
} }
if (runtimes[This->pos].found) item = (IUnknown*)&runtimes[This->pos].ICLRRuntimeInfo_iface;
{ IUnknown_AddRef(item);
item = (IUnknown*)&runtimes[This->pos].ICLRRuntimeInfo_iface; rgelt[num_fetched] = item;
IUnknown_AddRef(item); num_fetched++;
rgelt[num_fetched] = item;
num_fetched++;
}
This->pos++; This->pos++;
} }
...@@ -850,10 +802,7 @@ static HRESULT WINAPI InstalledRuntimeEnum_Skip(IEnumUnknown *iface, ULONG celt) ...@@ -850,10 +802,7 @@ static HRESULT WINAPI InstalledRuntimeEnum_Skip(IEnumUnknown *iface, ULONG celt)
hr = S_FALSE; hr = S_FALSE;
break; break;
} }
if (runtimes[This->pos].found) num_fetched++;
{
num_fetched++;
}
This->pos++; This->pos++;
} }
...@@ -996,21 +945,13 @@ static HRESULT get_runtime(LPCWSTR pwzVersion, BOOL allow_short, ...@@ -996,21 +945,13 @@ static HRESULT get_runtime(LPCWSTR pwzVersion, BOOL allow_short,
return CLR_E_SHIM_RUNTIME; return CLR_E_SHIM_RUNTIME;
} }
find_runtimes();
for (i=0; i<NUM_RUNTIMES; i++) for (i=0; i<NUM_RUNTIMES; i++)
{ {
if (runtimes[i].major == major && runtimes[i].minor == minor && if (runtimes[i].major == major && runtimes[i].minor == minor &&
(runtimes[i].build == build || (allow_short && major >= 4 && build == 0))) (runtimes[i].build == build || (allow_short && major >= 4 && build == 0)))
{ {
if (runtimes[i].found) return ICLRRuntimeInfo_QueryInterface(&runtimes[i].ICLRRuntimeInfo_iface, iid,
return ICLRRuntimeInfo_QueryInterface(&runtimes[i].ICLRRuntimeInfo_iface, iid, ppRuntime);
ppRuntime);
else
{
missing_runtime_message();
return CLR_E_SHIM_RUNTIME;
}
} }
} }
...@@ -1068,8 +1009,6 @@ static HRESULT WINAPI CLRMetaHost_EnumerateInstalledRuntimes(ICLRMetaHost* iface ...@@ -1068,8 +1009,6 @@ static HRESULT WINAPI CLRMetaHost_EnumerateInstalledRuntimes(ICLRMetaHost* iface
TRACE("%p\n", ppEnumerator); TRACE("%p\n", ppEnumerator);
find_runtimes();
new_enum = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_enum)); new_enum = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_enum));
if (!new_enum) if (!new_enum)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -1440,8 +1379,6 @@ HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file, ...@@ -1440,8 +1379,6 @@ HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file,
return CLR_E_SHIM_RUNTIME; return CLR_E_SHIM_RUNTIME;
} }
find_runtimes();
if (legacy) if (legacy)
i = 3; i = 3;
else else
...@@ -1449,16 +1386,13 @@ HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file, ...@@ -1449,16 +1386,13 @@ HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file,
while (i--) while (i--)
{ {
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) ||
(runtimes[i].major >= major && runtimes[i].minor > minor) ||
(runtimes[i].major > major)))
{ {
/* Must be greater or equal to the version passed in. */ return ICLRRuntimeInfo_QueryInterface(&runtimes[i].ICLRRuntimeInfo_iface,
if (!version || ((runtimes[i].major >= major && runtimes[i].minor >= minor && runtimes[i].build >= build) || &IID_ICLRRuntimeInfo, (void **)result);
(runtimes[i].major >= major && runtimes[i].minor > minor) ||
(runtimes[i].major > major)))
{
return ICLRRuntimeInfo_QueryInterface(&runtimes[i].ICLRRuntimeInfo_iface,
&IID_ICLRRuntimeInfo, (void **)result);
}
} }
} }
......
...@@ -60,13 +60,9 @@ typedef struct RuntimeHost RuntimeHost; ...@@ -60,13 +60,9 @@ typedef struct RuntimeHost RuntimeHost;
typedef struct CLRRuntimeInfo typedef struct CLRRuntimeInfo
{ {
ICLRRuntimeInfo ICLRRuntimeInfo_iface; ICLRRuntimeInfo ICLRRuntimeInfo_iface;
LPCWSTR mono_libdir;
DWORD major; DWORD major;
DWORD minor; DWORD minor;
DWORD build; DWORD build;
BOOL found;
WCHAR mono_path[MAX_PATH];
WCHAR mscorlib_path[MAX_PATH];
struct RuntimeHost *loaded_runtime; struct RuntimeHost *loaded_runtime;
} CLRRuntimeInfo; } CLRRuntimeInfo;
...@@ -146,7 +142,7 @@ extern MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* na ...@@ -146,7 +142,7 @@ extern MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* na
extern MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count) DECLSPEC_HIDDEN; extern MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count) DECLSPEC_HIDDEN;
extern MonoAssembly* (CDECL *mono_domain_assembly_open)(MonoDomain *domain, const char *name) DECLSPEC_HIDDEN; extern MonoAssembly* (CDECL *mono_domain_assembly_open)(MonoDomain *domain, const char *name) DECLSPEC_HIDDEN;
extern int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]) DECLSPEC_HIDDEN; extern int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]) DECLSPEC_HIDDEN;
extern MonoDomain* (CDECL *mono_jit_init)(const char *file) 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; extern MonoImage* (CDECL *mono_image_open_from_module_handle)(HMODULE module_handle, char* fname, UINT has_entry_point, MonoImageOpenStatus* status) DECLSPEC_HIDDEN;
extern void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type) DECLSPEC_HIDDEN; extern void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type) DECLSPEC_HIDDEN;
extern MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj) DECLSPEC_HIDDEN; extern MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment