wine-staging/patches/ntdll-Exception/0002-ntdll-OutputDebugString-should-throw-the-exception-a.patch
2023-08-23 12:05:42 +10:00

42 lines
1.2 KiB
Diff

From 6e2509a34fb6f8f06438ee9908eb61320b73697f Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 28 Sep 2014 23:39:51 +0200
Subject: [PATCH] ntdll: OutputDebugString should throw the exception a second
time, if a debugger is attached.
---
dlls/kernelbase/debug.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/dlls/kernelbase/debug.c b/dlls/kernelbase/debug.c
index e1976777b7f..7294f99da7e 100644
--- a/dlls/kernelbase/debug.c
+++ b/dlls/kernelbase/debug.c
@@ -202,6 +202,23 @@ void WINAPI DECLSPEC_HOTPATCH OutputDebugStringA( LPCSTR str )
__ENDTRY
if (caught_by_dbg) return;
+ /* for some unknown reason Windows sends the exception a second time, if a
+ * debugger is attached, and the event wasn't handled in the first attempt */
+ if (NtCurrentTeb()->Peb->BeingDebugged)
+ {
+ __TRY
+ {
+ ULONG_PTR args[2];
+ args[0] = strlen(str) + 1;
+ args[1] = (ULONG_PTR)str;
+ RaiseException( DBG_PRINTEXCEPTION_C, 0, 2, args );
+ }
+ __EXCEPT(debug_exception_handler)
+ {
+ }
+ __ENDTRY
+ }
+
/* send string to a system-wide monitor */
if (!mutex_inited)
{
--
2.40.1