2000-09-29 22:48:04 +02:00
|
|
|
/*
|
2002-12-13 21:30:06 +01:00
|
|
|
* Win32 kernel time functions
|
2000-09-29 22:48:04 +02:00
|
|
|
*
|
|
|
|
* Copyright 1995 Martin von Loewis and Cameron Heide
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
|
2002-03-11 06:08:38 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
#include <string.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2004-03-10 00:51:02 +01:00
|
|
|
#include <stdarg.h>
|
2000-11-01 04:11:12 +01:00
|
|
|
#include <stdlib.h>
|
2004-03-10 00:51:02 +01:00
|
|
|
#include <time.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
2002-08-26 23:53:24 +02:00
|
|
|
#ifdef HAVE_SYS_TIMES_H
|
|
|
|
# include <sys/times.h>
|
|
|
|
#endif
|
2005-08-22 11:33:37 +02:00
|
|
|
#ifdef HAVE_SYS_LIMITS_H
|
|
|
|
#include <sys/limits.h>
|
|
|
|
#elif defined(HAVE_MACHINE_LIMITS_H)
|
2005-05-18 20:20:23 +02:00
|
|
|
#include <machine/limits.h>
|
|
|
|
#endif
|
2019-05-30 10:49:08 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
# include <mach/mach_time.h>
|
|
|
|
#endif
|
2003-01-07 21:36:20 +01:00
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2015-03-12 10:39:31 +01:00
|
|
|
#define NONAMELESSUNION
|
2004-03-10 00:51:02 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2019-11-22 13:30:42 +01:00
|
|
|
#include "winreg.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2003-12-01 23:47:28 +01:00
|
|
|
#include "kernel_private.h"
|
2001-04-09 20:45:49 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2004-02-26 06:29:55 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(time);
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2019-05-15 12:45:49 +02:00
|
|
|
static inline void longlong_to_filetime( LONGLONG t, FILETIME *ft )
|
|
|
|
{
|
|
|
|
ft->dwLowDateTime = (DWORD)t;
|
|
|
|
ft->dwHighDateTime = (DWORD)(t >> 32);
|
|
|
|
}
|
|
|
|
|
2019-05-30 10:49:08 +02:00
|
|
|
#define TICKSPERSEC 10000000
|
|
|
|
#define TICKSPERMSEC 10000
|
|
|
|
|
|
|
|
/* return a monotonic time counter, in Win32 ticks */
|
|
|
|
static inline ULONGLONG monotonic_counter(void)
|
|
|
|
{
|
|
|
|
LARGE_INTEGER counter;
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
static mach_timebase_info_data_t timebase;
|
|
|
|
|
|
|
|
if (!timebase.denom) mach_timebase_info( &timebase );
|
2019-11-27 16:54:09 +01:00
|
|
|
#ifdef HAVE_MACH_CONTINUOUS_TIME
|
|
|
|
if (&mach_continuous_time != NULL)
|
|
|
|
return mach_continuous_time() * timebase.numer / timebase.denom / 100;
|
|
|
|
#endif
|
2019-05-30 10:49:08 +02:00
|
|
|
return mach_absolute_time() * timebase.numer / timebase.denom / 100;
|
|
|
|
#elif defined(HAVE_CLOCK_GETTIME)
|
|
|
|
struct timespec ts;
|
|
|
|
#ifdef CLOCK_MONOTONIC_RAW
|
|
|
|
if (!clock_gettime( CLOCK_MONOTONIC_RAW, &ts ))
|
|
|
|
return ts.tv_sec * (ULONGLONG)TICKSPERSEC + ts.tv_nsec / 100;
|
|
|
|
#endif
|
|
|
|
if (!clock_gettime( CLOCK_MONOTONIC, &ts ))
|
|
|
|
return ts.tv_sec * (ULONGLONG)TICKSPERSEC + ts.tv_nsec / 100;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NtQueryPerformanceCounter( &counter, NULL );
|
|
|
|
return counter.QuadPart;
|
|
|
|
}
|
|
|
|
|
2004-10-27 23:19:22 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetSystemTimeAdjustment (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Get the period between clock interrupts and the amount the clock
|
|
|
|
* is adjusted each interrupt so as to keep it in sync with an external source.
|
|
|
|
*
|
2006-01-06 21:07:46 +01:00
|
|
|
* PARAMS
|
|
|
|
* lpTimeAdjustment [out] The clock adjustment per interrupt in 100's of nanoseconds.
|
|
|
|
* lpTimeIncrement [out] The time between clock interrupts in 100's of nanoseconds.
|
|
|
|
* lpTimeAdjustmentDisabled [out] The clock synchronisation has been disabled.
|
|
|
|
*
|
2004-10-27 23:19:22 +02:00
|
|
|
* RETURNS
|
|
|
|
* TRUE.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Only the special case of disabled time adjustments is supported.
|
|
|
|
*/
|
2006-01-06 21:07:46 +01:00
|
|
|
BOOL WINAPI GetSystemTimeAdjustment( PDWORD lpTimeAdjustment, PDWORD lpTimeIncrement,
|
|
|
|
PBOOL lpTimeAdjustmentDisabled )
|
2004-10-27 23:19:22 +02:00
|
|
|
{
|
|
|
|
*lpTimeAdjustment = 0;
|
2009-09-30 22:09:31 +02:00
|
|
|
*lpTimeIncrement = 10000000 / sysconf(_SC_CLK_TCK);
|
2004-10-27 23:19:22 +02:00
|
|
|
*lpTimeAdjustmentDisabled = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-12-19 05:12:42 +01:00
|
|
|
|
2004-10-27 23:19:22 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetSystemTimeAdjustment (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Enables or disables the timing adjustments to the system's clock.
|
|
|
|
*
|
2006-01-06 21:07:46 +01:00
|
|
|
* PARAMS
|
|
|
|
* dwTimeAdjustment [in] Number of units to add per clock interrupt.
|
|
|
|
* bTimeAdjustmentDisabled [in] Adjustment mode.
|
|
|
|
*
|
2004-10-27 23:19:22 +02:00
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
|
|
|
*/
|
2006-01-06 21:07:46 +01:00
|
|
|
BOOL WINAPI SetSystemTimeAdjustment( DWORD dwTimeAdjustment, BOOL bTimeAdjustmentDisabled )
|
2004-10-27 23:19:22 +02:00
|
|
|
{
|
|
|
|
/* Fake function for now... */
|
2006-10-12 22:56:29 +02:00
|
|
|
FIXME("(%08x,%d): stub !\n", dwTimeAdjustment, bTimeAdjustmentDisabled);
|
2002-12-19 05:12:42 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
/*********************************************************************
|
2000-12-20 00:33:03 +01:00
|
|
|
* TIME_ClockTimeToFileTime (olorin@fandra.org, 20-Sep-1998)
|
|
|
|
*
|
|
|
|
* Used by GetProcessTimes to convert clock_t into FILETIME.
|
|
|
|
*
|
2000-09-29 22:48:04 +02:00
|
|
|
* Differences to UnixTimeToFileTime:
|
|
|
|
* 1) Divided by CLK_TCK
|
2002-06-01 01:06:46 +02:00
|
|
|
* 2) Time is relative. There is no 'starting date', so there is
|
2003-08-18 21:47:42 +02:00
|
|
|
* no need for offset correction, like in UnixTimeToFileTime
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
static void TIME_ClockTimeToFileTime(clock_t unix_time, LPFILETIME filetime)
|
|
|
|
{
|
2007-09-10 10:14:42 +02:00
|
|
|
long clocksPerSec = sysconf(_SC_CLK_TCK);
|
2009-08-24 12:50:11 +02:00
|
|
|
ULONGLONG secs = (ULONGLONG)unix_time * 10000000 / clocksPerSec;
|
2002-05-29 19:04:10 +02:00
|
|
|
filetime->dwLowDateTime = (DWORD)secs;
|
|
|
|
filetime->dwHighDateTime = (DWORD)(secs >> 32);
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetProcessTimes (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Get the user and kernel execution times of a process,
|
2000-12-20 00:33:03 +01:00
|
|
|
* along with the creation and exit times if known.
|
|
|
|
*
|
2006-01-06 21:07:46 +01:00
|
|
|
* PARAMS
|
|
|
|
* hprocess [in] The process to be queried.
|
|
|
|
* lpCreationTime [out] The creation time of the process.
|
|
|
|
* lpExitTime [out] The exit time of the process if exited.
|
|
|
|
* lpKernelTime [out] The time spent in kernel routines in 100's of nanoseconds.
|
|
|
|
* lpUserTime [out] The time spent in user routines in 100's of nanoseconds.
|
|
|
|
*
|
2000-12-20 00:33:03 +01:00
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* TRUE.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* NOTES
|
|
|
|
* olorin@fandra.org:
|
|
|
|
* Would be nice to subtract the cpu time used by Wine at startup.
|
|
|
|
* Also, there is a need to separate times used by different applications.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* BUGS
|
2006-07-20 23:30:04 +02:00
|
|
|
* KernelTime and UserTime are always for the current process
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2006-01-06 21:07:46 +01:00
|
|
|
BOOL WINAPI GetProcessTimes( HANDLE hprocess, LPFILETIME lpCreationTime,
|
|
|
|
LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
struct tms tms;
|
2006-07-20 23:30:04 +02:00
|
|
|
KERNEL_USER_TIMES pti;
|
2000-09-29 22:48:04 +02:00
|
|
|
|
|
|
|
times(&tms);
|
|
|
|
TIME_ClockTimeToFileTime(tms.tms_utime,lpUserTime);
|
|
|
|
TIME_ClockTimeToFileTime(tms.tms_stime,lpKernelTime);
|
2006-07-20 23:30:04 +02:00
|
|
|
if (NtQueryInformationProcess( hprocess, ProcessTimes, &pti, sizeof(pti), NULL))
|
|
|
|
return FALSE;
|
2019-05-15 12:45:49 +02:00
|
|
|
longlong_to_filetime( pti.CreateTime.QuadPart, lpCreationTime );
|
|
|
|
longlong_to_filetime( pti.ExitTime.QuadPart, lpExitTime );
|
2000-09-29 22:48:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-02-26 23:33:29 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 05:36:23 +02:00
|
|
|
* GetCalendarInfoA (KERNEL32.@)
|
2001-02-26 23:33:29 +01:00
|
|
|
*
|
|
|
|
*/
|
2003-12-01 23:47:28 +01:00
|
|
|
int WINAPI GetCalendarInfoA(LCID lcid, CALID Calendar, CALTYPE CalType,
|
2001-02-26 23:33:29 +01:00
|
|
|
LPSTR lpCalData, int cchData, LPDWORD lpValue)
|
|
|
|
{
|
2014-06-12 15:51:24 +02:00
|
|
|
int ret, cchDataW = cchData;
|
2002-05-14 23:44:07 +02:00
|
|
|
LPWSTR lpCalDataW = NULL;
|
|
|
|
|
2003-12-01 23:47:28 +01:00
|
|
|
if (NLS_IsUnicodeOnlyLcid(lcid))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-12 15:51:24 +02:00
|
|
|
if (!cchData && !(CalType & CAL_RETURN_NUMBER))
|
|
|
|
cchDataW = GetCalendarInfoW(lcid, Calendar, CalType, NULL, 0, NULL);
|
|
|
|
if (!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchDataW*sizeof(WCHAR))))
|
|
|
|
return 0;
|
2003-12-01 23:47:28 +01:00
|
|
|
|
2014-06-12 15:51:24 +02:00
|
|
|
ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchDataW, lpValue);
|
2002-05-14 23:44:07 +02:00
|
|
|
if(ret && lpCalDataW && lpCalData)
|
2014-06-12 15:51:24 +02:00
|
|
|
ret = WideCharToMultiByte(CP_ACP, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
|
2011-06-08 16:18:26 +02:00
|
|
|
else if (CalType & CAL_RETURN_NUMBER)
|
|
|
|
ret *= sizeof(WCHAR);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpCalDataW);
|
2002-05-14 23:44:07 +02:00
|
|
|
|
|
|
|
return ret;
|
2001-02-26 23:33:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 05:36:23 +02:00
|
|
|
* SetCalendarInfoA (KERNEL32.@)
|
2001-02-26 23:33:29 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
int WINAPI SetCalendarInfoA(LCID Locale, CALID Calendar, CALTYPE CalType, LPCSTR lpCalData)
|
|
|
|
{
|
2006-10-12 22:56:29 +02:00
|
|
|
FIXME("(%08x,%08x,%08x,%s): stub\n",
|
2001-02-26 23:33:29 +01:00
|
|
|
Locale, Calendar, CalType, debugstr_a(lpCalData));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-03-03 03:17:58 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* GetDaylightFlag (KERNEL32.@)
|
|
|
|
*
|
2008-03-17 21:51:39 +01:00
|
|
|
* Specifies if daylight savings time is in operation.
|
2006-01-06 21:07:46 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* This function is called from the Win98's control applet timedate.cpl.
|
2004-03-03 03:17:58 +01:00
|
|
|
*
|
2006-01-06 21:07:46 +01:00
|
|
|
* RETURNS
|
2008-03-17 21:51:39 +01:00
|
|
|
* TRUE if daylight savings time is in operation.
|
2006-01-06 21:07:46 +01:00
|
|
|
* FALSE otherwise.
|
2004-03-03 03:17:58 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetDaylightFlag(void)
|
|
|
|
{
|
2004-10-27 23:19:22 +02:00
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
2019-12-10 18:14:19 +01:00
|
|
|
return GetTimeZoneInformation( &tzinfo) == TIME_ZONE_ID_DAYLIGHT;
|
2004-03-03 03:17:58 +01:00
|
|
|
}
|
2004-04-28 05:53:19 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DosDateTimeToFileTime (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DosDateTimeToFileTime( WORD fatdate, WORD fattime, LPFILETIME ft)
|
|
|
|
{
|
|
|
|
struct tm newtm;
|
|
|
|
#ifndef HAVE_TIMEGM
|
|
|
|
struct tm *gtm;
|
|
|
|
time_t time1, time2;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
newtm.tm_sec = (fattime & 0x1f) * 2;
|
|
|
|
newtm.tm_min = (fattime >> 5) & 0x3f;
|
|
|
|
newtm.tm_hour = (fattime >> 11);
|
|
|
|
newtm.tm_mday = (fatdate & 0x1f);
|
|
|
|
newtm.tm_mon = ((fatdate >> 5) & 0x0f) - 1;
|
|
|
|
newtm.tm_year = (fatdate >> 9) + 80;
|
2007-03-08 21:06:41 +01:00
|
|
|
newtm.tm_isdst = -1;
|
2004-04-28 05:53:19 +02:00
|
|
|
#ifdef HAVE_TIMEGM
|
|
|
|
RtlSecondsSince1970ToTime( timegm(&newtm), (LARGE_INTEGER *)ft );
|
|
|
|
#else
|
|
|
|
time1 = mktime(&newtm);
|
|
|
|
gtm = gmtime(&time1);
|
|
|
|
time2 = mktime(gtm);
|
|
|
|
RtlSecondsSince1970ToTime( 2*time1-time2, (LARGE_INTEGER *)ft );
|
|
|
|
#endif
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FileTimeToDosDateTime (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileTimeToDosDateTime( const FILETIME *ft, LPWORD fatdate,
|
|
|
|
LPWORD fattime )
|
|
|
|
{
|
|
|
|
LARGE_INTEGER li;
|
|
|
|
ULONG t;
|
|
|
|
time_t unixtime;
|
|
|
|
struct tm* tm;
|
|
|
|
|
2011-03-08 00:55:35 +01:00
|
|
|
if (!fatdate || !fattime)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-04-28 05:53:19 +02:00
|
|
|
li.u.LowPart = ft->dwLowDateTime;
|
|
|
|
li.u.HighPart = ft->dwHighDateTime;
|
2011-03-08 00:55:35 +01:00
|
|
|
if (!RtlTimeToSecondsSince1970( &li, &t ))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-04-28 05:53:19 +02:00
|
|
|
unixtime = t;
|
|
|
|
tm = gmtime( &unixtime );
|
2017-02-15 10:51:31 +01:00
|
|
|
*fattime = (tm->tm_hour << 11) + (tm->tm_min << 5) + (tm->tm_sec / 2);
|
|
|
|
*fatdate = ((tm->tm_year - 80) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday;
|
2004-04-28 05:53:19 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2009-03-26 23:00:55 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* GetSystemTimes (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Retrieves system timing information
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpIdleTime [O] Destination for idle time.
|
|
|
|
* lpKernelTime [O] Destination for kernel time.
|
|
|
|
* lpUserTime [O] Destination for user time.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if success, FALSE otherwise.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetSystemTimes(LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime)
|
|
|
|
{
|
2015-06-10 05:38:08 +02:00
|
|
|
LARGE_INTEGER idle_time, kernel_time, user_time;
|
|
|
|
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION *sppi;
|
|
|
|
SYSTEM_BASIC_INFORMATION sbi;
|
|
|
|
ULONG ret_size;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", lpIdleTime, lpKernelTime, lpUserTime);
|
|
|
|
|
2019-10-01 09:36:16 +02:00
|
|
|
if (!set_ntstatus( NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), &ret_size )))
|
2015-06-10 05:38:08 +02:00
|
|
|
return FALSE;
|
2009-03-26 23:00:55 +01:00
|
|
|
|
2015-06-10 05:38:08 +02:00
|
|
|
sppi = HeapAlloc( GetProcessHeap(), 0,
|
|
|
|
sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * sbi.NumberOfProcessors);
|
|
|
|
if (!sppi)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_OUTOFMEMORY );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-10-01 09:36:16 +02:00
|
|
|
if (!set_ntstatus( NtQuerySystemInformation( SystemProcessorPerformanceInformation, sppi,
|
|
|
|
sizeof(*sppi) * sbi.NumberOfProcessors, &ret_size )))
|
2015-06-10 05:38:08 +02:00
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, sppi );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
idle_time.QuadPart = 0;
|
|
|
|
kernel_time.QuadPart = 0;
|
|
|
|
user_time.QuadPart = 0;
|
|
|
|
for (i = 0; i < sbi.NumberOfProcessors; i++)
|
|
|
|
{
|
|
|
|
idle_time.QuadPart += sppi[i].IdleTime.QuadPart;
|
|
|
|
kernel_time.QuadPart += sppi[i].KernelTime.QuadPart;
|
|
|
|
user_time.QuadPart += sppi[i].UserTime.QuadPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpIdleTime)
|
|
|
|
{
|
|
|
|
lpIdleTime->dwLowDateTime = idle_time.u.LowPart;
|
|
|
|
lpIdleTime->dwHighDateTime = idle_time.u.HighPart;
|
|
|
|
}
|
|
|
|
if (lpKernelTime)
|
|
|
|
{
|
|
|
|
lpKernelTime->dwLowDateTime = kernel_time.u.LowPart;
|
|
|
|
lpKernelTime->dwHighDateTime = kernel_time.u.HighPart;
|
|
|
|
}
|
|
|
|
if (lpUserTime)
|
|
|
|
{
|
|
|
|
lpUserTime->dwLowDateTime = user_time.u.LowPart;
|
|
|
|
lpUserTime->dwHighDateTime = user_time.u.HighPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, sppi );
|
|
|
|
return TRUE;
|
2009-03-26 23:00:55 +01:00
|
|
|
}
|
2012-07-05 15:26:48 +02:00
|
|
|
|
2019-05-30 10:49:08 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetTickCount64 (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
|
|
|
|
{
|
|
|
|
return monotonic_counter() / TICKSPERMSEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetTickCount (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Get the number of milliseconds the system has been running.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The current tick count.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The value returned will wrap around every 2^32 milliseconds.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
|
|
|
|
{
|
|
|
|
return monotonic_counter() / TICKSPERMSEC;
|
|
|
|
}
|