fix windows crashlog

This commit is contained in:
dank_meme 2024-06-08 07:47:52 +02:00
parent 47e7f8308a
commit 0602b34734

View file

@ -339,11 +339,15 @@ static std::string getInfo(LPEXCEPTION_POINTERS info, Mod* faultyMod) {
// show the thread that crashed
stream << "Crashed thread: " << utils::thread::getName() << "\n";
return stream.str();
}
static LONG WINAPI exceptionHandler(LPEXCEPTION_POINTERS info) {
// not all exceptions are critical, some (i.e. SetThreadName) can and should be ignored
if (info->ExceptionRecord->ExceptionCode == 0x406d1388) {
return EXCEPTION_CONTINUE_EXECUTION;
}
SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES);
@ -359,16 +363,8 @@ static LONG WINAPI exceptionHandler(LPEXCEPTION_POINTERS info) {
return EXCEPTION_CONTINUE_SEARCH;
}
static LONG WINAPI exceptionHandlerDummy(LPEXCEPTION_POINTERS info) {
SetUnhandledExceptionFilter(exceptionHandler);
return EXCEPTION_CONTINUE_SEARCH;
}
bool crashlog::setupPlatformHandler() {
// for some reason, on exceptions windows seems to clear SetUnhandledExceptionFilter
// so we attach a VE handler (which runs *earlier*) and inside set our crash handler
AddVectoredExceptionHandler(0, exceptionHandlerDummy);
SetUnhandledExceptionFilter(exceptionHandler);
AddVectoredExceptionHandler(1, exceptionHandler);
auto lastCrashedFile = crashlog::getCrashLogDirectory() / "last-crashed";
if (std::filesystem::exists(lastCrashedFile)) {