Author: ion Date: Thu Nov 30 23:37:21 2006 New Revision: 25004
URL: http://svn.reactos.org/svn/reactos?rev=25004&view=rev Log: - Implement support for DEBUG_PROCESS in CreateProcess so that processes can be started with a debugger (works and tested with a new test app). - We still seem to be suffering from a bug during certain debug event waits.
Modified: trunk/reactos/dll/win32/kernel32/process/create.c trunk/reactos/ntoskrnl/dbgk/debug.c
Modified: trunk/reactos/dll/win32/kernel32/process/create.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/process/... ============================================================================== --- trunk/reactos/dll/win32/kernel32/process/create.c (original) +++ trunk/reactos/dll/win32/kernel32/process/create.c Thu Nov 30 23:37:21 2006 @@ -642,7 +642,7 @@ UNICODE_STRING ApplicationName = {0}; OBJECT_ATTRIBUTES LocalObjectAttributes; POBJECT_ATTRIBUTES ObjectAttributes; - HANDLE hSection = NULL, hProcess = NULL, hThread = NULL; + HANDLE hSection = NULL, hProcess = NULL, hThread = NULL, hDebug = NULL; SECTION_IMAGE_INFORMATION SectionImageInfo; LPWSTR CurrentDirectory = NULL; LPWSTR CurrentDirectoryPart; @@ -1101,7 +1101,7 @@ }
/* FIXME: Check for Debugger */ - + /* FIXME: Check if Machine Type and SubSys Version Match */
/* We don't support POSIX or anything else for now */ @@ -1124,7 +1124,35 @@ ObjectAttributes = BasepConvertObjectAttributes(&LocalObjectAttributes, lpProcessAttributes, NULL); - + + /* Check if we're going to be debugged */ + if (dwCreationFlags & DEBUG_PROCESS) + { + /* FIXME: Set process flag */ + } + + /* Check if we're going to be debugged */ + if (dwCreationFlags & (DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS)) + { + /* Connect to DbgUi */ + Status = DbgUiConnectToDbg(); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to connect to DbgUI!\n"); + SetLastErrorByStatus(Status); + goto Cleanup; + } + + /* Get the debug object */ + hDebug = DbgUiGetThreadDebugObject(); + + /* Check if only this process will be debugged */ + if (dwCreationFlags & DEBUG_ONLY_THIS_PROCESS) + { + /* FIXME: Set process flag */ + } + } + /* Create the Process */ Status = NtCreateProcess(&hProcess, PROCESS_ALL_ACCESS, @@ -1132,7 +1160,7 @@ NtCurrentProcess(), bInheritHandles, hSection, - NULL, + hDebug, NULL); if(!NT_SUCCESS(Status)) {
Modified: trunk/reactos/ntoskrnl/dbgk/debug.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/debug.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/dbgk/debug.c (original) +++ trunk/reactos/ntoskrnl/dbgk/debug.c Thu Nov 30 23:37:21 2006 @@ -329,6 +329,7 @@ PAGED_CODE(); DBGKTRACE(DBGK_EXCEPTION_DEBUG, "ExceptionRecord: %p Port: %p\n", ExceptionRecord, DebugPort); + KEBUGCHECK(0);
/* Setup the API Message */ ApiMessage.h.u1.Length = sizeof(DBGKM_MSG) << 16 | @@ -339,7 +340,7 @@ /* Check if this is to be sent on the debug port */ if (DebugPort) { - /* Use the debug port, onless the thread is being hidden */ + /* Use the debug port, unless the thread is being hidden */ Port = PsGetCurrentThread()->HideFromDebugger ? NULL : Process->DebugPort; }