https://git.reactos.org/?p=reactos.git;a=commitdiff;h=743bbc32b74c23ed5920e…
commit 743bbc32b74c23ed5920e8c17a514f20eb6ce320
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Mon Oct 8 16:06:48 2018 +0300
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Oct 8 16:36:17 2018 +0200
[SYSTEMINFO] Improve uptime source
---
.../applications/sysutils/systeminfo/systeminfo.c | 46 +++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/modules/rosapps/applications/sysutils/systeminfo/systeminfo.c
b/modules/rosapps/applications/sysutils/systeminfo/systeminfo.c
index e0adc2d5a7..407553e887 100644
--- a/modules/rosapps/applications/sysutils/systeminfo/systeminfo.c
+++ b/modules/rosapps/applications/sysutils/systeminfo/systeminfo.c
@@ -179,6 +179,50 @@ FormatDateTime(time_t Time, LPWSTR lpBuf)
GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf + i, BUFFER_SIZE -
i);
}
+ULONGLONG GetSecondsQPC(VOID)
+{
+ LARGE_INTEGER Counter, Frequency;
+
+ QueryPerformanceCounter(&Counter);
+ QueryPerformanceFrequency(&Frequency);
+
+ return Counter.QuadPart / Frequency.QuadPart;
+}
+
+ULONGLONG GetSeconds(VOID)
+{
+ ULONGLONG (WINAPI * pGetTickCount64)(VOID);
+ ULONGLONG Ticks64;
+ HMODULE hModule = GetModuleHandleW(L"kernel32.dll");
+
+ pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
+ if (pGetTickCount64)
+ {
+ return pGetTickCount64() / 1000;
+ }
+
+ hModule = LoadLibraryW(L"kernel32_vista.dll");
+
+ if (!hModule)
+ {
+ return GetSecondsQPC();
+ }
+
+ pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
+
+ if (pGetTickCount64)
+ {
+ Ticks64 = pGetTickCount64() / 1000;
+ }
+ else
+ {
+ Ticks64 = GetSecondsQPC();
+ }
+
+ FreeLibrary(hModule);
+ return Ticks64;
+}
+
/* Show usage */
static
VOID
@@ -317,7 +361,7 @@ AllSysInfo(VOID)
RegCloseKey(hKey);
//getting System Up Time
- cSeconds = GetTickCount() / 1000;
+ cSeconds = GetSeconds();
if (!LoadStringW(GetModuleHandle(NULL), IDS_UP_TIME_FORMAT, Tmp, BUFFER_SIZE))
Tmp[0] = L'\0';
swprintf(Buf, Tmp, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60)
% 60, cSeconds % 60);