Snoop.GenericInjector/NetCoreApp3_0Executor.cpp
// Returns the ICLRRuntimeHost instance or nullptr on failure.
Returns the ICLRRuntimeHost instance or nullptr on failure.
Returns the ICLRRuntimeHost instance or nullptr on failure .
ICLRRuntimeHost* NetCoreApp3_0Executor::GetNETCoreCLRRuntimeHost()
{
	this->Log(L"Getting handle for coreclr.dll...");
	auto* const coreCLRModule = ::GetModuleHandle(L"coreclr.dll");
	if (!coreCLRModule)
	{
		this->Log(L"Could not get handle for coreclr.dll.");
		return nullptr;
	}
	this->Log(L"Got handle for coreclr.dll.");
	this->Log(L"Getting handle for GetCLRRuntimeHost...");
	const auto pfnGetCLRRuntimeHost = reinterpret_cast<FnGetNETCoreCLRRuntimeHost>(::GetProcAddress(coreCLRModule, "GetCLRRuntimeHost"));
	if (!pfnGetCLRRuntimeHost)
	{
		this->Log(L"Could not get handle for GetCLRRuntimeHost.");
		return nullptr;
	}
	this->Log(L"Got handle for GetCLRRuntimeHost.");
	this->Log(L"Trying to get runtime host...");
	ICLRRuntimeHost* clrRuntimeHost = nullptr;
	const auto hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost, reinterpret_cast<IUnknown**>(&clrRuntimeHost));
	if (FAILED(hr)) 
	{
		this->Log(L"Could not get runtime host.");
		return nullptr;
	}
	this->Log(L"Got runtime host.");
	return clrRuntimeHost;
}
ICLRRuntimeHost * NetCoreApp3_0Executor :: GetNETCoreCLRRuntimeHost ( ) { this -> Log ( L" " ) ; auto * const coreCLRModule = :: GetModuleHandle ( L" " ) ; if ( ! coreCLRModule ) { this -> Log ( L" " ) ; return nullptr ; } this -> Log ( L" " ) ; this -> Log ( L" " ) ; const auto pfnGetCLRRuntimeHost = reinterpret_cast < FnGetNETCoreCLRRuntimeHost > ( :: GetProcAddress ( coreCLRModule , " " ) ) ; if ( ! pfnGetCLRRuntimeHost ) { this -> Log ( L" " ) ; return nullptr ; } this -> Log ( L" " ) ; this -> Log ( L" " ) ; ICLRRuntimeHost * clrRuntimeHost = nullptr ; const auto hr = pfnGetCLRRuntimeHost ( IID_ICLRRuntimeHost , reinterpret_cast < IUnknown * * > ( & clrRuntimeHost ) ) ; if ( FAILED ( hr ) ) { this -> Log ( L" " ) ; return nullptr ; } this -> Log ( L" " ) ; return clrRuntimeHost ; }
Returns the ICLRRuntimeHost instance or nullptr on failure.
Returns the ICLRRuntimeHost instance or nullptr on failure .