Skip to content

Commit

Permalink
make legacy corrupted state exceptions policy configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
marzent committed Apr 13, 2024
1 parent 8f98443 commit 94ec953
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/CoreCLR/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ HRESULT InitializeClrAndGetEntryPoint(

int result;
SetEnvironmentVariable(L"DOTNET_MULTILEVEL_LOOKUP", L"0");
SetEnvironmentVariable(L"COMPlus_legacyCorruptedStateExceptionsPolicy", L"1");
SetEnvironmentVariable(L"DOTNET_legacyCorruptedStateExceptionsPolicy", L"1");
SetEnvironmentVariable(L"COMPLUS_ForceENC", L"1");
SetEnvironmentVariable(L"DOTNET_ForceENC", L"1");

Expand Down Expand Up @@ -83,6 +81,25 @@ HRESULT InitializeClrAndGetEntryPoint(
dotnet_path = _wcsdup(fs_app_data.append("XIVLauncher").append("runtime").c_str());
}

bool legacy_corrupted_state_exceptions_policy = false;
buffer.resize(0);
result = GetEnvironmentVariableW(L"DALAMUD_LEGACY_CORRUPTED_STATE_EXCEPTION", &buffer[0], 0);

if (result)
{
buffer.resize(result); // The first pass returns the required length
result = GetEnvironmentVariableW(L"DALAMUD_LEGACY_CORRUPTED_STATE_EXCEPTION", &buffer[0], result);
legacy_corrupted_state_exceptions_policy = buffer == L"1";
}
else
{
// Legacy fallback is true to preserve past behaviour
legacy_corrupted_state_exceptions_policy = true;
}

SetEnvironmentVariable(L"COMPlus_legacyCorruptedStateExceptionsPolicy", legacy_corrupted_state_exceptions_policy ? L"1" : L"0");
SetEnvironmentVariable(L"DOTNET_legacyCorruptedStateExceptionsPolicy", legacy_corrupted_state_exceptions_policy ? L"1" : L"0");

// =========================================================================== //

logging::I("with dotnet_path: {}", dotnet_path);
Expand Down

0 comments on commit 94ec953

Please sign in to comment.