#ifndef _NTOBAPI_H
//
// Objects, handles
//
#if (PHNT_MODE != PHNT_MODE_KERNEL)
/**
* The NtWaitForMultipleObjects routine waits until one or all of the specified objects are in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
*
* @param Count The number of object handles to wait for in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS. This parameter cannot be zero.
* @param Handles An array of object handles. The array can contain handles of objects of different types. It may not contain multiple copies of the same handle.
* @param WaitType If this parameter is WaitAll, the function returns when the state of all objects in the Handles array is set to signaled.
* @param Alertable f this parameter is TRUE and the thread is in the waiting state, the function returns when the system queues an I/O completion routine or APC, and the thread runs the routine or function.
* @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/synchapi/nf-synchapi-waitformultipleobjectsex
*/
NTSYSCALLAPI
NTSTATUS
NTAPI
NtWaitForMultipleObjects(
_In_ ULONG Count,
_In_reads_(Count) HANDLE Handles[],
_In_ WAIT_TYPE WaitType,
_In_ BOOLEAN Alertable,
_In_opt_ PLARGE_INTEGER Timeout
);
View code on GitHub
#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwWaitForMultipleObjects(
_In_ ULONG Count,
_In_reads_(Count) HANDLE Handles[],
_In_ WAIT_TYPE WaitType,
_In_ BOOLEAN Alertable,
_In_opt_ PLARGE_INTEGER Timeout
);
View code on GitHub
Waits for one or more objects to enter a signaled state.
Count
- the number of handles passed in the Handles
parameter, up to MAXIMUM_WAIT_OBJECTS
(64).Handles
- a pointer to an array of handles. Each handle must grant SYNCHRONIZE
access.WaitType
- the type of wait to perform, either WaitAll
or WaitAny
.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
..STATUS_WAIT_63
- the thread woke due to the n'th object being signaled.STATUS_ABANDONED_WAIT_0
..STATUS_ABANDONED_WAIT_63
- the thread woke due to the n'th 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.