2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/ps/kill.c
5 * PURPOSE: Terminating a thread
6 * PROGRAMMER: David Welch (welch@mcmail.com)
11 /* INCLUDES *****************************************************************/
13 #include <ddk/ntddk.h>
14 #include <internal/ps.h>
17 #include <internal/debug.h>
19 /* FUNCTIONS *****************************************************************/
21 NTSTATUS STDCALL
NtTerminateThread(IN HANDLE ThreadHandle
,
22 IN NTSTATUS ExitStatus
)
24 return(ZwTerminateThread(ThreadHandle
,ExitStatus
));
27 NTSTATUS STDCALL
ZwTerminateThread(IN HANDLE ThreadHandle
,
28 IN NTSTATUS ExitStatus
)
33 Status
= ObReferenceObjectByHandle(ThreadHandle
,
39 if (Status
!= STATUS_SUCCESS
)
44 if (Thread
== PsGetCurrentThread())
46 PsTerminateSystemThread(ExitStatus
);
55 NTSTATUS
PsTerminateSystemThread(NTSTATUS ExitStatus
)
57 * FUNCTION: Terminates the current thread
59 * ExitStatus = Status to pass to the creater
64 PETHREAD CurrentThread
;
66 CurrentThread
= PsGetCurrentThread();
68 CurrentThread
->ExitStatus
= ExitStatus
;
70 DPRINT("terminating %x\n",CurrentThread
);
71 KeRaiseIrql(DISPATCH_LEVEL
,&oldlvl
);
72 CurrentThread
->Tcb
.ThreadState
= THREAD_STATE_TERMINATED
;
73 RemoveEntryList(&CurrentThread
->Tcb
.Entry
);
78 NTSTATUS STDCALL
NtRegisterThreadTerminatePort(HANDLE TerminationPort
)
80 return(ZwRegisterThreadTerminatePort(TerminationPort
));
83 NTSTATUS STDCALL
ZwRegisterThreadTerminatePort(HANDLE TerminationPort
)