#ifndef _NTEXAPI_H
#if (PHNT_MODE != PHNT_MODE_KERNEL)
/**
* The NtSetTimerResolution routine sets the system interrupt timer resolution to the specified value.
*
* \param DesiredTime The desired timer resolution, in 100-nanosecond units.
* \param SetResolution If TRUE, the timer resolution is set to the value specified by DesiredTime. If FALSE, the timer resolution is reset to the default value.
* \param ActualTime The actual timer resolution, in 100-nanosecond units.
* \return NTSTATUS Successful or errant status.
*/
_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetTimerResolution(
_In_ ULONG DesiredTime,
_In_ BOOLEAN SetResolution,
_Out_ PULONG ActualTime
);
View code on GitHub#ifndef _NTZWAPI_H
_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwSetTimerResolution(
_In_ ULONG DesiredTime,
_In_ BOOLEAN SetResolution,
_Out_ PULONG ActualTime
);
View code on GitHubRequests or releases a system timer resolution on behalf of the calling process. A finer resolution increases the precision of waits and timers at the cost of higher power consumption.
DesiredTime - the requested interval between timer ticks, in 100-nanosecond units. Values outside the range reported by NtQueryTimerResolution are clamped to it. This parameter is ignored when SetResolution is FALSE.SetResolution - whether to set (TRUE) or release (FALSE) the request of the calling process.ActualTime - a pointer to a variable that receives the resulting timer resolution, in 100-nanosecond units. See the remarks for its limitations.STATUS_TIMER_RESOLUTION_NOT_SET - SetResolution is FALSE, but the calling process does not have an active request.Each process can have at most one active request. Calling the function with SetResolution set to TRUE replaces the previous request instead of adding another one, and a single call with FALSE releases it. The system releases the request automatically when the process exits.
The system uses the finest resolution among all active requests from processes and drivers (see ExSetTimerResolution). To check the resulting resolution, use the CurrentTime value from NtQueryTimerResolution. On recent versions of Windows, the value returned in ActualTime can differ from it.
Starting with Windows 10 version 2004, Windows does not guarantee a finer resolution for processes that did not request one. See the remarks for timeBeginPeriod for more details.
Requests from processes with PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION enabled (see ProcessPowerThrottlingState) succeed but do not affect the system timer resolution.
Function NtSetTimerResolution sets resolution of system Timer in calling process context.
Resolution to set. To receive minimum and maximum resolution values, call NtQueryTimerResolution.
If set, system Timer's resolution is set to DesiredResolution value. If no, parameter DesiredResolution is ignored.
Pointer to ULONG value receiving current timer's resolution, in 100-ns units.