Export (0) Print
Expand All

ZwTerminateProcess routine

The ZwTerminateProcess routine terminates a process and all of its threads.

Syntax


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

Parameters

ProcessHandle [in, optional]

A handle to the process object that represents the process to be terminated.

ExitStatus [in]

An NTSTATUS value that the operating system uses as the final status for the process and each of its threads.

Return value

ZwTerminateProcess returns STATUS_SUCCESS if the operation succeeds. Additional return values include:

Return codeDescription
STATUS_OBJECT_TYPE_MISMATCH

The specified handle is not a process handle.

STATUS_INVALID_HANDLE

The specified handle is not valid.

STATUS_ACCESS_DENIED

The driver cannot access the specified process object.

STATUS_PROCESS_IS_TERMINATING

The specified process is already terminating.

 

If the caller specifies the current process in the ProcessHandle parameter, ZwTerminateProcess does not return.

Remarks

To obtain a process handle that a driver can specify for the ProcessHandle parameter, the driver can call ZwOpenProcess. The handle must be a kernel handle.

Drivers must not specify the current process if resources have not been freed from the kernel stack, because the operating system will not unwind the kernel stack for the calling thread.

Note  If the call to this function occurs in user mode, you should use the name "NtTerminateProcess" instead of "ZwTerminateProcess".

Requirements

Target platform

Universal

Version

Available starting with Windows 2000.

Header

Ntddk.h (include Ntddk.h)

Library

Ntoskrnl.lib

IRQL

PASSIVE_LEVEL

DDI compliance rules

PowerIrpDDis, HwStorPortProhibitedDDIs

See also

ZwOpenProcess

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft