- Advance the CurrentEntry pointer before terminating thread in PspTerminateProcessThreads.
- Lock the process in NtTerminateProcess to prevent race conditions.
Modified: trunk/reactos/ntoskrnl/ps/kill.c

Modified: trunk/reactos/ntoskrnl/ps/kill.c
--- trunk/reactos/ntoskrnl/ps/kill.c	2005-03-21 17:13:55 UTC (rev 14255)
+++ trunk/reactos/ntoskrnl/ps/kill.c	2005-03-21 20:11:52 UTC (rev 14256)
@@ -93,6 +93,9 @@
         /* Get the Current Thread */
         Thread = CONTAINING_RECORD(CurrentEntry, ETHREAD, ThreadListEntry);
         
+        /* Move to the Next Thread */
+        CurrentEntry = CurrentEntry->Flink;
+        
         /* Make sure it's not the one we're in */
         if (Thread != CurrentThread) {
         
@@ -107,9 +110,6 @@
                 KeForceResumeThread(&Thread->Tcb);
             }
         }
-        
-        /* Move to the Next Thread */
-        CurrentEntry = CurrentEntry->Flink;
     }
 }
 
@@ -419,6 +419,8 @@
         return(Status);
     }
     
+    PsLockProcess(Process, FALSE);
+
     if(Process->ExitTime.QuadPart) {
         
         DPRINT1("Process has an exit time!\n");
@@ -431,6 +433,8 @@
 
     /* Save the Exit Time */
     KeQuerySystemTime(&Process->ExitTime);
+
+    PsUnlockProcess(Process);
             
     /* Only master thread remains... kill it off */
     if (PsGetCurrentThread()->ThreadsProcess == Process) {