NtTerminateProcess - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTPSAPI_H
// Processes
#if (PHNT_MODE != PHNT_MODE_KERNEL)

NTSYSCALLAPI
NTSTATUS
NTAPI
NtTerminateProcess(
    _In_opt_ HANDLE ProcessHandle,
    _In_ NTSTATUS ExitStatus
    );

#endif
#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwTerminateProcess(
    _In_opt_ HANDLE ProcessHandle,
    _In_ NTSTATUS ExitStatus
    );

#endif

View code on GitHub

Forces the process to terminate. This function is documented in Windows Driver Kit.

Parameters

Remarks

Note that specifying NULL as a process handle has a different semantic compared to using NtCurrentProcess. NtCurrentProcess immediately terminates the current process (without returning from the function) while NULL terminates all threads except for the calling, sets the exit status, and marks the process for self-delete. A second call to NtTerminateProcess with NULL completes termination.

To exit the current process gracefully, use RtlExitUserProcess.

Setting ExitStatus to DBG_TERMINATE_PROCESS automatically clears the process's debug object.

The process object becomes signalled after termination.

Related Win32 API

See also