Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.7 KiB

  1. //--------------------------------------------------------------------
  2. // AccurateSysCalls - implementation
  3. // Copyright (C) Microsoft Corporation, 1999
  4. //
  5. // Created by: Louis Thomas (louisth), 9-24-99
  6. //
  7. // More accurate time functions calling the NT api directly
  8. //
  9. #include <nt.h>
  10. //--------------------------------------------------------------------
  11. void __fastcall AccurateGetSystemTime(unsigned __int64 * pqwTime) {
  12. NtQuerySystemTime((LARGE_INTEGER *)pqwTime);
  13. }
  14. //--------------------------------------------------------------------
  15. void __fastcall AccurateSetSystemTime(unsigned __int64 * pqwTime) {
  16. NtSetSystemTime((LARGE_INTEGER *)pqwTime, NULL);
  17. }
  18. //--------------------------------------------------------------------
  19. void __fastcall AccurateGetTickCount(unsigned __int64 * pqwTick) {
  20. // HACKHACK: this is not thread safe and assumes that it will
  21. // always be called more often than every 47 days
  22. static unsigned __int32 dwLastTickCount=0;
  23. static unsigned __int32 dwHighTickCount=0;
  24. if (USER_SHARED_DATA->TickCountLow<dwLastTickCount) {
  25. dwHighTickCount++;
  26. }
  27. dwLastTickCount=USER_SHARED_DATA->TickCountLow;
  28. *pqwTick=USER_SHARED_DATA->TickCountLow+(((unsigned __int64)dwHighTickCount)<<32);
  29. };
  30. //--------------------------------------------------------------------
  31. unsigned __int32 SetTimeSlipEvent(HANDLE hTimeSlipEvent) {
  32. return NtSetSystemInformation(SystemTimeSlipNotification, &hTimeSlipEvent, sizeof(HANDLE));
  33. }
  34. //--------------------------------------------------------------------
  35. void GetSysExpirationDate(unsigned __int64 * pqwTime) {
  36. *(LARGE_INTEGER *)pqwTime=USER_SHARED_DATA->SystemExpirationDate;
  37. }