Removed PDB32_DEBUGGED flag and send all debug events unconditionally.
Implemented IsDebuggerPresent().
This commit is contained in:
parent
ff81d78708
commit
00641d5b1c
|
@ -13,7 +13,6 @@
|
|||
#include "wine/exception.h"
|
||||
#include "stackframe.h"
|
||||
#include "miscemu.h"
|
||||
#include "debugger.h"
|
||||
#include "debugtools.h"
|
||||
|
||||
DEFAULT_DEBUG_CHANNEL(seh)
|
||||
|
@ -92,11 +91,7 @@ static DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_FRAME *frame,
|
|||
*/
|
||||
static void EXC_DefaultHandling( EXCEPTION_RECORD *rec, CONTEXT *context )
|
||||
{
|
||||
if ((PROCESS_Current()->flags & PDB32_DEBUGGED) &&
|
||||
(DEBUG_SendExceptionEvent( rec, FALSE, context ) == DBG_CONTINUE))
|
||||
return; /* continue execution */
|
||||
|
||||
if (wine_debugger( rec, context, FALSE ) == DBG_CONTINUE)
|
||||
if (DEBUG_SendExceptionEvent( rec, FALSE, context ) == DBG_CONTINUE)
|
||||
return; /* continue execution */
|
||||
|
||||
if (rec->ExceptionFlags & EH_STACK_INVALID)
|
||||
|
@ -122,11 +117,7 @@ void WINAPI EXC_RtlRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context )
|
|||
|
||||
TRACE( "code=%lx flags=%lx\n", rec->ExceptionCode, rec->ExceptionFlags );
|
||||
|
||||
if ((PROCESS_Current()->flags & PDB32_DEBUGGED) &&
|
||||
(DEBUG_SendExceptionEvent( rec, TRUE, context ) == DBG_CONTINUE))
|
||||
return; /* continue execution */
|
||||
|
||||
if (wine_debugger( rec, context, TRUE ) == DBG_CONTINUE)
|
||||
if (DEBUG_SendExceptionEvent( rec, TRUE, context ) == DBG_CONTINUE)
|
||||
return; /* continue execution */
|
||||
|
||||
frame = NtCurrentTeb()->except;
|
||||
|
@ -286,30 +277,3 @@ void WINAPI RtlRaiseStatus( NTSTATUS status )
|
|||
ExceptionRec.NumberParameters = 0;
|
||||
RtlRaiseException( &ExceptionRec );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* DebugBreak (KERNEL32.181)
|
||||
*/
|
||||
void WINAPI DebugBreak(void)
|
||||
{
|
||||
DbgBreakPoint();
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* DebugBreak16 (KERNEL.203)
|
||||
*/
|
||||
void WINAPI DebugBreak16( CONTEXT86 *context )
|
||||
{
|
||||
#ifdef __i386__
|
||||
EXCEPTION_RECORD rec;
|
||||
|
||||
rec.ExceptionCode = EXCEPTION_BREAKPOINT;
|
||||
rec.ExceptionFlags = 0;
|
||||
rec.ExceptionRecord = NULL;
|
||||
rec.ExceptionAddress = GET_IP(context);
|
||||
rec.NumberParameters = 0;
|
||||
EXC_RtlRaiseException( &rec, context );
|
||||
#endif /* defined(__i386__) */
|
||||
}
|
||||
|
|
|
@ -961,7 +961,13 @@ NTSTATUS WINAPI NtClose(
|
|||
|
||||
/* misc */
|
||||
|
||||
#if defined(__i386__) && defined(__GNUC__)
|
||||
static inline void WINAPI DbgBreakPoint(void) { __asm__ __volatile__("int3"); }
|
||||
static inline void WINAPI DbgUserBreakPoint(void) { __asm__ __volatile__("int3"); }
|
||||
#else /* __i386__ && __GNUC__ */
|
||||
void WINAPI DbgBreakPoint(void);
|
||||
void WINAPI DbgUserBreakPoint(void);
|
||||
#endif /* __i386__ && __GNUC__ */
|
||||
void WINAPIV DbgPrint(LPCSTR fmt, ...);
|
||||
|
||||
DWORD WINAPI RtlAdjustPrivilege(DWORD x1,DWORD x2,DWORD x3,DWORD x4);
|
||||
|
|
|
@ -167,6 +167,7 @@ struct init_process_done_request
|
|||
{
|
||||
IN void* module; /* main module base address */
|
||||
IN void* entry; /* process entry point */
|
||||
OUT int debugged; /* being debugged? */
|
||||
};
|
||||
|
||||
|
||||
|
@ -209,8 +210,9 @@ struct terminate_thread_request
|
|||
/* Retrieve information about a process */
|
||||
struct get_process_info_request
|
||||
{
|
||||
IN int handle; /* process handle */
|
||||
IN int handle; /* process handle */
|
||||
OUT void* pid; /* server process id */
|
||||
OUT int debugged; /* debugged? */
|
||||
OUT int exit_code; /* process exit code */
|
||||
OUT int priority; /* priority class */
|
||||
OUT int process_affinity; /* process affinity mask */
|
||||
|
|
|
@ -1659,8 +1659,9 @@ BOOL WINAPI IsBadReadPtr(LPCVOID,UINT);
|
|||
BOOL WINAPI IsBadStringPtrA(LPCSTR,UINT);
|
||||
BOOL WINAPI IsBadStringPtrW(LPCWSTR,UINT);
|
||||
#define IsBadStringPtr WINELIB_NAME_AW(IsBadStringPtr)
|
||||
BOOL WINAPI IsBadWritePtr(LPVOID,UINT);
|
||||
BOOL WINAPI IsDBCSLeadByte(BYTE);
|
||||
BOOL WINAPI IsBadWritePtr(LPVOID,UINT);
|
||||
BOOL WINAPI IsDBCSLeadByte(BYTE);
|
||||
BOOL WINAPI IsDebuggerPresent(void);
|
||||
HINSTANCE16 WINAPI LoadLibrary16(LPCSTR);
|
||||
HMODULE WINAPI LoadLibraryA(LPCSTR);
|
||||
HMODULE WINAPI LoadLibraryW(LPCWSTR);
|
||||
|
@ -1689,8 +1690,9 @@ HFILE WINAPI OpenFile(LPCSTR,OFSTRUCT*,UINT);
|
|||
VOID WINAPI OutputDebugStringA(LPCSTR);
|
||||
VOID WINAPI OutputDebugStringW(LPCWSTR);
|
||||
#define OutputDebugString WINELIB_NAME_AW(OutputDebugString)
|
||||
BOOL WINAPI RemoveDirectoryA(LPCSTR);
|
||||
BOOL WINAPI RemoveDirectoryW(LPCWSTR);
|
||||
BOOL WINAPI ReadProcessMemory(HANDLE, LPCVOID, LPVOID, DWORD, LPDWORD);
|
||||
BOOL WINAPI RemoveDirectoryA(LPCSTR);
|
||||
BOOL WINAPI RemoveDirectoryW(LPCWSTR);
|
||||
#define RemoveDirectory WINELIB_NAME_AW(RemoveDirectory)
|
||||
BOOL WINAPI SetCurrentDirectoryA(LPCSTR);
|
||||
BOOL WINAPI SetCurrentDirectoryW(LPCWSTR);
|
||||
|
@ -1718,8 +1720,9 @@ BOOL WINAPI WriteProfileSectionW(LPCWSTR,LPCWSTR);
|
|||
BOOL WINAPI WritePrivateProfileStructA(LPCSTR,LPCSTR,LPVOID,UINT,LPCSTR);
|
||||
BOOL WINAPI WritePrivateProfileStructW(LPCWSTR,LPCWSTR,LPVOID,UINT,LPCWSTR);
|
||||
#define WritePrivateProfileStruct WINELIB_NAME_AW(WritePrivateProfileStruct)
|
||||
BOOL WINAPI WriteProfileStringA(LPCSTR,LPCSTR,LPCSTR);
|
||||
BOOL WINAPI WriteProfileStringW(LPCWSTR,LPCWSTR,LPCWSTR);
|
||||
BOOL WINAPI WriteProcessMemory(HANDLE, LPVOID, LPVOID, DWORD, LPDWORD);
|
||||
BOOL WINAPI WriteProfileStringA(LPCSTR,LPCSTR,LPCSTR);
|
||||
BOOL WINAPI WriteProfileStringW(LPCWSTR,LPCWSTR,LPCWSTR);
|
||||
#define WriteProfileString WINELIB_NAME_AW(WriteProfileString)
|
||||
#define Yield32()
|
||||
LPSTR WINAPI lstrcatA(LPSTR,LPCSTR);
|
||||
|
|
|
@ -1351,8 +1351,7 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
|
|||
wm = MODULE_LoadLibraryExA( libname, hfile, flags );
|
||||
if ( wm )
|
||||
{
|
||||
if ( PROCESS_Current()->flags & PDB32_DEBUGGED )
|
||||
MODULE_SendLoadDLLEvents();
|
||||
MODULE_SendLoadDLLEvents();
|
||||
|
||||
if ( !MODULE_DllProcessAttach( wm, NULL ) )
|
||||
{
|
||||
|
@ -1611,8 +1610,7 @@ BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
|
|||
if ( PROCESS_Current()->free_lib_count <= 1 )
|
||||
{
|
||||
MODULE_DllProcessDetach( FALSE, NULL );
|
||||
if (PROCESS_Current()->flags & PDB32_DEBUGGED)
|
||||
DEBUG_SendUnloadDLLEvent( wm->module );
|
||||
DEBUG_SendUnloadDLLEvent( wm->module );
|
||||
}
|
||||
|
||||
TRACE("(%s) - END\n", wm->modname );
|
||||
|
|
|
@ -195,16 +195,12 @@ BOOL WINAPI DebugActiveProcess( DWORD pid )
|
|||
*/
|
||||
void WINAPI OutputDebugStringA( LPCSTR str )
|
||||
{
|
||||
if (PROCESS_Current()->flags & PDB32_DEBUGGED)
|
||||
{
|
||||
struct send_debug_event_request *req = get_req_buffer();
|
||||
req->event.code = OUTPUT_DEBUG_STRING_EVENT;
|
||||
req->event.info.output_string.string = (void *)str;
|
||||
req->event.info.output_string.unicode = 0;
|
||||
req->event.info.output_string.length = strlen(str) + 1;
|
||||
server_call( REQ_SEND_DEBUG_EVENT );
|
||||
}
|
||||
|
||||
struct send_debug_event_request *req = get_req_buffer();
|
||||
req->event.code = OUTPUT_DEBUG_STRING_EVENT;
|
||||
req->event.info.output_string.string = (void *)str;
|
||||
req->event.info.output_string.unicode = 0;
|
||||
req->event.info.output_string.length = strlen(str) + 1;
|
||||
server_call_noerr( REQ_SEND_DEBUG_EVENT );
|
||||
TRACE("%s\n", str);
|
||||
}
|
||||
|
||||
|
@ -214,16 +210,12 @@ void WINAPI OutputDebugStringA( LPCSTR str )
|
|||
*/
|
||||
void WINAPI OutputDebugStringW( LPCWSTR str )
|
||||
{
|
||||
if (PROCESS_Current()->flags & PDB32_DEBUGGED)
|
||||
{
|
||||
struct send_debug_event_request *req = get_req_buffer();
|
||||
req->event.code = OUTPUT_DEBUG_STRING_EVENT;
|
||||
req->event.info.output_string.string = (void *)str;
|
||||
req->event.info.output_string.unicode = 1;
|
||||
req->event.info.output_string.length = (lstrlenW(str) + 1) * sizeof(WCHAR);
|
||||
server_call( REQ_SEND_DEBUG_EVENT );
|
||||
}
|
||||
|
||||
struct send_debug_event_request *req = get_req_buffer();
|
||||
req->event.code = OUTPUT_DEBUG_STRING_EVENT;
|
||||
req->event.info.output_string.string = (void *)str;
|
||||
req->event.info.output_string.unicode = 1;
|
||||
req->event.info.output_string.length = (lstrlenW(str) + 1) * sizeof(WCHAR);
|
||||
server_call_noerr( REQ_SEND_DEBUG_EVENT );
|
||||
TRACE("%s\n", debugstr_w(str));
|
||||
}
|
||||
|
||||
|
@ -235,3 +227,43 @@ void WINAPI OutputDebugString16( LPCSTR str )
|
|||
{
|
||||
OutputDebugStringA( str );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* DebugBreak (KERNEL32.181)
|
||||
*/
|
||||
void WINAPI DebugBreak(void)
|
||||
{
|
||||
DbgBreakPoint();
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* DebugBreak16 (KERNEL.203)
|
||||
*/
|
||||
void WINAPI DebugBreak16( CONTEXT86 *context )
|
||||
{
|
||||
#ifdef __i386__
|
||||
EXCEPTION_RECORD rec;
|
||||
|
||||
rec.ExceptionCode = EXCEPTION_BREAKPOINT;
|
||||
rec.ExceptionFlags = 0;
|
||||
rec.ExceptionRecord = NULL;
|
||||
rec.ExceptionAddress = GET_IP(context);
|
||||
rec.NumberParameters = 0;
|
||||
NtRaiseException( &rec, context, TRUE );
|
||||
#endif /* defined(__i386__) */
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* IsDebuggerPresent (KERNEL32)
|
||||
*/
|
||||
BOOL WINAPI IsDebuggerPresent(void)
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
struct get_process_info_request *req = get_req_buffer();
|
||||
req->handle = GetCurrentProcess();
|
||||
if (!server_call( REQ_GET_PROCESS_INFO )) ret = req->debugged;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -371,6 +371,7 @@ BOOL PROCESS_Init( BOOL win32 )
|
|||
void PROCESS_Start(void)
|
||||
{
|
||||
struct init_process_done_request *req = get_req_buffer();
|
||||
int debugged;
|
||||
UINT cmdShow = SW_SHOWNORMAL;
|
||||
LPTHREAD_START_ROUTINE entry = NULL;
|
||||
PDB *pdb = PROCESS_Current();
|
||||
|
@ -455,9 +456,10 @@ void PROCESS_Start(void)
|
|||
req->module = (void *)pModule->module32;
|
||||
req->entry = entry;
|
||||
server_call( REQ_INIT_PROCESS_DONE );
|
||||
debugged = req->debugged;
|
||||
|
||||
/* Send all required start-up debugger events */
|
||||
if ( type == PROC_WIN32 && (pdb->flags & PDB32_DEBUGGED) )
|
||||
if (type == PROC_WIN32 && debugged)
|
||||
{
|
||||
EnterCriticalSection( &pdb->crit_section );
|
||||
MODULE_SendLoadDLLEvents();
|
||||
|
@ -498,7 +500,7 @@ void PROCESS_Start(void)
|
|||
|
||||
case PROC_WIN32:
|
||||
TRACE_(relay)( "Starting Win32 process (entryproc=%p)\n", entry );
|
||||
if (pdb->flags & PDB32_DEBUGGED) DebugBreak();
|
||||
if (debugged) DbgBreakPoint();
|
||||
/* FIXME: should use _PEB as parameter for NT 3.5 programs !
|
||||
* Dunno about other OSs */
|
||||
ExitProcess( entry(NULL) );
|
||||
|
@ -563,10 +565,6 @@ PDB *PROCESS_Create( NE_MODULE *pModule, HFILE hFile, LPCSTR cmd_line, LPCSTR en
|
|||
info->hThread = req->thandle;
|
||||
info->dwThreadId = (DWORD)req->tid;
|
||||
|
||||
if ((flags & (DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS)) ||
|
||||
((parent->flags & PDB32_DEBUGGED) && !(flags & DEBUG_ONLY_THIS_PROCESS)))
|
||||
pdb->flags |= PDB32_DEBUGGED;
|
||||
|
||||
if (pModule->module32) /* Win32 process */
|
||||
{
|
||||
IMAGE_OPTIONAL_HEADER *header = &PE_HEADER(pModule->module32)->OptionalHeader;
|
||||
|
|
|
@ -366,6 +366,7 @@ void kill_debugged_processes( struct thread *debugger, int exit_code )
|
|||
static void get_process_info( struct process *process, struct get_process_info_request *req )
|
||||
{
|
||||
req->pid = process;
|
||||
req->debugged = (process->debugger != 0);
|
||||
req->exit_code = process->exit_code;
|
||||
req->priority = process->priority;
|
||||
req->process_affinity = process->affinity;
|
||||
|
@ -398,6 +399,11 @@ static void read_process_memory( struct process *process, const int *addr,
|
|||
set_error( STATUS_INVALID_PARAMETER );
|
||||
return;
|
||||
}
|
||||
if (!thread) /* process is dead */
|
||||
{
|
||||
set_error( STATUS_ACCESS_DENIED );
|
||||
return;
|
||||
}
|
||||
suspend_thread( thread, 0 );
|
||||
if (thread->attached)
|
||||
{
|
||||
|
@ -439,6 +445,11 @@ static void write_process_memory( struct process *process, int *addr, size_t len
|
|||
set_error( STATUS_INVALID_PARAMETER );
|
||||
return;
|
||||
}
|
||||
if (!thread) /* process is dead */
|
||||
{
|
||||
set_error( STATUS_ACCESS_DENIED );
|
||||
return;
|
||||
}
|
||||
suspend_thread( thread, 0 );
|
||||
if (thread->attached)
|
||||
{
|
||||
|
@ -591,6 +602,7 @@ DECL_HANDLER(init_process_done)
|
|||
release_object( process->init_event );
|
||||
process->init_event = NULL;
|
||||
if (current->suspend + current->process->suspend > 0) stop_thread( current );
|
||||
req->debugged = (current->process->debugger != 0);
|
||||
}
|
||||
|
||||
/* open a handle to a process */
|
||||
|
|
|
@ -262,6 +262,11 @@ static void dump_init_process_done_request( const struct init_process_done_reque
|
|||
fprintf( stderr, " entry=%p", req->entry );
|
||||
}
|
||||
|
||||
static void dump_init_process_done_reply( const struct init_process_done_request *req )
|
||||
{
|
||||
fprintf( stderr, " debugged=%d", req->debugged );
|
||||
}
|
||||
|
||||
static void dump_init_thread_request( const struct init_thread_request *req )
|
||||
{
|
||||
fprintf( stderr, " unix_pid=%d,", req->unix_pid );
|
||||
|
@ -300,6 +305,7 @@ static void dump_get_process_info_request( const struct get_process_info_request
|
|||
static void dump_get_process_info_reply( const struct get_process_info_request *req )
|
||||
{
|
||||
fprintf( stderr, " pid=%p,", req->pid );
|
||||
fprintf( stderr, " debugged=%d,", req->debugged );
|
||||
fprintf( stderr, " exit_code=%d,", req->exit_code );
|
||||
fprintf( stderr, " priority=%d,", req->priority );
|
||||
fprintf( stderr, " process_affinity=%d,", req->process_affinity );
|
||||
|
@ -1329,7 +1335,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
|
|||
(dump_func)dump_new_thread_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_init_process_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_init_process_done_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_get_thread_buffer_reply,
|
||||
(dump_func)0,
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "process.h"
|
||||
#include "thread.h"
|
||||
#include "stackframe.h"
|
||||
#include "debugger.h"
|
||||
#include "debugtools.h"
|
||||
|
||||
DEFAULT_DEBUG_CHANNEL(seh)
|
||||
|
@ -73,7 +72,9 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
|
|||
char message[80];
|
||||
PDB *pdb = PROCESS_Current();
|
||||
|
||||
if (pdb->flags & PDB32_DEBUGGED) return EXCEPTION_CONTINUE_SEARCH;
|
||||
if (DEBUG_SendExceptionEvent( epointers->ExceptionRecord, FALSE,
|
||||
epointers->ContextRecord ) == DBG_CONTINUE)
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
|
||||
if (pdb->top_filter)
|
||||
{
|
||||
|
@ -81,11 +82,6 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
|
|||
if (ret != EXCEPTION_CONTINUE_SEARCH) return ret;
|
||||
}
|
||||
|
||||
/* FIXME: does not belong here */
|
||||
if (wine_debugger( epointers->ExceptionRecord,
|
||||
epointers->ContextRecord, FALSE ) == DBG_CONTINUE)
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
|
||||
/* FIXME: Should check the current error mode */
|
||||
|
||||
sprintf( message, "Unhandled exception 0x%08lx at address 0x%08lx.",
|
||||
|
|
|
@ -293,15 +293,6 @@ BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE ports,DWORD bufsize,LPDWORD
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* IsDebuggerPresent [KERNEL32.827]
|
||||
*
|
||||
*/
|
||||
BOOL WINAPI IsDebuggerPresent() {
|
||||
FIXME(" ... no debuggers yet, returning FALSE.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* OpenDesktop32A [USER32.408]
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue