NtWaitForAlertByThreadId - NtDoc

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

// rev
/**
 * The NtWaitForAlertByThreadId routine blocks the calling thread until another thread calls NtAlertThreadByThreadId
 * with a matching address, or until the timeout expires.
 *
 * \param Address A unique address used to identify this wait operation. Other threads call
 *                NtAlertThreadByThreadId with this same address to wake the waiting thread.
 *                Can be NULL to wait on the thread ID itself.
 * \param Timeout Optional timeout value. If NULL, waits indefinitely. If present, specifies
 *                the absolute or relative time to wait before returning STATUS_TIMEOUT.
 * \return STATUS_SUCCESS if alerted successfully.
 * \return STATUS_TIMEOUT if the timeout expired before being alerted.
 * \return STATUS_ALERTED if woken by NtAlertThreadByThreadId.
 */
NTSYSCALLAPI
NTSTATUS
NTAPI
NtWaitForAlertByThreadId(
    _In_opt_ PVOID Address,
    _In_opt_ PLARGE_INTEGER Timeout
    );

#endif
#endif
#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwWaitForAlertByThreadId(
    _In_opt_ PVOID Address,
    _In_opt_ PLARGE_INTEGER Timeout
    );

#endif

View code on GitHub

NtDoc

Waits on the specified address to be alerted-by-ID by another thread.

Parameters

Notable return values

Remarks

Despite the name, the wait this function enters is not alertable and, thus, cannot be interrupted by APCs or NtAlertThread. Alertable waits via NtDelayExecution are unrelated to this functionality.

Related Win32 API

Required OS version

This function was introduced in Windows 8.

See also