2014-11-14 02:17:24 -08:00
|
|
|
From 51935986a1e973ab26dc3035905a47e1f19c6062 Mon Sep 17 00:00:00 2001
|
2014-09-28 14:54:50 -07:00
|
|
|
From: Sebastian Lackner <sebastian@fds-team.de>
|
|
|
|
Date: Sun, 28 Sep 2014 23:39:51 +0200
|
|
|
|
Subject: ntdll: OutputDebugString should throw the exception a second time, if
|
|
|
|
a debugger is attached.
|
|
|
|
|
|
|
|
---
|
|
|
|
dlls/kernel32/debugger.c | 17 +++++++++++++++++
|
|
|
|
dlls/ntdll/tests/exception.c | 19 +++++++------------
|
|
|
|
2 files changed, 24 insertions(+), 12 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/dlls/kernel32/debugger.c b/dlls/kernel32/debugger.c
|
|
|
|
index d4d66b2..981661b 100644
|
|
|
|
--- a/dlls/kernel32/debugger.c
|
|
|
|
+++ b/dlls/kernel32/debugger.c
|
|
|
|
@@ -277,6 +277,23 @@ void WINAPI 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)
|
|
|
|
{
|
|
|
|
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
|
2014-11-14 02:17:24 -08:00
|
|
|
index 7a97ae5..b0f0fac 100644
|
2014-09-28 14:54:50 -07:00
|
|
|
--- a/dlls/ntdll/tests/exception.c
|
|
|
|
+++ b/dlls/ntdll/tests/exception.c
|
2014-11-14 02:17:24 -08:00
|
|
|
@@ -1727,7 +1727,7 @@ static LONG CALLBACK outputdebugstring_vectored_handler(EXCEPTION_POINTERS *Exce
|
2014-09-28 14:54:50 -07:00
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static void test_outputdebugstring(DWORD numexc, BOOL todo)
|
|
|
|
+static void test_outputdebugstring(DWORD numexc)
|
|
|
|
{
|
|
|
|
PVOID vectored_handler;
|
|
|
|
|
2014-11-14 02:17:24 -08:00
|
|
|
@@ -1742,13 +1742,8 @@ static void test_outputdebugstring(DWORD numexc, BOOL todo)
|
2014-09-28 14:54:50 -07:00
|
|
|
|
|
|
|
outputdebugstring_exceptions = 0;
|
|
|
|
OutputDebugStringA("Hello World");
|
|
|
|
- if (todo)
|
|
|
|
- todo_wine
|
|
|
|
- ok(outputdebugstring_exceptions == numexc, "OutputDebugStringA generated %d exceptions, expected %d\n",
|
|
|
|
- outputdebugstring_exceptions, numexc);
|
|
|
|
- else
|
|
|
|
- ok(outputdebugstring_exceptions == numexc, "OutputDebugStringA generated %d exceptions, expected %d\n",
|
|
|
|
- outputdebugstring_exceptions, numexc);
|
|
|
|
+ ok(outputdebugstring_exceptions == numexc, "OutputDebugStringA generated %d exceptions, expected %d\n",
|
|
|
|
+ outputdebugstring_exceptions, numexc);
|
|
|
|
|
|
|
|
pRtlRemoveVectoredExceptionHandler(vectored_handler);
|
|
|
|
}
|
2014-11-14 02:17:24 -08:00
|
|
|
@@ -1962,9 +1957,9 @@ START_TEST(exception)
|
2014-09-28 14:54:50 -07:00
|
|
|
run_rtlraiseexception_test(EXCEPTION_BREAKPOINT);
|
|
|
|
run_rtlraiseexception_test(EXCEPTION_INVALID_HANDLE);
|
|
|
|
test_stage = 3;
|
|
|
|
- test_outputdebugstring(0, FALSE);
|
|
|
|
+ test_outputdebugstring(0);
|
|
|
|
test_stage = 4;
|
|
|
|
- test_outputdebugstring(2, TRUE); /* is this a Windows bug? */
|
|
|
|
+ test_outputdebugstring(2);
|
|
|
|
test_stage = 5;
|
|
|
|
test_ripevent(0);
|
|
|
|
test_stage = 6;
|
2014-11-14 02:17:24 -08:00
|
|
|
@@ -1984,7 +1979,7 @@ START_TEST(exception)
|
2014-09-28 14:54:50 -07:00
|
|
|
test_unwind();
|
|
|
|
test_exceptions();
|
|
|
|
test_rtlraiseexception();
|
|
|
|
- test_outputdebugstring(1, FALSE);
|
|
|
|
+ test_outputdebugstring(1);
|
|
|
|
test_ripevent(1);
|
|
|
|
test_closehandle(0);
|
2014-11-14 02:17:24 -08:00
|
|
|
test_vectored_continue_handler();
|
|
|
|
@@ -2004,7 +1999,7 @@ START_TEST(exception)
|
2014-09-28 14:54:50 -07:00
|
|
|
pRtlLookupFunctionEntry = (void *)GetProcAddress( hntdll,
|
|
|
|
"RtlLookupFunctionEntry" );
|
|
|
|
|
|
|
|
- test_outputdebugstring(1, FALSE);
|
|
|
|
+ test_outputdebugstring(1);
|
|
|
|
test_ripevent(1);
|
|
|
|
test_closehandle(0);
|
2014-11-14 02:17:24 -08:00
|
|
|
test_vectored_continue_handler();
|
2014-09-28 14:54:50 -07:00
|
|
|
--
|
2014-11-14 02:17:24 -08:00
|
|
|
2.1.3
|
2014-09-28 14:54:50 -07:00
|
|
|
|