From 63feab70a0e681a67e2a7ccb8c852930499eb703 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 19 Aug 2013 19:40:25 +0000 Subject: [PATCH] [NTOS] - Aleksandar Andrejevic: Implement NtQueryTimerResolution(). CORE-7387 svn path=/trunk/; revision=59785 --- reactos/ntoskrnl/ke/clock.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/ke/clock.c b/reactos/ntoskrnl/ke/clock.c index a60eabf8a8d..5d3fdf00911 100644 --- a/reactos/ntoskrnl/ke/clock.c +++ b/reactos/ntoskrnl/ke/clock.c @@ -242,8 +242,40 @@ NtQueryTimerResolution(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG ActualResolution) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + 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 -- 2.17.1