Code: Select all
bool speedhacking = false;
bool (__stdcall *QPG_orig)(LARGE_INTEGER *lp);
bool __stdcall QPC_hooked(LARGE_INTEGER *lp)
{
static __int64 oldfake = 0;
static __int64 oldreal = 0;
__int64 factor;
__int64 newvalue;
int ret;
if( oldfake == 0 || oldreal == 0 )
{
oldfake = lp->QuadPart;
oldreal = lp->QuadPart;
}
ret = (*QPC_orig)(lp);
newvalue = lp->QuadPart;
if(speedhacking == 1)
{
factor = 2.0;
//factor = 3.0;
//factor = 5.0;
}
else
{
factor = 1.0;
}
newvalue = oldfakevalue + (__int64)((newvalue - oldrealvalue) * tempfactor);
oldrealvalue = lp->QuadPart;
oldfakevalue = newvalue;
lp->QuadPart = newvalue;
return ret;
}
bool WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved )
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
QPC_orig = (bool (__stdcall*)(LARGE_INTEGER*))DetourFunction((PBYTE)GetProcAddress(GetModuleHandle("kernel32.dll"), "QueryPerformanceCounter"), (PBYTE)QPC_hooked);
case DLL_PROCESS_DETACH:
DetourRemove((PBYTE)GetProcAddress(GetModuleHandle("kernel32.dll"), "QueryPerformanceCounter"), (PBYTE)QPC_hooked);
}
return TRUE;
}