mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-19 09:43:20 +00:00
1. Removed LoadLibraryExA() call for GetTickCount64 on windows
2. Fixed self update bug on older installs
This commit is contained in:
@@ -722,7 +722,7 @@ int wmain(int argc, char* wargv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Legacy
|
// 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
|
// Console Mode
|
||||||
updateLen = sprintf_s(update, 1024, "require('agent-installer').update(false, ['%s']);", argv[2]);
|
updateLen = sprintf_s(update, 1024, "require('agent-installer').update(false, ['%s']);", argv[2]);
|
||||||
|
|||||||
@@ -9283,24 +9283,7 @@ static long long ILibGetUptimeUpperEmulation1;
|
|||||||
static long long ILibGetUptimeUpperEmulation2;
|
static long long ILibGetUptimeUpperEmulation2;
|
||||||
long long ILibGetUptime()
|
long long ILibGetUptime()
|
||||||
{
|
{
|
||||||
long long r;
|
return(GetTickCount64());
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
long long ILibGetUptime()
|
long long ILibGetUptime()
|
||||||
|
|||||||
Reference in New Issue
Block a user