Author: sginsberg
Date: Wed Jan 14 08:55:46 2009
New Revision: 38761
URL:
http://svn.reactos.org/svn/reactos?rev=38761&view=rev
Log:
- DBGK: Use flags instead of magic values for Debug Events -- names taken from
http://neitsabes.online.fr/dc/index.php?2007/12/04/7-ntqueryinformationproc…
Modified:
trunk/reactos/include/ndk/dbgktypes.h
trunk/reactos/ntoskrnl/dbgk/dbgkobj.c
Modified: trunk/reactos/include/ndk/dbgktypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/dbgktypes.h?re…
==============================================================================
--- trunk/reactos/include/ndk/dbgktypes.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/dbgktypes.h [iso-8859-1] Wed Jan 14 08:55:46 2009
@@ -32,6 +32,16 @@
#define DEBUG_OBJECT_ADD_REMOVE_PROCESS 0x0002
#define DEBUG_OBJECT_SET_INFORMATION 0x0004
#define DEBUG_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE |
0x0F)
+
+//
+// Debug Event Flags
+//
+#define DEBUG_EVENT_READ (0x01)
+#define DEBUG_EVENT_NOWAIT (0x02)
+#define DEBUG_EVENT_INACTIVE (0x04)
+#define DEBUG_EVENT_RELEASE (0x08)
+#define DEBUG_EVENT_PROTECT_FAILED (0x10)
+#define DEBUG_EVENT_SUSPEND (0x20)
//
// Debug Object Information Classes for NtQueryDebugObject
Modified: trunk/reactos/ntoskrnl/dbgk/dbgkobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/dbgkobj.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/dbgk/dbgkobj.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/dbgk/dbgkobj.c [iso-8859-1] Wed Jan 14 08:55:46 2009
@@ -53,7 +53,7 @@
Process, Thread, Message, Flags);
/* Check if we have to allocate a debug event */
- NewEvent = (Flags & 2) ? TRUE : FALSE;
+ NewEvent = (Flags & DEBUG_EVENT_NOWAIT) ? TRUE : FALSE;
if (NewEvent)
{
/* Allocate it */
@@ -63,7 +63,7 @@
if (!DebugEvent) return STATUS_INSUFFICIENT_RESOURCES;
/* Set flags */
- DebugEvent->Flags = Flags | 4;
+ DebugEvent->Flags = Flags | DEBUG_EVENT_INACTIVE;
/* Reference the thread and process */
ObReferenceObject(Thread);
@@ -428,17 +428,17 @@
DBGKTRACE(DBGK_OBJECT_DEBUG, "DebugEvent: %p\n", DebugEvent);
/* Check if we have to wake the thread */
- if (DebugEvent->Flags & 0x20) PsResumeThread(Thread, NULL);
+ if (DebugEvent->Flags & DEBUG_EVENT_SUSPEND) PsResumeThread(Thread, NULL);
/* Check if we had locked the thread */
- if (DebugEvent->Flags & 8)
+ if (DebugEvent->Flags & DEBUG_EVENT_RELEASE)
{
/* Unlock it */
ExReleaseRundownProtection(&Thread->RundownProtect);
}
/* Check if we have to wake up the event */
- if (DebugEvent->Flags & 2)
+ if (DebugEvent->Flags & DEBUG_EVENT_NOWAIT)
{
/* Otherwise, free the debug event */
DbgkpFreeDebugEvent(DebugEvent);
@@ -552,7 +552,7 @@
Status = DbgkpQueueMessage(Process,
Thread,
&ApiMessage,
- 2,
+ DEBUG_EVENT_NOWAIT,
DebugObject);
if (!NT_SUCCESS(Status))
{
@@ -621,7 +621,7 @@
if (ExAcquireRundownProtection(&ThisThread->RundownProtect))
{
/* Acquire worked, set flags */
- Flags = 0x8 | 0x2;
+ Flags = DEBUG_EVENT_RELEASE | DEBUG_EVENT_NOWAIT;
/* Check if this is a user thread */
if (!ThisThread->SystemThread)
@@ -630,14 +630,14 @@
if (NT_SUCCESS(PsSuspendThread(ThisThread, NULL)))
{
/* Remember this */
- Flags = 0x8 | 0x2 | 0x20;
+ Flags |= DEBUG_EVENT_SUSPEND;
}
}
}
else
{
/* Couldn't acquire rundown */
- Flags = 0x10 | 0x2;
+ Flags = DEBUG_EVENT_PROTECT_FAILED | DEBUG_EVENT_NOWAIT;
}
/* Clear the API Message */
@@ -645,7 +645,7 @@
/* Check if this is the first thread */
if ((IsFirstThread) &&
- !(Flags & 0x10) &&
+ !(Flags & DEBUG_EVENT_PROTECT_FAILED) &&
!(ThisThread->SystemThread) &&
(ThisThread->GrantedAccess))
{
@@ -1279,7 +1279,7 @@
DebugEvent->BackoutThread, PsGetCurrentThread());
/* Check for if the debug event queue needs flushing */
- if ((DebugEvent->Flags & 4) &&
+ if ((DebugEvent->Flags & DEBUG_EVENT_INACTIVE) &&
(DebugEvent->BackoutThread == PsGetCurrentThread()))
{
/* Get the event's thread */
@@ -1293,7 +1293,7 @@
(!EventThread->SystemThread))
{
/* Check if we couldn't acquire rundown for it */
- if (DebugEvent->Flags & 0x10)
+ if (DebugEvent->Flags & DEBUG_EVENT_PROTECT_FAILED)
{
/* Set the skip termination flag */
PspSetCrossThreadFlag(EventThread, CT_SKIP_CREATION_MSG_BIT);
@@ -1308,7 +1308,7 @@
if (DoSetEvent)
{
/* Do it */
- DebugEvent->Flags &= ~4;
+ DebugEvent->Flags &= ~DEBUG_EVENT_INACTIVE;
KeSetEvent(&DebugObject->EventsPresent,
IO_NO_INCREMENT,
FALSE);
@@ -1330,10 +1330,10 @@
}
/* Check if the lock is held */
- if (DebugEvent->Flags & 8)
+ if (DebugEvent->Flags & DEBUG_EVENT_RELEASE)
{
/* Release it */
- DebugEvent->Flags &= ~8;
+ DebugEvent->Flags &= ~DEBUG_EVENT_RELEASE;
ExReleaseRundownProtection(&EventThread->RundownProtect);
}
}
@@ -1569,7 +1569,7 @@
if (NeedsWake)
{
/* Wake it up and break out */
- DebugEvent->Flags &= ~4;
+ DebugEvent->Flags &= ~DEBUG_EVENT_INACTIVE;
KeSetEvent(&DebugEvent->ContinueEvent,
IO_NO_INCREMENT,
FALSE);
@@ -1578,7 +1578,7 @@
/* Compare thread ID and flag */
if ((DebugEvent->ClientId.UniqueThread ==
- AppClientId->UniqueThread) && (DebugEvent->Flags
& 1))
+ AppClientId->UniqueThread) && (DebugEvent->Flags
& DEBUG_EVENT_READ))
{
/* Remove the event from the list */
RemoveEntryList(NextEntry);
@@ -1931,7 +1931,7 @@
DebugEvent, DebugEvent->Flags);
/* Check flags */
- if (!(DebugEvent->Flags & (4 | 1)))
+ if (!(DebugEvent->Flags & (DEBUG_EVENT_INACTIVE |
DEBUG_EVENT_READ)))
{
/* We got an event */
GotEvent = TRUE;
@@ -1950,7 +1950,7 @@
DebugEvent->ClientId.UniqueProcess)
{
/* Found it, break out */
- DebugEvent->Flags |= 4;
+ DebugEvent->Flags |= DEBUG_EVENT_INACTIVE;
DebugEvent->BackoutThread = NULL;
GotEvent = FALSE;
break;
@@ -1982,7 +1982,7 @@
DebugEvent);
/* Set flag */
- DebugEvent->Flags |= 1;
+ DebugEvent->Flags |= DEBUG_EVENT_READ;
}
else
{
@@ -2049,5 +2049,3 @@
/* Return status */
return Status;
}
-
-/* EOF */