From 49b1d66ec3a759375b3bbb2f99ddaf6c45cb29b5 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 21 Mar 2005 20:11:52 +0000 Subject: [PATCH] - Advance the CurrentEntry pointer before terminating thread in PspTerminateProcessThreads. - Lock the process in NtTerminateProcess to prevent race conditions. svn path=/trunk/; revision=14256 --- reactos/ntoskrnl/ps/kill.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index 25e0ee2a204..2dd69d7439a 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -93,6 +93,9 @@ PspTerminateProcessThreads(PEPROCESS Process, /* 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 @@ PspTerminateProcessThreads(PEPROCESS Process, KeForceResumeThread(&Thread->Tcb); } } - - /* Move to the Next Thread */ - CurrentEntry = CurrentEntry->Flink; } } @@ -419,6 +419,8 @@ NtTerminateProcess(IN HANDLE ProcessHandle OPTIONAL, return(Status); } + PsLockProcess(Process, FALSE); + if(Process->ExitTime.QuadPart) { DPRINT1("Process has an exit time!\n"); @@ -431,6 +433,8 @@ NtTerminateProcess(IN HANDLE ProcessHandle OPTIONAL, /* Save the Exit Time */ KeQuerySystemTime(&Process->ExitTime); + + PsUnlockProcess(Process); /* Only master thread remains... kill it off */ if (PsGetCurrentThread()->ThreadsProcess == Process) {