Commit 4d44363e authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

mscoree: Set config path for default app domain.

parent f2ceadc6
...@@ -104,8 +104,11 @@ end: ...@@ -104,8 +104,11 @@ end:
return res; return res;
} }
static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, MonoDomain **result) static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, const WCHAR *config_path, MonoDomain **result)
{ {
WCHAR config_dir[MAX_PATH];
WCHAR base_dir[MAX_PATH];
char *base_dirA, *config_pathA, *slash;
HRESULT res=S_OK; HRESULT res=S_OK;
EnterCriticalSection(&This->lock); EnterCriticalSection(&This->lock);
...@@ -114,6 +117,48 @@ static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, MonoDomain **resu ...@@ -114,6 +117,48 @@ static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, MonoDomain **resu
res = RuntimeHost_AddDomain(This, &This->default_domain); res = RuntimeHost_AddDomain(This, &This->default_domain);
if (!config_path)
{
DWORD len = sizeof(config_dir)/sizeof(*config_dir);
static const WCHAR machine_configW[] = {'\\','C','O','N','F','I','G','\\','m','a','c','h','i','n','e','.','c','o','n','f','i','g',0};
res = ICLRRuntimeInfo_GetRuntimeDirectory(&This->version->ICLRRuntimeInfo_iface,
config_dir, &len);
if (FAILED(res))
goto end;
lstrcatW(config_dir, machine_configW);
config_path = config_dir;
}
config_pathA = WtoA(config_path);
if (!config_pathA)
{
res = E_OUTOFMEMORY;
goto end;
}
GetModuleFileNameW(NULL, base_dir, sizeof(base_dir) / sizeof(*base_dir));
base_dirA = WtoA(base_dir);
if (!base_dirA)
{
HeapFree(GetProcessHeap(), 0, config_pathA);
res = E_OUTOFMEMORY;
goto end;
}
slash = strrchr(base_dirA, '\\');
if (slash)
*slash = 0;
TRACE("setting base_dir: %s, config_path: %s\n", base_dirA, config_pathA);
mono_domain_set_config(This->default_domain, base_dirA, config_pathA);
HeapFree(GetProcessHeap(), 0, config_pathA);
HeapFree(GetProcessHeap(), 0, base_dirA);
end: end:
*result = This->default_domain; *result = This->default_domain;
...@@ -241,7 +286,7 @@ void RuntimeHost_ExitProcess(RuntimeHost *This, INT exitcode) ...@@ -241,7 +286,7 @@ void RuntimeHost_ExitProcess(RuntimeHost *This, INT exitcode)
MonoDomain *domain; MonoDomain *domain;
MonoObject *dummy; MonoObject *dummy;
hr = RuntimeHost_GetDefaultDomain(This, &domain); hr = RuntimeHost_GetDefaultDomain(This, NULL, &domain);
if (FAILED(hr)) if (FAILED(hr))
{ {
ERR("Cannot get domain, hr=%x\n", hr); ERR("Cannot get domain, hr=%x\n", hr);
...@@ -371,7 +416,7 @@ static HRESULT WINAPI corruntimehost_Start( ...@@ -371,7 +416,7 @@ static HRESULT WINAPI corruntimehost_Start(
TRACE("%p\n", This); TRACE("%p\n", This);
return RuntimeHost_GetDefaultDomain(This, &dummy); return RuntimeHost_GetDefaultDomain(This, NULL, &dummy);
} }
static HRESULT WINAPI corruntimehost_Stop( static HRESULT WINAPI corruntimehost_Stop(
...@@ -401,7 +446,7 @@ static HRESULT WINAPI corruntimehost_GetDefaultDomain( ...@@ -401,7 +446,7 @@ static HRESULT WINAPI corruntimehost_GetDefaultDomain(
TRACE("(%p)\n", iface); TRACE("(%p)\n", iface);
hr = RuntimeHost_GetDefaultDomain(This, &domain); hr = RuntimeHost_GetDefaultDomain(This, NULL, &domain);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -459,7 +504,7 @@ static HRESULT WINAPI corruntimehost_CreateDomainSetup( ...@@ -459,7 +504,7 @@ static HRESULT WINAPI corruntimehost_CreateDomainSetup(
TRACE("(%p)\n", iface); TRACE("(%p)\n", iface);
hr = RuntimeHost_GetDefaultDomain(This, &domain); hr = RuntimeHost_GetDefaultDomain(This, NULL, &domain);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = RuntimeHost_CreateManagedInstance(This, classnameW, domain, &obj); hr = RuntimeHost_CreateManagedInstance(This, classnameW, domain, &obj);
...@@ -625,7 +670,7 @@ static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain(ICLRRuntimeHost* ...@@ -625,7 +670,7 @@ static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain(ICLRRuntimeHost*
TRACE("(%p,%s,%s,%s,%s)\n", iface, debugstr_w(pwzAssemblyPath), TRACE("(%p,%s,%s,%s,%s)\n", iface, debugstr_w(pwzAssemblyPath),
debugstr_w(pwzTypeName), debugstr_w(pwzMethodName), debugstr_w(pwzArgument)); debugstr_w(pwzTypeName), debugstr_w(pwzMethodName), debugstr_w(pwzArgument));
hr = RuntimeHost_GetDefaultDomain(This, &domain); hr = RuntimeHost_GetDefaultDomain(This, NULL, &domain);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -717,7 +762,7 @@ HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name, ...@@ -717,7 +762,7 @@ HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name,
MonoObject *obj; MonoObject *obj;
if (!domain) if (!domain)
hr = RuntimeHost_GetDefaultDomain(This, &domain); hr = RuntimeHost_GetDefaultDomain(This, NULL, &domain);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -921,7 +966,7 @@ static void CDECL ReallyFixupVTable(struct dll_fixup *fixup) ...@@ -921,7 +966,7 @@ static void CDECL ReallyFixupVTable(struct dll_fixup *fixup)
hr = ICLRRuntimeInfo_GetRuntimeHost(info, &host); hr = ICLRRuntimeInfo_GetRuntimeHost(info, &host);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = RuntimeHost_GetDefaultDomain(host, &domain); hr = RuntimeHost_GetDefaultDomain(host, NULL, &domain);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -1077,7 +1122,15 @@ __int32 WINAPI _CorExeMain(void) ...@@ -1077,7 +1122,15 @@ __int32 WINAPI _CorExeMain(void)
hr = ICLRRuntimeInfo_GetRuntimeHost(info, &host); hr = ICLRRuntimeInfo_GetRuntimeHost(info, &host);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = RuntimeHost_GetDefaultDomain(host, &domain); {
WCHAR config_file[MAX_PATH];
static const WCHAR dotconfig[] = {'.','c','o','n','f','i','g',0};
strcpyW(config_file, filename);
strcatW(config_file, dotconfig);
hr = RuntimeHost_GetDefaultDomain(host, config_file, &domain);
}
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -1157,7 +1210,7 @@ void runtimehost_uninit(void) ...@@ -1157,7 +1210,7 @@ void runtimehost_uninit(void)
} }
} }
HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version, RuntimeHost** result) HRESULT RuntimeHost_Construct(CLRRuntimeInfo *runtime_version, RuntimeHost** result)
{ {
RuntimeHost *This; RuntimeHost *This;
...@@ -1342,7 +1395,7 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj ) ...@@ -1342,7 +1395,7 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj )
hr = ICLRRuntimeInfo_GetRuntimeHost(info, &host); hr = ICLRRuntimeInfo_GetRuntimeHost(info, &host);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = RuntimeHost_GetDefaultDomain(host, &domain); hr = RuntimeHost_GetDefaultDomain(host, NULL, &domain);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
......
...@@ -79,6 +79,7 @@ MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_spac ...@@ -79,6 +79,7 @@ MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_spac
MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count); 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); static void (CDECL *mono_config_parse)(const char *filename);
MonoAssembly* (CDECL *mono_domain_assembly_open)(MonoDomain *domain, const char *name); MonoAssembly* (CDECL *mono_domain_assembly_open)(MonoDomain *domain, const char *name);
void (CDECL *mono_domain_set_config)(MonoDomain *domain,const char *base_dir,const char *config_file_name);
static void (CDECL *mono_free)(void *); static void (CDECL *mono_free)(void *);
static MonoImage* (CDECL *mono_image_open)(const char *fname, MonoImageOpenStatus *status); 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); MonoImage* (CDECL *mono_image_open_from_module_handle)(HMODULE module_handle, char* fname, UINT has_entry_point, MonoImageOpenStatus* status);
...@@ -179,6 +180,7 @@ static HRESULT load_mono(LPCWSTR mono_path) ...@@ -179,6 +180,7 @@ static HRESULT load_mono(LPCWSTR mono_path)
LOAD_MONO_FUNCTION(mono_class_from_name); LOAD_MONO_FUNCTION(mono_class_from_name);
LOAD_MONO_FUNCTION(mono_class_get_method_from_name); LOAD_MONO_FUNCTION(mono_class_get_method_from_name);
LOAD_MONO_FUNCTION(mono_domain_assembly_open); LOAD_MONO_FUNCTION(mono_domain_assembly_open);
LOAD_MONO_FUNCTION(mono_domain_set_config);
LOAD_MONO_FUNCTION(mono_free); LOAD_MONO_FUNCTION(mono_free);
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);
......
...@@ -70,7 +70,7 @@ struct RuntimeHost ...@@ -70,7 +70,7 @@ struct RuntimeHost
{ {
ICorRuntimeHost ICorRuntimeHost_iface; ICorRuntimeHost ICorRuntimeHost_iface;
ICLRRuntimeHost ICLRRuntimeHost_iface; ICLRRuntimeHost ICLRRuntimeHost_iface;
const CLRRuntimeInfo *version; CLRRuntimeInfo *version;
struct list domains; struct list domains;
MonoDomain *default_domain; MonoDomain *default_domain;
CRITICAL_SECTION lock; CRITICAL_SECTION lock;
...@@ -143,6 +143,7 @@ extern MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type) DECLSPEC_HI ...@@ -143,6 +143,7 @@ extern MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type) DECLSPEC_HI
extern MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_space, const char *name) DECLSPEC_HIDDEN; extern MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_space, const char *name) DECLSPEC_HIDDEN;
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 void (CDECL *mono_domain_set_config)(MonoDomain *domain,const char *base_dir,const char *config_file_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_version)(const char *domain_name, const char *runtime_version) 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;
...@@ -164,7 +165,7 @@ extern void (CDECL *mono_trace_set_printerr_handler)(MonoPrintCallback callback) ...@@ -164,7 +165,7 @@ extern void (CDECL *mono_trace_set_printerr_handler)(MonoPrintCallback callback)
/* loaded runtime interfaces */ /* loaded runtime interfaces */
extern void expect_no_runtimes(void) DECLSPEC_HIDDEN; extern void expect_no_runtimes(void) DECLSPEC_HIDDEN;
extern HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version, RuntimeHost** result) DECLSPEC_HIDDEN; extern HRESULT RuntimeHost_Construct(CLRRuntimeInfo *runtime_version, RuntimeHost** result) DECLSPEC_HIDDEN;
extern void RuntimeHost_ExitProcess(RuntimeHost *This, INT exitcode) DECLSPEC_HIDDEN; extern void RuntimeHost_ExitProcess(RuntimeHost *This, INT exitcode) 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