ReactOS  0.4.14-dev-608-gd495a4f
time.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for time.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define TICKSPERMINUTE   600000000
 

Functions

BOOLEAN NTAPI ExAcquireTimeRefreshLock (IN BOOLEAN Wait)
 
VOID NTAPI ExReleaseTimeRefreshLock (VOID)
 
ULONG NTAPI ExSetTimerResolution (IN ULONG DesiredTime, IN BOOLEAN SetResolution)
 
VOID NTAPI ExUpdateSystemTimeFromCmos (IN BOOLEAN UpdateInterruptTime, IN ULONG MaxSepInSeconds)
 
BOOLEAN NTAPI ExRefreshTimeZoneInformation (IN PLARGE_INTEGER CurrentBootTime)
 
NTSTATUS ExpSetTimeZoneInformation (PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
 
NTSTATUS NTAPI NtSetSystemTime (IN PLARGE_INTEGER SystemTime, OUT PLARGE_INTEGER PreviousTime OPTIONAL)
 
NTSTATUS NTAPI NtQuerySystemTime (OUT PLARGE_INTEGER SystemTime)
 
VOID NTAPI ExLocalTimeToSystemTime (PLARGE_INTEGER LocalTime, PLARGE_INTEGER SystemTime)
 
VOID NTAPI ExSystemTimeToLocalTime (PLARGE_INTEGER SystemTime, PLARGE_INTEGER LocalTime)
 
NTSTATUS NTAPI NtQueryTimerResolution (OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG ActualResolution)
 
NTSTATUS NTAPI NtSetTimerResolution (IN ULONG DesiredResolution, IN BOOLEAN SetResolution, OUT PULONG CurrentResolution)
 

Variables

RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo
 
ULONG ExpLastTimeZoneBias = -1
 
LARGE_INTEGER ExpTimeZoneBias
 
ULONG ExpAltTimeZoneBias
 
ULONG ExpTimeZoneId
 
ULONG ExpTickCountMultiplier
 
ERESOURCE ExpTimeRefreshLock
 
ULONG ExpKernelResolutionCount = 0
 
ULONG ExpTimerResolutionCount = 0
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file time.c.

◆ TICKSPERMINUTE

#define TICKSPERMINUTE   600000000

Definition at line 16 of file time.c.

Function Documentation

◆ ExAcquireTimeRefreshLock()

BOOLEAN NTAPI ExAcquireTimeRefreshLock ( IN BOOLEAN  Wait)

Definition at line 51 of file time.c.

52 {
53  /* Block APCs */
55 
56  /* Attempt lock acquisition */
58  {
59  /* Lock was not acquired, enable APCs and fail */
61  return FALSE;
62  }
63 
64  /* Lock has been acquired */
65  return TRUE;
66 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
ERESOURCE ExpTimeRefreshLock
Definition: time.c:27
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by ExSetTimerResolution().

◆ ExLocalTimeToSystemTime()

VOID NTAPI ExLocalTimeToSystemTime ( PLARGE_INTEGER  LocalTime,
PLARGE_INTEGER  SystemTime 
)

Definition at line 459 of file time.c.

461 {
462  SystemTime->QuadPart = LocalTime->QuadPart + ExpTimeZoneBias.QuadPart;
463 }
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by ExpSetTimeZoneInformation().

◆ ExpSetTimeZoneInformation()

NTSTATUS ExpSetTimeZoneInformation ( PRTL_TIME_ZONE_INFORMATION  TimeZoneInformation)

Definition at line 278 of file time.c.

279 {
280  LARGE_INTEGER LocalTime, SystemTime, OldTime;
282  DPRINT("ExpSetTimeZoneInformation() called\n");
283 
284  DPRINT("Old time zone bias: %d minutes\n", ExpTimeZoneInfo.Bias);
285  DPRINT("Old time zone standard bias: %d minutes\n",
287  DPRINT("New time zone bias: %d minutes\n", TimeZoneInformation->Bias);
288  DPRINT("New time zone standard bias: %d minutes\n",
289  TimeZoneInformation->StandardBias);
290 
291  /* Get the local time */
293  RtlTimeFieldsToTime(&TimeFields, &LocalTime);
294 
295  /* FIXME: Calculate transition dates */
296 
297  /* Calculate the bias and set the ID */
298  ExpTimeZoneBias.QuadPart = ((LONGLONG)(TimeZoneInformation->Bias +
299  TimeZoneInformation->StandardBias)) *
302 
303  /* Copy the timezone information */
305  TimeZoneInformation,
306  sizeof(RTL_TIME_ZONE_INFORMATION));
307 
308  /* Set the new time zone information */
309  SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;
310  SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.u.HighPart;
311  SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.u.LowPart;
312  SharedUserData->TimeZoneId = ExpTimeZoneId;
313 
314  DPRINT("New time zone bias: %I64d minutes\n",
316 
317  /* Calculate the new system time */
318  ExLocalTimeToSystemTime(&LocalTime, &SystemTime);
319 
320  /* Set the new system time */
321  KeSetSystemTime(&SystemTime, &OldTime, FALSE, NULL);
322 
323  /* Return success */
324  DPRINT("ExpSetTimeZoneInformation() done\n");
325  return STATUS_SUCCESS;
326 }
struct _LARGE_INTEGER::@2220 u
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BOOLEAN NTAPI HalQueryRealTimeClock(IN PTIME_FIELDS Time)
Definition: rtc.c:24
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
ULONG ExpTimeZoneId
Definition: time.c:25
int64_t LONGLONG
Definition: typedefs.h:66
#define TIME_ZONE_ID_STANDARD
Definition: rtltypes.h:251
#define SharedUserData
RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo
Definition: time.c:21
BOOLEAN NTAPI RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, OUT PLARGE_INTEGER Time)
Definition: time.c:170
VOID NTAPI KeSetSystemTime(IN PLARGE_INTEGER NewSystemTime, OUT PLARGE_INTEGER OldSystemTime, IN BOOLEAN FixInterruptTime, IN PLARGE_INTEGER HalTime)
Definition: clock.c:28
static PTIME_FIELDS TimeFields
Definition: time.c:104
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define TICKSPERMINUTE
Definition: time.c:16
VOID NTAPI ExLocalTimeToSystemTime(PLARGE_INTEGER LocalTime, PLARGE_INTEGER SystemTime)
Definition: time.c:459
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by SSI_DEF().

◆ ExRefreshTimeZoneInformation()

BOOLEAN NTAPI ExRefreshTimeZoneInformation ( IN PLARGE_INTEGER  CurrentBootTime)

Definition at line 226 of file time.c.

227 {
228  LARGE_INTEGER CurrentTime;
230 
231  /* Read time zone information from the registry */
233  if (!NT_SUCCESS(Status))
234  {
235  /* Failed, clear all data */
239  }
240  else
241  {
242  /* FIXME: Calculate transition dates */
243 
244  /* Set bias and ID */
249  }
250 
251  /* Change it for user-mode applications */
252  SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;
253  SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.u.HighPart;
254  SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.u.LowPart;
255  SharedUserData->TimeZoneId = ExpTimeZoneId;
256 
257  /* Convert boot time from local time to UTC */
259 
260  /* Convert system time from local time to UTC */
261  do
262  {
263  CurrentTime.u.HighPart = SharedUserData->SystemTime.High1Time;
264  CurrentTime.u.LowPart = SharedUserData->SystemTime.LowPart;
265  } while (CurrentTime.u.HighPart != SharedUserData->SystemTime.High2Time);
266 
267  /* Change it for user-mode applications */
268  CurrentTime.QuadPart += ExpTimeZoneBias.QuadPart;
269  SharedUserData->SystemTime.LowPart = CurrentTime.u.LowPart;
270  SharedUserData->SystemTime.High1Time = CurrentTime.u.HighPart;
271  SharedUserData->SystemTime.High2Time = CurrentTime.u.HighPart;
272 
273  /* Return success */
274  return TRUE;
275 }
struct _LARGE_INTEGER::@2220 u
#define TRUE
Definition: types.h:120
#define TIME_ZONE_ID_UNKNOWN
Definition: rtltypes.h:250
LONG NTSTATUS
Definition: precomp.h:26
LARGE_INTEGER KeBootTime
Definition: clock.c:17
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
ULONG ExpTimeZoneId
Definition: time.c:25
int64_t LONGLONG
Definition: typedefs.h:66
#define TIME_ZONE_ID_STANDARD
Definition: rtltypes.h:251
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SharedUserData
Status
Definition: gdiplustypes.h:24
RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo
Definition: time.c:21
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define TICKSPERMINUTE
Definition: time.c:16
NTSYSAPI NTSTATUS NTAPI RtlQueryTimeZoneInformation(_Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by Phase1InitializationDiscard().

◆ ExReleaseTimeRefreshLock()

VOID NTAPI ExReleaseTimeRefreshLock ( VOID  )

Definition at line 83 of file time.c.

84 {
85  /* Release the lock and re-enable APCs */
88 }
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
ERESOURCE ExpTimeRefreshLock
Definition: time.c:27

Referenced by ExSetTimerResolution().

◆ ExSetTimerResolution()

ULONG NTAPI ExSetTimerResolution ( IN ULONG  DesiredTime,
IN BOOLEAN  SetResolution 
)

Definition at line 131 of file time.c.

133 {
134  ULONG CurrentIncrement;
135 
136  /* Wait for clock interrupt frequency and power requests to synchronize */
138 
139  /* Obey remark 2*/
140  CurrentIncrement = KeTimeIncrement;
141 
142  /* Check the type of operation this is */
143  if (SetResolution)
144  {
145  /*
146  * If this is the first kernel change, bump the timer resolution change
147  * count, then bump the kernel change count as well.
148  *
149  * These two variables are tracked differently since user-mode processes
150  * can also change the timer resolution through the NtSetTimerResolution
151  * system call. A per-process flag in the EPROCESS then stores the per-
152  * process change state.
153  *
154  */
156 
157  /* Obey remark 3 */
158  if (DesiredTime < KeMinimumIncrement) DesiredTime = KeMinimumIncrement;
159 
160  /* Obey remark 1 */
161  if (DesiredTime < KeTimeIncrement)
162  {
163  /* Force this thread on CPU zero, since we don't want it to drift */
165 
166  /* Now call the platform driver (HAL) to make the change */
167  CurrentIncrement = HalSetTimeIncrement(DesiredTime);
168 
169  /* Put the thread back to its original affinity */
171 
172  /* Finally, keep track of the new value in the kernel */
173  KeTimeIncrement = CurrentIncrement;
174  }
175  }
176  else
177  {
178  /* First, make sure that a driver has actually changed the resolution */
180  {
181  /* Obey remark 4 */
183  {
184  /*
185  * All kernel drivers have requested the original frequency to
186  * be restored, but there might still be user processes with an
187  * ongoing clock interrupt frequency change, so make sure that
188  * this isn't the case.
189  */
191  {
192  /* Force this thread on one CPU so that it doesn't drift */
194 
195  /* Call the HAL to restore the frequency to its default */
196  CurrentIncrement = HalSetTimeIncrement(KeMaximumIncrement);
197 
198  /* Put the thread back to its original affinity */
200 
201  /* Finally, keep track of the new value in the kernel */
202  KeTimeIncrement = CurrentIncrement;
203  }
204  }
205  }
206  }
207 
208  /* Release the clock interrupt frequency lock since changes are done */
210 
211  /* And return the current value -- which could reflect the new frequency */
212  return CurrentIncrement;
213 }
ULONG KeMaximumIncrement
Definition: clock.c:20
VOID NTAPI ExReleaseTimeRefreshLock(VOID)
Definition: time.c:83
#define TRUE
Definition: types.h:120
ULONG KeMinimumIncrement
Definition: clock.c:21
VOID NTAPI KeRevertToUserAffinityThread(VOID)
Definition: thrdobj.c:1030
ULONG ExpTimerResolutionCount
Definition: time.c:29
ULONG ExpKernelResolutionCount
Definition: time.c:28
VOID NTAPI KeSetSystemAffinityThread(IN KAFFINITY Affinity)
Definition: thrdobj.c:1116
BOOLEAN NTAPI ExAcquireTimeRefreshLock(IN BOOLEAN Wait)
Definition: time.c:51
ULONG KeTimeIncrement
Definition: clock.c:22
_In_ BOOLEAN SetResolution
Definition: exfuncs.h:870
unsigned int ULONG
Definition: retypes.h:1
ULONG NTAPI HalSetTimeIncrement(IN ULONG Increment)
Definition: timer.c:102

Referenced by NtSetTimerResolution().

◆ ExSystemTimeToLocalTime()

VOID NTAPI ExSystemTimeToLocalTime ( PLARGE_INTEGER  SystemTime,
PLARGE_INTEGER  LocalTime 
)

Definition at line 470 of file time.c.

472 {
473  LocalTime->QuadPart = SystemTime->QuadPart - ExpTimeZoneBias.QuadPart;
474 }
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by NtSetSystemTime().

◆ ExUpdateSystemTimeFromCmos()

VOID NTAPI ExUpdateSystemTimeFromCmos ( IN BOOLEAN  UpdateInterruptTime,
IN ULONG  MaxSepInSeconds 
)

Definition at line 217 of file time.c.

219 {
220  /* FIXME: TODO */
221  return;
222 }

◆ NtQuerySystemTime()

NTSTATUS NTAPI NtQuerySystemTime ( OUT PLARGE_INTEGER  SystemTime)

Definition at line 417 of file time.c.

418 {
420  PAGED_CODE();
421 
422  /* Check if we were called from user-mode */
423  if (PreviousMode != KernelMode)
424  {
425  _SEH2_TRY
426  {
427  /* Verify the time pointer */
428  ProbeForWriteLargeInteger(SystemTime);
429 
430  /*
431  * It's safe to pass the pointer directly to KeQuerySystemTime
432  * as it's just a basic copy to this pointer. If it raises an
433  * exception nothing dangerous can happen!
434  */
435  KeQuerySystemTime(SystemTime);
436  }
438  {
439  /* Return the exception code */
441  }
442  _SEH2_END;
443  }
444  else
445  {
446  /* Query the time directly */
447  KeQuerySystemTime(SystemTime);
448  }
449 
450  /* Return success */
451  return STATUS_SUCCESS;
452 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3066
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define ProbeForWriteLargeInteger(Ptr)
Definition: probe.h:46

Referenced by CalcVolumeSerialNumber(), create_bad_block_inode(), ElfReportEventA(), ElfReportEventW(), ext2_flush(), ext2_initialize_sb(), ext2_mkdir(), GetPasswordAge(), HTTP_ProcessExpires(), LogfReportEvent(), LogfWriteRecord(), LsaApLogonUserEx2(), LsapCreateDatabaseObjects(), LsapCreateRandomDomainSid(), LsarCreateSecret(), LsarSetSecret(), LsarStorePrivateData(), NetrRemoteTOD(), NtProcessStartup(), RtlRunEncodeUnicodeString(), SampSetupCreateDomain(), SampSetUserAll(), SampSetUserInternal1(), SampSetUserInternal2(), SamrChangePasswordUser(), SetDiskSignature(), START_TEST(), Test_ProcessTimes(), test_tp_timer(), test_tp_wait(), and test_tp_window_length().

◆ NtQueryTimerResolution()

NTSTATUS NTAPI NtQueryTimerResolution ( OUT PULONG  MinimumResolution,
OUT PULONG  MaximumResolution,
OUT PULONG  ActualResolution 
)

Definition at line 481 of file time.c.

484 {
486 
487  /* Check if the call came from user-mode */
488  if (PreviousMode != KernelMode)
489  {
490  _SEH2_TRY
491  {
492  /* Probe the parameters */
493  ProbeForWriteUlong(MinimumResolution);
494  ProbeForWriteUlong(MaximumResolution);
495  ProbeForWriteUlong(ActualResolution);
496 
497  /*
498  * Set the parameters to the actual values.
499  *
500  * NOTE:
501  * MinimumResolution corresponds to the biggest time increment and
502  * MaximumResolution corresponds to the smallest time increment.
503  */
504  *MinimumResolution = KeMaximumIncrement;
505  *MaximumResolution = KeMinimumIncrement;
506  *ActualResolution = KeTimeIncrement;
507  }
509  {
510  /* Return the exception code */
512  }
513  _SEH2_END;
514  }
515  else
516  {
517  /* Set the parameters to the actual values */
518  *MinimumResolution = KeMaximumIncrement;
519  *MaximumResolution = KeMinimumIncrement;
520  *ActualResolution = KeTimeIncrement;
521  }
522 
523  /* Return success */
524  return STATUS_SUCCESS;
525 }
#define ProbeForWriteUlong(Ptr)
Definition: probe.h:36
ULONG KeMaximumIncrement
Definition: clock.c:20
ULONG KeMinimumIncrement
Definition: clock.c:21
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3066
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
ULONG KeTimeIncrement
Definition: clock.c:22
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by START_TEST().

◆ NtSetSystemTime()

NTSTATUS NTAPI NtSetSystemTime ( IN PLARGE_INTEGER  SystemTime,
OUT PLARGE_INTEGER PreviousTime  OPTIONAL 
)

Definition at line 339 of file time.c.

341 {
342  LARGE_INTEGER OldSystemTime;
343  LARGE_INTEGER NewSystemTime;
344  LARGE_INTEGER LocalTime;
348  PAGED_CODE();
349 
350  /* Check if we were called from user-mode */
351  if (PreviousMode != KernelMode)
352  {
353  _SEH2_TRY
354  {
355  /* Verify the time pointers */
356  NewSystemTime = ProbeForReadLargeInteger(SystemTime);
357  if(PreviousTime) ProbeForWriteLargeInteger(PreviousTime);
358  }
360  {
361  /* Return the exception code */
363  }
364  _SEH2_END;
365  }
366  else
367  {
368  /* Reuse the pointer */
369  NewSystemTime = *SystemTime;
370  }
371 
372  /* Make sure we have permission to change the time */
374  {
375  DPRINT1("NtSetSystemTime: Caller requires the "
376  "SeSystemtimePrivilege privilege!\n");
378  }
379 
380  /* Convert the time and set it in HAL */
381  ExSystemTimeToLocalTime(&NewSystemTime, &LocalTime);
382  RtlTimeToTimeFields(&LocalTime, &TimeFields);
384 
385  /* Now set system time */
386  KeSetSystemTime(&NewSystemTime, &OldSystemTime, FALSE, NULL);
387 
388  /* Check if caller wanted previous time */
389  if (PreviousTime)
390  {
391  /* Enter SEH Block for return */
392  _SEH2_TRY
393  {
394  /* Return the previous time */
395  *PreviousTime = OldSystemTime;
396  }
398  {
399  /* Get the exception code */
401  }
402  _SEH2_END;
403  }
404 
405  /* Return status */
406  return Status;
407 }
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
const LUID SeSystemtimePrivilege
Definition: priv.c:33
VOID NTAPI RtlTimeToTimeFields(IN PLARGE_INTEGER Time, OUT PTIME_FIELDS TimeFields)
Definition: time.c:253
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:524
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3066
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define ProbeForReadLargeInteger(Ptr)
Definition: probe.h:75
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
LONG NTAPI ExSystemExceptionFilter(VOID)
Definition: harderr.c:351
#define DPRINT1
Definition: precomp.h:8
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
VOID NTAPI KeSetSystemTime(IN PLARGE_INTEGER NewSystemTime, OUT PLARGE_INTEGER OldSystemTime, IN BOOLEAN FixInterruptTime, IN PLARGE_INTEGER HalTime)
Definition: clock.c:28
static PTIME_FIELDS TimeFields
Definition: time.c:104
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define ProbeForWriteLargeInteger(Ptr)
Definition: probe.h:46
VOID NTAPI ExSystemTimeToLocalTime(PLARGE_INTEGER SystemTime, PLARGE_INTEGER LocalTime)
Definition: time.c:470
BOOLEAN NTAPI HalSetRealTimeClock(IN PTIME_FIELDS Time)
Definition: rtc.c:45

Referenced by SetLocalTime(), and SetSystemTime().

◆ NtSetTimerResolution()

NTSTATUS NTAPI NtSetTimerResolution ( IN ULONG  DesiredResolution,
IN BOOLEAN  SetResolution,
OUT PULONG  CurrentResolution 
)

Definition at line 532 of file time.c.

535 {
539  ULONG NewResolution;
540 
541  /* Check if the call came from user-mode */
542  if (PreviousMode != KernelMode)
543  {
544  _SEH2_TRY
545  {
546  /* Probe the parameter */
547  ProbeForWriteUlong(CurrentResolution);
548  }
550  {
551  /* Return the exception code */
553  }
554  _SEH2_END;
555  }
556 
557  /* Set and return the new resolution */
558  NewResolution = ExSetTimerResolution(DesiredResolution, SetResolution);
559 
560  if (PreviousMode != KernelMode)
561  {
562  _SEH2_TRY
563  {
564  *CurrentResolution = NewResolution;
565  }
567  {
568  /* Return the exception code */
570  }
571  _SEH2_END;
572  }
573  else
574  {
575  *CurrentResolution = NewResolution;
576  }
577 
578  if (SetResolution || Process->SetTimerResolution)
579  {
580  /* The resolution has been changed now or in an earlier call */
582  }
583  else
584  {
585  /* The resolution hasn't been changed */
587  }
588 
589  /* Update the flag */
590  Process->SetTimerResolution = SetResolution;
591 
592  return Status;
593 }
#define ProbeForWriteUlong(Ptr)
Definition: probe.h:36
LONG NTSTATUS
Definition: precomp.h:26
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3066
ULONG NTAPI ExSetTimerResolution(IN ULONG DesiredTime, IN BOOLEAN SetResolution)
Definition: time.c:131
_SEH2_TRY
Definition: create.c:4250
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
_In_ BOOLEAN SetResolution
Definition: exfuncs.h:870
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define STATUS_TIMER_RESOLUTION_NOT_SET
Definition: ntstatus.h:699
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by START_TEST().

Variable Documentation

◆ ExpAltTimeZoneBias

ULONG ExpAltTimeZoneBias

Definition at line 24 of file time.c.

Referenced by Phase1InitializationDiscard().

◆ ExpKernelResolutionCount

ULONG ExpKernelResolutionCount = 0

Definition at line 28 of file time.c.

Referenced by ExSetTimerResolution().

◆ ExpLastTimeZoneBias

ULONG ExpLastTimeZoneBias = -1

Definition at line 22 of file time.c.

Referenced by Phase1InitializationDiscard().

◆ ExpTickCountMultiplier

ULONG ExpTickCountMultiplier

Definition at line 26 of file time.c.

Referenced by ExpInitializeExecutive().

◆ ExpTimeRefreshLock

ERESOURCE ExpTimeRefreshLock

Definition at line 27 of file time.c.

Referenced by ExAcquireTimeRefreshLock(), and ExReleaseTimeRefreshLock().

◆ ExpTimerResolutionCount

ULONG ExpTimerResolutionCount = 0

Definition at line 29 of file time.c.

Referenced by ExSetTimerResolution().

◆ ExpTimeZoneBias

◆ ExpTimeZoneId

ULONG ExpTimeZoneId

Definition at line 25 of file time.c.

Referenced by ExpSetTimeZoneInformation(), ExRefreshTimeZoneInformation(), and QSI_DEF().

◆ ExpTimeZoneInfo

RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo

Definition at line 21 of file time.c.

Referenced by ExpSetTimeZoneInformation(), ExRefreshTimeZoneInformation(), and QSI_DEF().