#ifndef _NTOBAPI_H
//
// Objects, handles
//
#if (PHNT_MODE != PHNT_MODE_KERNEL)
/**
* The NtWaitForSingleObject routine waits until the specified object is in the signaled state or the time-out interval elapses.
*
* @param Handle The handle to the wait object.
* @param Alertable The function returns when either the time-out period has elapsed or when the APC function is called.
* @param Timeout A pointer to an absolute or relative time over which the wait is to occur. Can be null. If a timeout is specified,
* and the object has not attained a state of signaled when the timeout expires, then the wait is automatically satisfied.
* If an explicit timeout value of zero is specified, then no wait occurs if the wait cannot be satisfied immediately.
* @return NTSTATUS Successful or errant status.
* @sa https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntwaitforsingleobject
*/
NTSYSCALLAPI
NTSTATUS
NTAPI
NtWaitForSingleObject(
_In_ HANDLE Handle,
_In_ BOOLEAN Alertable,
_In_opt_ PLARGE_INTEGER Timeout
);
View code on GitHub
#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwWaitForSingleObject(
_In_ HANDLE Handle,
_In_ BOOLEAN Alertable,
_In_opt_ PLARGE_INTEGER Timeout
);
View code on GitHub
Waits for the object to enter a signaled state. This function is documented in Windows Driver Kit.
Handle
- a handle granting SYNCHRONIZE
access.Alertable
- determines whether the wait should be altertable. This allows external triggers (such as APCs or calls to NtAlertThread
) to interrupt wait prematurely.Timeout
- an optional pointer to a variable that stores the wait internal. A negative value indicates relative timeout for the specified number of 100-nanosecond intervals. To wait a specific number of milliseconds, multiply them by -10,000
. Positive values indicate an absolute time. NULL
indicates an infinite timeout.STATUS_WAIT_0
- the thread woke due to the object being signaled.STATUS_ABANDONED_WAIT_0
- the thread woke due to the passed mutex becoming abandoned.STATUS_TIMEOUT
- the thread woke due to the timeout.STATUS_USER_APC
- the wait was interrupted by an APC.STATUS_ALERTED
- the wait was interrupted by a call to NtAlertThread
.Despite the name, NtAlertThreadByThreadId
is unrelated to alertable waits and cannot interrupt them.