first PID is 0, separate idle to system
This commit is contained in:
1 parent
0d7f71b693
commit
db175ab20a
7 files changed
+84
-25
No files matched your search
@@ -14,7 +14,8 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
static LIST_ENTRY gProcessList;
|
||||
static SPINLOCK gProcessListLock;
|
||||
static uint32_t gNextProcessId = 1;
|
||||
static uint32_t gNextProcessId = 0;
|
||||
static PROCESS* gSystemProcess = (PROCESS*)0;
|
||||
|
||||
static void KiProcessInit(void) {
|
||||
static int inited = 0;
|
||||
@@ -38,6 +39,29 @@ PROCESS* KeGetCurrentProcess(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PROCESS* KeGetSystemProcess(void) {
|
||||
return gSystemProcess;
|
||||
}
|
||||
|
||||
KSTATUS KeCreateSystemProcess(PROCESS** out) {
|
||||
if (!out) return STATUS_INVALID_PARAMETER;
|
||||
if (gSystemProcess) {
|
||||
*out = gSystemProcess;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
PROCESS* proc = (PROCESS*)0;
|
||||
KSTATUS s = KeCreateProcess("system", &proc);
|
||||
if (!KSUCCESS(s)) {
|
||||
*out = (PROCESS*)0;
|
||||
return s;
|
||||
}
|
||||
|
||||
gSystemProcess = proc;
|
||||
*out = proc;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
size_t KeCopyProcessIds(uint32_t* pidsOut, size_t maxCount) {
|
||||
KiProcessInit();
|
||||
|
||||
@@ -59,6 +83,9 @@ size_t KeCopyProcessIds(uint32_t* pidsOut, size_t maxCount) {
|
||||
static void KiProcessDestroy(OBJECT* obj) {
|
||||
PROCESS* proc = CONTAINING_RECORD(obj, PROCESS, Header);
|
||||
|
||||
if (proc == gSystemProcess)
|
||||
gSystemProcess = (PROCESS*)0;
|
||||
|
||||
// Release all remaining handles.
|
||||
for (int i = 1; i < HANDLE_TABLE_SIZE; i++) {
|
||||
if (proc->Handles[i]) {
|
||||
|
||||
Reference in new issue
Block a user