ReactOS  r76032
time.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for time.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL WINAPI IsTimeZoneRedirectionEnabled (VOID)
 
BOOL WINAPI FileTimeToDosDateTime (IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
 
BOOL WINAPI DosDateTimeToFileTime (IN WORD wFatDate, IN WORD wFatTime, OUT LPFILETIME lpFileTime)
 
LONG WINAPI CompareFileTime (IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
 
VOID WINAPI GetSystemTimeAsFileTime (OUT PFILETIME lpFileTime)
 
BOOL WINAPI SystemTimeToFileTime (IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
 
BOOL WINAPI FileTimeToSystemTime (IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
 
BOOL WINAPI FileTimeToLocalFileTime (IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
 
BOOL WINAPI LocalFileTimeToFileTime (IN CONST FILETIME *lpLocalFileTime, OUT LPFILETIME lpFileTime)
 
VOID WINAPI GetLocalTime (OUT LPSYSTEMTIME lpSystemTime)
 
VOID WINAPI GetSystemTime (OUT LPSYSTEMTIME lpSystemTime)
 
BOOL WINAPI SetLocalTime (IN CONST SYSTEMTIME *lpSystemTime)
 
BOOL WINAPI SetSystemTime (IN CONST SYSTEMTIME *lpSystemTime)
 
DWORD WINAPI GetTickCount (VOID)
 
BOOL WINAPI GetSystemTimeAdjustment (OUT PDWORD lpTimeAdjustment, OUT PDWORD lpTimeIncrement, OUT PBOOL lpTimeAdjustmentDisabled)
 
BOOL WINAPI SetSystemTimeAdjustment (IN DWORD dwTimeAdjustment, IN BOOL bTimeAdjustmentDisabled)
 
BOOL WINAPI GetSystemTimes (OUT LPFILETIME lpIdleTime OPTIONAL, OUT LPFILETIME lpKernelTime OPTIONAL, OUT LPFILETIME lpUserTime OPTIONAL)
 
BOOL WINAPI SetClientTimeZoneInformation (IN CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
 

Macro Definition Documentation

#define NDEBUG

Definition at line 16 of file time.c.

Function Documentation

LONG WINAPI CompareFileTime ( IN CONST FILETIME lpFileTime1,
IN CONST FILETIME lpFileTime2 
)

Definition at line 106 of file time.c.

Referenced by add_cert_to_store(), cert_mgr_sort_by_date(), CertAddCRLContextToStore(), CertAddCTLContextToStore(), CertVerifyCRLTimeValidity(), CertVerifyTimeValidity(), compareDate(), CRecycleBin::CompareIDs(), CRYPT_CacheURL(), CRYPT_GetObjectFromCache(), CAvailableApps::Enum(), get_cookie(), load_persistent_cookie(), LPropCompareProp(), MONTHCAL_CompareSystemTime(), MONTHCAL_IsSelRangeValid(), MONTHCAL_SetRange(), save_persistent_cookie(), set_cookie(), test_CopyFile2(), test_CopyFileA(), test_RealizationInfo(), urlcache_entry_is_expired(), verify_cert_revocation_with_crl_offline(), and XCOPY_DoCopy().

108 {
109  LARGE_INTEGER Time1, Time2, Diff;
110 
111  Time1.LowPart = lpFileTime1->dwLowDateTime;
112  Time2.LowPart = lpFileTime2->dwLowDateTime;
113  Time1.HighPart = lpFileTime1->dwHighDateTime;
114  Time2.HighPart = lpFileTime2->dwHighDateTime;
115 
116  Diff.QuadPart = Time1.QuadPart - Time2.QuadPart;
117 
118  if (Diff.HighPart < 0) return -1;
119  if (Diff.QuadPart == 0) return 0;
120  return 1;
121 }
ULONG LowPart
Definition: typedefs.h:104
LONGLONG QuadPart
Definition: typedefs.h:112
BOOL WINAPI DosDateTimeToFileTime ( IN WORD  wFatDate,
IN WORD  wFatTime,
OUT LPFILETIME  lpFileTime 
)

Definition at line 75 of file time.c.

Referenced by _ILGetFileDateTime(), ACTION_AppSearchGetSignature(), cabinet_close_file_info(), ATL::CTime::CTime(), dos_date_time_to_file_time(), DosInt21h(), ExtCabCallback(), CCabinet::ExtractFile(), fdi_notify_extract(), test_conversions(), and test_invalid_arg().

78 {
80  LARGE_INTEGER SystemTime;
81 
82  TimeFields.Year = (wFatDate >> 9) + 1980;
83  TimeFields.Month = (wFatDate >> 5) & 0xF;
84  TimeFields.Day = (wFatDate & 0x1F);
85  TimeFields.Hour = (wFatTime >> 11);
86  TimeFields.Minute = (wFatTime >> 5) & 0x3F;
87  TimeFields.Second = (wFatTime & 0x1F) << 1;
88  TimeFields.Milliseconds = 0;
89 
90  if (RtlTimeFieldsToTime(&TimeFields, &SystemTime))
91  {
92  lpFileTime->dwLowDateTime = SystemTime.LowPart;
93  lpFileTime->dwHighDateTime = SystemTime.HighPart;
94  return TRUE;
95  }
96 
98  return FALSE;
99 }
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define FALSE
Definition: types.h:117
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
USHORT Milliseconds
Definition: env_spec_w32.h:717
ULONG LowPart
Definition: typedefs.h:104
BOOLEAN NTAPI RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, OUT PLARGE_INTEGER Time)
Definition: time.c:170
static PTIME_FIELDS TimeFields
Definition: time.c:27
BOOL WINAPI FileTimeToDosDateTime ( IN CONST FILETIME lpFileTime,
OUT LPWORD  lpFatDate,
OUT LPWORD  lpFatTime 
)

Definition at line 37 of file time.c.

Referenced by _ILCreateFromFindDataW(), demFileFindFirst(), demFileFindNext(), DosInt21h(), file_time_to_dos_date_time(), get_open_info(), CCabinet::GetFileTimes(), and test_FileTimeToDosDateTime().

40 {
41  LARGE_INTEGER FileTime;
43 
44  FileTime.HighPart = lpFileTime->dwHighDateTime;
45  FileTime.LowPart = lpFileTime->dwLowDateTime;
46 
47  if (FileTime.QuadPart < 0)
48  {
50  return FALSE;
51  }
52 
53  RtlTimeToTimeFields(&FileTime, &TimeFields);
54  if ((TimeFields.Year < 1980) || (TimeFields.Year > 2107))
55  {
57  return FALSE;
58  }
59 
60  *lpFatDate = (TimeFields.Day) |
61  (TimeFields.Month << 5) |
62  ((TimeFields.Year - 1980) << 9);
63  *lpFatTime = (TimeFields.Second >> 1) |
64  (TimeFields.Minute << 5) |
65  (TimeFields.Hour << 11);
66 
67  return TRUE;
68 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
VOID NTAPI RtlTimeToTimeFields(IN PLARGE_INTEGER Time, OUT PTIME_FIELDS TimeFields)
Definition: time.c:253
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define FALSE
Definition: types.h:117
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define SetLastError(x)
Definition: compat.h:409
ULONG LowPart
Definition: typedefs.h:104
static PTIME_FIELDS TimeFields
Definition: time.c:27
LONGLONG QuadPart
Definition: typedefs.h:112
BOOL WINAPI FileTimeToLocalFileTime ( IN CONST FILETIME lpFileTime,
OUT LPFILETIME  lpLocalFileTime 
)

Definition at line 211 of file time.c.

Referenced by _ILGetFileDate(), _tmain(), DateConstr_value(), DirPrintFileDateTime(), EventTimeToSystemTime(), format_date(), FormatDateTime(), get_date_from_filetime(), get_open_info(), GetEnhancedVar(), CFileDefExt::GetFileTimeString(), GetFileTimeString(), CRegistryKey::GetLastWriteTime(), PrintDateTime(), SHFormatDateTimeW(), summaryinfo_invoke(), test_FileTimeToLocalFileTime(), test_GetTimeZoneInformation(), test_SummaryInfo(), and ATL::CFileTime::UTCToLocal().

213 {
214  LARGE_INTEGER TimeZoneBias, FileTime;
215  volatile KSYSTEM_TIME *TimePtr;
216 
217  TimePtr = IsTimeZoneRedirectionEnabled() ?
219  &SharedUserData->TimeZoneBias;
220  do
221  {
222  TimeZoneBias.HighPart = TimePtr->High1Time;
223  TimeZoneBias.LowPart = TimePtr->LowPart;
224  }
225  while (TimeZoneBias.HighPart != TimePtr->High2Time);
226 
227  FileTime.LowPart = lpFileTime->dwLowDateTime;
228  FileTime.HighPart = lpFileTime->dwHighDateTime;
229 
230  FileTime.QuadPart -= TimeZoneBias.QuadPart;
231 
232  lpLocalFileTime->dwLowDateTime = FileTime.LowPart;
233  lpLocalFileTime->dwHighDateTime = FileTime.HighPart;
234 
235  return TRUE;
236 }
ULONG LowPart
Definition: ketypes.h:895
#define TRUE
Definition: types.h:120
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
LONG High1Time
Definition: ketypes.h:896
#define SharedUserData
ULONG LowPart
Definition: typedefs.h:104
LONG High2Time
Definition: ketypes.h:897
KSYSTEM_TIME ktTermsrvClientBias
Definition: base.h:131
BOOL WINAPI IsTimeZoneRedirectionEnabled(VOID)
Definition: time.c:26
LONGLONG QuadPart
Definition: typedefs.h:112
BOOL WINAPI FileTimeToSystemTime ( IN CONST FILETIME lpFileTime,
OUT LPSYSTEMTIME  lpSystemTime 
)

Definition at line 178 of file time.c.

Referenced by _ILGetFileDate(), _tmain(), add_cert_to_view(), add_date_string_to_control(), compareTime(), CRYPT_AsnEncodeChoiceOfTime(), CRYPT_AsnEncodeGeneralizedTime(), CRYPT_AsnEncodeUtcTime(), CRYPT_MakeCertInfo(), ATL::CTime::CTime(), day_of_month(), DirPrintFileDateTime(), EventTimeToSystemTime(), ExtCabCallback(), filetime_to_str(), format_date(), format_long_date(), FormatDateTime(), get_date_from_filetime(), GetDriverDateString(), GetEnhancedVar(), GetFileModifyTime(), CFileDefExt::GetFileTimeString(), GetFileTimeString(), CRegistryKey::GetLastWriteTime(), CShellLink::Load(), LoadDIBFromFile(), MONTHCAL_CalculateDayOfWeek(), MONTHCAL_IsSelRangeValid(), NLS_GetDateTimeFormatW(), PrintDateTime(), printFileTime(), PROPVAR_ConvertFILETIME(), RtlTimeToTimeFields(), save_prop(), SaveDIBToFile(), SetupDiInstallDevice(), SHFormatDateTimeW(), summaryinfo_invoke(), SystemTimeToTzSpecificLocalTime(), test4(), test_FileTimeToLocalFileTime(), test_FileTimeToSystemTime(), test_GetTimeZoneInformation(), test_query_process_times(), test_SummaryInfo(), TIME_CompTimeZoneID(), TzSpecificLocalTimeToSystemTime(), UpdateSystemTime(), BtrfsScrub::UpdateTextBox(), and XCOPY_ParseCommandLine().

180 {
182  LARGE_INTEGER liTime;
183 
184  liTime.u.LowPart = lpFileTime->dwLowDateTime;
185  liTime.u.HighPart = lpFileTime->dwHighDateTime;
186  if (liTime.QuadPart < 0)
187  {
189  return FALSE;
190  }
191 
192  RtlTimeToTimeFields(&liTime, &TimeFields);
193 
194  lpSystemTime->wYear = TimeFields.Year;
195  lpSystemTime->wMonth = TimeFields.Month;
196  lpSystemTime->wDay = TimeFields.Day;
197  lpSystemTime->wHour = TimeFields.Hour;
198  lpSystemTime->wMinute = TimeFields.Minute;
199  lpSystemTime->wSecond = TimeFields.Second;
200  lpSystemTime->wMilliseconds = TimeFields.Milliseconds;
201  lpSystemTime->wDayOfWeek = TimeFields.Weekday;
202 
203  return TRUE;
204 }
USHORT Weekday
Definition: env_spec_w32.h:718
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
VOID NTAPI RtlTimeToTimeFields(IN PLARGE_INTEGER Time, OUT PTIME_FIELDS TimeFields)
Definition: time.c:253
struct _LARGE_INTEGER::@2037 u
#define FALSE
Definition: types.h:117
USHORT Milliseconds
Definition: env_spec_w32.h:717
#define SetLastError(x)
Definition: compat.h:409
static PTIME_FIELDS TimeFields
Definition: time.c:27
LONGLONG QuadPart
Definition: typedefs.h:112
VOID WINAPI GetLocalTime ( OUT LPSYSTEMTIME  lpSystemTime)

Definition at line 276 of file time.c.

Referenced by _getsystime(), CTrayClockWnd::CalculateDueTime(), CalculateNextStartTime(), ClockWndProc(), cmd_time(), CmosReadData(), CmosWriteData(), collect_query_data(), create_snapshot(), CreateProfile(), DATETIME_Create(), datetime_proc(), DateTimePageProc(), DIALOG_EditTimeDate(), DosInt21h(), EngQueryLocalTime(), fill_datetime_information(), FillMonthsComboBox(), FTP_ParseNextFile(), get_date_str(), get_localdatetime(), GetCurrentDayOfMonth(), GetDateString(), GetTimeAsJobTime(), GetTimeString(), Global_Date(), Global_Now(), Global_Time(), Global_Timer(), main(), MONTHCAL_Create(), MONTHCAL_Timer(), MonthCalSetLocalTime(), MonthCalSetupDayTimer(), msi_publish_install_properties(), NLS_GetDateTimeFormatW(), ClockWindow::Notify(), ParseDate(), ParseTime(), pSetupDebugPrint(), ReadPipeCompletion(), RtcTimeUpdate(), ServicesPageWndProc(), set_print_template(), TaskTriggerConstructor(), test_GetTimeZoneInformationForYear(), test_SetTrigger_GetTrigger(), test_SHFormatDateTimeA(), test_SHFormatDateTimeW(), TimerProc(), CTrayClockWnd::Update(), UpdateLocalSystemTime(), and vsyslog().

277 {
278  LARGE_INTEGER SystemTime, TimeZoneBias;
280  volatile KSYSTEM_TIME *TimePtr;
281 
282  do
283  {
284  SystemTime.HighPart = SharedUserData->SystemTime.High1Time;
285  SystemTime.LowPart = SharedUserData->SystemTime.LowPart;
286  }
287  while (SystemTime.HighPart != SharedUserData->SystemTime.High2Time);
288 
289  TimePtr = IsTimeZoneRedirectionEnabled() ?
291  &SharedUserData->TimeZoneBias;
292  do
293  {
294  TimeZoneBias.HighPart = TimePtr->High1Time;
295  TimeZoneBias.LowPart = TimePtr->LowPart;
296  }
297  while (TimeZoneBias.HighPart != TimePtr->High2Time);
298 
299  SystemTime.QuadPart -= TimeZoneBias.QuadPart;
300  RtlTimeToTimeFields(&SystemTime, &TimeFields);
301 
302  lpSystemTime->wYear = TimeFields.Year;
303  lpSystemTime->wMonth = TimeFields.Month;
304  lpSystemTime->wDay = TimeFields.Day;
305  lpSystemTime->wHour = TimeFields.Hour;
306  lpSystemTime->wMinute = TimeFields.Minute;
307  lpSystemTime->wSecond = TimeFields.Second;
308  lpSystemTime->wMilliseconds = TimeFields.Milliseconds;
309  lpSystemTime->wDayOfWeek = TimeFields.Weekday;
310 }
USHORT Weekday
Definition: env_spec_w32.h:718
ULONG LowPart
Definition: ketypes.h:895
VOID NTAPI RtlTimeToTimeFields(IN PLARGE_INTEGER Time, OUT PTIME_FIELDS TimeFields)
Definition: time.c:253
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
USHORT Milliseconds
Definition: env_spec_w32.h:717
LONG High1Time
Definition: ketypes.h:896
#define SharedUserData
ULONG LowPart
Definition: typedefs.h:104
LONG High2Time
Definition: ketypes.h:897
KSYSTEM_TIME ktTermsrvClientBias
Definition: base.h:131
static PTIME_FIELDS TimeFields
Definition: time.c:27
BOOL WINAPI IsTimeZoneRedirectionEnabled(VOID)
Definition: time.c:26
LONGLONG QuadPart
Definition: typedefs.h:112
VOID WINAPI GetSystemTime ( OUT LPSYSTEMTIME  lpSystemTime)

Definition at line 317 of file time.c.

Referenced by CComCatCachedCategory::CacheDSA(), copy(), CreateJob(), InternetTimeToSystemTimeW(), NetrRemoteTOD(), RecycleBin5_RecycleBin5_DeleteFile(), set_installer_properties(), SOFTPUB_LoadCertMessage(), test_dtm_set_and_get_system_time(), test_GetTimeZoneInformation(), test_IWinHttpRequest(), test_monthcal(), test_not_modified(), test_VarDateFromStr(), test_verifyTimeValidity(), TouchFileTimes(), VARIANT_MakeDate(), WinHttpTimeToSystemTime(), and WINTRUST_CertVerifyObjTrust().

318 {
319  LARGE_INTEGER SystemTime;
321 
322  do
323  {
324  SystemTime.HighPart = SharedUserData->SystemTime.High1Time;
325  SystemTime.LowPart = SharedUserData->SystemTime.LowPart;
326  }
327  while (SystemTime.HighPart != SharedUserData->SystemTime.High2Time);
328 
329  RtlTimeToTimeFields(&SystemTime, &TimeFields);
330 
331  lpSystemTime->wYear = TimeFields.Year;
332  lpSystemTime->wMonth = TimeFields.Month;
333  lpSystemTime->wDay = TimeFields.Day;
334  lpSystemTime->wHour = TimeFields.Hour;
335  lpSystemTime->wMinute = TimeFields.Minute;
336  lpSystemTime->wSecond = TimeFields.Second;
337  lpSystemTime->wMilliseconds = TimeFields.Milliseconds;
338  lpSystemTime->wDayOfWeek = TimeFields.Weekday;
339 }
USHORT Weekday
Definition: env_spec_w32.h:718
VOID NTAPI RtlTimeToTimeFields(IN PLARGE_INTEGER Time, OUT PTIME_FIELDS TimeFields)
Definition: time.c:253
USHORT Milliseconds
Definition: env_spec_w32.h:717
#define SharedUserData
ULONG LowPart
Definition: typedefs.h:104
static PTIME_FIELDS TimeFields
Definition: time.c:27
BOOL WINAPI GetSystemTimeAdjustment ( OUT PDWORD  lpTimeAdjustment,
OUT PDWORD  lpTimeIncrement,
OUT PBOOL  lpTimeAdjustmentDisabled 
)

Definition at line 476 of file time.c.

479 {
482 
484  &TimeInfo,
485  sizeof(TimeInfo),
486  NULL);
487  if (!NT_SUCCESS(Status))
488  {
489  BaseSetLastNTError(Status);
490  return FALSE;
491  }
492 
493  *lpTimeAdjustment = (DWORD)TimeInfo.TimeAdjustment;
494  *lpTimeIncrement = (DWORD)TimeInfo.TimeIncrement;
495  *lpTimeAdjustmentDisabled = (BOOL)TimeInfo.Enable;
496 
497  return TRUE;
498 }
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
static BOOL(WINAPI *pTzSpecificLocalTimeToSystemTime)(LPTIME_ZONE_INFORMATION
DWORD DWORD
Definition: winlogon.h:75
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
static DWORD(WINAPI *pGetDynamicTimeZoneInformation)(DYNAMIC_TIME_ZONE_INFORMATION *)
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
VOID WINAPI GetSystemTimeAsFileTime ( OUT PFILETIME  lpFileTime)

Definition at line 128 of file time.c.

Referenced by __security_init_cookie(), _ftime_s(), _LocalGetJobLevel2(), _time(), cache_container_set_size(), CertDllVerifyRevocation(), CertTrustFinalPolicy(), CertVerifyCRLTimeValidity(), CertVerifyTimeValidity(), clock(), CoFileTimeNow(), create_cache_entry(), CRYPT_CacheURL(), CRYPT_GetObjectFromCache(), CRYPT_MakeCertInfo(), DateConstr_value(), FreeUrlCacheSpaceW(), get_cookie(), get_cred_mgr_encryption_key(), get_file_time(), ATL::CFileTime::GetCurrentTime(), GetCurrentTimeInSeconds(), GetJobName(), GetTimeInSeconds(), gettimeofday(), init_fs_tree(), initclock(), is_not_current(), load_persistent_cookie(), registry_write_credential(), RPC_UuidGetSystemTime(), run_child_process(), save_persistent_cookie(), set_cookie(), START_TEST(), test_cache_read(), test_GetSystemTimePreciseAsFileTime(), test_IsUrlCacheEntryExpiredA(), test_urlcacheA(), TIME_ZoneID(), urlcache_entry_commit(), urlcache_entry_create(), urlcache_entry_get_file(), urlcache_entry_is_expired(), and urlcache_hash_entry_is_locked().

129 {
130  LARGE_INTEGER SystemTime;
131 
132  do
133  {
134  SystemTime.HighPart = SharedUserData->SystemTime.High1Time;
135  SystemTime.LowPart = SharedUserData->SystemTime.LowPart;
136  }
137  while (SystemTime.HighPart != SharedUserData->SystemTime.High2Time);
138 
139  lpFileTime->dwLowDateTime = SystemTime.LowPart;
140  lpFileTime->dwHighDateTime = SystemTime.HighPart;
141 }
#define SharedUserData
ULONG LowPart
Definition: typedefs.h:104
BOOL WINAPI GetSystemTimes ( OUT LPFILETIME lpIdleTime  OPTIONAL,
OUT LPFILETIME lpKernelTime  OPTIONAL,
OUT LPFILETIME lpUserTime  OPTIONAL 
)

Definition at line 531 of file time.c.

534 {
536  LARGE_INTEGER TotalUserTime, TotalKernTime, TotalIdleTime;
538  CCHAR i;
540 
541  TotalUserTime.QuadPart = TotalKernTime.QuadPart = TotalIdleTime.QuadPart = 0;
542 
543  BufferSize = sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) *
545 
546  ProcPerfInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferSize);
547  if (!ProcPerfInfo)
548  {
550  return FALSE;
551  }
552 
554  ProcPerfInfo,
555  BufferSize,
556  &ReturnLength);
557  if ((NT_SUCCESS(Status)) && (ReturnLength == BufferSize))
558  {
559  if (lpIdleTime)
560  {
561  for (i = 0; i < BaseStaticServerData->SysInfo.NumberOfProcessors; i++)
562  {
563  TotalIdleTime.QuadPart += ProcPerfInfo[i].IdleTime.QuadPart;
564  }
565 
566  lpIdleTime->dwLowDateTime = TotalIdleTime.LowPart;
567  lpIdleTime->dwHighDateTime = TotalIdleTime.HighPart;
568  }
569 
570  if (lpKernelTime)
571  {
572  for (i = 0; i < BaseStaticServerData->SysInfo.NumberOfProcessors; i++)
573  {
574  TotalKernTime.QuadPart += ProcPerfInfo[i].KernelTime.QuadPart;
575  }
576 
577  lpKernelTime->dwLowDateTime = TotalKernTime.LowPart;
578  lpKernelTime->dwHighDateTime = TotalKernTime.HighPart;
579  }
580 
581  if (lpUserTime)
582  {
583  for (i = 0; i < BaseStaticServerData->SysInfo.NumberOfProcessors; i++)
584  {
585  TotalUserTime.QuadPart += ProcPerfInfo[i].UserTime.QuadPart;
586  }
587 
588  lpUserTime->dwLowDateTime = TotalUserTime.LowPart;
589  lpUserTime->dwHighDateTime = TotalUserTime.HighPart;
590  }
591  }
592  else if (NT_SUCCESS(Status))
593  {
594  Status = STATUS_INTERNAL_ERROR;
595  }
596 
597  RtlFreeHeap(RtlGetProcessHeap(), 0, ProcPerfInfo);
598  if (!NT_SUCCESS(Status))
599  {
600  BaseSetLastNTError(Status);
601  return FALSE;
602  }
603 
604  return TRUE;
605 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
#define BufferSize
Definition: acefiex.h:377
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:451
GLenum GLclampf GLint i
Definition: glfuncs.h:14
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
#define FALSE
Definition: types.h:117
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
SYSTEM_BASIC_INFORMATION SysInfo
Definition: base.h:122
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
char CCHAR
Definition: typedefs.h:50
ULONG LowPart
Definition: typedefs.h:104
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int ULONG
Definition: retypes.h:1
LONGLONG QuadPart
Definition: typedefs.h:112
DWORD WINAPI GetTickCount ( VOID  )

Definition at line 445 of file time.c.

Referenced by __security_init_cookie(), _FileOpCount(), _FileOpCountManager(), _tmain(), _tWinMain(), AllSysInfo(), apartment_freeunusedlibraries(), BiosMiscService(), CalibrateTest(), CardWindow::CardWindow(), check_exe(), ClockUpdate(), collect_connections(), CommandChoice(), CommandTimer(), CFileDefExt::CountFolderAndFiles(), CoWaitForMultipleHandles(), CProgressDialog::CProgressDialog(), Defragment::Defragment(), DispatchMessageA(), DispatchMessageW(), DoControlService(), DoStartService(), DoStopService(), DrawGLScene(), DSOUND_callback(), DSOUND_capture_callback(), DSOUND_PrimaryGetPosition(), DSOUND_timer(), empty_message_queue(), EnableHardwareTimer(), flush_events(), GdiSAPCallback(), GenerateComputerName(), GetTime(), http_release_netconn(), IcmpSendEcho(), IDirectSoundBufferImpl_GetCurrentPosition(), IDirectSoundBufferImpl_Lock(), IDirectSoundCaptureBufferImpl_Lock(), InitMatrixMessage(), InitScreenSaveClass(), InputWait(), install_cab_file(), LBItemFromPt(), LISTVIEW_ProcessLetterKeys(), mailslot_test(), main(), make_discover(), MediaControl_GetState(), MIDI_player(), midiStreamRestart(), MMSYSTEM_MidiStream_MessageHandler(), MMSYSTEM_MidiStream_Player(), NotifyInfo::modify(), msi_create_empty_local_file(), mstsc_mousewheel(), NBNameCacheAddEntry(), NBNameCacheWalk(), NetBTAstatRemote(), NetBTNameWaitLoop(), NetBTWaitForNameResponse(), NetrRemoteTOD(), NotifyInfo::NotifyInfo(), NotifyTopLevelWindow(), OSK_DlgCommand(), OSK_ReleaseKey(), PeekMessageWorker(), PreInit(), PrimaryBufferImpl_GetCurrentPosition(), PrimaryBufferImpl_Lock(), process_timer(), processPendingMessages(), ProcessTest(), PulseSample(), pump_msg_loop_timeout(), QUARTZ_CreateSystemClock(), QueryTime(), NotifyArea::Refresh(), TrayNotifyDlg::RefreshProperties(), remove_target_tasks(), RetrieveQuote(), RPC_GetLocalClassObject(), rpcrt4_http_timer_calc_timeout(), rpcrt4_http_timer_thread(), rpcrt4_ncacn_http_open(), rpcrt4_ncacn_http_write(), run_benchmark(), CWineTest::RunTest(), ScreenSaverProc(), ScreenSaverThreadMain(), SendGetState(), ServiceStart(), set_task_timer(), SetAbortProc(), CProgressDialog::SetProgress64(), SHWaitForSendMessageThread(), SpeakerChange(), Defragment::Start(), StartDocW(), StartScreenSaver(), state_reboot(), StorageImpl_LockRegionSync(), swapchain_gdi_present(), swapchain_gl_present(), SystemClockImpl_GetTime(), test_AbortWaitCts(), test_api(), test_buffer(), test_buffer8(), test_dbcs_wm_char(), test_get_state(), test_globalness(), test_InputObject(), test_LoopbackRead(), test_not_modified(), test_OpenFileById(), test_QueueUserWorkItem(), test_read_write(), test_ReadTimeOut(), test_runner(), test_select(), test_send(), test_sioAddressListChange(), test_timers(), test_timers_no_wnd(), test_WaitBreak(), test_WaitCommEvent(), test_WaitCts(), test_WaitDcd(), test_WaitDsr(), test_WaitRing(), test_WaitRx(), test_waittxempty(), test_WM_GETDLGCODE(), ThemeWaitForServiceReady(), TIME_MMSysTimeCallback(), TIME_SetEventInternal(), TIME_TriggerCallBack(), timeGetSystemTime(), timeGetTime(), TREEVIEW_ProcessLetterKeys(), UpdateLanStatusUiDlg(), UpdateProgressBar(), verify_cert_revocation_from_dist_points_ext(), wait_for_event(), wait_move_event(), WaitService(), WDML_SyncWaitTransactionReply(), wmain(), WndProc(), and NotifyArea::WndProc().

446 {
447  ULARGE_INTEGER TickCount;
448 
449 #ifdef _WIN64
450  TickCount.QuadPart = *((volatile ULONG64*)&SharedUserData->TickCount);
451 #else
452  while (TRUE)
453  {
454  TickCount.HighPart = (ULONG)SharedUserData->TickCount.High1Time;
455  TickCount.LowPart = SharedUserData->TickCount.LowPart;
456 
457  if (TickCount.HighPart == (ULONG)SharedUserData->TickCount.High2Time)
458  break;
459 
460  YieldProcessor();
461  }
462 #endif
463 
464  return (ULONG)((UInt32x32To64(TickCount.LowPart,
465  SharedUserData->TickCountMultiplier) >> 24) +
466  UInt32x32To64((TickCount.HighPart << 8) & 0xFFFFFFFF,
467  SharedUserData->TickCountMultiplier));
468 
469 }
#define TRUE
Definition: types.h:120
$ULONG LowPart
Definition: ntbasedef.h:568
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
uint64_t ULONG64
Definition: typedefs.h:65
$ULONG HighPart
Definition: ntbasedef.h:569
if(!(yy_init))
Definition: macro.lex.yy.c:704
#define SharedUserData
unsigned int ULONG
Definition: retypes.h:1
#define UInt32x32To64(a, b)
Definition: intsafe.h:258
BOOL WINAPI IsTimeZoneRedirectionEnabled ( VOID  )

Definition at line 26 of file time.c.

Referenced by FileTimeToLocalFileTime(), GetLocalTime(), LocalFileTimeToFileTime(), and SetLocalTime().

27 {
28  /* Return if a TS Timezone ID is active */
30 }
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
#define TIME_ZONE_ID_INVALID
Definition: winbase.h:281
ULONG TermsrvClientTimeZoneId
Definition: base.h:132
BOOL WINAPI LocalFileTimeToFileTime ( IN CONST FILETIME lpLocalFileTime,
OUT LPFILETIME  lpFileTime 
)

Definition at line 243 of file time.c.

Referenced by cabinet_close_file_info(), fdi_notify_extract(), ATL::CFileTime::LocalToUTC(), summaryinfo_invoke(), test_SHFormatDateTimeA(), and test_SHFormatDateTimeW().

245 {
246  LARGE_INTEGER TimeZoneBias, FileTime;
247  volatile KSYSTEM_TIME *TimePtr;
248 
249  TimePtr = IsTimeZoneRedirectionEnabled() ?
251  &SharedUserData->TimeZoneBias;
252 
253  do
254  {
255  TimeZoneBias.HighPart = TimePtr->High1Time;
256  TimeZoneBias.LowPart = TimePtr->LowPart;
257  }
258  while (TimeZoneBias.HighPart != TimePtr->High2Time);
259 
260  FileTime.LowPart = lpLocalFileTime->dwLowDateTime;
261  FileTime.HighPart = lpLocalFileTime->dwHighDateTime;
262 
263  FileTime.QuadPart += TimeZoneBias.QuadPart;
264 
265  lpFileTime->dwLowDateTime = FileTime.LowPart;
266  lpFileTime->dwHighDateTime = FileTime.HighPart;
267 
268  return TRUE;
269 }
ULONG LowPart
Definition: ketypes.h:895
#define TRUE
Definition: types.h:120
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
LONG High1Time
Definition: ketypes.h:896
#define SharedUserData
ULONG LowPart
Definition: typedefs.h:104
LONG High2Time
Definition: ketypes.h:897
KSYSTEM_TIME ktTermsrvClientBias
Definition: base.h:131
BOOL WINAPI IsTimeZoneRedirectionEnabled(VOID)
Definition: time.c:26
LONGLONG QuadPart
Definition: typedefs.h:112
BOOL WINAPI SetClientTimeZoneInformation ( IN CONST TIME_ZONE_INFORMATION lpTimeZoneInformation)

Definition at line 612 of file time.c.

613 {
614  STUB;
615  return 0;
616 }
#define STUB
Definition: kernel32.h:27
BOOL WINAPI SetLocalTime ( IN CONST SYSTEMTIME lpSystemTime)

Definition at line 346 of file time.c.

Referenced by _setsystime(), CmosWriteData(), DosInt21h(), ParseDate(), ParseTime(), SetSystemLocalTime(), and SystemSetLocalTime().

347 {
348  LARGE_INTEGER NewSystemTime, TimeZoneBias;
352  PVOID State;
353  volatile KSYSTEM_TIME *TimePtr;
354 
355  TimePtr = IsTimeZoneRedirectionEnabled() ?
357  &SharedUserData->TimeZoneBias;
358  do
359  {
360  TimeZoneBias.HighPart = TimePtr->High1Time;
361  TimeZoneBias.LowPart = TimePtr->LowPart;
362  }
363  while (TimeZoneBias.HighPart != TimePtr->High2Time);
364 
365  TimeFields.Year = lpSystemTime->wYear;
366  TimeFields.Month = lpSystemTime->wMonth;
367  TimeFields.Day = lpSystemTime->wDay;
368  TimeFields.Hour = lpSystemTime->wHour;
369  TimeFields.Minute = lpSystemTime->wMinute;
370  TimeFields.Second = lpSystemTime->wSecond;
371  TimeFields.Milliseconds = lpSystemTime->wMilliseconds;
372 
373  if (!RtlTimeFieldsToTime(&TimeFields, &NewSystemTime))
374  {
376  return FALSE;
377  }
378 
379  NewSystemTime.QuadPart += TimeZoneBias.QuadPart;
380 
381  Status = RtlAcquirePrivilege(&Privilege, 1, 0, &State);
382  if (NT_SUCCESS(Status))
383  {
384  Status = NtSetSystemTime(&NewSystemTime, NULL);
385  RtlReleasePrivilege(State);
386  }
387 
388  if (!NT_SUCCESS(Status))
389  {
390  BaseSetLastNTError(Status);
391  return FALSE;
392  }
393 
394  return TRUE;
395 }
DWORD *typedef PVOID
Definition: winlogon.h:52
ULONG LowPart
Definition: ketypes.h:895
#define TRUE
Definition: types.h:120
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define SE_SYSTEMTIME_PRIVILEGE
Definition: security.c:672
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
NTSYSAPI VOID NTAPI RtlReleasePrivilege(_In_ PVOID ReturnedState)
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
USHORT Milliseconds
Definition: env_spec_w32.h:717
NTSTATUS NTAPI NtSetSystemTime(IN PLARGE_INTEGER SystemTime, OUT PLARGE_INTEGER PreviousTime OPTIONAL)
Definition: time.c:339
LONG High1Time
Definition: ketypes.h:896
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531
#define SharedUserData
ULONG LowPart
Definition: typedefs.h:104
Status
Definition: gdiplustypes.h:24
LONG High2Time
Definition: ketypes.h:897
enum State_ State
Definition: pofuncs.h:54
LONG NTSTATUS
Definition: DriverTester.h:11
KSYSTEM_TIME ktTermsrvClientBias
Definition: base.h:131
BOOLEAN NTAPI RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, OUT PLARGE_INTEGER Time)
Definition: time.c:170
NTSYSAPI NTSTATUS NTAPI RtlAcquirePrivilege(_In_ PULONG Privilege, _In_ ULONG NumPriv, _In_ ULONG Flags, _Out_ PVOID *ReturnedState)
unsigned int ULONG
Definition: retypes.h:1
static PTIME_FIELDS TimeFields
Definition: time.c:27
BOOL WINAPI IsTimeZoneRedirectionEnabled(VOID)
Definition: time.c:26
LONGLONG QuadPart
Definition: typedefs.h:112
BOOL WINAPI SetSystemTime ( IN CONST SYSTEMTIME lpSystemTime)

Definition at line 402 of file time.c.

403 {
404  LARGE_INTEGER NewSystemTime;
408  PVOID State;
409 
410  TimeFields.Year = lpSystemTime->wYear;
411  TimeFields.Month = lpSystemTime->wMonth;
412  TimeFields.Day = lpSystemTime->wDay;
413  TimeFields.Hour = lpSystemTime->wHour;
414  TimeFields.Minute = lpSystemTime->wMinute;
415  TimeFields.Second = lpSystemTime->wSecond;
416  TimeFields.Milliseconds = lpSystemTime->wMilliseconds;
417 
418  if (!RtlTimeFieldsToTime(&TimeFields, &NewSystemTime))
419  {
421  return FALSE;
422  }
423 
424  Status = RtlAcquirePrivilege(&Privilege, 1, 0, &State);
425  if (NT_SUCCESS(Status))
426  {
427  Status = NtSetSystemTime(&NewSystemTime, NULL);
428  RtlReleasePrivilege(State);
429  }
430 
431  if (!NT_SUCCESS(Status))
432  {
433  BaseSetLastNTError(Status);
434  return FALSE;
435  }
436 
437  return TRUE;
438 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define SE_SYSTEMTIME_PRIVILEGE
Definition: security.c:672
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
NTSYSAPI VOID NTAPI RtlReleasePrivilege(_In_ PVOID ReturnedState)
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
USHORT Milliseconds
Definition: env_spec_w32.h:717
NTSTATUS NTAPI NtSetSystemTime(IN PLARGE_INTEGER SystemTime, OUT PLARGE_INTEGER PreviousTime OPTIONAL)
Definition: time.c:339
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531
Status
Definition: gdiplustypes.h:24
enum State_ State
Definition: pofuncs.h:54
LONG NTSTATUS
Definition: DriverTester.h:11
BOOLEAN NTAPI RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, OUT PLARGE_INTEGER Time)
Definition: time.c:170
NTSYSAPI NTSTATUS NTAPI RtlAcquirePrivilege(_In_ PULONG Privilege, _In_ ULONG NumPriv, _In_ ULONG Flags, _Out_ PVOID *ReturnedState)
unsigned int ULONG
Definition: retypes.h:1
static PTIME_FIELDS TimeFields
Definition: time.c:27
BOOL WINAPI SetSystemTimeAdjustment ( IN DWORD  dwTimeAdjustment,
IN BOOL  bTimeAdjustmentDisabled 
)

Definition at line 505 of file time.c.

507 {
510 
511  TimeInfo.TimeAdjustment = (ULONG)dwTimeAdjustment;
512  TimeInfo.Enable = (BOOLEAN)bTimeAdjustmentDisabled;
513 
515  &TimeInfo,
516  sizeof(TimeInfo));
517  if (!NT_SUCCESS(Status))
518  {
519  BaseSetLastNTError(Status);
520  return FALSE;
521  }
522 
523  return TRUE;
524 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
NTSYSAPI NTSTATUS NTAPI NtSetSystemInformation(IN INT SystemInformationClass, IN PVOID SystemInformation, IN ULONG SystemInformationLength)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
#define BOOLEAN
Definition: pedump.c:73
unsigned int ULONG
Definition: retypes.h:1
BOOL WINAPI SystemTimeToFileTime ( IN CONST SYSTEMTIME lpSystemTime,
OUT LPFILETIME  lpFileTime 
)

Definition at line 148 of file time.c.

Referenced by _LocalGetJobLevel2(), _PrinterJobListCompareRoutine(), CalculateNextStartTime(), collect_query_data(), copy(), CRYPT_AsnDecodeGeneralizedTime(), CRYPT_AsnDecodeUtcTimeInternal(), CRYPT_MakeCertInfo(), day_of_month(), EventTimeToSystemTime(), FTP_ConvertFileProp(), getChain(), GetCurrentTimeInSeconds(), gettimeofday(), GetVersionInformationFromInfFile(), HTTP_ParseDateAsAsctime(), HTTP_ParseRfc1123Date(), HTTP_ParseRfc850Date(), HTTP_RetrieveEncodedObjectW(), MONTHCAL_CalculateDayOfWeek(), MONTHCAL_CompareSystemTime(), MONTHCAL_IsSelRangeValid(), MONTHCAL_SetRange(), NLS_GetDateTimeFormatW(), parse_filetime(), RecycleBin5_RecycleBin5_DeleteFile(), RtlTimeFieldsToTime(), set_cookie(), SOFTPUB_LoadCertMessage(), summaryinfo_invoke(), system_time_to_minutes(), SystemTimeToTzSpecificLocalTime(), test_CERT_CHAIN_PARA_cbSize(), test_conversions(), test_decodeCTL(), test_decodeFiletime(), test_encodeCTL(), test_GetTimeZoneInformation(), test_invalid_arg(), test_SHFormatDateTimeA(), test_SHFormatDateTimeW(), test_verifyRevocation(), test_verifyTimeValidity(), testGetCertChain(), testTimeEncoding(), time_to_filetime(), TouchFileTimes(), TzSpecificLocalTimeToSystemTime(), UpdateSystemTime(), WINTRUST_CertVerifyObjTrust(), and XCOPY_ParseCommandLine().

150 {
152  LARGE_INTEGER liTime;
153 
154  TimeFields.Year = lpSystemTime->wYear;
155  TimeFields.Month = lpSystemTime->wMonth;
156  TimeFields.Day = lpSystemTime->wDay;
157  TimeFields.Hour = lpSystemTime->wHour;
158  TimeFields.Minute = lpSystemTime->wMinute;
159  TimeFields.Second = lpSystemTime->wSecond;
160  TimeFields.Milliseconds = lpSystemTime->wMilliseconds;
161 
162  if (RtlTimeFieldsToTime(&TimeFields, &liTime))
163  {
164  lpFileTime->dwLowDateTime = liTime.u.LowPart;
165  lpFileTime->dwHighDateTime = liTime.u.HighPart;
166  return TRUE;
167  }
168 
170  return FALSE;
171 }
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _LARGE_INTEGER::@2037 u
#define FALSE
Definition: types.h:117
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
USHORT Milliseconds
Definition: env_spec_w32.h:717
BOOLEAN NTAPI RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, OUT PLARGE_INTEGER Time)
Definition: time.c:170
static PTIME_FIELDS TimeFields
Definition: time.c:27