diff --git a/src/bootstrap.c b/src/bootstrap.c index ed38f71..df3a35e 100644 --- a/src/bootstrap.c +++ b/src/bootstrap.c @@ -10,12 +10,22 @@ bool_t mono_debug_init_called = FALSE; bool_t mono_is_net35 = FALSE; +static bool_t doorstop_bootstrapped = FALSE; void mono_doorstop_bootstrap(void *mono_domain) { - if (getenv(TEXT("DOORSTOP_INITIALIZED"))) { + if (doorstop_bootstrapped) { + LOG("Doorstop already bootstrapped in this process, skipping!"); + return; + } + // Steam (and other launchers) can leak DOORSTOP_INITIALIZED into a new + // game process, the same env-isolation issue ignore_disable_switch already + // covers for DOORSTOP_DISABLE. Honor that switch here; use the static flag + // above for genuine in-process re-entry. + if (getenv(TEXT("DOORSTOP_INITIALIZED")) && !config.ignore_disabled_env) { LOG("DOORSTOP_INITIALIZED is set! Skipping!"); return; } + doorstop_bootstrapped = TRUE; setenv(TEXT("DOORSTOP_INITIALIZED"), TEXT("TRUE"), TRUE); mono.thread_set_main(mono.thread_current()); diff --git a/src/nix/entrypoint.c b/src/nix/entrypoint.c index 457e11d..aa2950b 100644 --- a/src/nix/entrypoint.c +++ b/src/nix/entrypoint.c @@ -95,6 +95,11 @@ int dup2_hook(int od, int nd) { __attribute__((constructor)) void doorstop_ctor() { init_logger(); load_config(); + if (config.ignore_disabled_env) { + unsetenv("DOORSTOP_INITIALIZED"); + unsetenv("DOORSTOP_DISABLE"); + LOG("Cleared inherited DOORSTOP_INITIALIZED / DOORSTOP_DISABLE"); + } if (!config.enabled) { LOG("Doorstop not enabled! Skipping!"); diff --git a/src/windows/entrypoint.c b/src/windows/entrypoint.c index 7de774b..663a477 100644 --- a/src/windows/entrypoint.c +++ b/src/windows/entrypoint.c @@ -284,6 +284,11 @@ BOOL WINAPI DllEntry(HINSTANCE hInstDll, DWORD reasonForDllLoad, load_config(); LOG("Config loaded"); + if (config.ignore_disabled_env) { + SetEnvironmentVariableW(L"DOORSTOP_INITIALIZED", NULL); + SetEnvironmentVariableW(L"DOORSTOP_DISABLE", NULL); + LOG("Cleared inherited DOORSTOP_INITIALIZED / DOORSTOP_DISABLE"); + } redirect_output_log(paths);