From 31193f6c4dfca8de73eeabbca74777ad00ff4052 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Mon, 16 Sep 2024 22:17:42 +0100 Subject: [PATCH] [*] TODO: Fix and revert (this is already being rewritten. just need this to not break for now) Reece, [16/09/2024 21:22] need to finish audebug update on the laptop Reece, [16/09/2024 21:22] loading broken dlls (incl missing iat resolves) results in a telemetry deadlock Reece, [16/09/2024 21:23] win32 ldr lock is held while dbghelp tries to acquire lock --- Source/Debug/ExceptionWatcher.Win32.cpp | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Source/Debug/ExceptionWatcher.Win32.cpp b/Source/Debug/ExceptionWatcher.Win32.cpp index 82e4c204..c267b06c 100644 --- a/Source/Debug/ExceptionWatcher.Win32.cpp +++ b/Source/Debug/ExceptionWatcher.Win32.cpp @@ -31,6 +31,8 @@ #include #endif +#include + static thread_local int gDebugLocked = 0; namespace Aurora::Debug @@ -206,6 +208,21 @@ namespace Aurora::Debug }; StackTrace backtrace; + + BOOL bLocked {}; + if (AuxUlibIsDLLSynchronizationHeld(&bLocked)) + { + if (bLocked) + { + ParseStack(ExceptionInfo->ContextRecord, backtrace); + + AuLogWarn("DLL Load NT Exception: 0x{:x}", ExceptionInfo->ExceptionRecord->ExceptionCode); + AuLogWarn("{}", StringifyStackTrace(backtrace)); + gDebugLocked = 0; + return EXCEPTION_CONTINUE_SEARCH; + } + } + { static bool bRunOnce {}; struct ArrowEx : Grug::Arrow @@ -245,9 +262,16 @@ namespace Aurora::Debug CONTEXT ctx {}; ctx.ContextFlags = CONTEXT_ALL; - if (!GetThreadContext(GetCurrentThread(), &ctx)) + if (ExceptionInfo->ContextRecord) { - Debug::Panic(); + ctx = *ExceptionInfo->ContextRecord; + } + else + { + if (!GetThreadContext(GetCurrentThread(), &ctx)) + { + Debug::Panic(); + } } AuVoidFunc doReportLocal;