From 18e4a262c84a3e23185b9134196cb1cd64ae6bfb Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 19 Jun 2023 01:35:10 +0200 Subject: [PATCH] Fix double crash dialog boxes bug This occurs when the game's unhandled exception handler is getting called after ours. both will create a crashmsg process. This happened as CCrashHandler::End() was called before the in-game exception filter was fired, and therefore CCrashHandler::Handled would return false, and this fire the in-game exception filter. This commit removes the additional check, we just use our vectored exception handler entirely over the game's one, as this one captures everything an unhandled exception handler will capture, and more. The 'Handled' function/fields in CCrashHandler have been renamed to 'Handling', as this is a more appropriate name. --- r5dev/launcher/launcher.cpp | 2 +- r5dev/public/tier0/crashhandler.h | 4 ++-- r5dev/tier0/crashhandler.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/r5dev/launcher/launcher.cpp b/r5dev/launcher/launcher.cpp index 8a354896..d0a2b645 100644 --- a/r5dev/launcher/launcher.cpp +++ b/r5dev/launcher/launcher.cpp @@ -165,7 +165,7 @@ LONG WINAPI TopLevelExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) { // Don't run the unhandled exception filter from the // game if we have a valid vectored exception filter. - if (g_CrashHandler && g_CrashHandler->Handled()) + if (g_CrashHandler) { return NULL; } diff --git a/r5dev/public/tier0/crashhandler.h b/r5dev/public/tier0/crashhandler.h index c331d629..744313e4 100644 --- a/r5dev/public/tier0/crashhandler.h +++ b/r5dev/public/tier0/crashhandler.h @@ -29,7 +29,7 @@ public: inline bool GetState() const { return m_bCallState; }; inline bool IsValid() const { return m_hExceptionHandler != nullptr; }; - inline bool Handled() const { return m_bExceptionHandled; }; + inline bool Handling() const { return m_bExceptionHandling; }; //------------------------------------------------------------------------- // Formatters: @@ -93,7 +93,7 @@ private: bool m_bCallState; // Set when called to prevent recursive calls. bool m_bCrashMsgCreated; // Set when crashmsg.exe is created to prevent recursive messages. - bool m_bExceptionHandled; // Set on filter entry, unset within the same lock if exception was not handled, never unset if handled. + bool m_bExceptionHandling; // Set on filter entry, unset within the same lock if exception was not handled, never unset if handled. std::set m_WhiteList; mutable std::mutex m_Mutex; diff --git a/r5dev/tier0/crashhandler.cpp b/r5dev/tier0/crashhandler.cpp index 15ae506d..00170cae 100644 --- a/r5dev/tier0/crashhandler.cpp +++ b/r5dev/tier0/crashhandler.cpp @@ -13,7 +13,7 @@ void CCrashHandler::Start() { Lock(); - m_bExceptionHandled = true; + m_bExceptionHandling = true; } //----------------------------------------------------------------------------- @@ -21,7 +21,7 @@ void CCrashHandler::Start() //----------------------------------------------------------------------------- void CCrashHandler::End() { - m_bExceptionHandled = false; + m_bExceptionHandling = false; Unlock(); } @@ -650,7 +650,7 @@ CCrashHandler::CCrashHandler() , m_nCrashMsgFlags(0) , m_bCallState(false) , m_bCrashMsgCreated(false) - , m_bExceptionHandled(false) + , m_bExceptionHandling(false) { Init(); }