Commit fdeaf812 authored by Charles Davis's avatar Charles Davis Committed by Alexandre Julliard

mscoree: Implement ICorRuntimeHost::CreateDomain{, Ex}().

parent c94336f3
...@@ -68,7 +68,7 @@ struct dll_fixup ...@@ -68,7 +68,7 @@ struct dll_fixup
void *tokens; /* pointer into process heap */ void *tokens; /* pointer into process heap */
}; };
static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, MonoDomain **result) static HRESULT RuntimeHost_AddDefaultDomain(RuntimeHost *This, MonoDomain **result)
{ {
struct DomainEntry *entry; struct DomainEntry *entry;
HRESULT res=S_OK; HRESULT res=S_OK;
...@@ -115,7 +115,7 @@ static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, const WCHAR *conf ...@@ -115,7 +115,7 @@ static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, const WCHAR *conf
if (This->default_domain) goto end; if (This->default_domain) goto end;
res = RuntimeHost_AddDomain(This, &This->default_domain); res = RuntimeHost_AddDefaultDomain(This, &This->default_domain);
if (!config_path) if (!config_path)
{ {
...@@ -188,49 +188,55 @@ static void RuntimeHost_DeleteDomain(RuntimeHost *This, MonoDomain *domain) ...@@ -188,49 +188,55 @@ static void RuntimeHost_DeleteDomain(RuntimeHost *This, MonoDomain *domain)
LeaveCriticalSection(&This->lock); LeaveCriticalSection(&This->lock);
} }
static HRESULT RuntimeHost_Invoke(RuntimeHost *This, MonoDomain *domain, static BOOL RuntimeHost_GetMethod(MonoDomain *domain, const char *assemblyname,
const char *assemblyname, const char *namespace, const char *typename, const char *methodname, const char *namespace, const char *typename, const char *methodname, int arg_count,
MonoObject *obj, void **args, int arg_count, MonoObject **result) MonoMethod **method)
{ {
MonoAssembly *assembly; MonoAssembly *assembly;
MonoImage *image; MonoImage *image;
MonoClass *klass; MonoClass *klass;
MonoMethod *method;
MonoObject *exc;
static const char *get_hresult = "get_HResult";
*result = NULL;
mono_thread_attach(domain);
assembly = mono_domain_assembly_open(domain, assemblyname); assembly = mono_domain_assembly_open(domain, assemblyname);
if (!assembly) if (!assembly)
{ {
ERR("Cannot load assembly %s\n", assemblyname); ERR("Cannot load assembly %s\n", assemblyname);
return E_FAIL; return FALSE;
} }
image = mono_assembly_get_image(assembly); image = mono_assembly_get_image(assembly);
if (!image) if (!image)
{ {
ERR("Couldn't get assembly image for %s\n", assemblyname); ERR("Couldn't get assembly image for %s\n", assemblyname);
return E_FAIL; return FALSE;
} }
klass = mono_class_from_name(image, namespace, typename); klass = mono_class_from_name(image, namespace, typename);
if (!klass) if (!klass)
{ {
ERR("Couldn't get class %s.%s from image\n", namespace, typename); ERR("Couldn't get class %s.%s from image\n", namespace, typename);
return E_FAIL; return FALSE;
} }
method = mono_class_get_method_from_name(klass, methodname, arg_count); *method = mono_class_get_method_from_name(klass, methodname, arg_count);
if (!method) if (!*method)
{ {
ERR("Couldn't get method %s from class %s.%s\n", methodname, namespace, typename); ERR("Couldn't get method %s from class %s.%s\n", methodname, namespace, typename);
return E_FAIL; return FALSE;
} }
return TRUE;
}
static HRESULT RuntimeHost_Invoke(RuntimeHost *This, MonoDomain *domain,
const char *assemblyname, const char *namespace, const char *typename, const char *methodname,
MonoObject *obj, void **args, int arg_count, MonoObject **result);
static HRESULT RuntimeHost_DoInvoke(RuntimeHost *This, MonoDomain *domain,
const char *methodname, MonoMethod *method, MonoObject *obj, void **args, MonoObject **result)
{
MonoObject *exc;
static const char *get_hresult = "get_HResult";
*result = mono_runtime_invoke(method, obj, args, &exc); *result = mono_runtime_invoke(method, obj, args, &exc);
if (exc) if (exc)
{ {
...@@ -249,7 +255,6 @@ static HRESULT RuntimeHost_Invoke(RuntimeHost *This, MonoDomain *domain, ...@@ -249,7 +255,6 @@ static HRESULT RuntimeHost_Invoke(RuntimeHost *This, MonoDomain *domain,
} }
else else
hr = E_FAIL; hr = E_FAIL;
ERR("Method %s.%s:%s raised an exception, hr=%x\n", namespace, typename, methodname, hr);
*result = NULL; *result = NULL;
return hr; return hr;
} }
...@@ -257,6 +262,173 @@ static HRESULT RuntimeHost_Invoke(RuntimeHost *This, MonoDomain *domain, ...@@ -257,6 +262,173 @@ static HRESULT RuntimeHost_Invoke(RuntimeHost *This, MonoDomain *domain,
return S_OK; return S_OK;
} }
static HRESULT RuntimeHost_Invoke(RuntimeHost *This, MonoDomain *domain,
const char *assemblyname, const char *namespace, const char *typename, const char *methodname,
MonoObject *obj, void **args, int arg_count, MonoObject **result)
{
MonoMethod *method;
HRESULT hr;
*result = NULL;
mono_thread_attach(domain);
if (!RuntimeHost_GetMethod(domain, assemblyname, namespace, typename, methodname,
arg_count, &method))
{
return E_FAIL;
}
hr = RuntimeHost_DoInvoke(This, domain, methodname, method, obj, args, result);
if (FAILED(hr))
{
ERR("Method %s.%s:%s raised an exception, hr=%x\n", namespace, typename, methodname, hr);
}
return hr;
}
static HRESULT RuntimeHost_VirtualInvoke(RuntimeHost *This, MonoDomain *domain,
const char *assemblyname, const char *namespace, const char *typename, const char *methodname,
MonoObject *obj, void **args, int arg_count, MonoObject **result)
{
MonoMethod *method;
HRESULT hr;
*result = NULL;
if (!obj)
{
ERR("\"this\" object cannot be null\n");
return E_POINTER;
}
mono_thread_attach(domain);
if (!RuntimeHost_GetMethod(domain, assemblyname, namespace, typename, methodname,
arg_count, &method))
{
return E_FAIL;
}
method = mono_object_get_virtual_method(obj, method);
if (!method)
{
ERR("Object %p does not support method %s.%s:%s\n", obj, namespace, typename, methodname);
return E_FAIL;
}
hr = RuntimeHost_DoInvoke(This, domain, methodname, method, obj, args, result);
if (FAILED(hr))
{
ERR("Method %s.%s:%s raised an exception, hr=%x\n", namespace, typename, methodname, hr);
}
return hr;
}
static HRESULT RuntimeHost_GetObjectForIUnknown(RuntimeHost *This, MonoDomain *domain,
IUnknown *unk, MonoObject **obj)
{
HRESULT hr;
void *args[1];
MonoObject *result;
args[0] = &unk;
hr = RuntimeHost_Invoke(This, domain, "mscorlib", "System.Runtime.InteropServices", "Marshal", "GetObjectForIUnknown",
NULL, args, 1, &result);
if (SUCCEEDED(hr))
{
*obj = result;
}
return hr;
}
static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, const WCHAR *name, IUnknown *setup,
IUnknown *evidence, MonoDomain **result)
{
HRESULT res;
char *nameA;
MonoDomain *domain;
void *args[3];
MonoObject *new_domain, *id;
res = RuntimeHost_GetDefaultDomain(This, NULL, &domain);
if (FAILED(res))
{
return res;
}
nameA = WtoA(name);
if (!nameA)
{
return E_OUTOFMEMORY;
}
args[0] = mono_string_new(domain, nameA);
HeapFree(GetProcessHeap(), 0, nameA);
if (!args[0])
{
return E_OUTOFMEMORY;
}
if (evidence)
{
res = RuntimeHost_GetObjectForIUnknown(This, domain, evidence, (MonoObject **)&args[1]);
if (FAILED(res))
{
return res;
}
}
else
{
args[1] = NULL;
}
if (setup)
{
res = RuntimeHost_GetObjectForIUnknown(This, domain, setup, (MonoObject **)&args[2]);
if (FAILED(res))
{
return res;
}
}
else
{
args[2] = NULL;
}
res = RuntimeHost_Invoke(This, domain, "mscorlib", "System", "AppDomain", "CreateDomain",
NULL, args, 3, &new_domain);
if (FAILED(res))
{
return res;
}
/* new_domain is not the AppDomain itself, but a transparent proxy.
* So, we'll retrieve its ID, and use that to get the real domain object.
* We can't do a regular invoke, because that will bypass the proxy.
* Instead, do a vcall.
*/
res = RuntimeHost_VirtualInvoke(This, domain, "mscorlib", "System", "AppDomain", "get_Id",
new_domain, NULL, 0, &id);
if (FAILED(res))
{
return res;
}
TRACE("returning domain id %d\n", *(int *)mono_object_unbox(id));
*result = mono_domain_get_by_id(*(int *)mono_object_unbox(id));
return S_OK;
}
static HRESULT RuntimeHost_GetIUnknownForDomain(RuntimeHost *This, MonoDomain *domain, IUnknown **punk) static HRESULT RuntimeHost_GetIUnknownForDomain(RuntimeHost *This, MonoDomain *domain, IUnknown **punk)
{ {
HRESULT hr; HRESULT hr;
...@@ -432,8 +604,7 @@ static HRESULT WINAPI corruntimehost_CreateDomain( ...@@ -432,8 +604,7 @@ static HRESULT WINAPI corruntimehost_CreateDomain(
IUnknown *identityArray, IUnknown *identityArray,
IUnknown **appDomain) IUnknown **appDomain)
{ {
FIXME("stub %p\n", iface); return ICorRuntimeHost_CreateDomainEx(iface, friendlyName, NULL, NULL, appDomain);
return E_NOTIMPL;
} }
static HRESULT WINAPI corruntimehost_GetDefaultDomain( static HRESULT WINAPI corruntimehost_GetDefaultDomain(
...@@ -488,8 +659,29 @@ static HRESULT WINAPI corruntimehost_CreateDomainEx( ...@@ -488,8 +659,29 @@ static HRESULT WINAPI corruntimehost_CreateDomainEx(
IUnknown *evidence, IUnknown *evidence,
IUnknown **appDomain) IUnknown **appDomain)
{ {
FIXME("stub %p\n", iface); RuntimeHost *This = impl_from_ICorRuntimeHost( iface );
return E_NOTIMPL; HRESULT hr;
MonoDomain *domain;
if (!friendlyName || !appDomain)
{
return E_POINTER;
}
if (!is_mono_started)
{
return E_FAIL;
}
TRACE("(%p)\n", iface);
hr = RuntimeHost_AddDomain(This, friendlyName, setup, evidence, &domain);
if (SUCCEEDED(hr))
{
hr = RuntimeHost_GetIUnknownForDomain(This, domain, appDomain);
}
return hr;
} }
static HRESULT WINAPI corruntimehost_CreateDomainSetup( static HRESULT WINAPI corruntimehost_CreateDomainSetup(
......
...@@ -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);
MonoDomain* (CDECL *mono_domain_get_by_id)(int id);
void (CDECL *mono_domain_set_config)(MonoDomain *domain,const char *base_dir,const char *config_file_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);
...@@ -89,6 +90,7 @@ MonoDomain* (CDECL *mono_jit_init_version)(const char *domain_name, const char * ...@@ -89,6 +90,7 @@ MonoDomain* (CDECL *mono_jit_init_version)(const char *domain_name, const char *
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);
MonoMethod* (CDECL *mono_object_get_virtual_method)(MonoObject *obj, MonoMethod *method);
MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass); MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass);
void* (CDECL *mono_object_unbox)(MonoObject *obj); void* (CDECL *mono_object_unbox)(MonoObject *obj);
static void (CDECL *mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback); static void (CDECL *mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback);
...@@ -175,6 +177,7 @@ static HRESULT load_mono(LPCWSTR mono_path) ...@@ -175,6 +177,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_get_by_id);
LOAD_MONO_FUNCTION(mono_domain_set_config); 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);
...@@ -184,6 +187,7 @@ static HRESULT load_mono(LPCWSTR mono_path) ...@@ -184,6 +187,7 @@ static HRESULT load_mono(LPCWSTR mono_path)
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);
LOAD_MONO_FUNCTION(mono_object_get_virtual_method);
LOAD_MONO_FUNCTION(mono_object_new); LOAD_MONO_FUNCTION(mono_object_new);
LOAD_MONO_FUNCTION(mono_object_unbox); LOAD_MONO_FUNCTION(mono_object_unbox);
LOAD_MONO_FUNCTION(mono_profiler_install); LOAD_MONO_FUNCTION(mono_profiler_install);
......
...@@ -146,12 +146,14 @@ extern MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type) DECLSPEC_HI ...@@ -146,12 +146,14 @@ 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 MonoDomain* (CDECL *mono_domain_get_by_id)(int id);
extern void (CDECL *mono_domain_set_config)(MonoDomain *domain,const char *base_dir,const char *config_file_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;
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;
extern MonoMethod* (CDECL *mono_object_get_virtual_method)(MonoObject *obj, MonoMethod *method) DECLSPEC_HIDDEN;
extern MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass) DECLSPEC_HIDDEN; extern MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass) DECLSPEC_HIDDEN;
extern void* (CDECL *mono_object_unbox)(MonoObject *obj) DECLSPEC_HIDDEN; extern void* (CDECL *mono_object_unbox)(MonoObject *obj) DECLSPEC_HIDDEN;
extern MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image) DECLSPEC_HIDDEN; extern MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image) DECLSPEC_HIDDEN;
......
...@@ -23,8 +23,13 @@ ...@@ -23,8 +23,13 @@
#include "mscoree.h" #include "mscoree.h"
#include "metahost.h" #include "metahost.h"
#include "shlwapi.h" #include "shlwapi.h"
#include "initguid.h"
#include "wine/test.h" #include "wine/test.h"
DEFINE_GUID(IID__AppDomain, 0x05f696dc,0x2b29,0x3663,0xad,0x8b,0xc4,0x38,0x9c,0xf2,0xa7,0x13);
static const WCHAR v4_0[] = {'v','4','.','0','.','3','0','3','1','9',0};
static HMODULE hmscoree; static HMODULE hmscoree;
static HRESULT (WINAPI *pGetCORVersion)(LPWSTR, DWORD, DWORD*); static HRESULT (WINAPI *pGetCORVersion)(LPWSTR, DWORD, DWORD*);
...@@ -33,6 +38,7 @@ static HRESULT (WINAPI *pGetRequestedRuntimeInfo)(LPCWSTR, LPCWSTR, LPCWSTR, DWO ...@@ -33,6 +38,7 @@ static HRESULT (WINAPI *pGetRequestedRuntimeInfo)(LPCWSTR, LPCWSTR, LPCWSTR, DWO
static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR, LPCWSTR, LPVOID, HMODULE*); static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR, LPCWSTR, LPVOID, HMODULE*);
static HRESULT (WINAPI *pCreateConfigStream)(LPCWSTR, IStream**); static HRESULT (WINAPI *pCreateConfigStream)(LPCWSTR, IStream**);
static HRESULT (WINAPI *pCreateInterface)(REFCLSID, REFIID, VOID**); static HRESULT (WINAPI *pCreateInterface)(REFCLSID, REFIID, VOID**);
static HRESULT (WINAPI *pCLRCreateInstance)(REFCLSID, REFIID, VOID**);
static BOOL no_legacy_runtimes; static BOOL no_legacy_runtimes;
...@@ -52,9 +58,11 @@ static BOOL init_functionpointers(void) ...@@ -52,9 +58,11 @@ static BOOL init_functionpointers(void)
pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim"); pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim");
pCreateConfigStream = (void *)GetProcAddress(hmscoree, "CreateConfigStream"); pCreateConfigStream = (void *)GetProcAddress(hmscoree, "CreateConfigStream");
pCreateInterface = (void *)GetProcAddress(hmscoree, "CreateInterface"); pCreateInterface = (void *)GetProcAddress(hmscoree, "CreateInterface");
pCLRCreateInstance = (void *)GetProcAddress(hmscoree, "CLRCreateInstance");
if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo || !pLoadLibraryShim || if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo || !pLoadLibraryShim ||
!pCreateInterface) !pCreateInterface || !pCLRCreateInstance
)
{ {
win_skip("functions not available\n"); win_skip("functions not available\n");
FreeLibrary(hmscoree); FreeLibrary(hmscoree);
...@@ -195,7 +203,6 @@ static void test_versioninfo(void) ...@@ -195,7 +203,6 @@ static void test_versioninfo(void)
static void test_loadlibraryshim(void) static void test_loadlibraryshim(void)
{ {
const WCHAR v4_0[] = {'v','4','.','0','.','3','0','3','1','9',0};
const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0}; const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
const WCHAR v1_1[] = {'v','1','.','1','.','4','3','2','2',0}; const WCHAR v1_1[] = {'v','1','.','1','.','4','3','2','2',0};
const WCHAR vbogus[] = {'v','b','o','g','u','s',0}; const WCHAR vbogus[] = {'v','b','o','g','u','s',0};
...@@ -425,6 +432,92 @@ static void test_createinstance(void) ...@@ -425,6 +432,92 @@ static void test_createinstance(void)
} }
} }
static void test_createdomain(void)
{
static const WCHAR test_name[] = {'t','e','s','t',0};
static const WCHAR test2_name[] = {'t','e','s','t','2',0};
ICLRMetaHost *metahost;
ICLRRuntimeInfo *runtimeinfo;
ICorRuntimeHost *runtimehost;
IUnknown *domain, *defaultdomain_unk, *defaultdomain, *newdomain_unk, *newdomain, *domainsetup,
*newdomain2_unk, *newdomain2;
HRESULT hr;
if (!pCLRCreateInstance)
{
win_skip("Function CLRCreateInstance not found.");
return;
}
hr = pCLRCreateInstance(&CLSID_CLRMetaHost, &IID_ICLRMetaHost, (void **)&metahost);
ok(SUCCEEDED(hr), "CLRCreateInstance failed, hr=%#.8x\n", hr);
hr = ICLRMetaHost_GetRuntime(metahost, v4_0, &IID_ICLRRuntimeInfo, (void **)&runtimeinfo);
ok(SUCCEEDED(hr), "ICLRMetaHost::GetRuntime failed, hr=%#.8x\n", hr);
hr = ICLRRuntimeInfo_GetInterface(runtimeinfo, &CLSID_CorRuntimeHost, &IID_ICorRuntimeHost,
(void **)&runtimehost);
ok(SUCCEEDED(hr), "ICLRRuntimeInfo::GetInterface failed, hr=%#.8x\n", hr);
hr = ICorRuntimeHost_Start(runtimehost);
ok(SUCCEEDED(hr), "ICorRuntimeHost::Start failed, hr=%#.8x\n", hr);
hr = ICorRuntimeHost_GetDefaultDomain(runtimehost, &domain);
ok(SUCCEEDED(hr), "ICorRuntimeHost::GetDefaultDomain failed, hr=%#.8x\n", hr);
hr = IUnknown_QueryInterface(domain, &IID_IUnknown, (void **)&defaultdomain_unk);
ok(SUCCEEDED(hr), "COM object doesn't support IUnknown?!\n");
hr = IUnknown_QueryInterface(domain, &IID__AppDomain, (void **)&defaultdomain);
ok(SUCCEEDED(hr), "AppDomain object doesn't support _AppDomain interface\n");
IUnknown_Release(domain);
hr = ICorRuntimeHost_CreateDomain(runtimehost, test_name, NULL, &domain);
ok(SUCCEEDED(hr), "ICorRuntimeHost::CreateDomain failed, hr=%#.8x\n", hr);
hr = IUnknown_QueryInterface(domain, &IID_IUnknown, (void **)&newdomain_unk);
ok(SUCCEEDED(hr), "COM object doesn't support IUnknown?!\n");
hr = IUnknown_QueryInterface(domain, &IID__AppDomain, (void **)&newdomain);
ok(SUCCEEDED(hr), "AppDomain object doesn't support _AppDomain interface\n");
IUnknown_Release(domain);
ok(defaultdomain_unk != newdomain_unk, "New and default domain objects are the same\n");
hr = ICorRuntimeHost_CreateDomainSetup(runtimehost, &domainsetup);
ok(SUCCEEDED(hr), "ICorRuntimeHost::CreateDomainSetup failed, hr=%#.8x\n", hr);
hr = ICorRuntimeHost_CreateDomainEx(runtimehost, test2_name, domainsetup, NULL, &domain);
ok(SUCCEEDED(hr), "ICorRuntimeHost::CreateDomainEx failed, hr=%#.8x\n", hr);
hr = IUnknown_QueryInterface(domain, &IID_IUnknown, (void **)&newdomain2_unk);
ok(SUCCEEDED(hr), "COM object doesn't support IUnknown?!\n");
hr = IUnknown_QueryInterface(domain, &IID__AppDomain, (void **)&newdomain2);
ok(SUCCEEDED(hr), "AppDomain object doesn't support _AppDomain interface\n");
IUnknown_Release(domain);
ok(defaultdomain_unk != newdomain2_unk, "New and default domain objects are the same\n");
ok(newdomain_unk != newdomain2_unk, "Both new domain objects are the same\n");
IUnknown_Release(newdomain2);
IUnknown_Release(newdomain2_unk);
IUnknown_Release(domainsetup);
IUnknown_Release(newdomain);
IUnknown_Release(newdomain_unk);
IUnknown_Release(defaultdomain);
IUnknown_Release(defaultdomain_unk);
ICorRuntimeHost_Release(runtimehost);
ICLRRuntimeInfo_Release(runtimeinfo);
ICLRMetaHost_Release(metahost);
}
START_TEST(mscoree) START_TEST(mscoree)
{ {
if (!init_functionpointers()) if (!init_functionpointers())
...@@ -434,6 +527,7 @@ START_TEST(mscoree) ...@@ -434,6 +527,7 @@ START_TEST(mscoree)
test_loadlibraryshim(); test_loadlibraryshim();
test_createconfigstream(); test_createconfigstream();
test_createinstance(); test_createinstance();
test_createdomain();
FreeLibrary(hmscoree); FreeLibrary(hmscoree);
} }
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