Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
Modified: trunk/reactos/ntoskrnl/ps/idle.c
Modified: trunk/reactos/ntoskrnl/ps/process.c
Modified: trunk/reactos/ntoskrnl/ps/thread.c
--- trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-03-14 11:34:02 UTC (rev 14057)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-03-14 13:18:29 UTC (rev 14058)
@@ -15,6 +15,7 @@
#define NDEBUG
#include <internal/debug.h>
+extern PEPROCESS PsIdleProcess;
extern ULONG NtGlobalFlag; /* FIXME: it should go in a ddk/?.h */
ULONGLONG STDCALL KeQueryInterruptTime(VOID);
@@ -611,13 +612,20 @@
SpiCur->ProcessName.Buffer = (void*)(pCur+curSize);
// copy name to the end of the struct
- RtlInitAnsiString(&imgName, pr->ImageFileName);
- RtlAnsiStringToUnicodeString(&SpiCur->ProcessName, &imgName, FALSE);
+ if(pr != PsIdleProcess)
+ {
+ RtlInitAnsiString(&imgName, pr->ImageFileName);
+ RtlAnsiStringToUnicodeString(&SpiCur->ProcessName, &imgName, FALSE);
+ }
+ else
+ {
+ RtlInitUnicodeString(&SpiCur->ProcessName, NULL);
+ }
SpiCur->BasePriority = pr->Pcb.BasePriority;
SpiCur->ProcessId = pr->UniqueProcessId;
SpiCur->InheritedFromProcessId = pr->InheritedFromUniqueProcessId;
- SpiCur->HandleCount = ObpGetHandleCountByHandleTable(pr->ObjectTable);
+ SpiCur->HandleCount = (pr->ObjectTable ? ObpGetHandleCountByHandleTable(pr->ObjectTable) : 0);
SpiCur->VmCounters.PeakVirtualSize = pr->PeakVirtualSize;
SpiCur->VmCounters.VirtualSize = pr->VirtualSize.QuadPart;
SpiCur->VmCounters.PageFaultCount = pr->LastFaultCount;
@@ -670,10 +678,6 @@
} while ((pr != syspr) && (pr != NULL));
*ReqSize = ovlSize;
- if (pr != NULL)
- {
- ObDereferenceObject(pr);
- }
return (STATUS_SUCCESS);
}
@@ -849,7 +853,7 @@
do
{
- hCount = hCount + ObpGetHandleCountByHandleTable(pr->ObjectTable);
+ hCount = hCount + (pr->ObjectTable ? ObpGetHandleCountByHandleTable(pr->ObjectTable) : 0);
pr = PsGetNextProcess(pr);
if ((pr == syspr) || (pr == NULL))
@@ -858,11 +862,6 @@
DPRINT("SystemHandleInformation 2\n");
- if (pr != NULL)
- {
- ObDereferenceObject(pr);
- }
-
curSize = sizeof(SYSTEM_HANDLE_INFORMATION)+
( (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO) * hCount) -
(sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO) ));
@@ -883,9 +882,9 @@
do
{
- int Count = 0, HandleCount = 0;
+ int Count = 0, HandleCount;
- HandleCount = ObpGetHandleCountByHandleTable(pr->ObjectTable);
+ HandleCount = (pr->ObjectTable ? ObpGetHandleCountByHandleTable(pr->ObjectTable) : 0);
for (Count = 0; HandleCount > 0 ; HandleCount--)
{
@@ -900,12 +899,6 @@
break;
} while ((pr != syspr) && (pr != NULL));
-
- if (pr != NULL)
- {
- ObDereferenceObject(pr);
- }
-
DPRINT("SystemHandleInformation 4\n");
return (STATUS_SUCCESS);
--- trunk/reactos/ntoskrnl/ps/idle.c 2005-03-14 11:34:02 UTC (rev 14057)
+++ trunk/reactos/ntoskrnl/ps/idle.c 2005-03-14 13:18:29 UTC (rev 14058)
@@ -16,6 +16,8 @@
/* GLOBALS *******************************************************************/
+extern PEPROCESS PsIdleProcess;
+
/* FUNCTIONS *****************************************************************/
/** System idle thread procedure
@@ -53,8 +55,8 @@
NTSTATUS Status;
PETHREAD IdleThread;
KIRQL oldIrql;
-
- Status = PsInitializeThread(NULL,
+
+ Status = PsInitializeThread(PsIdleProcess,
&IdleThread,
NULL,
KernelMode,
--- trunk/reactos/ntoskrnl/ps/process.c 2005-03-14 11:34:02 UTC (rev 14057)
+++ trunk/reactos/ntoskrnl/ps/process.c 2005-03-14 13:18:29 UTC (rev 14058)
@@ -19,6 +19,7 @@
VOID INIT_FUNCTION PsInitClientIDManagment(VOID);
PEPROCESS EXPORTED PsInitialSystemProcess = NULL;
+PEPROCESS PsIdleProcess = NULL;
POBJECT_TYPE EXPORTED PsProcessType = NULL;
@@ -120,34 +121,36 @@
if (OldProcess == NULL)
{
- Status = ObReferenceObjectByPointer(PsInitialSystemProcess,
+ Status = ObReferenceObjectByPointer(PsIdleProcess,
PROCESS_ALL_ACCESS,
PsProcessType,
KernelMode);
if (!NT_SUCCESS(Status))
{
- CPRINT("PsGetNextProcess(): ObReferenceObjectByPointer failed for PsInitialSystemProcess\n");
+ CPRINT("PsGetNextProcess(): ObReferenceObjectByPointer failed for PsIdleProcess\n");
KEBUGCHECK(0);
}
- return PsInitialSystemProcess;
+ return PsIdleProcess;
}
ExAcquireFastMutex(&PspActiveProcessMutex);
NextProcess = OldProcess;
while (1)
{
- if (NextProcess->ProcessListEntry.Blink == &PsActiveProcessHead)
+ PLIST_ENTRY Flink = (NextProcess == PsIdleProcess ? PsActiveProcessHead.Flink :
+ NextProcess->ProcessListEntry.Flink);
+ if (Flink != &PsActiveProcessHead)
{
- NextProcess = CONTAINING_RECORD(PsActiveProcessHead.Blink,
- EPROCESS,
- ProcessListEntry);
+ NextProcess = CONTAINING_RECORD(Flink,
+ EPROCESS,
+ ProcessListEntry);
}
else
{
- NextProcess = CONTAINING_RECORD(NextProcess->ProcessListEntry.Blink,
- EPROCESS,
- ProcessListEntry);
+ NextProcess = NULL;
+ break;
}
+
Status = ObReferenceObjectByPointer(NextProcess,
PROCESS_ALL_ACCESS,
PsProcessType,
@@ -162,8 +165,7 @@
}
else if (!NT_SUCCESS(Status))
{
- CPRINT("PsGetNextProcess(): ObReferenceObjectByPointer failed\n");
- KEBUGCHECK(0);
+ continue;
}
}
@@ -363,6 +365,44 @@
RtlZeroMemory(PiLoadImageNotifyRoutine, sizeof(PiLoadImageNotifyRoutine));
/*
+ * Initialize the idle process
+ */
+ Status = ObCreateObject(KernelMode,
+ PsProcessType,
+ NULL,
+ KernelMode,
+ NULL,
+ sizeof(EPROCESS),
+ 0,
+ 0,
+ (PVOID*)&PsIdleProcess);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create the idle process object, Status: 0x%x\n", Status);
+ KEBUGCHECK(0);
+ return;
+ }
+
+ RtlZeroMemory(PsIdleProcess, sizeof(EPROCESS));
+
+ PsIdleProcess->Pcb.Affinity = 0xFFFFFFFF;
+ PsIdleProcess->Pcb.IopmOffset = 0xffff;
+ PsIdleProcess->Pcb.LdtDescriptor[0] = 0;
+ PsIdleProcess->Pcb.LdtDescriptor[1] = 0;
+ PsIdleProcess->Pcb.BasePriority = PROCESS_PRIO_IDLE;
+ PsIdleProcess->Pcb.ThreadQuantum = 6;
+ InitializeListHead(&PsIdleProcess->Pcb.ThreadListHead);
+ InitializeListHead(&PsIdleProcess->ThreadListHead);
+ InitializeListHead(&PsIdleProcess->ProcessListEntry);
+ KeInitializeDispatcherHeader(&PsIdleProcess->Pcb.DispatcherHeader,
+ ProcessObject,
+ sizeof(EPROCESS),
+ FALSE);
+ PsIdleProcess->Pcb.DirectoryTableBase =
+ (LARGE_INTEGER)(LONGLONG)(ULONG)MmGetPageDirectory();
+ strcpy(PsInitialSystemProcess->ImageFileName, "Idle");
+
+ /*
* Initialize the system process
*/
Status = ObCreateObject(KernelMode,
@@ -376,7 +416,9 @@
(PVOID*)&PsInitialSystemProcess);
if (!NT_SUCCESS(Status))
{
- return;
+ DPRINT1("Failed to create the system process object, Status: 0x%x\n", Status);
+ KEBUGCHECK(0);
+ return;
}
/* System threads may run on any processor. */
@@ -886,7 +928,7 @@
Process->Win32WindowStation = (HANDLE)0;
ExAcquireFastMutex(&PspActiveProcessMutex);
- InsertHeadList(&PsActiveProcessHead, &Process->ProcessListEntry);
+ InsertTailList(&PsActiveProcessHead, &Process->ProcessListEntry);
InitializeListHead(&Process->ThreadListHead);
ExReleaseFastMutex(&PspActiveProcessMutex);
--- trunk/reactos/ntoskrnl/ps/thread.c 2005-03-14 11:34:02 UTC (rev 14057)
+++ trunk/reactos/ntoskrnl/ps/thread.c 2005-03-14 13:18:29 UTC (rev 14058)
@@ -28,6 +28,7 @@
/* GLOBALS ******************************************************************/
extern LIST_ENTRY PsActiveProcessHead;
+extern PEPROCESS PsIdleProcess;
POBJECT_TYPE EXPORTED PsThreadType = NULL;
@@ -703,7 +704,7 @@
PETHREAD IdleThread;
PKPRCB Prcb = ((PKPCR)((ULONG_PTR)KPCR_BASE + Id * PAGE_SIZE))->Prcb;
- PsInitializeThread(NULL,
+ PsInitializeThread(PsIdleProcess,
&IdleThread,
NULL,
KernelMode,