- 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.

svn path=/trunk/; revision=24986
This commit is contained in:
Alex Ionescu 2006-11-30 09:22:07 +00:00
parent ef1120e56b
commit cca4a71164
4 changed files with 22 additions and 19 deletions

View file

@ -243,7 +243,7 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
break;
/* DLL Load */
case DbgLoadDllStateChange :
case DbgLoadDllStateChange:
/* Set the Win32 debug code */
DebugEvent->dwDebugEventCode = LOAD_DLL_DEBUG_EVENT;
@ -261,9 +261,9 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
/* 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 */

View file

@ -39,14 +39,12 @@ DbgkpSectionToFileHandle(IN PVOID Section)
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);

View file

@ -51,7 +51,6 @@ DbgkpQueueMessage(IN PEPROCESS Process,
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 @@ DbgkpQueueMessage(IN PEPROCESS Process,
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 @@ DbgkpPostFakeThreadMessages(IN PEPROCESS Process,
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 @@ DbgkpPostFakeThreadMessages(IN PEPROCESS Process,
}
/* 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 @@ NTAPI
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 @@ DbgkpOpenHandles(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
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 @@ ThreadScan:
{
/* 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 @@ NtWaitForDebugEvent(IN HANDLE DebugHandle,
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 @@ NtWaitForDebugEvent(IN HANDLE DebugHandle,
if (!NT_SUCCESS(Status)) break;
/* Check if we got an event */
if (GotEvent)
if (!GotEvent)
{
/* Check if we can wait again */
if (!SafeTimeOut.QuadPart)

View file

@ -929,6 +929,10 @@ IopQueryNameFile(IN PVOID ObjectBody,
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 @@ IopQueryNameFile(IN PVOID ObjectBody,
/* Copy the information */
RtlCopyMemory(ObjectNameInfo,
LocalInfo,
LocalReturnLength > Length ?
(LocalReturnLength > Length) ?
Length : LocalReturnLength);
/* Set buffer pointer */