Print dotnet stack trace on veh error msgbox, and use precompiled headers.

This commit is contained in:
Soreepeong 2021-12-24 12:23:23 +09:00
parent 2c99778eeb
commit e64cc7e687
16 changed files with 298 additions and 170 deletions

View file

@ -23,6 +23,8 @@ void ConsoleTeardown()
FreeConsole();
}
std::optional<CoreCLR> g_clr;
int InitializeClrAndGetEntryPoint(
std::wstring runtimeconfig_path,
std::wstring module_path,
@ -31,8 +33,9 @@ int InitializeClrAndGetEntryPoint(
std::wstring entrypoint_delegate_type_name,
void** entrypoint_fn)
{
g_clr = CoreCLR();
int result;
CoreCLR clr;
SetEnvironmentVariable(L"DOTNET_MULTILEVEL_LOOKUP", L"0");
//SetEnvironmentVariable(L"COMPlus_legacyCorruptedStateExceptionsPolicy", L"1");
SetEnvironmentVariable(L"DOTNET_legacyCorruptedStateExceptionsPolicy", L"1");
@ -85,7 +88,7 @@ int InitializeClrAndGetEntryPoint(
};
printf("Loading hostfxr... ");
if ((result = clr.load_hostfxr(&init_parameters)) != 0)
if ((result = g_clr->load_hostfxr(&init_parameters)) != 0)
{
printf("\nError: Failed to load the `hostfxr` library (err=%d)\n", result);
return result;
@ -102,7 +105,7 @@ int InitializeClrAndGetEntryPoint(
};
printf("Loading coreclr... ");;
if ((result = clr.load_runtime(runtimeconfig_path, &runtime_parameters)) != 0)
if ((result = g_clr->load_runtime(runtimeconfig_path, &runtime_parameters)) != 0)
{
printf("\nError: Failed to load coreclr (err=%d)\n", result);
return result;
@ -112,7 +115,7 @@ int InitializeClrAndGetEntryPoint(
// =========================================================================== //
printf("Loading module... ");
if ((result = clr.load_assembly_and_get_function_pointer(
if ((result = g_clr->load_assembly_and_get_function_pointer(
module_path.c_str(),
entrypoint_assembly_name.c_str(),
entrypoint_method_name.c_str(),