diff --git a/Dalamud.Boot/crashhandler_shared.h b/Dalamud.Boot/crashhandler_shared.h index 8d93e4460..0308306ce 100644 --- a/Dalamud.Boot/crashhandler_shared.h +++ b/Dalamud.Boot/crashhandler_shared.h @@ -6,6 +6,8 @@ #define WIN32_LEAN_AND_MEAN #include +#define CUSTOM_EXCEPTION_EXTERNAL_EVENT 0x12345679 + struct exception_info { LPEXCEPTION_POINTERS pExceptionPointers; diff --git a/Dalamud.Boot/veh.cpp b/Dalamud.Boot/veh.cpp index 25c9b5045..50ac9b34c 100644 --- a/Dalamud.Boot/veh.cpp +++ b/Dalamud.Boot/veh.cpp @@ -11,8 +11,6 @@ #include "crashhandler_shared.h" #include "DalamudStartInfo.h" -#define CUSTOM_EXCEPTION_EXTERNAL_EVENT 0x12345679 - #pragma comment(lib, "comctl32.lib") #if defined _M_IX86 diff --git a/DalamudCrashHandler/DalamudCrashHandler.cpp b/DalamudCrashHandler/DalamudCrashHandler.cpp index 107261541..1feec4b2f 100644 --- a/DalamudCrashHandler/DalamudCrashHandler.cpp +++ b/DalamudCrashHandler/DalamudCrashHandler.cpp @@ -938,9 +938,19 @@ int main() { } while (false); } + const bool is_external_event = exinfo.ExceptionRecord.ExceptionCode == CUSTOM_EXCEPTION_EXTERNAL_EVENT; + std::wostringstream log; - log << std::format(L"Unhandled native exception occurred at {}", to_address_string(exinfo.ContextRecord.Rip, false)) << std::endl; - log << std::format(L"Code: {:X}", exinfo.ExceptionRecord.ExceptionCode) << std::endl; + + if (!is_external_event) + { + log << std::format(L"Unhandled native exception occurred at {}", to_address_string(exinfo.ContextRecord.Rip, false)) << std::endl; + log << std::format(L"Code: {:X}", exinfo.ExceptionRecord.ExceptionCode) << std::endl; + } + else + { + log << L"CLR error occurred" << std::endl; + } if (shutup) log << L"======= Crash handler was globally muted(shutdown?) =======" << std::endl; @@ -957,9 +967,19 @@ int main() { if (pProgressDialog) pProgressDialog->SetLine(3, L"Refreshing Module List", FALSE, NULL); + std::wstring window_log_str; + + // Cut the log here for external events, the rest is unreadable and doesn't matter since we can't get + // symbols for mixed-mode stacks yet. + if (is_external_event) + window_log_str = log.str(); + SymRefreshModuleList(GetCurrentProcess()); print_exception_info(exinfo.hThreadHandle, exinfo.ExceptionPointers, exinfo.ContextRecord, log); - const auto window_log_str = log.str(); + + if (!is_external_event) + window_log_str = log.str(); + print_exception_info_extended(exinfo.ExceptionPointers, exinfo.ContextRecord, log); std::wofstream(logPath) << log.str();