#include <windows.h>
#include "Detour\CDetour.h" //You'll need Detours to compile because of ZChat::Input
void* GravityADDR = (void*)0x5F0CE8;
float Gravity;
DWORD ZChat__Input = 0x0042A300;
CDetour ZChat__InputDet;
bool __stdcall ZChat__InputHook(const char* lpcLine)
{
bool bRet = true;
if (memcmp(lpcLine,"/gravconst ",11)==0)
{
sscanf(lpcLine,"/gravconst %f",&Speedd);
Sleep(1000);
VirtualProtect((void *)GravityConstADDR, 8, PAGE_EXECUTE_READWRITE, &ulOldProtect);
*(float*)GravityADDR=Gravity;
bRet = false;
}
ZChat__InputDet.Ret(bRet);
return true;
}
__declspec(dllexport) BOOL __stdcall DllMain(HINSTANCE hInst,DWORD reason,LPVOID lpv)
{
DisableThreadLibraryCalls(hInst);
if (reason == DLL_PROCESS_ATTACH)
{
ZChat__InputDet.Detour((BYTE*)ZChat__Input, (BYTE*)ZChat__InputHook, true);
ZChat__InputDet.Apply();
}
else if(reason == DLL_PROCESS_DETACH)
{
ZChat__InputDet.Remove();
}
return true;
}