From cb7b76a1ab948797991d2d7ee0d2171f45e7c9d0 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Tue, 10 Nov 2020 17:13:02 -0800 Subject: [PATCH] 1. Removed LoadLibraryExA() call for GetTickCount64 on windows 2. Fixed self update bug on older installs --- meshservice/ServiceMain.c | 2 +- microstack/ILibParsers.c | 19 +------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/meshservice/ServiceMain.c b/meshservice/ServiceMain.c index c1f89ef..561dd26 100644 --- a/meshservice/ServiceMain.c +++ b/meshservice/ServiceMain.c @@ -722,7 +722,7 @@ int wmain(int argc, char* wargv[]) else { // Legacy - if (argc > 1 && (strcmp(argv[2], "run") == 0 || strcmp(argv[2], "connect") == 0)) + if (argc > 2 && (strcmp(argv[2], "run") == 0 || strcmp(argv[2], "connect") == 0)) { // Console Mode updateLen = sprintf_s(update, 1024, "require('agent-installer').update(false, ['%s']);", argv[2]); diff --git a/microstack/ILibParsers.c b/microstack/ILibParsers.c index dd73cc7..d8d8441 100644 --- a/microstack/ILibParsers.c +++ b/microstack/ILibParsers.c @@ -9283,24 +9283,7 @@ static long long ILibGetUptimeUpperEmulation1; static long long ILibGetUptimeUpperEmulation2; long long ILibGetUptime() { - long long r; - - // Windows 7 & Vista - if (ILibGetUptimeFirst) { - HMODULE hlib = LoadLibraryExA((LPCSTR)"KERNEL32.DLL", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); - if (hlib == NULL) return 0; - pILibGetUptimeGetTickCount64 = (ULONGLONG(*)())GetProcAddress(hlib, "GetTickCount64"); - ILibGetUptimeFirst = 0; - FreeLibrary(hlib); - } - if (pILibGetUptimeGetTickCount64 != NULL) return pILibGetUptimeGetTickCount64(); - - // Windows XP with rollover prevention - r = (long long)GetTickCount(); // Static Analyser reports this could roll over, but that's why this block is doing rollover prevention - if (r < ILibGetUptimeUpperEmulation1) ILibGetUptimeUpperEmulation2 += ((long long)1) << 32; - ILibGetUptimeUpperEmulation1 = r; - r += ILibGetUptimeUpperEmulation2; - return r; + return(GetTickCount64()); } #elif __APPLE__ long long ILibGetUptime()