Removed PDB32_DEBUGGED flag and send all debug events unconditionally.
Implemented IsDebuggerPresent().
diff --git a/scheduler/debugger.c b/scheduler/debugger.c
index f8357d1..4479368 100644
--- a/scheduler/debugger.c
+++ b/scheduler/debugger.c
@@ -195,16 +195,12 @@
*/
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 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 @@
{
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;
+}
diff --git a/scheduler/process.c b/scheduler/process.c
index a1b68f7..b7dc85a 100644
--- a/scheduler/process.c
+++ b/scheduler/process.c
@@ -371,6 +371,7 @@
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 @@
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 @@
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 @@
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;