From fdf155f733047515e9d9bf79de95deb5e8f84fe0 Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 27 Dec 2022 22:35:23 +0100 Subject: [PATCH 1/2] feat: fix symbols in crash handler --- DalamudCrashHandler/DalamudCrashHandler.cpp | 43 ++++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/DalamudCrashHandler/DalamudCrashHandler.cpp b/DalamudCrashHandler/DalamudCrashHandler.cpp index 81dc7ebf4..d1c37327e 100644 --- a/DalamudCrashHandler/DalamudCrashHandler.cpp +++ b/DalamudCrashHandler/DalamudCrashHandler.cpp @@ -739,14 +739,36 @@ int main() { std::cout << "Crash triggered" << std::endl; + /* + Hard won wisdom: changing symbol path with SymSetSearchPath() after modules + have been loaded (invadeProcess=TRUE in SymInitialize() or SymRefreshModuleList()) + doesn't work. + I had to provide symbol path in SymInitialize() (and either invadeProcess=TRUE + or invadeProcess=FALSE and call SymRefreshModuleList()). There's probably + a way to force it, but I'm happy I found a way that works. + + https://github.com/sumatrapdfreader/sumatrapdf/blob/master/src/utils/DbgHelpDyn.cpp + */ + if (g_bSymbolsAvailable) { SymRefreshModuleList(g_hProcess); - } else if (g_bSymbolsAvailable = SymInitialize(g_hProcess, nullptr, true); g_bSymbolsAvailable) { - if (!assetDir.empty()) { - if (!SymSetSearchPathW(g_hProcess, std::format(L".;{}", (assetDir / "UIRes" / "pdb").wstring()).c_str())) - std::wcerr << std::format(L"SymSetSearchPathW error: 0x{:x}", GetLastError()) << std::endl; - } - } else { + } + else if(!assetDir.empty()) + { + auto symbol_search_path = std::format(L".;{}", (assetDir / "UIRes" / "pdb").wstring()); + + g_bSymbolsAvailable = SymInitializeW(g_hProcess, symbol_search_path.c_str(), true); + std::wcout << std::format(L"Init symbols with PDB at {}", symbol_search_path) << std::endl; + + SymRefreshModuleList(g_hProcess); + } + else + { + g_bSymbolsAvailable = SymInitializeW(g_hProcess, nullptr, true); + std::cout << std::format("Init symbols without PDB") << std::endl; + } + + if (!g_bSymbolsAvailable) { std::wcerr << std::format(L"SymInitialize error: 0x{:x}", GetLastError()) << std::endl; } @@ -873,13 +895,14 @@ int main() { config.hInstance = GetModuleHandleW(nullptr); config.dwFlags = TDF_ENABLE_HYPERLINKS | TDF_CAN_BE_MINIMIZED | TDF_ALLOW_DIALOG_CANCELLATION | TDF_USE_COMMAND_LINKS; config.pszMainIcon = MAKEINTRESOURCE(IDI_ICON1); - config.pszMainInstruction = L"An error occurred"; + config.pszMainInstruction = L"An error in the game occurred"; config.pszContent = (L"" - R"aa(This error may be caused by a faulty plugin, a broken TexTools modification, any other third-party tool, or simply a bug in the game.)aa" "\n" + R"aa(The game has to close. This error may be caused by a faulty plugin, a broken mod, any other third-party tool, or simply a bug in the game.)aa" "\n" + "\n" + R"aa(Try running a game repair in XIVLauncher by right clicking the login button, and disabling plugins you don't need. Please also check your antivirus, see our help site for more information.)aa" "\n" "\n" R"aa(Upload this file (click here) if you want to ask for help in our Discord server.)aa" "\n" - "\n" - R"aa(Try running a game repair in XIVLauncher by right clicking the login button, and disabling plugins you don't need.)aa" + ); config.pButtons = buttons; config.cButtons = ARRAYSIZE(buttons); From 9b066fde0195d6de5b2ed1dbe1f4bdf43ada488c Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 27 Dec 2022 22:37:33 +0100 Subject: [PATCH 2/2] build: 7.3.5.0 --- Dalamud/Dalamud.csproj | 2 +- DalamudCrashHandler/DalamudCrashHandler.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index b1005163c..bfa7f1b61 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -8,7 +8,7 @@ - 7.3.4.0 + 7.3.5.0 XIV Launcher addon framework $(DalamudVersion) $(DalamudVersion) diff --git a/DalamudCrashHandler/DalamudCrashHandler.cpp b/DalamudCrashHandler/DalamudCrashHandler.cpp index d1c37327e..f31715c5e 100644 --- a/DalamudCrashHandler/DalamudCrashHandler.cpp +++ b/DalamudCrashHandler/DalamudCrashHandler.cpp @@ -765,7 +765,7 @@ int main() { else { g_bSymbolsAvailable = SymInitializeW(g_hProcess, nullptr, true); - std::cout << std::format("Init symbols without PDB") << std::endl; + std::cout << "Init symbols without PDB" << std::endl; } if (!g_bSymbolsAvailable) {