[ros-diffs] [ion] 24986: - Fix some bugs in NtWaitForDebugEvent which caused debug events to be sent in the wrong order and also more then one event to be sent at the same time (and thus some events skipped). - Test app now properly receives the "create process" event along with valid process/thread handles and the image base. No file handle sent yet because of the I/O Manager File Object bug. - There's still a bug in NtContinueDebugEvent due to wrong Client IDs being sent.

ion at svn.reactos.org ion at svn.reactos.org
Thu Nov 30 10:22:08 CET 2006


Author: ion
Date: Thu Nov 30 12:22:07 2006
New Revision: 24986

URL: http://svn.reactos.org/svn/reactos?rev=24986&view=rev
Log:
- Fix some bugs in NtWaitForDebugEvent which caused debug events to be sent in the wrong order and also more then one event to be sent at the same time (and thus some events skipped).
- Test app now properly receives the "create process" event along with valid process/thread handles and the image base. No file handle sent yet because of the I/O Manager File Object bug.
- There's still a bug in NtContinueDebugEvent due to wrong Client IDs being sent.

Modified:
    trunk/reactos/dll/ntdll/dbg/dbgui.c
    trunk/reactos/ntoskrnl/dbgk/dbgkutil.c
    trunk/reactos/ntoskrnl/dbgk/debug.c
    trunk/reactos/ntoskrnl/io/iomgr/file.c

Modified: trunk/reactos/dll/ntdll/dbg/dbgui.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/dbg/dbgui.c?rev=24986&r1=24985&r2=24986&view=diff
==============================================================================
--- trunk/reactos/dll/ntdll/dbg/dbgui.c (original)
+++ trunk/reactos/dll/ntdll/dbg/dbgui.c Thu Nov 30 12:22:07 2006
@@ -243,7 +243,7 @@
             break;
 
         /* DLL Load */
-        case DbgLoadDllStateChange :
+        case DbgLoadDllStateChange:
 
             /* Set the Win32 debug code */
             DebugEvent->dwDebugEventCode = LOAD_DLL_DEBUG_EVENT;
@@ -261,9 +261,9 @@
             /* Open the thread */
             InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
             Status = NtOpenThread(&ThreadHandle,
-                                 THREAD_QUERY_INFORMATION,
-                                 &ObjectAttributes,
-                                 &WaitStateChange->AppClientId);
+                                  THREAD_QUERY_INFORMATION,
+                                  &ObjectAttributes,
+                                  &WaitStateChange->AppClientId);
             if (NT_SUCCESS(Status))
             {
                 /* Query thread information */

Modified: trunk/reactos/ntoskrnl/dbgk/dbgkutil.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/dbgkutil.c?rev=24986&r1=24985&r2=24986&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/dbgk/dbgkutil.c (original)
+++ trunk/reactos/ntoskrnl/dbgk/dbgkutil.c Thu Nov 30 12:22:07 2006
@@ -39,14 +39,12 @@
                                NULL);
 
     /* Open the file */
-    DPRINT1("Trying to open: %wZ\n", &FileName->Name);
     Status = ZwOpenFile(&Handle,
                         GENERIC_READ | SYNCHRONIZE,
                         &ObjectAttributes,
                         &IoStatusBlock,
                         FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
                         FILE_SYNCHRONOUS_IO_NONALERT);
-    DPRINT1("Status: %lx\n", Status);
 
     /* Free the name and return the handle if we succeeded */
     ExFreePool(FileName);

Modified: trunk/reactos/ntoskrnl/dbgk/debug.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/debug.c?rev=24986&r1=24985&r2=24986&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/dbgk/debug.c (original)
+++ trunk/reactos/ntoskrnl/dbgk/debug.c Thu Nov 30 12:22:07 2006
@@ -51,7 +51,6 @@
     DBGKTRACE(DBGK_MESSAGE_DEBUG,
               "Process: %p Thread: %p Message: %p Flags: %lx\n",
               Process, Thread, Message, Flags);
-    DBGKTRACE(DBGK_MESSAGE_DEBUG, "MessageType: %lx\n", Message->ApiNumber);
 
     /* Check if we have to allocate a debug event */
     NewEvent = (Flags & 2) ? TRUE : FALSE;
@@ -134,6 +133,8 @@
         if (!DebugObject->DebuggerInactive)
         {
             /* Add the event into the object's list */
+            DBGKTRACE(DBGK_MESSAGE_DEBUG, "Inserting: %lx %p\n",
+                      DebugEvent, Message->ApiNumber);
             InsertTailList(&DebugObject->EventList, &DebugEvent->EventList);
 
             /* Check if we have to signal it */
@@ -653,17 +654,14 @@
         if (First)
         {
             /* So we'll start with the create process message */
-            DPRINT1("new proces!\n");
             ApiMessage.ApiNumber = DbgKmCreateProcessApi;
 
             /* Get the file handle */
-            DPRINT1("section object: %p\n", Process->SectionObject);
             if (Process->SectionObject)
             {
                 /* Use the section object */
                 CreateProcess->FileHandle =
                     DbgkpSectionToFileHandle(Process->SectionObject);
-                DPRINT1("FileHandle: %p\n", CreateProcess->FileHandle);
             }
             else
             {
@@ -672,9 +670,7 @@
             }
 
             /* Set the base address */
-            DPRINT1("SectionBaseAddress: %p\n", Process->SectionBaseAddress);
             CreateProcess->BaseOfImage = Process->SectionBaseAddress;
-            KEBUGCHECK(0);
 
             /* Get the NT Header */
             NtHeader = RtlImageNtHeader(Process->SectionBaseAddress);
@@ -803,6 +799,8 @@
 DbgkpConvertKernelToUserStateChange(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
                                     IN PDEBUG_EVENT DebugEvent)
 {
+    DBGKTRACE(DBGK_OBJECT_DEBUG, "DebugEvent: %p\n", DebugEvent);
+
     /* Start by copying the client ID */
     WaitStateChange->AppClientId = DebugEvent->ClientId;
 
@@ -954,8 +952,8 @@
     HANDLE Handle;
     PHANDLE DupHandle;
     PAGED_CODE();
-    DBGKTRACE(DBGK_OBJECT_DEBUG, "Process: %p Thread: %p\n",
-              Process, Thread);
+    DBGKTRACE(DBGK_OBJECT_DEBUG, "Process: %p Thread: %p State: %lx\n",
+              Process, Thread, WaitStateChange->NewState);
 
     /* Check which state this is */
     switch (WaitStateChange->NewState)
@@ -1272,11 +1270,12 @@
     {
         /* Get the debug event */
         DebugEvent = CONTAINING_RECORD(NextEntry, DEBUG_EVENT, EventList);
-        DBGKTRACE(DBGK_PROCESS_DEBUG, "DebugEvent: %p Flags: %lx\n",
-                  DebugEvent, DebugEvent->Flags);
+        DBGKTRACE(DBGK_PROCESS_DEBUG, "DebugEvent: %p Flags: %lx TH: %p/%p\n",
+                  DebugEvent, DebugEvent->Flags,
+                  DebugEvent->BackoutThread, PsGetCurrentThread());
 
         /* Check for if the debug event queue needs flushing */
-        if ((DebugEvent->Flags & 4) &
+        if ((DebugEvent->Flags & 4) &&
             (DebugEvent->BackoutThread == PsGetCurrentThread()))
         {
             /* Get the event's thread */
@@ -1905,6 +1904,8 @@
                 DebugEvent = CONTAINING_RECORD(NextEntry,
                                                DEBUG_EVENT,
                                                EventList);
+                DBGKTRACE(DBGK_PROCESS_DEBUG, "DebugEvent: %p Flags: %lx\n",
+                          DebugEvent, DebugEvent->Flags);
 
                 /* Check flags */
                 if (!(DebugEvent->Flags & (4 | 1)))
@@ -1973,7 +1974,7 @@
         if (!NT_SUCCESS(Status)) break;
 
         /* Check if we got an event */
-        if (GotEvent)
+        if (!GotEvent)
         {
             /* Check if we can wait again */
             if (!SafeTimeOut.QuadPart)

Modified: trunk/reactos/ntoskrnl/io/iomgr/file.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/file.c?rev=24986&r1=24985&r2=24986&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/file.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/file.c Thu Nov 30 12:22:07 2006
@@ -929,6 +929,10 @@
     if (!LocalInfo) return STATUS_INSUFFICIENT_RESOURCES;
 
     /* Query the name */
+    DPRINT("Do. Drv, DrvName: %p %p %wZ\n",
+           FileObject->DeviceObject,
+           FileObject->DeviceObject->DriverObject,
+           &FileObject->DeviceObject->DriverObject->DriverName);
     Status = ObQueryNameString(FileObject->DeviceObject,
                                LocalInfo,
                                Length,
@@ -943,7 +947,7 @@
     /* Copy the information */
     RtlCopyMemory(ObjectNameInfo,
                   LocalInfo,
-                  LocalReturnLength > Length ?
+                  (LocalReturnLength > Length) ?
                   Length : LocalReturnLength);
 
     /* Set buffer pointer */




More information about the Ros-diffs mailing list