#include <Windows.h>
#include <iostream>
typedef bool(__thiscall* CreateMove_t)(void*, float, CUserCmd*);
CreateMove_t oCreateMove;
struct CUserCmd {
int command_number;
int tick_count;
float viewangles[3];
float forwardmove;
float sidemove;
float upmove;
int buttons;
char impulse;
int weaponselect;
int weaponsubtype;
int random_seed;
short mousedx;
short mousedy;
bool hasbeenpredicted;
};
constexpr int IN_JUMP = (1 << 1);
constexpr int FL_ONGROUND = (1 << 0);
bool __stdcall hkCreateMove(void* ecx, float sample_time, CUserCmd* cmd) {
if (!cmd) return false;
int playerFlags = 65665;
if (GetAsyncKeyState(VK_SPACE) & 0x8000) {
if (playerFlags & FL_ONGROUND) {
cmd->buttons |= IN_JUMP;
}
}
return oCreateMove(ecx, sample_time, cmd);
}
void HookCreateMove() {
uintptr_t* clientMode = *(uintptr_t**)(GetModuleHandleA("client.dll") + 0x5A5F20);
oCreateMove = (CreateMove_t)clientMode[24];
DWORD oldProtect;
VirtualProtect(&clientMode[24], sizeof(uintptr_t), PAGE_EXECUTE_READWRITE, &oldProtect);
clientMode[24] = (uintptr_t)&hkCreateMove;
VirtualProtect(&clientMode[24], sizeof(uintptr_t), oldProtect, &oldProtect);
}
DWORD WINAPI HackThread(LPVOID param) {
while (!GetModuleHandleA("client.dll")) Sleep(100);
HookCreateMove();
return 0;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
CreateThread(nullptr, 0, HackThread, hModule, 0, nullptr);
}
return TRUE;
}