2y ago · Nov 20, 2023 2:10 PM
Ever wondered how Cheat Engine's Speedhack works so smoothly across almost any DirectX or Win32 game?
The Core Concept:
Games rely on high-precision system timers to compute delta time () between frames:
- &
- (winmm.dll)
- /
When you activate Speedhack at 2.0x speed, Cheat Engine injects hooks into these timer functions inside the target process.
By scaling the delta time that the game's physics, animation, and game loop receive, the game advances 2x faster in the exact same wall-clock duration!
The Core Concept:
Games rely on high-precision system timers to compute delta time (
CPP
dt-
CPP
QueryPerformanceCounter CPP
QueryPerformanceFrequency-
CPP
timeGetTime-
CPP
GetTickCount CPP
GetTickCount64When you activate Speedhack at 2.0x speed, Cheat Engine injects hooks into these timer functions inside the target process.
CPP
// Conceptual timing hook representation
static LARGE_INTEGER s_LastRealTime;
static LARGE_INTEGER s_FakeTime;
static double s_SpeedMultiplier = 2.0;
BOOL WINAPI Hooked_QueryPerformanceCounter(LARGE_INTEGER* lpPerformanceCount) {
LARGE_INTEGER currentReal;
Original_QueryPerformanceCounter(¤tReal);
LONGLONG realDelta = currentReal.QuadPart - s_LastRealTime.QuadPart;
s_FakeTime.QuadPart += (LONGLONG)(realDelta * s_SpeedMultiplier);
s_LastRealTime = currentReal;
*lpPerformanceCount = s_FakeTime;
return TRUE;
}By scaling the delta time that the game's physics, animation, and game loop receive, the game advances 2x faster in the exact same wall-clock duration!
ByteSurgeon | Cheat Engine & Lua Automation
The following users thanked ByteSurgeon for this post: