diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 8b60412..d20671c 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -121,6 +121,21 @@ char* GetMyDocumentsPath() return cUserFilesPath; } +static LARGE_INTEGER FrameTime; +DWORD GetTimeSinceLastFrame() +{ + LARGE_INTEGER curTime; + QueryPerformanceCounter(&curTime); + return curTime.QuadPart - FrameTime.QuadPart; +} + +static void (*RsEventHandler)(int, void*); +void NewFrameRender(int nEvent, void* pParam) +{ + QueryPerformanceCounter(&FrameTime); + RsEventHandler(nEvent, pParam); +} + static char aNoDesktopMode[64]; void Patch_VC_10(const RECT& desktop) @@ -183,6 +198,12 @@ void Patch_VC_10(const RECT& desktop) // Mouse fucking fix! Patch(0x601740, 0xC3C030); + // (Hopefully) more precise frame limiter + int pAddress = 0x6004A2; + RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); + InjectHook(pAddress, NewFrameRender); + InjectHook(0x600449, GetTimeSinceLastFrame); + // Default to desktop res Patch(0x600E7E, desktop.right); Patch(0x600E88, desktop.bottom); @@ -263,6 +284,12 @@ void Patch_VC_11(const RECT& desktop) // Mouse fucking fix! Patch(0x601770, 0xC3C030); + // (Hopefully) more precise frame limiter + int pAddress = 0x6004C2; + RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); + InjectHook(pAddress, NewFrameRender); + InjectHook(0x600469, GetTimeSinceLastFrame); + // Default to desktop res Patch(0x600E9E, desktop.right); Patch(0x600EA8, desktop.bottom); @@ -343,6 +370,12 @@ void Patch_VC_Steam(const RECT& desktop) // Mouse fucking fix! Patch(0x6013B0, 0xC3C030); + // (Hopefully) more precise frame limiter + int pAddress = 0x600102; + RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5); + InjectHook(pAddress, NewFrameRender); + InjectHook(0x6000A9, GetTimeSinceLastFrame); + // Default to desktop res Patch(0x600ADE, desktop.right); Patch(0x600AE8, desktop.bottom);