mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Add console argument/env var to disable legacy corrupted state exceptions policy
This commit is contained in:
parent
cf1d8a81c6
commit
b21a0c9298
8 changed files with 35 additions and 15 deletions
|
|
@ -123,6 +123,7 @@ void from_json(const nlohmann::json& json, DalamudStartInfo& config) {
|
||||||
config.BootVehEnabled = json.value("BootVehEnabled", config.BootVehEnabled);
|
config.BootVehEnabled = json.value("BootVehEnabled", config.BootVehEnabled);
|
||||||
config.BootVehFull = json.value("BootVehFull", config.BootVehFull);
|
config.BootVehFull = json.value("BootVehFull", config.BootVehFull);
|
||||||
config.BootEnableEtw = json.value("BootEnableEtw", config.BootEnableEtw);
|
config.BootEnableEtw = json.value("BootEnableEtw", config.BootEnableEtw);
|
||||||
|
config.BootDisableLegacyCorruptedStateExceptions = json.value("BootDisableLegacyCorruptedStateExceptions", config.BootDisableLegacyCorruptedStateExceptions);
|
||||||
config.BootDotnetOpenProcessHookMode = json.value("BootDotnetOpenProcessHookMode", config.BootDotnetOpenProcessHookMode);
|
config.BootDotnetOpenProcessHookMode = json.value("BootDotnetOpenProcessHookMode", config.BootDotnetOpenProcessHookMode);
|
||||||
if (const auto it = json.find("BootEnabledGameFixes"); it != json.end() && it->is_array()) {
|
if (const auto it = json.find("BootEnabledGameFixes"); it != json.end() && it->is_array()) {
|
||||||
config.BootEnabledGameFixes.clear();
|
config.BootEnabledGameFixes.clear();
|
||||||
|
|
@ -148,6 +149,7 @@ void DalamudStartInfo::from_envvars() {
|
||||||
BootVehEnabled = utils::get_env<bool>(L"DALAMUD_IS_VEH");
|
BootVehEnabled = utils::get_env<bool>(L"DALAMUD_IS_VEH");
|
||||||
BootVehFull = utils::get_env<bool>(L"DALAMUD_IS_VEH_FULL");
|
BootVehFull = utils::get_env<bool>(L"DALAMUD_IS_VEH_FULL");
|
||||||
BootEnableEtw = utils::get_env<bool>(L"DALAMUD_ENABLE_ETW");
|
BootEnableEtw = utils::get_env<bool>(L"DALAMUD_ENABLE_ETW");
|
||||||
|
BootDisableLegacyCorruptedStateExceptions = utils::get_env<bool>(L"DALAMUD_DISABLE_LEGACY_CORRUPTED_STATE_EXCEPTIONS");
|
||||||
BootDotnetOpenProcessHookMode = static_cast<DotNetOpenProcessHookMode>(utils::get_env<int>(L"DALAMUD_DOTNET_OPENPROCESS_HOOKMODE"));
|
BootDotnetOpenProcessHookMode = static_cast<DotNetOpenProcessHookMode>(utils::get_env<int>(L"DALAMUD_DOTNET_OPENPROCESS_HOOKMODE"));
|
||||||
for (const auto& item : utils::get_env_list<std::string>(L"DALAMUD_GAMEFIX_LIST"))
|
for (const auto& item : utils::get_env_list<std::string>(L"DALAMUD_GAMEFIX_LIST"))
|
||||||
BootEnabledGameFixes.insert(unicode::convert<std::string>(item, &unicode::lower));
|
BootEnabledGameFixes.insert(unicode::convert<std::string>(item, &unicode::lower));
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ struct DalamudStartInfo {
|
||||||
DirectHook = 1,
|
DirectHook = 1,
|
||||||
};
|
};
|
||||||
friend void from_json(const nlohmann::json&, DotNetOpenProcessHookMode&);
|
friend void from_json(const nlohmann::json&, DotNetOpenProcessHookMode&);
|
||||||
|
|
||||||
enum class ClientLanguage : int {
|
enum class ClientLanguage : int {
|
||||||
Japanese,
|
Japanese,
|
||||||
English,
|
English,
|
||||||
|
|
@ -61,6 +61,7 @@ struct DalamudStartInfo {
|
||||||
bool BootVehEnabled = false;
|
bool BootVehEnabled = false;
|
||||||
bool BootVehFull = false;
|
bool BootVehFull = false;
|
||||||
bool BootEnableEtw = false;
|
bool BootEnableEtw = false;
|
||||||
|
bool BootDisableLegacyCorruptedStateExceptions = false;
|
||||||
DotNetOpenProcessHookMode BootDotnetOpenProcessHookMode = DotNetOpenProcessHookMode::ImportHooks;
|
DotNetOpenProcessHookMode BootDotnetOpenProcessHookMode = DotNetOpenProcessHookMode::ImportHooks;
|
||||||
std::set<std::string> BootEnabledGameFixes{};
|
std::set<std::string> BootEnabledGameFixes{};
|
||||||
std::set<std::string> BootUnhookDlls{};
|
std::set<std::string> BootUnhookDlls{};
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ HINSTANCE g_hGameInstance = GetModuleHandleW(nullptr);
|
||||||
|
|
||||||
HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
||||||
g_startInfo.from_envvars();
|
g_startInfo.from_envvars();
|
||||||
|
|
||||||
std::string jsonParseError;
|
std::string jsonParseError;
|
||||||
try {
|
try {
|
||||||
from_json(nlohmann::json::parse(std::string_view(static_cast<char*>(lpParam))), g_startInfo);
|
from_json(nlohmann::json::parse(std::string_view(static_cast<char*>(lpParam))), g_startInfo);
|
||||||
|
|
@ -21,7 +21,7 @@ HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
||||||
|
|
||||||
if (g_startInfo.BootShowConsole)
|
if (g_startInfo.BootShowConsole)
|
||||||
ConsoleSetup(L"Dalamud Boot");
|
ConsoleSetup(L"Dalamud Boot");
|
||||||
|
|
||||||
logging::update_dll_load_status(true);
|
logging::update_dll_load_status(true);
|
||||||
|
|
||||||
const auto logFilePath = unicode::convert<std::wstring>(g_startInfo.BootLogPath);
|
const auto logFilePath = unicode::convert<std::wstring>(g_startInfo.BootLogPath);
|
||||||
|
|
@ -29,16 +29,16 @@ HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
||||||
auto attemptFallbackLog = false;
|
auto attemptFallbackLog = false;
|
||||||
if (logFilePath.empty()) {
|
if (logFilePath.empty()) {
|
||||||
attemptFallbackLog = true;
|
attemptFallbackLog = true;
|
||||||
|
|
||||||
logging::I("No log file path given; not logging to file.");
|
logging::I("No log file path given; not logging to file.");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
logging::start_file_logging(logFilePath, !g_startInfo.BootShowConsole);
|
logging::start_file_logging(logFilePath, !g_startInfo.BootShowConsole);
|
||||||
logging::I("Logging to file: {}", logFilePath);
|
logging::I("Logging to file: {}", logFilePath);
|
||||||
|
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
attemptFallbackLog = true;
|
attemptFallbackLog = true;
|
||||||
|
|
||||||
logging::E("Couldn't open log file: {}", logFilePath);
|
logging::E("Couldn't open log file: {}", logFilePath);
|
||||||
logging::E("Error: {} / {}", errno, e.what());
|
logging::E("Error: {} / {}", errno, e.what());
|
||||||
}
|
}
|
||||||
|
|
@ -59,15 +59,15 @@ HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
GetLocalTime(&st);
|
GetLocalTime(&st);
|
||||||
logFilePath += std::format(L"Dalamud.Boot.{:04}{:02}{:02}.{:02}{:02}{:02}.{:03}.{}.log", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, GetCurrentProcessId());
|
logFilePath += std::format(L"Dalamud.Boot.{:04}{:02}{:02}.{:02}{:02}{:02}.{:03}.{}.log", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, GetCurrentProcessId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logging::start_file_logging(logFilePath, !g_startInfo.BootShowConsole);
|
logging::start_file_logging(logFilePath, !g_startInfo.BootShowConsole);
|
||||||
logging::I("Logging to fallback log file: {}", logFilePath);
|
logging::I("Logging to fallback log file: {}", logFilePath);
|
||||||
|
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
if (!g_startInfo.BootShowConsole && !g_startInfo.BootDisableFallbackConsole)
|
if (!g_startInfo.BootShowConsole && !g_startInfo.BootDisableFallbackConsole)
|
||||||
ConsoleSetup(L"Dalamud Boot - Fallback Console");
|
ConsoleSetup(L"Dalamud Boot - Fallback Console");
|
||||||
|
|
||||||
logging::E("Couldn't open fallback log file: {}", logFilePath);
|
logging::E("Couldn't open fallback log file: {}", logFilePath);
|
||||||
logging::E("Error: {} / {}", errno, e.what());
|
logging::E("Error: {} / {}", errno, e.what());
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +83,7 @@ HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
||||||
} else {
|
} else {
|
||||||
logging::E("Failed to initialize MinHook (status={}({}))", MH_StatusToString(mhStatus), static_cast<int>(mhStatus));
|
logging::E("Failed to initialize MinHook (status={}({}))", MH_StatusToString(mhStatus), static_cast<int>(mhStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
logging::I("Dalamud.Boot Injectable, (c) 2021 XIVLauncher Contributors");
|
logging::I("Dalamud.Boot Injectable, (c) 2021 XIVLauncher Contributors");
|
||||||
logging::I("Built at: " __DATE__ "@" __TIME__);
|
logging::I("Built at: " __DATE__ "@" __TIME__);
|
||||||
|
|
||||||
|
|
@ -117,6 +117,7 @@ HRESULT WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
||||||
const auto result = InitializeClrAndGetEntryPoint(
|
const auto result = InitializeClrAndGetEntryPoint(
|
||||||
g_hModule,
|
g_hModule,
|
||||||
g_startInfo.BootEnableEtw,
|
g_startInfo.BootEnableEtw,
|
||||||
|
!g_startInfo.BootDisableLegacyCorruptedStateExceptions,
|
||||||
runtimeconfig_path,
|
runtimeconfig_path,
|
||||||
module_path,
|
module_path,
|
||||||
L"Dalamud.EntryPoint, Dalamud",
|
L"Dalamud.EntryPoint, Dalamud",
|
||||||
|
|
@ -174,11 +175,11 @@ BOOL APIENTRY DllMain(const HMODULE hModule, const DWORD dwReason, LPVOID lpRese
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
// do not show debug message boxes on abort() here
|
// do not show debug message boxes on abort() here
|
||||||
_set_abort_behavior(0, _WRITE_ABORT_MSG);
|
_set_abort_behavior(0, _WRITE_ABORT_MSG);
|
||||||
|
|
||||||
// process is terminating; don't bother cleaning up
|
// process is terminating; don't bother cleaning up
|
||||||
if (lpReserved)
|
if (lpReserved)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
logging::update_dll_load_status(false);
|
logging::update_dll_load_status(false);
|
||||||
|
|
||||||
xivfixes::apply_all(false);
|
xivfixes::apply_all(false);
|
||||||
|
|
|
||||||
|
|
@ -120,10 +120,15 @@ public record DalamudStartInfo
|
||||||
public bool BootVehFull { get; set; }
|
public bool BootVehFull { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether or not ETW should be enabled.
|
/// Gets or sets a value indicating whether ETW should be enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool BootEnableEtw { get; set; }
|
public bool BootEnableEtw { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to enable legacy corrupted state exceptions.
|
||||||
|
/// </summary>
|
||||||
|
public bool BootDisableLegacyCorruptedStateExceptions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value choosing the OpenProcess hookmode.
|
/// Gets or sets a value choosing the OpenProcess hookmode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ int wmain(int argc, wchar_t** argv)
|
||||||
const auto result = InitializeClrAndGetEntryPoint(
|
const auto result = InitializeClrAndGetEntryPoint(
|
||||||
GetModuleHandleW(nullptr),
|
GetModuleHandleW(nullptr),
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
runtimeconfig_path,
|
runtimeconfig_path,
|
||||||
module_path,
|
module_path,
|
||||||
L"Dalamud.Injector.EntryPoint, Dalamud.Injector",
|
L"Dalamud.Injector.EntryPoint, Dalamud.Injector",
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ namespace Dalamud.Injector
|
||||||
args.Remove("--msgbox2");
|
args.Remove("--msgbox2");
|
||||||
args.Remove("--msgbox3");
|
args.Remove("--msgbox3");
|
||||||
args.Remove("--etw");
|
args.Remove("--etw");
|
||||||
|
args.Remove("--no-legacy-corrupted-state-exceptions");
|
||||||
args.Remove("--veh");
|
args.Remove("--veh");
|
||||||
args.Remove("--veh-full");
|
args.Remove("--veh-full");
|
||||||
args.Remove("--no-plugin");
|
args.Remove("--no-plugin");
|
||||||
|
|
@ -399,6 +400,7 @@ namespace Dalamud.Injector
|
||||||
// Set boot defaults
|
// Set boot defaults
|
||||||
startInfo.BootShowConsole = args.Contains("--console");
|
startInfo.BootShowConsole = args.Contains("--console");
|
||||||
startInfo.BootEnableEtw = args.Contains("--etw");
|
startInfo.BootEnableEtw = args.Contains("--etw");
|
||||||
|
startInfo.BootDisableLegacyCorruptedStateExceptions = args.Contains("--no-legacy-corrupted-state-exceptions");
|
||||||
startInfo.BootLogPath = GetLogPath(startInfo.LogPath, "dalamud.boot", startInfo.LogName);
|
startInfo.BootLogPath = GetLogPath(startInfo.LogPath, "dalamud.boot", startInfo.LogName);
|
||||||
startInfo.BootEnabledGameFixes = new()
|
startInfo.BootEnabledGameFixes = new()
|
||||||
{
|
{
|
||||||
|
|
@ -470,6 +472,7 @@ namespace Dalamud.Injector
|
||||||
Console.WriteLine("Verbose logging:\t[-v]");
|
Console.WriteLine("Verbose logging:\t[-v]");
|
||||||
Console.WriteLine("Show Console:\t[--console] [--crash-handler-console]");
|
Console.WriteLine("Show Console:\t[--console] [--crash-handler-console]");
|
||||||
Console.WriteLine("Enable ETW:\t[--etw]");
|
Console.WriteLine("Enable ETW:\t[--etw]");
|
||||||
|
Console.WriteLine("Disable legacy corrupted state exceptions:\t[--no-legacy-corrupted-state-exceptions]");
|
||||||
Console.WriteLine("Enable VEH:\t[--veh], [--veh-full], [--unhandled-exception=default|stalldebug|none]");
|
Console.WriteLine("Enable VEH:\t[--veh], [--veh-full], [--unhandled-exception=default|stalldebug|none]");
|
||||||
Console.WriteLine("Show messagebox:\t[--msgbox1], [--msgbox2], [--msgbox3]");
|
Console.WriteLine("Show messagebox:\t[--msgbox1], [--msgbox2], [--msgbox3]");
|
||||||
Console.WriteLine("No plugins:\t[--no-plugin] [--no-3rd-plugin]");
|
Console.WriteLine("No plugins:\t[--no-plugin] [--no-3rd-plugin]");
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ std::optional<CoreCLR> g_clr;
|
||||||
HRESULT InitializeClrAndGetEntryPoint(
|
HRESULT InitializeClrAndGetEntryPoint(
|
||||||
void* calling_module,
|
void* calling_module,
|
||||||
bool enable_etw,
|
bool enable_etw,
|
||||||
|
bool enable_legacy_corrupted_state_exception_policy,
|
||||||
std::wstring runtimeconfig_path,
|
std::wstring runtimeconfig_path,
|
||||||
std::wstring module_path,
|
std::wstring module_path,
|
||||||
std::wstring entrypoint_assembly_name,
|
std::wstring entrypoint_assembly_name,
|
||||||
|
|
@ -41,8 +42,13 @@ HRESULT InitializeClrAndGetEntryPoint(
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
SetEnvironmentVariable(L"DOTNET_MULTILEVEL_LOOKUP", L"0");
|
SetEnvironmentVariable(L"DOTNET_MULTILEVEL_LOOKUP", L"0");
|
||||||
SetEnvironmentVariable(L"COMPlus_legacyCorruptedStateExceptionsPolicy", L"1");
|
|
||||||
SetEnvironmentVariable(L"DOTNET_legacyCorruptedStateExceptionsPolicy", L"1");
|
if (enable_legacy_corrupted_state_exception_policy)
|
||||||
|
{
|
||||||
|
SetEnvironmentVariable(L"COMPlus_legacyCorruptedStateExceptionsPolicy", L"1");
|
||||||
|
SetEnvironmentVariable(L"DOTNET_legacyCorruptedStateExceptionsPolicy", L"1");
|
||||||
|
}
|
||||||
|
|
||||||
SetEnvironmentVariable(L"COMPLUS_ForceENC", L"1");
|
SetEnvironmentVariable(L"COMPLUS_ForceENC", L"1");
|
||||||
SetEnvironmentVariable(L"DOTNET_ForceENC", L"1");
|
SetEnvironmentVariable(L"DOTNET_ForceENC", L"1");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ void ConsoleTeardown();
|
||||||
HRESULT InitializeClrAndGetEntryPoint(
|
HRESULT InitializeClrAndGetEntryPoint(
|
||||||
void* calling_module,
|
void* calling_module,
|
||||||
bool enable_etw,
|
bool enable_etw,
|
||||||
|
bool enable_legacy_corrupted_state_exception_policy,
|
||||||
std::wstring runtimeconfig_path,
|
std::wstring runtimeconfig_path,
|
||||||
std::wstring module_path,
|
std::wstring module_path,
|
||||||
std::wstring entrypoint_assembly_name,
|
std::wstring entrypoint_assembly_name,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue