mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 05:25:48 +00:00
[NTOSKRNL]
- Move NtQueryTimerResolution and NtSetTimerResolution from ke/clock.c to their proper place in ex/time.c - Simplify NtQueryTimerResolution and implement NtSetTimerResolution based on the patch of Aleksandar Andrejevic. CORE-7387 #resolve #comment NtSetTimerResolution function committed in revision 59790, thanks :D svn path=/trunk/; revision=59790
This commit is contained in:
parent
7b25683467
commit
068cf237e9
2 changed files with 90 additions and 58 deletions
|
@ -48,9 +48,7 @@ ULONG ExpTimerResolutionCount = 0;
|
|||
*--*/
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
ExAcquireTimeRefreshLock(
|
||||
IN BOOLEAN Wait
|
||||
)
|
||||
ExAcquireTimeRefreshLock(IN BOOLEAN Wait)
|
||||
{
|
||||
/* Block APCs */
|
||||
KeEnterCriticalRegion();
|
||||
|
@ -82,9 +80,7 @@ ExAcquireTimeRefreshLock(
|
|||
*--*/
|
||||
VOID
|
||||
NTAPI
|
||||
ExReleaseTimeRefreshLock(
|
||||
VOID
|
||||
)
|
||||
ExReleaseTimeRefreshLock(VOID)
|
||||
{
|
||||
/* Release the lock and re-enable APCs */
|
||||
ExReleaseResourceLite(&ExpTimeRefreshLock);
|
||||
|
@ -478,4 +474,92 @@ ExSystemTimeToLocalTime(PLARGE_INTEGER SystemTime,
|
|||
LocalTime->QuadPart = SystemTime->QuadPart - ExpTimeZoneBias.QuadPart;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtQueryTimerResolution(OUT PULONG MinimumResolution,
|
||||
OUT PULONG MaximumResolution,
|
||||
OUT PULONG ActualResolution)
|
||||
{
|
||||
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
||||
|
||||
/* Check if the call came from user mode */
|
||||
if (PreviousMode != KernelMode)
|
||||
{
|
||||
_SEH2_TRY
|
||||
{
|
||||
/* Probe the parameters */
|
||||
ProbeForWriteUlong(MinimumResolution);
|
||||
ProbeForWriteUlong(MaximumResolution);
|
||||
ProbeForWriteUlong(ActualResolution);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
/* Return the exception code */
|
||||
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
||||
}
|
||||
_SEH2_END;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the parameters to the actual values.
|
||||
*
|
||||
* NOTE:
|
||||
* MinimumResolution corresponds to the biggest time increment and
|
||||
* MaximumResolution corresponds to the smallest time increment.
|
||||
*/
|
||||
*MinimumResolution = KeMaximumIncrement;
|
||||
*MaximumResolution = KeMinimumIncrement;
|
||||
*ActualResolution = KeTimeIncrement;
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtSetTimerResolution(IN ULONG DesiredResolution,
|
||||
IN BOOLEAN SetResolution,
|
||||
OUT PULONG CurrentResolution)
|
||||
{
|
||||
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
||||
PEPROCESS Process = PsGetCurrentProcess();
|
||||
ULONG NewResolution;
|
||||
|
||||
/* Check if the call came from user mode */
|
||||
if (PreviousMode != KernelMode)
|
||||
{
|
||||
_SEH2_TRY
|
||||
{
|
||||
/* Probe the parameter */
|
||||
ProbeForWriteUlong(CurrentResolution);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
/* Return the exception code */
|
||||
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
||||
}
|
||||
_SEH2_END;
|
||||
}
|
||||
|
||||
/* Set and return the new resolution */
|
||||
NewResolution = ExSetTimerResolution(DesiredResolution, SetResolution);
|
||||
*CurrentResolution = NewResolution;
|
||||
|
||||
if (SetResolution)
|
||||
{
|
||||
/* Set the flag that the resolution has been changed */
|
||||
Process->SetTimerResolution = TRUE;
|
||||
}
|
||||
|
||||
/* Return success if the process changed its timer resolution */
|
||||
if (Process->SetTimerResolution) return STATUS_SUCCESS;
|
||||
else return STATUS_TIMER_RESOLUTION_NOT_SET;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -236,56 +236,4 @@ KeSetTimeIncrement(IN ULONG MaxIncrement,
|
|||
KiTickOffset = MaxIncrement;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtQueryTimerResolution(OUT PULONG MinimumResolution,
|
||||
OUT PULONG MaximumResolution,
|
||||
OUT PULONG ActualResolution)
|
||||
{
|
||||
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
||||
|
||||
/* Check if the call came from user mode */
|
||||
if (PreviousMode != KernelMode)
|
||||
{
|
||||
_SEH2_TRY
|
||||
{
|
||||
/* Probe the parameters */
|
||||
ProbeForWriteUlong(MinimumResolution);
|
||||
ProbeForWriteUlong(MaximumResolution);
|
||||
ProbeForWriteUlong(ActualResolution);
|
||||
|
||||
/* Try to set the parameters to the actual values */
|
||||
*MinimumResolution = KeMinimumIncrement;
|
||||
*MaximumResolution = KeMaximumIncrement;
|
||||
*ActualResolution = KeTimeIncrement;
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
/* Return the exception code */
|
||||
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
||||
}
|
||||
_SEH2_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The call came from kernel mode. Use the pointers directly */
|
||||
*MinimumResolution = KeMinimumIncrement;
|
||||
*MaximumResolution = KeMaximumIncrement;
|
||||
*ActualResolution = KeTimeIncrement;
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtSetTimerResolution(IN ULONG DesiredResolution,
|
||||
IN BOOLEAN SetResolution,
|
||||
OUT PULONG CurrentResolution)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue