From 15fa6111af44eebf313fe058e849f602db494e99 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 19 Jun 2014 21:18:31 +0200 Subject: [PATCH] kernel32: Process OutputDebugString events like regular exceptions. --- dlls/kernel32/debugger.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/dlls/kernel32/debugger.c b/dlls/kernel32/debugger.c index 34ef30ad6aa..738b6f0a2ef 100644 --- a/dlls/kernel32/debugger.c +++ b/dlls/kernel32/debugger.c @@ -77,6 +77,14 @@ BOOL WINAPI WaitForDebugEvent( switch(data.code) { case EXCEPTION_DEBUG_EVENT: + if (data.exception.exc_code == DBG_PRINTEXCEPTION_C && data.exception.nb_params >= 2) + { + event->dwDebugEventCode = OUTPUT_DEBUG_STRING_EVENT; + event->u.DebugString.lpDebugStringData = wine_server_get_ptr( data.exception.params[1] ); + event->u.DebugString.fUnicode = FALSE; + event->u.DebugString.nDebugStringLength = data.exception.params[0]; + break; + } event->u.Exception.dwFirstChance = data.exception.first; event->u.Exception.ExceptionRecord.ExceptionCode = data.exception.exc_code; event->u.Exception.ExceptionRecord.ExceptionFlags = data.exception.flags; @@ -120,11 +128,6 @@ BOOL WINAPI WaitForDebugEvent( case UNLOAD_DLL_DEBUG_EVENT: event->u.UnloadDll.lpBaseOfDll = wine_server_get_ptr( data.unload_dll.base ); break; - case OUTPUT_DEBUG_STRING_EVENT: - event->u.DebugString.lpDebugStringData = wine_server_get_ptr( data.output_string.string ); - event->u.DebugString.fUnicode = FALSE; - event->u.DebugString.nDebugStringLength = data.output_string.length; - break; case RIP_EVENT: event->u.RipInfo.dwError = data.rip_info.error; event->u.RipInfo.dwType = data.rip_info.type; @@ -251,10 +254,12 @@ void WINAPI OutputDebugStringA( LPCSTR str ) { static HANDLE DBWinMutex = NULL; static BOOL mutex_inited = FALSE; + BOOL caught_by_dbg = TRUE; if (!str) str = ""; + WARN("%s\n", debugstr_a(str)); - /* raise fake exception to make copy protections happy */ + /* raise exception, WaitForDebugEvent() will generate a corresponding debug event */ __TRY { ULONG_PTR args[2]; @@ -264,25 +269,12 @@ void WINAPI OutputDebugStringA( LPCSTR str ) } __EXCEPT(debug_exception_handler) { + caught_by_dbg = FALSE; } __ENDTRY - - /* send string to attached debugger */ - /* FIXME should only send to debugger if exception is not caught by user-mode application */ - - SERVER_START_REQ( output_debug_string ) - { - req->string = wine_server_client_ptr( str ); - req->length = strlen(str) + 1; - wine_server_call( req ); - } - SERVER_END_REQ; - - WARN("%s\n", debugstr_a(str)); + if (caught_by_dbg) return; /* send string to a system-wide monitor */ - /* FIXME should only send to monitor if no debuggers are attached */ - if (!mutex_inited) { /* first call to OutputDebugString, initialize mutex handle */ -- 2.11.4.GIT