#ifndef _NTPSAPI_H
//
// Threads
//
#if (PHNT_MODE != PHNT_MODE_KERNEL)
/**
* Terminates the specified thread.
*
* @param ThreadHandle Optional. A handle to the thread to be terminated. If this parameter is NULL, the calling thread is terminated.
* @param ExitStatus The exit status to be used by the thread and the thread's termination status.
* @return NTSTATUS Successful or errant status.
*/
NTSYSCALLAPI
NTSTATUS
NTAPI
NtTerminateThread(
_In_opt_ HANDLE ThreadHandle,
_In_ NTSTATUS ExitStatus
);
View code on GitHub
#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwTerminateThread(
_In_opt_ HANDLE ThreadHandle,
_In_ NTSTATUS ExitStatus
);
View code on GitHub
Forcefully terminates a thread.
ThreadHandle
- an optional handle to a thread granting THREAD_TERMINATE
access or the NtCurrentThread
pseudo-handle. If this value is NULL
, the calling thread is terminated.ExitStatus
- the value to set as the exit status of the thread.STATUS_CANT_TERMINATE_SELF
- indicates that a thread attempted to terminate itself by default (called NtTerminateThread
with NULL
) and it was the last thread in the current process.To exit the current thread gracefully, use RtlExitUserThread
.
The thread object becomes signalled after termination.