#ifndef _NTRTL_H
/**
* The RtlExitUserThread routine ends the calling thread and returns the specified exit status.
*
* \param ExitStatus The exit status for the thread.
* \remarks This function does not return to the caller. It terminates the thread immediately.
* \sa https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-exitthread
* \remarks These alter execution lifecycle rather than just creating/freeing a data structure. Thread exit
* can become process exit for the last thread; runtime loader notifications and synchronization matter.
*/
_Analysis_noreturn_
DECLSPEC_NORETURN
NTSYSAPI
VOID
NTAPI
RtlExitUserThread(
_In_ NTSTATUS ExitStatus
);
View code on GitHubGracefully terminates the current thread.
ExitStatus - the value to set as the exist status of the thread.The function calls NtQueryInformationThread with the the THREADINFOCLASS value of ThreadAmILastThread (12) and either detaches DLLs and exists the current thread or calls RtlExitUserProcess.