i can post my speedhack generic!
speedhack.h
Code:
#include <windows.h>
#include <Mmsystem.h>
#include "detours.h" //detours 1.5
DWORD WINAPI GetTickCount_Detour(void);
DWORD WINAPI timeGetTime_Detour(void);
BOOL WINAPI QueryPerformanceCounter_Detour(LARGE_INTEGER *lp);
extern "C" __declspec(dllexport) void SetSpeedFactor(DWORD speed);
extern "C" __declspec(dllexport) DWORD GetSpeedFactor();
extern "C" __declspec(dllexport) void SetSpeedEnabled(DWORD enabled);
extern "C" __declspec(dllexport) DWORD GetSpeedEnabled();
extern DWORD increasefactor;
extern DWORD speedenabled;
speedhack.cpp
Code:
#define WIN32_LEAN_AND_MEAN
#include "speedhack.h"
#include <winbase.h>
#pragma comment(lib, "winmm.lib")
//set up our trampolines
DETOUR_TRAMPOLINE(DWORD WINAPI GetTickCount_Trampoline(void), GetTickCount);
DETOUR_TRAMPOLINE(DWORD WINAPI timeGetTime_Trampoline(void), timeGetTime);
DETOUR_TRAMPOLINE(BOOL WINAPI QueryPerformanceCounter_Trampoline(LARGE_INTEGER *lp), QueryPerformanceCounter);
//global variables for QueryPerformanceCounter hook
DWORD qpc_last_fake, qpc_last_real;
//global variables for timeGetTime hook
DWORD tgt_last_real, tgt_last_fake;
//global variables for GetTickCount hook
DWORD gtc_last_real, gtc_last_fake;
//shared data segment for changing speed from external program
#pragma data_seg(".shared")
DWORD increasefactor = 200;
DWORD speedenabled = 1;
#pragma data_seg()
#pragma comment(linker,"/SECTION:.shared,RWS")
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
char szParentEXEName[MAX_PATH] = {0};
char szModuleName[MAX_PATH] = {0};
GetModuleFileName( (HMODULE)hModule, szModuleName, MAX_PATH);
GetModuleFileName( 0, szParentEXEName, MAX_PATH);
char *pEXEName = strrchr(szParentEXEName, '\');
bool shouldattach = true;
//detour everything but our handler
if (ul_reason_for_call == DLL_PROCESS_ATTACH && shouldattach)
{
DisableThreadLibraryCalls(GetModuleHandle(NULL));
//detour our functions
DetourFunctionWithTrampoline((PBYTE)GetTickCount_Trampoline, (PBYTE)GetTickCount_Detour);
DetourFunctionWithTrampoline((PBYTE)timeGetTime_Trampoline, (PBYTE)timeGetTime_Detour);
DetourFunctionWithTrampoline((PBYTE)QueryPerformanceCounter_Trampoline, (PBYTE)QueryPerformanceCounter_Detour);
MessageBox(NULL, L"Sucefully INJECTED!", L"Done By GRB", MB_OK);
}
return true;
}
DWORD WINAPI GetTickCount_Detour()
{
DWORD ret = GetTickCount_Trampoline();
DWORD nReal = ret;
DWORD dReal = nReal - gtc_last_real;
DWORD dFake = (increasefactor/100) * dReal;
if (speedenabled == 1)
{
ret = gtc_last_fake + dFake;
gtc_last_fake += dFake;
}
else
{
ret = gtc_last_fake + dReal;
gtc_last_fake += dReal;
}
gtc_last_real += dReal;
return ret;
}
DWORD WINAPI timeGetTime_Detour()
{
DWORD ret = timeGetTime_Trampoline();
DWORD nReal = ret;
DWORD dReal = nReal - tgt_last_real;
DWORD dFake = (increasefactor/100) * dReal;
if (speedenabled == 1)
{
ret = tgt_last_fake + dFake;
tgt_last_fake += dFake;
}
else
{
ret = tgt_last_fake + dReal;
tgt_last_fake += dReal;
}
tgt_last_real += dReal;
return ret;
}
BOOL WINAPI QueryPerformanceCounter_Detour(LARGE_INTEGER *lp)
{
BOOL ret = QueryPerformanceCounter_Trampoline(lp);
DWORD nReal = lp->LowPart;
DWORD dReal = nReal - qpc_last_real;
DWORD dFake = (increasefactor/100) * dReal;
if (speedenabled == 1)
{
lp->LowPart = qpc_last_fake + dFake;
qpc_last_fake += dFake;
}
else
{
lp->LowPart = qpc_last_fake + dReal;
qpc_last_fake += dReal;
}
qpc_last_real += dReal;
return ret;
}
extern "C" __declspec(dllexport) void SetSpeedFactor(DWORD speed)
{
increasefactor = speed;
}
extern "C" __declspec(dllexport) DWORD GetSpeedFactor()
{
return increasefactor;
}
extern "C" __declspec(dllexport) void SetSpeedEnabled(DWORD enabled)
{
speedenabled = enabled;
}
extern "C" __declspec(dllexport) DWORD GetSpeedEnabled()
{
return speedenabled;
}
This a generic speedhack, the base for all speed hacks, from here develope the rest of code for working in any game!