Ejemplo n.º 1
0
static HRESULT dotnet_init(char **p_where)
{
	HRESULT hr;
	struct dotnet_runtime_stuff *stuff;
	IUnknown *unk = NULL;
	char *where = "";

	stuff = malloc(sizeof(*stuff));
	if (!stuff) {
		return S_FALSE;
	}
	memset(stuff, 0, sizeof(*stuff));

	where = "CoCreateInstance";
	hr = CoCreateInstance(&CLSID_CorRuntimeHost, NULL, CLSCTX_ALL,
			&IID_ICorRuntimeHost, (LPVOID*)&stuff->dotnet_host);

	if (FAILED(hr))
		goto out;

	/* fire up the host and get the domain object */
	where = "ICorRuntimeHost_Start\n";
	hr = ICorRuntimeHost_Start(stuff->dotnet_host);
	if (FAILED(hr))
		goto out;

	where = "ICorRuntimeHost_GetDefaultDomain";
	hr = ICorRuntimeHost_GetDefaultDomain(stuff->dotnet_host, &unk);
	if (FAILED(hr))
		goto out;

	where = "QI: System._AppDomain";
	hr = IUnknown_QueryInterface(unk, &IID_mscorlib_System_AppDomain, (LPVOID*)&stuff->dotnet_domain);
	if (FAILED(hr))
		goto out;

	COMG(dotnet_runtime_stuff) = stuff;

out:
	if (unk) {
		IUnknown_Release(unk);
	}
	if (COMG(dotnet_runtime_stuff) == NULL) {
		/* clean up */
		if (stuff->dotnet_domain) {
			IUnknown_Release(stuff->dotnet_domain);
		}
		if (stuff->dotnet_host) {
			ICorRuntimeHost_Stop(stuff->dotnet_host);
			ICorRuntimeHost_Release(stuff->dotnet_host);
		}
		free(stuff);

		*p_where = where;

		return hr;
	}

	return S_OK;
}
Ejemplo n.º 2
0
void php_com_dotnet_mshutdown(void)
{
	struct dotnet_runtime_stuff *stuff = COMG(dotnet_runtime_stuff);

	if (stuff->dotnet_domain) {
		IDispatch_Release(stuff->dotnet_domain);
	}
	if (stuff->dotnet_host) {
		ICorRuntimeHost_Stop(stuff->dotnet_host);
		ICorRuntimeHost_Release(stuff->dotnet_host);
		stuff->dotnet_host = NULL;
	}
	free(stuff);
	COMG(dotnet_runtime_stuff) = NULL;
}
Ejemplo n.º 3
0
static int check_runtime(void)
{
    ICLRMetaHost *metahost;
    ICLRRuntimeInfo *runtimeinfo;
    ICorRuntimeHost *runtimehost;
    HRESULT hr;

    if (!pCLRCreateInstance)
    {
        win_skip("Function CLRCreateInstance not found.\n");
        return 1;
    }

    hr = pCLRCreateInstance(&CLSID_CLRMetaHost, &IID_ICLRMetaHost, (void **)&metahost);
    if (hr == E_NOTIMPL)
    {
        win_skip("CLRCreateInstance not implemented\n");
        return 1;
    }
    ok(SUCCEEDED(hr), "CLRCreateInstance failed, hr=%#.8x\n", hr);
    if (FAILED(hr))
        return 1;

    hr = ICLRMetaHost_GetRuntime(metahost, v4_0, &IID_ICLRRuntimeInfo, (void **)&runtimeinfo);
    ok(SUCCEEDED(hr), "ICLRMetaHost::GetRuntime failed, hr=%#.8x\n", hr);
    if (FAILED(hr))
        return 1;

    hr = ICLRRuntimeInfo_GetInterface(runtimeinfo, &CLSID_CorRuntimeHost, &IID_ICorRuntimeHost,
        (void **)&runtimehost);
    ok(SUCCEEDED(hr), "ICLRRuntimeInfo::GetInterface failed, hr=%#.8x\n", hr);
    if (FAILED(hr))
        return 1;

    hr = ICorRuntimeHost_Start(runtimehost);
    ok(SUCCEEDED(hr), "ICorRuntimeHost::Start failed, hr=%#.8x\n", hr);
    if (FAILED(hr))
        return 1;

    ICorRuntimeHost_Release(runtimehost);

    ICLRRuntimeInfo_Release(runtimeinfo);

    ICLRMetaHost_ExitProcess(metahost, 0);

    ok(0, "ICLRMetaHost_ExitProcess is not supposed to return\n");
    return 1;
}
Ejemplo n.º 4
0
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.\n");
        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);
}
Ejemplo n.º 5
0
static ULONG WINAPI CLRRuntimeHost_Release(ICLRRuntimeHost* iface)
{
    RuntimeHost *This = impl_from_ICLRRuntimeHost( iface );
    return ICorRuntimeHost_Release(&This->ICorRuntimeHost_iface);
}