Move removing process from active list to PspDeleteProcess instead of PspExitProcess. This way we don't have to do it manually after ObInsertObject failure in PspCreateProces. Also, set the Process Query Time at the end of Process Creation, since the process doesn't really exist before then. Thanks to Hartmut for finding the bugs.
Modified: trunk/reactos/ntoskrnl/ps/kill.c

Modified: trunk/reactos/ntoskrnl/ps/kill.c
--- trunk/reactos/ntoskrnl/ps/kill.c	2005-04-23 16:16:59 UTC (rev 14777)
+++ trunk/reactos/ntoskrnl/ps/kill.c	2005-04-23 16:17:27 UTC (rev 14778)
@@ -148,6 +148,11 @@
 
     DPRINT("PiDeleteProcess(ObjectBody %x)\n", ObjectBody);
 
+    /* Remove it from the Active List */
+    ExAcquireFastMutex(&PspActiveProcessMutex);
+    RemoveEntryList(&Process->ProcessListEntry);
+    ExReleaseFastMutex(&PspActiveProcessMutex);
+    
     /* Delete the CID Handle */   
     if(Process->UniqueProcessId != NULL) {
     
@@ -411,12 +416,7 @@
     DPRINT("PspExitProcess 0x%x\n", Process);
            
     PspRunCreateProcessNotifyRoutines(Process, FALSE);
-           
-    /* Remove it from the Active List */
-    ExAcquireFastMutex(&PspActiveProcessMutex);
-    RemoveEntryList(&Process->ProcessListEntry);
-    ExReleaseFastMutex(&PspActiveProcessMutex);
-    
+               
     /* close all handles associated with our process, this needs to be done
        when the last thread still runs */
     ObKillProcess(Process);