Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/coreclr/hosts/coreconsole/coreconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class HostEnvironment
// The list of paths to the assemblies that will be trusted by CoreCLR
StringBuffer m_tpaList;

ICLRRuntimeHost2* m_CLRRuntimeHost;
ICLRRuntimeHost4* m_CLRRuntimeHost;

HMODULE m_coreCLRModule;

Expand Down Expand Up @@ -326,8 +326,8 @@ class HostEnvironment
return m_hostExeName;
}

// Returns the ICLRRuntimeHost2 instance, loading it from CoreCLR.dll if necessary, or nullptr on failure.
ICLRRuntimeHost2* GetCLRRuntimeHost() {
// Returns the ICLRRuntimeHost4 instance, loading it from CoreCLR.dll if necessary, or nullptr on failure.
ICLRRuntimeHost4* GetCLRRuntimeHost() {
if (!m_CLRRuntimeHost) {

if (!m_coreCLRModule) {
Expand All @@ -347,9 +347,9 @@ class HostEnvironment

*m_log << W("Calling GetCLRRuntimeHost(...)") << Logger::endl;

HRESULT hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost2, (IUnknown**)&m_CLRRuntimeHost);
HRESULT hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost4, (IUnknown**)&m_CLRRuntimeHost);
if (FAILED(hr)) {
*m_log << W("Failed to get ICLRRuntimeHost2 interface. ERRORCODE: ") << hr << Logger::endl;
*m_log << W("Failed to get ICLRRuntimeHost4 interface. ERRORCODE: ") << hr << Logger::endl;
return nullptr;
}
}
Expand Down Expand Up @@ -405,14 +405,14 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo

// Start the CoreCLR

ICLRRuntimeHost2 *host = hostEnvironment.GetCLRRuntimeHost();
ICLRRuntimeHost4 *host = hostEnvironment.GetCLRRuntimeHost();
if (!host) {
return false;
}

HRESULT hr;

log << W("Setting ICLRRuntimeHost2 startup flags") << Logger::endl;
log << W("Setting ICLRRuntimeHost4 startup flags") << Logger::endl;

// Default startup flags
hr = host->SetStartupFlags((STARTUP_FLAGS)
Expand All @@ -424,7 +424,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo
return false;
}

log << W("Starting ICLRRuntimeHost2") << Logger::endl;
log << W("Starting ICLRRuntimeHost4") << Logger::endl;

hr = host->Start();
if (FAILED(hr)) {
Expand Down Expand Up @@ -541,15 +541,17 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo

log << W("Unloading the AppDomain") << Logger::endl;

hr = host->UnloadAppDomain(
hr = host->UnloadAppDomain2(
domainId,
true); // Wait until done
true,
(int *)&exitCode); // Wait until done

if (FAILED(hr)) {
log << W("Failed to unload the AppDomain. ERRORCODE: ") << hr << Logger::endl;
return false;
}

log << W("App domain unloaded exit value = ") << exitCode << Logger::endl;

//-------------------------------------------------------------

Expand All @@ -568,7 +570,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo

// Release the reference to the host

log << W("Releasing ICLRRuntimeHost2") << Logger::endl;
log << W("Releasing ICLRRuntimeHost4") << Logger::endl;

host->Release();

Expand Down
24 changes: 13 additions & 11 deletions src/coreclr/hosts/corerun/corerun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class HostEnvironment
// The list of paths to the assemblies that will be trusted by CoreCLR
SString m_tpaList;

ICLRRuntimeHost2* m_CLRRuntimeHost;
ICLRRuntimeHost4* m_CLRRuntimeHost;

HMODULE m_coreCLRModule;

Expand Down Expand Up @@ -298,8 +298,8 @@ class HostEnvironment
return m_hostExeName;
}

// Returns the ICLRRuntimeHost2 instance, loading it from CoreCLR.dll if necessary, or nullptr on failure.
ICLRRuntimeHost2* GetCLRRuntimeHost() {
// Returns the ICLRRuntimeHost4 instance, loading it from CoreCLR.dll if necessary, or nullptr on failure.
ICLRRuntimeHost4* GetCLRRuntimeHost() {
if (!m_CLRRuntimeHost) {

if (!m_coreCLRModule) {
Expand All @@ -319,9 +319,9 @@ class HostEnvironment

*m_log << W("Calling GetCLRRuntimeHost(...)") << Logger::endl;

HRESULT hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost2, (IUnknown**)&m_CLRRuntimeHost);
HRESULT hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost4, (IUnknown**)&m_CLRRuntimeHost);
if (FAILED(hr)) {
*m_log << W("Failed to get ICLRRuntimeHost2 interface. ERRORCODE: ") << Logger::hresult << hr << Logger::endl;
*m_log << W("Failed to get ICLRRuntimeHost4 interface. ERRORCODE: ") << Logger::hresult << hr << Logger::endl;
return nullptr;
}
}
Expand Down Expand Up @@ -442,7 +442,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo

// Start the CoreCLR

ICLRRuntimeHost2 *host = hostEnvironment.GetCLRRuntimeHost();
ICLRRuntimeHost4 *host = hostEnvironment.GetCLRRuntimeHost();
if (!host) {
return false;
}
Expand All @@ -451,7 +451,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo


STARTUP_FLAGS flags = CreateStartupFlags();
log << W("Setting ICLRRuntimeHost2 startup flags") << Logger::endl;
log << W("Setting ICLRRuntimeHost4 startup flags") << Logger::endl;
log << W("Server GC enabled: ") << HAS_FLAG(flags, STARTUP_FLAGS::STARTUP_SERVER_GC) << Logger::endl;
log << W("Concurrent GC enabled: ") << HAS_FLAG(flags, STARTUP_FLAGS::STARTUP_CONCURRENT_GC) << Logger::endl;

Expand All @@ -462,7 +462,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo
return false;
}

log << W("Starting ICLRRuntimeHost2") << Logger::endl;
log << W("Starting ICLRRuntimeHost4") << Logger::endl;

hr = host->Start();
if (FAILED(hr)) {
Expand Down Expand Up @@ -581,15 +581,17 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo

log << W("Unloading the AppDomain") << Logger::endl;

hr = host->UnloadAppDomain(
hr = host->UnloadAppDomain2(
domainId,
true); // Wait until done
true,
(int *)&exitCode); // Wait until done

if (FAILED(hr)) {
log << W("Failed to unload the AppDomain. ERRORCODE: ") << Logger::hresult << hr << Logger::endl;
return false;
}

log << W("App domain unloaded exit value = ") << exitCode << Logger::endl;

//-------------------------------------------------------------

Expand All @@ -608,7 +610,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo

// Release the reference to the host

log << W("Releasing ICLRRuntimeHost2") << Logger::endl;
log << W("Releasing ICLRRuntimeHost4") << Logger::endl;

host->Release();

Expand Down
18 changes: 18 additions & 0 deletions src/inc/MSCOREE.IDL
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ cpp_quote("EXTERN_GUID(IID_ICLRRuntimeHost, 0x90F1A06C, 0x7712, 0x4762, 0x86, 0x
// IID ICLRRuntimeHost2: uuid(712AB73F-2C22-4807-AD7E-F501D7B72C2D)
cpp_quote("EXTERN_GUID(IID_ICLRRuntimeHost2, 0x712AB73F, 0x2C22, 0x4807, 0xAD, 0x7E, 0xF5, 0x01, 0xD7, 0xb7, 0x2C, 0x2D);")

// IID ICLRRuntimeHost4: uuid(64F6D366-D7C2-4F1F-B4B2-E8160CAC43AF)
cpp_quote("EXTERN_GUID(IID_ICLRRuntimeHost4, 0x64F6D366, 0xD7C2, 0x4F1F, 0xB4, 0xB2, 0xE8, 0x16, 0x0C, 0xAC, 0x43, 0xAF);")

// IID IID_ICLRExecutionManager: uuid(1000A3E7-B420-4620-AE30-FB19B587AD1D)
cpp_quote("EXTERN_GUID(IID_ICLRExecutionManager, 0x1000A3E7, 0xB420, 0x4620, 0xAE, 0x30, 0xFB, 0x19, 0xB5, 0x87, 0xAD, 0x1D);")

Expand Down Expand Up @@ -847,6 +850,21 @@ interface ICLRRuntimeHost2 : ICLRRuntimeHost

};

[
object,
uuid(64F6D366-D7C2-4F1F-B4B2-E8160CAC43AF),
version(4.0),
helpstring("Common Language Runtime Hosting Interface"),
pointer_default(unique),
local
]
interface ICLRRuntimeHost4 : ICLRRuntimeHost2
{
HRESULT UnloadAppDomain2([in] DWORD dwAppDomainId,
[in] BOOL fWaitUntilDone,
[out] int *pLatchedExitCode);
};

[
uuid(1000A3E7-B420-4620-AE30-FB19B587AD1D),
version(1.0),
Expand Down