Newbie Spellweaver
- Joined
- Aug 8, 2018
- Messages
- 58
- Reaction score
- 41
suck a fat dick
suck a fat dick
suck a fat dick
Last edited:
(g_real_timeGetTime() - g_iTimeGetTime) % INT32_MAX;
// bug started with windows 8
if(!IsWindows8OrGreater())
{
return;
}
I'm sure you're here because of my reply on StackOverflow
The modulo operator makes sure it'll never overflow to negative.
Nexon uses signed comparisons (debug symbols hint they use `int` instead of `ulong` or `DWORD`).
Imagine it being cast like so:
Code:DWORD dwProperTime = timeGetTime(); // this is an unsigned long int nWrongTimeImplicit = dwProperTime; int nWrongTimeExplicit1 = (int) dwProperTime; int nWrongTimeExplicit2 = reinterpret_cast<int>(dwProperTime);
When casted to int, the last 4 bytes of dwProperTime will be ignored; so you're stuck at the exact same number.
Nexon sometimes uses an int instead of the proper DWORD/ulong to store this number. As a result, it can overflow to negative after 24.8 days of system uptime and the game isn't designed to handle negative durations.
The logic is counting from 0 rather than from your system's uptime, as well as using modulo so we never overflow above 0x7FFFFFFF.
I don't know why, but I can't get the timeGetTime hook to work on operating systems older than Windows 8. `timeGetTime` seems to be null when using the Windows 10 SDK to build the DLL, as well as `GetProcAddress(LoadLibraryA("KERNEL32"), "timeGetTime")` not exactly being on our side.
Looking at it once again on MSDN, it seems like you're right. However I'm confused about why the code still executes fine on newer versions of Windows if that's the case.

I did some further testing and winmm.dll seems to be loaded dynamically by KERNEL32 when running Windows 10, but it doesn't on Windows 7. Which is why GetProcAddress on it works there.
My testing was simply using a server machine which isn't being rebooted at all.