Use official THREAD_STATE enumeration for thread states

svn path=/trunk/; revision=14671
This commit is contained in:
Alex Ionescu 2005-04-18 15:49:57 +00:00
parent 6733de66c9
commit 610dd8e8bc
16 changed files with 77 additions and 70 deletions

View file

@ -338,7 +338,7 @@ typedef struct _SYSTEM_THREAD_INFORMATION
KPRIORITY Priority; KPRIORITY Priority;
LONG BasePriority; LONG BasePriority;
ULONG ContextSwitches; ULONG ContextSwitches;
ULONG ThreadState; LONG ThreadState;
KWAIT_REASON WaitReason; KWAIT_REASON WaitReason;
} SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION; } SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;

View file

@ -878,10 +878,10 @@ KdbpCmdThread(ULONG Argc, PCHAR Argv[])
ULONG Eip; ULONG Eip;
ULONG ul = 0; ULONG ul = 0;
PCHAR State, pend, str1, str2; PCHAR State, pend, str1, str2;
STATIC CONST PCHAR ThreadStateToString[THREAD_STATE_MAX] = STATIC CONST PCHAR ThreadStateToString[DeferredReady+1] =
{ "Initialized", "Ready", "Running", { "Initialized", "Ready", "Running",
"Suspended", "Frozen", "Terminated1", "Standby", "Terminated", "Waiting",
"Terminated2", "Blocked" }; "Transition", "DeferredReady" };
ASSERT(KdbCurrentProcess != NULL); ASSERT(KdbCurrentProcess != NULL);
if (Argc >= 2 && _stricmp(Argv[1], "list") == 0) if (Argc >= 2 && _stricmp(Argv[1], "list") == 0)
@ -943,7 +943,7 @@ KdbpCmdThread(ULONG Argc, PCHAR Argv[])
if (Ebp != NULL) /* FIXME: Should we attach to the process to read Ebp[1]? */ if (Ebp != NULL) /* FIXME: Should we attach to the process to read Ebp[1]? */
KdbpSafeReadMemory(&Eip, Ebp + 1, sizeof (Eip));; KdbpSafeReadMemory(&Eip, Ebp + 1, sizeof (Eip));;
} }
if (Thread->Tcb.State < THREAD_STATE_MAX) if (Thread->Tcb.State < (DeferredReady + 1))
State = ThreadStateToString[Thread->Tcb.State]; State = ThreadStateToString[Thread->Tcb.State];
else else
State = "Unknown"; State = "Unknown";
@ -1001,7 +1001,7 @@ KdbpCmdThread(ULONG Argc, PCHAR Argv[])
} }
} }
if (Thread->Tcb.State < THREAD_STATE_MAX) if (Thread->Tcb.State < (DeferredReady + 1))
State = ThreadStateToString[Thread->Tcb.State]; State = ThreadStateToString[Thread->Tcb.State];
else else
State = "Unknown"; State = "Unknown";

View file

@ -572,8 +572,10 @@ QSI_DEF(SystemProcessInformation)
return (STATUS_INFO_LENGTH_MISMATCH); // in case buffer size is too small return (STATUS_INFO_LENGTH_MISMATCH); // in case buffer size is too small
} }
DPRINT1("getting next proc\n");
syspr = PsGetNextProcess(NULL); syspr = PsGetNextProcess(NULL);
pr = syspr; pr = syspr;
DPRINT1("next proc: %x\n", pr);
pCur = (unsigned char *)Spi; pCur = (unsigned char *)Spi;
do do
@ -661,6 +663,7 @@ QSI_DEF(SystemProcessInformation)
// SpiCur->Threads[i].CreateTime = current->CreateTime; // SpiCur->Threads[i].CreateTime = current->CreateTime;
SpiCur->Threads[i].WaitTime = current->Tcb.WaitTime; SpiCur->Threads[i].WaitTime = current->Tcb.WaitTime;
SpiCur->Threads[i].StartAddress = (PVOID) current->StartAddress; SpiCur->Threads[i].StartAddress = (PVOID) current->StartAddress;
DPRINT1("cid: %d\n", current->Cid.UniqueThread);
SpiCur->Threads[i].ClientId = current->Cid; SpiCur->Threads[i].ClientId = current->Cid;
SpiCur->Threads[i].Priority = current->Tcb.Priority; SpiCur->Threads[i].Priority = current->Tcb.Priority;
SpiCur->Threads[i].BasePriority = current->Tcb.BasePriority; SpiCur->Threads[i].BasePriority = current->Tcb.BasePriority;
@ -672,6 +675,7 @@ QSI_DEF(SystemProcessInformation)
} }
pr = PsGetNextProcess(pr); pr = PsGetNextProcess(pr);
DPRINT1("next proc: %x\n", pr);
nThreads = 0; nThreads = 0;
if ((pr == syspr) || (pr == NULL)) if ((pr == syspr) || (pr == NULL))
{ {
@ -688,6 +692,7 @@ QSI_DEF(SystemProcessInformation)
} }
*ReqSize = ovlSize; *ReqSize = ovlSize;
DPRINT1("done\n");
return (STATUS_SUCCESS); return (STATUS_SUCCESS);
} }

View file

@ -49,6 +49,17 @@ struct _KEXCEPTION_FRAME;
#define IPI_REQUEST_DPC 2 #define IPI_REQUEST_DPC 2
#define IPI_REQUEST_FREEZE 3 #define IPI_REQUEST_FREEZE 3
typedef enum _KTHREAD_STATE {
Initialized,
Ready,
Running,
Standby,
Terminated,
Waiting,
Transition,
DeferredReady,
} THREAD_STATE, *PTHREAD_STATE;
/* MACROS *************************************************************************/ /* MACROS *************************************************************************/
#define KeEnterCriticalRegion(X) \ #define KeEnterCriticalRegion(X) \

View file

@ -496,15 +496,6 @@ STDCALL
PspInitializeProcessSecurity(PEPROCESS Process, PspInitializeProcessSecurity(PEPROCESS Process,
PEPROCESS Parent OPTIONAL); PEPROCESS Parent OPTIONAL);
#define THREAD_STATE_INITIALIZED (0)
#define THREAD_STATE_READY (1)
#define THREAD_STATE_RUNNING (2)
#define THREAD_STATE_SUSPENDED (3)
#define THREAD_STATE_FROZEN (4)
#define THREAD_STATE_TERMINATED_1 (5)
#define THREAD_STATE_TERMINATED_2 (6)
#define THREAD_STATE_BLOCKED (7)
#define THREAD_STATE_MAX (8)
/* /*

View file

@ -151,16 +151,15 @@ static CPU_REGISTER GspRegisters[NUMREGS] =
{ 4, FIELD_OFFSET (KTRAP_FRAME_X86, Gs), FIELD_OFFSET (CONTEXT, SegGs), TRUE } { 4, FIELD_OFFSET (KTRAP_FRAME_X86, Gs), FIELD_OFFSET (CONTEXT, SegGs), TRUE }
}; };
static PCHAR GspThreadStates[THREAD_STATE_MAX] = static PCHAR GspThreadStates[DeferredReady+1] =
{ { "Initialized",
"Initialized", /* THREAD_STATE_INITIALIZED */ "Ready",
"Ready", /* THREAD_STATE_READY */ "Running",
"Running", /* THREAD_STATE_RUNNING */ "Standby",
"Suspended", /* THREAD_STATE_SUSPENDED */ "Terminated",
"Frozen", /* THREAD_STATE_FROZEN */ "Waiting",
"Terminated 1", /* THREAD_STATE_TERMINATED_1 */ "Transition",
"Terminated 2", /* THREAD_STATE_TERMINATED_2 */ "DeferredReady"
"Blocked" /* THREAD_STATE_BLOCKED */
}; };
char * char *

View file

@ -313,13 +313,13 @@ KiInsertQueueApc(PKAPC Apc,
Thread->ApcState.KernelApcPending = TRUE; Thread->ApcState.KernelApcPending = TRUE;
/* Check the Thread State */ /* Check the Thread State */
if (Thread->State == THREAD_STATE_RUNNING) { if (Thread->State == Running) {
/* FIXME: Use IPI */ /* FIXME: Use IPI */
DPRINT ("Requesting APC Interrupt for Running Thread \n"); DPRINT ("Requesting APC Interrupt for Running Thread \n");
HalRequestSoftwareInterrupt(APC_LEVEL); HalRequestSoftwareInterrupt(APC_LEVEL);
} else if ((Thread->State == THREAD_STATE_BLOCKED) && (Thread->WaitIrql == PASSIVE_LEVEL) && } else if ((Thread->State == Waiting) && (Thread->WaitIrql == PASSIVE_LEVEL) &&
((Apc->NormalRoutine == NULL) || ((Apc->NormalRoutine == NULL) ||
((!Thread->KernelApcDisable) && (!Thread->ApcState.KernelApcInProgress)))) { ((!Thread->KernelApcDisable) && (!Thread->ApcState.KernelApcInProgress)))) {
@ -327,7 +327,7 @@ KiInsertQueueApc(PKAPC Apc,
KiAbortWaitThread(Thread, STATUS_KERNEL_APC, PriorityBoost); KiAbortWaitThread(Thread, STATUS_KERNEL_APC, PriorityBoost);
} }
} else if ((Thread->State == THREAD_STATE_BLOCKED) && } else if ((Thread->State == Waiting) &&
(Thread->WaitMode == UserMode) && (Thread->WaitMode == UserMode) &&
(Thread->Alertable)) { (Thread->Alertable)) {

View file

@ -491,7 +491,7 @@ KiQuantumEnd(VOID)
/* Dispatch the Thread */ /* Dispatch the Thread */
KeLowerIrql(DISPATCH_LEVEL); KeLowerIrql(DISPATCH_LEVEL);
KiDispatchThread(THREAD_STATE_READY); KiDispatchThread(Ready);
} }
/* /*

View file

@ -146,7 +146,7 @@ KeCreateApplicationProcessorIdleThread(ULONG Id)
NULL, NULL,
KernelMode, KernelMode,
FALSE); FALSE);
IdleThread->Tcb.State = THREAD_STATE_RUNNING; IdleThread->Tcb.State = Running;
IdleThread->Tcb.FreezeCount = 0; IdleThread->Tcb.FreezeCount = 0;
IdleThread->Tcb.Affinity = 1 << Id; IdleThread->Tcb.Affinity = 1 << Id;
IdleThread->Tcb.UserAffinity = 1 << Id; IdleThread->Tcb.UserAffinity = 1 << Id;

View file

@ -45,7 +45,7 @@ VOID
KiInsertIntoThreadList(KPRIORITY Priority, KiInsertIntoThreadList(KPRIORITY Priority,
PKTHREAD Thread) PKTHREAD Thread)
{ {
ASSERT(THREAD_STATE_READY == Thread->State); ASSERT(Ready == Thread->State);
ASSERT(Thread->Priority == Priority); ASSERT(Thread->Priority == Priority);
if (Priority >= MAXIMUM_PRIORITY || Priority < LOW_PRIORITY) { if (Priority >= MAXIMUM_PRIORITY || Priority < LOW_PRIORITY) {
@ -62,7 +62,7 @@ STATIC
VOID VOID
KiRemoveFromThreadList(PKTHREAD Thread) KiRemoveFromThreadList(PKTHREAD Thread)
{ {
ASSERT(THREAD_STATE_READY == Thread->State); ASSERT(Ready == Thread->State);
RemoveEntryList(&Thread->QueueListEntry); RemoveEntryList(&Thread->QueueListEntry);
if (IsListEmpty(&PriorityListHead[(ULONG)Thread->Priority])) { if (IsListEmpty(&PriorityListHead[(ULONG)Thread->Priority])) {
@ -89,12 +89,12 @@ KiScanThreadList(KPRIORITY Priority,
current = CONTAINING_RECORD(current_entry, KTHREAD, QueueListEntry); current = CONTAINING_RECORD(current_entry, KTHREAD, QueueListEntry);
if (current->State != THREAD_STATE_READY) { if (current->State != Ready) {
DPRINT1("%d/%d\n", &current, current->State); DPRINT1("%d/%d\n", &current, current->State);
} }
ASSERT(current->State == THREAD_STATE_READY); ASSERT(current->State == Ready);
if (current->Affinity & Affinity) { if (current->Affinity & Affinity) {
@ -123,7 +123,7 @@ KiDispatchThreadNoLock(ULONG NewThreadStatus)
CurrentThread->State = (UCHAR)NewThreadStatus; CurrentThread->State = (UCHAR)NewThreadStatus;
if (NewThreadStatus == THREAD_STATE_READY) { if (NewThreadStatus == Ready) {
KiInsertIntoThreadList(CurrentThread->Priority, KiInsertIntoThreadList(CurrentThread->Priority,
CurrentThread); CurrentThread);
@ -137,7 +137,7 @@ KiDispatchThreadNoLock(ULONG NewThreadStatus)
if (Candidate == CurrentThread) { if (Candidate == CurrentThread) {
Candidate->State = THREAD_STATE_RUNNING; Candidate->State = Ready;
KeReleaseDispatcherDatabaseLockFromDpcLevel(); KeReleaseDispatcherDatabaseLockFromDpcLevel();
return; return;
} }
@ -149,7 +149,7 @@ KiDispatchThreadNoLock(ULONG NewThreadStatus)
DPRINT("Scheduling %x(%d)\n",Candidate, CurrentPriority); DPRINT("Scheduling %x(%d)\n",Candidate, CurrentPriority);
Candidate->State = THREAD_STATE_RUNNING; Candidate->State = Ready;
OldThread = CurrentThread; OldThread = CurrentThread;
CurrentThread = Candidate; CurrentThread = Candidate;
@ -199,7 +199,7 @@ KiBlockThread(PNTSTATUS Status,
Thread->WaitBlockList = NULL; Thread->WaitBlockList = NULL;
/* Dispatch it and return status */ /* Dispatch it and return status */
KiDispatchThreadNoLock (THREAD_STATE_READY); KiDispatchThreadNoLock (Ready);
if (Status != NULL) *Status = STATUS_KERNEL_APC; if (Status != NULL) *Status = STATUS_KERNEL_APC;
} else { } else {
@ -211,7 +211,7 @@ KiBlockThread(PNTSTATUS Status,
Thread->WaitReason = WaitReason; Thread->WaitReason = WaitReason;
/* Dispatch it and return status */ /* Dispatch it and return status */
KiDispatchThreadNoLock(THREAD_STATE_BLOCKED); KiDispatchThreadNoLock(Waiting);
DPRINT("Dispatching Thread as blocked: %d\n", Thread->WaitStatus); DPRINT("Dispatching Thread as blocked: %d\n", Thread->WaitStatus);
if (Status != NULL) *Status = Thread->WaitStatus; if (Status != NULL) *Status = Thread->WaitStatus;
} }
@ -241,17 +241,16 @@ KiUnblockThread(PKTHREAD Thread,
PNTSTATUS WaitStatus, PNTSTATUS WaitStatus,
KPRIORITY Increment) KPRIORITY Increment)
{ {
if (THREAD_STATE_TERMINATED_1 == Thread->State || if (Terminated == Thread->State) {
THREAD_STATE_TERMINATED_2 == Thread->State) {
DPRINT("Can't unblock thread 0x%x because it's terminating\n", DPRINT("Can't unblock thread 0x%x because it's terminating\n",
Thread); Thread);
} else if (THREAD_STATE_READY == Thread->State || } else if (Ready == Thread->State ||
THREAD_STATE_RUNNING == Thread->State) { Running == Thread->State) {
DPRINT("Can't unblock thread 0x%x because it's %s\n", DPRINT("Can't unblock thread 0x%x because it's %s\n",
Thread, (Thread->State == THREAD_STATE_READY ? "ready" : "running")); Thread, (Thread->State == Ready ? "ready" : "running"));
} else { } else {
@ -279,7 +278,7 @@ KiUnblockThread(PKTHREAD Thread,
Thread->WaitStatus = *WaitStatus; Thread->WaitStatus = *WaitStatus;
} }
Thread->State = THREAD_STATE_READY; Thread->State = Ready;
KiInsertIntoThreadList(Thread->Priority, Thread); KiInsertIntoThreadList(Thread->Priority, Thread);
Processor = KeGetCurrentProcessorNumber(); Processor = KeGetCurrentProcessorNumber();
Affinity = Thread->Affinity; Affinity = Thread->Affinity;
@ -588,7 +587,7 @@ KeAlertResumeThread(IN PKTHREAD Thread)
if (Thread->Alerted[KernelMode] == FALSE) { if (Thread->Alerted[KernelMode] == FALSE) {
/* If it's Blocked, unblock if it we should */ /* If it's Blocked, unblock if it we should */
if (Thread->State == THREAD_STATE_BLOCKED && Thread->Alertable) { if (Thread->State == Waiting && Thread->Alertable) {
DPRINT("Aborting Wait\n"); DPRINT("Aborting Wait\n");
KiAbortWaitThread(Thread, STATUS_ALERTED, THREAD_ALERT_INCREMENT); KiAbortWaitThread(Thread, STATUS_ALERTED, THREAD_ALERT_INCREMENT);
@ -639,7 +638,7 @@ KeAlertThread(PKTHREAD Thread,
if (PreviousState == FALSE) { if (PreviousState == FALSE) {
/* If it's Blocked, unblock if it we should */ /* If it's Blocked, unblock if it we should */
if (Thread->State == THREAD_STATE_BLOCKED && if (Thread->State == Waiting &&
(AlertMode == KernelMode || Thread->WaitMode == AlertMode) && (AlertMode == KernelMode || Thread->WaitMode == AlertMode) &&
Thread->Alertable) { Thread->Alertable) {
@ -779,7 +778,7 @@ KeInitializeThread(PKPROCESS Process,
MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread, sizeof(ETHREAD)); MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread, sizeof(ETHREAD));
/* Set the Thread to initalized */ /* Set the Thread to initalized */
Thread->State = THREAD_STATE_INITIALIZED; Thread->State = Initialized;
/* The Native API function will initialize the TEB field later */ /* The Native API function will initialize the TEB field later */
Thread->Teb = NULL; Thread->Teb = NULL;
@ -1017,7 +1016,7 @@ KeRevertToUserAffinityThread(VOID)
/* We need to dispatch a new thread */ /* We need to dispatch a new thread */
CurrentThread->WaitIrql = OldIrql; CurrentThread->WaitIrql = OldIrql;
KiDispatchThreadNoLock(THREAD_STATE_READY); KiDispatchThreadNoLock(Ready);
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
} }
} }
@ -1080,7 +1079,7 @@ KeSetSystemAffinityThread(IN KAFFINITY Affinity)
/* We need to dispatch a new thread */ /* We need to dispatch a new thread */
CurrentThread->WaitIrql = OldIrql; CurrentThread->WaitIrql = OldIrql;
KiDispatchThreadNoLock(THREAD_STATE_READY); KiDispatchThreadNoLock(Ready);
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
} }
} }
@ -1146,7 +1145,7 @@ KeSetPriorityThread(PKTHREAD Thread,
CurrentThread = KeGetCurrentThread(); CurrentThread = KeGetCurrentThread();
if (Thread->State == THREAD_STATE_READY) { if (Thread->State == Ready) {
KiRemoveFromThreadList(Thread); KiRemoveFromThreadList(Thread);
Thread->BasePriority = Thread->Priority = (CHAR)Priority; Thread->BasePriority = Thread->Priority = (CHAR)Priority;
@ -1154,12 +1153,12 @@ KeSetPriorityThread(PKTHREAD Thread,
if (CurrentThread->Priority < Priority) { if (CurrentThread->Priority < Priority) {
KiDispatchThreadNoLock(THREAD_STATE_READY); KiDispatchThreadNoLock(Ready);
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
return (OldPriority); return (OldPriority);
} }
} else if (Thread->State == THREAD_STATE_RUNNING) { } else if (Thread->State == Running) {
Thread->BasePriority = Thread->Priority = (CHAR)Priority; Thread->BasePriority = Thread->Priority = (CHAR)Priority;
@ -1171,7 +1170,7 @@ KeSetPriorityThread(PKTHREAD Thread,
if (Thread == CurrentThread) { if (Thread == CurrentThread) {
KiDispatchThreadNoLock(THREAD_STATE_READY); KiDispatchThreadNoLock(Ready);
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
return (OldPriority); return (OldPriority);
@ -1229,14 +1228,14 @@ KeSetAffinityThread(PKTHREAD Thread,
Thread->Affinity = Affinity; Thread->Affinity = Affinity;
if (Thread->State == THREAD_STATE_RUNNING) { if (Thread->State == Running) {
ProcessorMask = 1 << KeGetCurrentKPCR()->ProcessorNumber; ProcessorMask = 1 << KeGetCurrentKPCR()->ProcessorNumber;
if (Thread == KeGetCurrentThread()) { if (Thread == KeGetCurrentThread()) {
if (!(Affinity & ProcessorMask)) { if (!(Affinity & ProcessorMask)) {
KiDispatchThreadNoLock(THREAD_STATE_READY); KiDispatchThreadNoLock(Ready);
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -1318,7 +1317,7 @@ KeTerminateThread(IN KPRIORITY Increment)
} }
/* Find a new Thread */ /* Find a new Thread */
KiDispatchThreadNoLock(THREAD_STATE_TERMINATED_1); KiDispatchThreadNoLock(Terminated);
} }
/* /*

View file

@ -53,7 +53,6 @@ ULONG KeMemoryMapRangeCount;
ULONG_PTR FirstKrnlPhysAddr; ULONG_PTR FirstKrnlPhysAddr;
ULONG_PTR LastKrnlPhysAddr; ULONG_PTR LastKrnlPhysAddr;
ULONG_PTR LastKernelAddress; ULONG_PTR LastKernelAddress;
volatile BOOLEAN Initialized = FALSE;
ULONG KeLargestCacheLine = 0x40; /* FIXME: Arch-specific */ ULONG KeLargestCacheLine = 0x40; /* FIXME: Arch-specific */

View file

@ -724,7 +724,7 @@ KiAbortWaitThread(PKTHREAD Thread,
/* If we are blocked, we must be waiting on something also */ /* If we are blocked, we must be waiting on something also */
DPRINT("KiAbortWaitThread: %x, Status: %x, %x \n", Thread, WaitStatus, Thread->WaitBlockList); DPRINT("KiAbortWaitThread: %x, Status: %x, %x \n", Thread, WaitStatus, Thread->WaitBlockList);
ASSERT((Thread->State == THREAD_STATE_BLOCKED) == (Thread->WaitBlockList != NULL)); ASSERT((Thread->State == Waiting) == (Thread->WaitBlockList != NULL));
/* Remove the Wait Blocks from the list */ /* Remove the Wait Blocks from the list */
DPRINT("Removing waits\n"); DPRINT("Removing waits\n");
@ -886,7 +886,7 @@ KeReleaseDispatcherDatabaseLock(KIRQL OldIrql)
if (!KeIsExecutingDpc() && OldIrql < DISPATCH_LEVEL && KeGetCurrentThread() != NULL && if (!KeIsExecutingDpc() && OldIrql < DISPATCH_LEVEL && KeGetCurrentThread() != NULL &&
KeGetCurrentThread() == KeGetCurrentPrcb()->IdleThread) { KeGetCurrentThread() == KeGetCurrentPrcb()->IdleThread) {
KiDispatchThreadNoLock(THREAD_STATE_READY); KiDispatchThreadNoLock(Ready);
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
} else { } else {

View file

@ -151,7 +151,7 @@ PspDeleteProcess(PVOID ObjectBody)
{ {
PEPROCESS Process = (PEPROCESS)ObjectBody; PEPROCESS Process = (PEPROCESS)ObjectBody;
DPRINT1("PiDeleteProcess(ObjectBody %x)\n",Process->UniqueProcessId); DPRINT("PiDeleteProcess(ObjectBody %x)\n", ObjectBody);
/* Delete the CID Handle */ /* Delete the CID Handle */
if(Process->UniqueProcessId != NULL) { if(Process->UniqueProcessId != NULL) {
@ -160,6 +160,7 @@ PspDeleteProcess(PVOID ObjectBody)
} }
/* KDB hook */ /* KDB hook */
DPRINT1("deleted: %d\n", Process->UniqueProcessId);
KDB_DELETEPROCESS_HOOK(Process); KDB_DELETEPROCESS_HOOK(Process);
/* Dereference the Token and release Memory Information */ /* Dereference the Token and release Memory Information */

View file

@ -363,6 +363,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
Status = PsCreateCidHandle(Process, Status = PsCreateCidHandle(Process,
PsProcessType, PsProcessType,
&Process->UniqueProcessId); &Process->UniqueProcessId);
DPRINT1("Created CID: %d\n", Process->UniqueProcessId);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
DPRINT1("Failed to create CID handle (unique process ID)! Status: 0x%x\n", Status); DPRINT1("Failed to create CID handle (unique process ID)! Status: 0x%x\n", Status);
@ -872,7 +873,7 @@ NtOpenProcess(OUT PHANDLE ProcessHandle,
if (ClientId->UniqueThread) if (ClientId->UniqueThread)
{ {
/* Get the Process */ /* Get the Process */
DPRINT("Opening by Thread ID: %x\n", ClientId->UniqueThread); DPRINT1("Opening by Thread ID: %x\n", ClientId->UniqueThread);
Status = PsLookupProcessThreadByCid(ClientId, Status = PsLookupProcessThreadByCid(ClientId,
&Process, &Process,
&Thread); &Thread);
@ -881,7 +882,7 @@ NtOpenProcess(OUT PHANDLE ProcessHandle,
else else
{ {
/* Get the Process */ /* Get the Process */
DPRINT("Opening by Process ID: %x\n", ClientId->UniqueProcess); DPRINT1("Opening by Process ID: %x\n", ClientId->UniqueProcess);
Status = PsLookupProcessByProcessId(ClientId->UniqueProcess, Status = PsLookupProcessByProcessId(ClientId->UniqueProcess,
&Process); &Process);
DPRINT("Found: %x\n", Process); DPRINT("Found: %x\n", Process);

View file

@ -104,7 +104,7 @@ PsInitThreadManagment(VOID)
ObpCreateTypeObject(PsThreadType); ObpCreateTypeObject(PsThreadType);
PsInitializeThread(NULL, &FirstThread, NULL, KernelMode, TRUE); PsInitializeThread(NULL, &FirstThread, NULL, KernelMode, TRUE);
FirstThread->Tcb.State = THREAD_STATE_RUNNING; FirstThread->Tcb.State = Running;
FirstThread->Tcb.FreezeCount = 0; FirstThread->Tcb.FreezeCount = 0;
FirstThread->Tcb.UserAffinity = (1 << 0); /* Set the affinity of the first thread to the boot processor */ FirstThread->Tcb.UserAffinity = (1 << 0); /* Set the affinity of the first thread to the boot processor */
FirstThread->Tcb.Affinity = (1 << 0); FirstThread->Tcb.Affinity = (1 << 0);

View file

@ -164,9 +164,9 @@ VOID PsDumpThreads(BOOLEAN IncludeSystem)
Thread->ThreadsProcess->UniqueProcessId, Thread->ThreadsProcess->UniqueProcessId,
Thread->Cid.UniqueThread, Thread->Cid.UniqueThread,
Thread->ThreadsProcess->ImageFileName); Thread->ThreadsProcess->ImageFileName);
if(Thread->Tcb.State == THREAD_STATE_READY || if(Thread->Tcb.State == Ready ||
Thread->Tcb.State == THREAD_STATE_SUSPENDED || Thread->Tcb.State == Standby ||
Thread->Tcb.State == THREAD_STATE_BLOCKED) Thread->Tcb.State == Waiting)
{ {
ULONG i = 0; ULONG i = 0;
PULONG Esp = (PULONG)Thread->Tcb.KernelStack; PULONG Esp = (PULONG)Thread->Tcb.KernelStack;
@ -567,6 +567,7 @@ NtCreateThread (
/* create a client id handle */ /* create a client id handle */
Status = PsCreateCidHandle ( Status = PsCreateCidHandle (
Thread, PsThreadType, &Thread->Cid.UniqueThread); Thread, PsThreadType, &Thread->Cid.UniqueThread);
DPRINT1("cid: %d\n", Thread->Cid.UniqueThread);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ObDereferenceObject(Thread); ObDereferenceObject(Thread);
@ -760,7 +761,7 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
NTSTATUS STDCALL NTSTATUS STDCALL
NtYieldExecution(VOID) NtYieldExecution(VOID)
{ {
KiDispatchThread(THREAD_STATE_READY); KiDispatchThread(Ready);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }