1999-05-23 21:57:42 +02:00
|
|
|
/*
|
|
|
|
* Win32 debugger functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-05-23 21:57:42 +02:00
|
|
|
*/
|
|
|
|
|
2011-06-15 20:04:27 +02:00
|
|
|
#include "config.h"
|
2000-11-26 23:39:50 +01:00
|
|
|
#include <stdio.h>
|
1999-07-31 19:36:48 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2010-03-14 21:53:28 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2000-03-08 13:01:30 +01:00
|
|
|
#include "winerror.h"
|
2001-07-19 02:39:09 +02:00
|
|
|
#include "wine/server.h"
|
2005-05-16 16:45:18 +02:00
|
|
|
#include "kernel_private.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-05-23 21:57:42 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(debugstr);
|
1999-05-23 21:57:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* WaitForDebugEvent (KERNEL32.@)
|
1999-05-23 21:57:42 +02:00
|
|
|
*
|
2000-12-20 00:33:03 +01:00
|
|
|
* Waits for a debugging event to occur in a process being debugged before
|
|
|
|
* filling out the debug event structure.
|
1999-05-23 21:57:42 +02:00
|
|
|
*
|
2004-08-26 20:22:17 +02:00
|
|
|
* PARAMS
|
|
|
|
* event [O] Address of structure for event information.
|
|
|
|
* timeout [I] Number of milliseconds to wait for event.
|
|
|
|
*
|
2000-12-20 00:33:03 +01:00
|
|
|
* RETURNS
|
1999-05-23 21:57:42 +02:00
|
|
|
*
|
2000-12-20 00:33:03 +01:00
|
|
|
* Returns true if a debug event occurred and false if the call timed out.
|
1999-05-23 21:57:42 +02:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
BOOL WINAPI WaitForDebugEvent(
|
2004-08-26 20:22:17 +02:00
|
|
|
LPDEBUG_EVENT event,
|
|
|
|
DWORD timeout)
|
1999-05-23 21:57:42 +02:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
BOOL ret;
|
2013-02-11 23:44:12 +01:00
|
|
|
DWORD res;
|
|
|
|
int i;
|
2001-01-26 01:22:26 +01:00
|
|
|
|
|
|
|
for (;;)
|
1999-05-23 21:57:42 +02:00
|
|
|
{
|
2001-01-26 01:22:26 +01:00
|
|
|
HANDLE wait = 0;
|
2001-11-30 19:46:42 +01:00
|
|
|
debug_event_t data;
|
|
|
|
SERVER_START_REQ( wait_debug_event )
|
2001-01-26 01:22:26 +01:00
|
|
|
{
|
|
|
|
req->get_handle = (timeout != 0);
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_set_reply( req, &data, sizeof(data) );
|
|
|
|
if (!(ret = !wine_server_call_err( req ))) goto done;
|
2000-08-30 02:00:48 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!wine_server_reply_size(reply)) /* timeout */
|
2001-01-26 01:22:26 +01:00
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
wait = wine_server_ptr_handle( reply->wait );
|
2001-01-26 01:22:26 +01:00
|
|
|
ret = FALSE;
|
|
|
|
goto done;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
event->dwDebugEventCode = data.code;
|
|
|
|
event->dwProcessId = (DWORD)reply->pid;
|
|
|
|
event->dwThreadId = (DWORD)reply->tid;
|
|
|
|
switch(data.code)
|
2001-01-26 01:22:26 +01:00
|
|
|
{
|
|
|
|
case EXCEPTION_DEBUG_EVENT:
|
2009-01-02 20:12:46 +01:00
|
|
|
event->u.Exception.dwFirstChance = data.exception.first;
|
|
|
|
event->u.Exception.ExceptionRecord.ExceptionCode = data.exception.exc_code;
|
|
|
|
event->u.Exception.ExceptionRecord.ExceptionFlags = data.exception.flags;
|
|
|
|
event->u.Exception.ExceptionRecord.ExceptionRecord = wine_server_get_ptr( data.exception.record );
|
|
|
|
event->u.Exception.ExceptionRecord.ExceptionAddress = wine_server_get_ptr( data.exception.address );
|
|
|
|
event->u.Exception.ExceptionRecord.NumberParameters = data.exception.nb_params;
|
|
|
|
for (i = 0; i < data.exception.nb_params; i++)
|
|
|
|
event->u.Exception.ExceptionRecord.ExceptionInformation[i] = data.exception.params[i];
|
2001-01-26 01:22:26 +01:00
|
|
|
break;
|
|
|
|
case CREATE_THREAD_DEBUG_EVENT:
|
2009-01-02 20:09:25 +01:00
|
|
|
event->u.CreateThread.hThread = wine_server_ptr_handle( data.create_thread.handle );
|
|
|
|
event->u.CreateThread.lpThreadLocalBase = wine_server_get_ptr( data.create_thread.teb );
|
|
|
|
event->u.CreateThread.lpStartAddress = wine_server_get_ptr( data.create_thread.start );
|
2001-01-26 01:22:26 +01:00
|
|
|
break;
|
|
|
|
case CREATE_PROCESS_DEBUG_EVENT:
|
2009-01-02 20:09:25 +01:00
|
|
|
event->u.CreateProcessInfo.hFile = wine_server_ptr_handle( data.create_process.file );
|
|
|
|
event->u.CreateProcessInfo.hProcess = wine_server_ptr_handle( data.create_process.process );
|
|
|
|
event->u.CreateProcessInfo.hThread = wine_server_ptr_handle( data.create_process.thread );
|
|
|
|
event->u.CreateProcessInfo.lpBaseOfImage = wine_server_get_ptr( data.create_process.base );
|
|
|
|
event->u.CreateProcessInfo.dwDebugInfoFileOffset = data.create_process.dbg_offset;
|
|
|
|
event->u.CreateProcessInfo.nDebugInfoSize = data.create_process.dbg_size;
|
|
|
|
event->u.CreateProcessInfo.lpThreadLocalBase = wine_server_get_ptr( data.create_process.teb );
|
|
|
|
event->u.CreateProcessInfo.lpStartAddress = wine_server_get_ptr( data.create_process.start );
|
|
|
|
event->u.CreateProcessInfo.lpImageName = wine_server_get_ptr( data.create_process.name );
|
|
|
|
event->u.CreateProcessInfo.fUnicode = data.create_process.unicode;
|
2001-01-26 01:22:26 +01:00
|
|
|
break;
|
|
|
|
case EXIT_THREAD_DEBUG_EVENT:
|
2009-01-02 20:09:25 +01:00
|
|
|
event->u.ExitThread.dwExitCode = data.exit.exit_code;
|
2001-01-26 01:22:26 +01:00
|
|
|
break;
|
|
|
|
case EXIT_PROCESS_DEBUG_EVENT:
|
2009-01-02 20:09:25 +01:00
|
|
|
event->u.ExitProcess.dwExitCode = data.exit.exit_code;
|
2001-01-26 01:22:26 +01:00
|
|
|
break;
|
|
|
|
case LOAD_DLL_DEBUG_EVENT:
|
2009-01-02 20:09:25 +01:00
|
|
|
event->u.LoadDll.hFile = wine_server_ptr_handle( data.load_dll.handle );
|
|
|
|
event->u.LoadDll.lpBaseOfDll = wine_server_get_ptr( data.load_dll.base );
|
|
|
|
event->u.LoadDll.dwDebugInfoFileOffset = data.load_dll.dbg_offset;
|
|
|
|
event->u.LoadDll.nDebugInfoSize = data.load_dll.dbg_size;
|
|
|
|
event->u.LoadDll.lpImageName = wine_server_get_ptr( data.load_dll.name );
|
|
|
|
event->u.LoadDll.fUnicode = data.load_dll.unicode;
|
2001-01-26 01:22:26 +01:00
|
|
|
break;
|
|
|
|
case UNLOAD_DLL_DEBUG_EVENT:
|
2009-01-02 20:09:25 +01:00
|
|
|
event->u.UnloadDll.lpBaseOfDll = wine_server_get_ptr( data.unload_dll.base );
|
2001-01-26 01:22:26 +01:00
|
|
|
break;
|
|
|
|
case OUTPUT_DEBUG_STRING_EVENT:
|
2009-01-02 20:09:25 +01:00
|
|
|
event->u.DebugString.lpDebugStringData = wine_server_get_ptr( data.output_string.string );
|
2009-10-05 19:42:22 +02:00
|
|
|
event->u.DebugString.fUnicode = FALSE;
|
2009-01-02 20:09:25 +01:00
|
|
|
event->u.DebugString.nDebugStringLength = data.output_string.length;
|
2001-01-26 01:22:26 +01:00
|
|
|
break;
|
|
|
|
case RIP_EVENT:
|
2009-01-02 20:09:25 +01:00
|
|
|
event->u.RipInfo.dwError = data.rip_info.error;
|
|
|
|
event->u.RipInfo.dwType = data.rip_info.type;
|
2001-01-26 01:22:26 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
done:
|
2001-11-19 03:24:14 +01:00
|
|
|
/* nothing */ ;
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2001-01-26 01:22:26 +01:00
|
|
|
if (ret) return TRUE;
|
|
|
|
if (!wait) break;
|
|
|
|
res = WaitForSingleObject( wait, timeout );
|
|
|
|
CloseHandle( wait );
|
|
|
|
if (res != STATUS_WAIT_0) break;
|
1999-05-23 21:57:42 +02:00
|
|
|
}
|
2001-01-26 01:22:26 +01:00
|
|
|
SetLastError( ERROR_SEM_TIMEOUT );
|
|
|
|
return FALSE;
|
1999-05-23 21:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* ContinueDebugEvent (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* Enables a thread that previously produced a debug event to continue.
|
|
|
|
*
|
2004-08-26 20:22:17 +02:00
|
|
|
* PARAMS
|
|
|
|
* pid [I] The id of the process to continue.
|
|
|
|
* tid [I] The id of the thread to continue.
|
|
|
|
* status [I] The rule to apply to unhandled exeptions.
|
|
|
|
*
|
2000-12-20 00:33:03 +01:00
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* True if the debugger is listed as the processes owner and the process
|
|
|
|
* and thread are valid.
|
1999-05-23 21:57:42 +02:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
BOOL WINAPI ContinueDebugEvent(
|
2004-08-26 20:22:17 +02:00
|
|
|
DWORD pid,
|
|
|
|
DWORD tid,
|
|
|
|
DWORD status)
|
1999-05-23 21:57:42 +02:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
BOOL ret;
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( continue_debug_event )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
2002-10-03 21:54:57 +02:00
|
|
|
req->pid = pid;
|
|
|
|
req->tid = tid;
|
2000-08-30 02:00:48 +02:00
|
|
|
req->status = status;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1999-05-23 21:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DebugActiveProcess (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2002-02-27 02:28:30 +01:00
|
|
|
* Attempts to attach the debugger to a process.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2004-08-26 20:22:17 +02:00
|
|
|
* PARAMS
|
|
|
|
* pid [I] The process to be debugged.
|
|
|
|
*
|
2000-12-20 00:33:03 +01:00
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* True if the debugger was attached to process.
|
1999-05-23 21:57:42 +02:00
|
|
|
*/
|
2004-08-26 20:22:17 +02:00
|
|
|
BOOL WINAPI DebugActiveProcess( DWORD pid )
|
1999-05-23 21:57:42 +02:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
BOOL ret;
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( debug_process )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
2002-10-03 21:54:57 +02:00
|
|
|
req->pid = pid;
|
2002-02-27 02:28:30 +01:00
|
|
|
req->attach = 1;
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* DebugActiveProcessStop (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Attempts to detach the debugger from a process.
|
|
|
|
*
|
2004-08-26 20:22:17 +02:00
|
|
|
* PARAMS
|
|
|
|
* pid [I] The process to be detached.
|
|
|
|
*
|
2002-02-27 02:28:30 +01:00
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* True if the debugger was detached from the process.
|
|
|
|
*/
|
2004-08-26 20:22:17 +02:00
|
|
|
BOOL WINAPI DebugActiveProcessStop( DWORD pid )
|
2002-02-27 02:28:30 +01:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
SERVER_START_REQ( debug_process )
|
|
|
|
{
|
2002-10-03 21:54:57 +02:00
|
|
|
req->pid = pid;
|
2002-02-27 02:28:30 +01:00
|
|
|
req->attach = 0;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1999-05-23 21:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OutputDebugStringA (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2004-01-16 22:26:08 +01:00
|
|
|
* Output by an application of an ascii string to a debugger (if attached)
|
2000-12-20 00:33:03 +01:00
|
|
|
* and program log.
|
2004-08-26 20:22:17 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I] The message to be logged and given to the debugger.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* Nothing.
|
1999-05-23 21:57:42 +02:00
|
|
|
*/
|
2004-08-26 20:22:17 +02:00
|
|
|
void WINAPI OutputDebugStringA( LPCSTR str )
|
1999-05-23 21:57:42 +02:00
|
|
|
{
|
2009-10-05 19:42:36 +02:00
|
|
|
static HANDLE DBWinMutex = NULL;
|
|
|
|
static BOOL mutex_inited = FALSE;
|
|
|
|
|
2012-05-30 22:47:34 +02:00
|
|
|
if (!str) str = "";
|
|
|
|
|
2009-10-05 19:42:36 +02:00
|
|
|
/* send string to attached debugger */
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( output_debug_string )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
2008-12-29 17:12:20 +01:00
|
|
|
req->string = wine_server_client_ptr( str );
|
2000-08-30 02:00:48 +02:00
|
|
|
req->length = strlen(str) + 1;
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_call( req );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2009-10-05 19:42:36 +02:00
|
|
|
|
2011-02-19 13:06:40 +01:00
|
|
|
WARN("%s\n", debugstr_a(str));
|
2009-10-05 19:42:36 +02:00
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
static const WCHAR mutexname[] = {'D','B','W','i','n','M','u','t','e','x',0};
|
|
|
|
HANDLE mutex = CreateMutexExW( NULL, mutexname, 0, SYNCHRONIZE );
|
|
|
|
if (mutex)
|
|
|
|
{
|
|
|
|
if (InterlockedCompareExchangePointer( &DBWinMutex, mutex, 0 ) != 0)
|
|
|
|
{
|
|
|
|
/* someone beat us here... */
|
|
|
|
CloseHandle( mutex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_inited = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DBWinMutex)
|
|
|
|
{
|
|
|
|
static const WCHAR shmname[] = {'D','B','W','I','N','_','B','U','F','F','E','R',0};
|
|
|
|
static const WCHAR eventbuffername[] = {'D','B','W','I','N','_','B','U','F','F','E','R','_','R','E','A','D','Y',0};
|
|
|
|
static const WCHAR eventdataname[] = {'D','B','W','I','N','_','D','A','T','A','_','R','E','A','D','Y',0};
|
|
|
|
HANDLE mapping;
|
|
|
|
|
|
|
|
mapping = OpenFileMappingW( FILE_MAP_WRITE, FALSE, shmname );
|
|
|
|
if (mapping)
|
|
|
|
{
|
|
|
|
LPVOID buffer;
|
|
|
|
HANDLE eventbuffer, eventdata;
|
|
|
|
|
|
|
|
buffer = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 );
|
|
|
|
eventbuffer = OpenEventW( SYNCHRONIZE, FALSE, eventbuffername );
|
|
|
|
eventdata = OpenEventW( EVENT_MODIFY_STATE, FALSE, eventdataname );
|
|
|
|
|
|
|
|
if (buffer && eventbuffer && eventdata)
|
|
|
|
{
|
2011-07-27 13:38:43 +02:00
|
|
|
/* monitor is present, synchronize with other OutputDebugString invocations */
|
2009-10-05 19:42:36 +02:00
|
|
|
WaitForSingleObject( DBWinMutex, INFINITE );
|
|
|
|
|
|
|
|
/* acquire control over the buffer */
|
|
|
|
if (WaitForSingleObject( eventbuffer, 10000 ) == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
int str_len;
|
|
|
|
struct _mon_buffer_t {
|
|
|
|
DWORD pid;
|
|
|
|
char buffer[1];
|
|
|
|
} *mon_buffer = (struct _mon_buffer_t*) buffer;
|
|
|
|
|
|
|
|
str_len = strlen( str );
|
|
|
|
if (str_len > (4096 - sizeof(DWORD) - 1))
|
|
|
|
str_len = 4096 - sizeof(DWORD) - 1;
|
|
|
|
|
|
|
|
mon_buffer->pid = GetCurrentProcessId();
|
|
|
|
memcpy( mon_buffer->buffer, str, str_len );
|
|
|
|
mon_buffer->buffer[str_len] = 0;
|
|
|
|
|
|
|
|
/* signal data ready */
|
|
|
|
SetEvent( eventdata );
|
|
|
|
}
|
|
|
|
ReleaseMutex( DBWinMutex );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer)
|
|
|
|
UnmapViewOfFile( buffer );
|
|
|
|
if (eventbuffer)
|
|
|
|
CloseHandle( eventbuffer );
|
|
|
|
if (eventdata)
|
|
|
|
CloseHandle( eventdata );
|
|
|
|
CloseHandle( mapping );
|
|
|
|
}
|
|
|
|
}
|
1999-05-23 21:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OutputDebugStringW (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2004-01-16 22:26:08 +01:00
|
|
|
* Output by an application of a unicode string to a debugger (if attached)
|
2000-12-20 00:33:03 +01:00
|
|
|
* and program log.
|
2004-08-26 20:22:17 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I] The message to be logged and given to the debugger.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* Nothing.
|
1999-05-23 21:57:42 +02:00
|
|
|
*/
|
2004-08-26 20:22:17 +02:00
|
|
|
void WINAPI OutputDebugStringW( LPCWSTR str )
|
1999-05-23 21:57:42 +02:00
|
|
|
{
|
2009-10-05 19:42:22 +02:00
|
|
|
UNICODE_STRING strW;
|
|
|
|
STRING strA;
|
|
|
|
|
|
|
|
RtlInitUnicodeString( &strW, str );
|
|
|
|
if (!RtlUnicodeStringToAnsiString( &strA, &strW, TRUE ))
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
2009-10-05 19:42:22 +02:00
|
|
|
OutputDebugStringA( strA.Buffer );
|
|
|
|
RtlFreeAnsiString( &strA );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
1999-05-23 21:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-08 17:41:37 +01:00
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DebugBreak (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* Raises an exception so that a debugger (if attached)
|
|
|
|
* can take some action.
|
2000-03-08 17:41:37 +01:00
|
|
|
*/
|
2011-06-15 20:04:27 +02:00
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
2011-06-21 10:39:06 +02:00
|
|
|
__ASM_STDCALL_FUNC( DebugBreak, 0, "jmp " __ASM_NAME("DbgBreakPoint") )
|
2011-06-15 20:04:27 +02:00
|
|
|
#else
|
2000-03-08 17:41:37 +01:00
|
|
|
void WINAPI DebugBreak(void)
|
|
|
|
{
|
|
|
|
DbgBreakPoint();
|
|
|
|
}
|
2011-06-15 20:04:27 +02:00
|
|
|
#endif
|
2000-03-08 17:41:37 +01:00
|
|
|
|
2002-02-27 02:28:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DebugBreakProcess (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Raises an exception so that a debugger (if attached)
|
|
|
|
* can take some action. Same as DebugBreak, but applies to any process.
|
2004-08-26 20:22:17 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hProc [I] Process to break into.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* True if successful.
|
2002-02-27 02:28:30 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI DebugBreakProcess(HANDLE hProc)
|
|
|
|
{
|
2002-02-27 02:55:02 +01:00
|
|
|
BOOL ret, self;
|
2002-02-27 02:28:30 +01:00
|
|
|
|
2002-10-25 23:02:30 +02:00
|
|
|
TRACE("(%p)\n", hProc);
|
2002-02-27 02:28:30 +01:00
|
|
|
|
2002-02-27 02:55:02 +01:00
|
|
|
SERVER_START_REQ( debug_break )
|
2002-02-27 02:28:30 +01:00
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( hProc );
|
2002-02-27 02:55:02 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
self = ret && reply->self;
|
2002-02-27 02:28:30 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2002-02-27 02:55:02 +01:00
|
|
|
if (self) DbgBreakPoint();
|
|
|
|
return ret;
|
2002-02-27 02:28:30 +01:00
|
|
|
}
|
|
|
|
|
2000-03-08 17:41:37 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* IsDebuggerPresent (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* Allows a process to determine if there is a debugger attached.
|
|
|
|
*
|
2004-08-26 20:22:17 +02:00
|
|
|
* PARAMS
|
|
|
|
*
|
2000-12-20 00:33:03 +01:00
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* True if there is a debugger attached.
|
2000-03-08 17:41:37 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI IsDebuggerPresent(void)
|
|
|
|
{
|
2003-10-14 03:30:42 +02:00
|
|
|
return NtCurrentTeb()->Peb->BeingDebugged;
|
2000-03-08 17:41:37 +01:00
|
|
|
}
|
2000-11-26 23:39:50 +01:00
|
|
|
|
2007-02-16 19:12:06 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CheckRemoteDebuggerPresent (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Allows a process to determine if there is a remote debugger
|
|
|
|
* attached.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* TRUE because it is a stub.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CheckRemoteDebuggerPresent(HANDLE process, PBOOL DebuggerPresent)
|
|
|
|
{
|
2010-03-14 21:53:28 +01:00
|
|
|
NTSTATUS status;
|
|
|
|
DWORD_PTR port;
|
|
|
|
|
2009-09-27 10:10:41 +02:00
|
|
|
if(!process || !DebuggerPresent)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-03-14 21:53:28 +01:00
|
|
|
|
|
|
|
status = NtQueryInformationProcess(process, ProcessDebugPort, &port, sizeof(port), NULL);
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*DebuggerPresent = !!port;
|
2007-02-16 19:12:06 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2000-11-26 23:39:50 +01:00
|
|
|
|
2002-02-27 02:28:30 +01:00
|
|
|
/***********************************************************************
|
2002-03-11 02:17:26 +01:00
|
|
|
* DebugSetProcessKillOnExit (KERNEL32.@)
|
2002-02-27 02:28:30 +01:00
|
|
|
*
|
2004-01-16 22:26:08 +01:00
|
|
|
* Let a debugger decide whether a debuggee will be killed upon debugger
|
2004-08-26 20:22:17 +02:00
|
|
|
* termination.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* kill [I] If set to true then kill the process on exit.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* True if successful, false otherwise.
|
2002-02-27 02:28:30 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI DebugSetProcessKillOnExit(BOOL kill)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_debugger_kill_on_exit )
|
|
|
|
{
|
|
|
|
req->kill_on_exit = kill;
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|