NtSetTimer - NtDoc

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

/**
 * The NtSetTimer routine arms or replaces an ordinary timer's due time and optional periodic/APC behavior.
 * Rearming clears the previous signal and removes pending completion APCs; it does not signal threads waiting
 * for the old deadline. An already-due deadline can signal the timer again immediately.
 *
 * \param TimerHandle Handle with TIMER_MODIFY_STATE (0x2).
 * \param DueTime Required pointer to a time in 100-nanosecond units. Negative values
 * specify a relative interval; nonnegative values specify an absolute UTC deadline
 * in FILETIME units. A deadline in the past expires immediately.
 * \param TimerApcRoutine Optional completion APC delivered to the setting thread
 * when it enters an alertable wait. See TIMER_APC_ROUTINE for arguments and context.
 * \param TimerContext Optional opaque value passed to TimerApcRoutine.
 * \param ResumeTimer Requests that expiration wake the system from a suspended
 * power state. This does not mean resume a paused timer. Support depends on the
 * platform and wake policy; STATUS_TIMER_RESUME_IGNORED can accompany an armed timer.
 * \param Period Milliseconds between periodic expirations, in the range 0 through
 * 0x7FFFFFFF. Zero selects one-shot operation; negative values return
 * STATUS_INVALID_PARAMETER_6.
 * \param PreviousState Optional writable byte receiving the previous signal state,
 * not an armed-state indicator or a count of pending expirations.
 * \return NTSTATUS. STATUS_TIMER_RESUME_IGNORED (0x40000025) is informational:
 * the timer was set, but its wake request could not be honored.
 * \remarks Ordinary timers created by NtCreateTimer are described here. Timer2/IR
 * compatibility paths have additional restrictions on callbacks, context and state
 * output; do not assume those object types support the complete ordinary-timer contract.
 */
_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetTimer(
    _In_ HANDLE TimerHandle,
    _In_ PLARGE_INTEGER DueTime,
    _In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine,
    _In_opt_ PVOID TimerContext,
    _In_ BOOLEAN ResumeTimer,
    _In_opt_ LONG Period,
    _Out_opt_ PBOOLEAN PreviousState
    );

#endif
#endif

View code on GitHub
#ifndef _NTZWAPI_H

_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwSetTimer(
    _In_ HANDLE TimerHandle,
    _In_ PLARGE_INTEGER DueTime,
    _In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine,
    _In_opt_ PVOID TimerContext,
    _In_ BOOLEAN ResumeTimer,
    _In_opt_ LONG Period,
    _Out_opt_ PBOOLEAN PreviousState
    );

#endif

View code on GitHub

NtDoc

No description available.

NTinternals.net (undocumented.ntinternals.net)

TimerHandle

HANDLE to Timer Object opened with TIMER_MODIFY_STATE access.

DueTime

Time when timer should be set, in 100ns units. If it is negative value, it means relative time.

TimerApcRoutine

User's APC routine, defined as follows:

typedef void (*PTIMER_APC_ROUTINE)(
        IN PVOID TimerContext,
        IN ULONG TimerLowValue,
        IN LONG TimerHighValue
        );

TimerContext

Optional parameter to TimerApcRoutine.

ResumeTimer

If set, Power Management restores system to normal mode when timer is signaled.

Period

If zero, timer is set only once. Else will be set periodic in time intervals defined in Period value (in 100ms units).

PreviousState

Optional pointer to value receiving state of Timer Object before NtSetTimer call.

Documented by

See also