From c925fc53425ffd64e9e4c1c81e86f4309436e577 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 14 Apr 2022 19:02:14 -0400 Subject: [PATCH] Fix encrypted arguments on macOS failing It seems something changed in recent Wine versions(?) so there's now a new TickCount() function using mach_continuous_time() based off of XIV on Mac's implementation. --- src/encryptedarg.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/encryptedarg.cpp b/src/encryptedarg.cpp index 01a020f..e7a018c 100644 --- a/src/encryptedarg.cpp +++ b/src/encryptedarg.cpp @@ -10,12 +10,16 @@ #endif #if defined(Q_OS_MAC) -// this is pretty much what wine does :-0 +// taken from XIV-on-Mac, apparently Wine changed this? uint32_t TickCount() { - struct mach_timebase_info convfact; - mach_timebase_info(&convfact); + struct mach_timebase_info timebase; + mach_timebase_info(&timebase); - return (mach_absolute_time() * convfact.numer) / (convfact.denom * 1000000); + auto machtime = mach_continuous_time(); + auto numer = uint64_t (timebase.numer); + auto denom = uint64_t(timebase.denom); + auto monotonic_time = machtime * numer / denom / 100; + return monotonic_time / 10000; } #endif