From 5a97f250e745cacee709f6ba56ab08440360e82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 14 Sep 2004 18:37:40 +0000 Subject: [PATCH] Check if attached when terminating thread. Suggested by tamlin. svn path=/trunk/; revision=10857 --- reactos/ntoskrnl/ps/kill.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index 3b020d46c07..b1da4ed6910 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -1,4 +1,4 @@ -/* $Id: kill.c,v 1.74 2004/08/31 20:17:18 hbirr Exp $ +/* $Id: kill.c,v 1.75 2004/09/14 18:37:40 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -124,6 +124,15 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus) CurrentThread = PsGetCurrentThread(); CurrentProcess = CurrentThread->ThreadsProcess; + /* Can't terminate a thread if it attached another process */ + if (AttachedApcEnvironment == CurrentThread->Tcb.ApcStateIndex) + { + KEBUGCHECKEX(INVALID_PROCESS_ATTACH_ATTEMPT, (ULONG) CurrentProcess, + (ULONG) CurrentThread->Tcb.ApcState.Process, + (ULONG) CurrentThread->Tcb.ApcStateIndex, + (ULONG) CurrentThread); + } + KeAcquireSpinLock(&PiThreadListLock, &oldIrql); DPRINT("terminating %x\n",CurrentThread);