/* Function: void HackThread(void) Purpose: The main function for our hack, here is where we have our code Arguments: - Returns: - */ void HackThread(void) { HMODULE hEngineModule, hClientModule; //module handles CreateInterfaceFn pEngineFactory, pClientFactory; //CreateInterface function pointers while(!IsGameReady()) //while the game isn't ready Sleep(1000); //wait for a second before checking again //Here the game is ready, so we get handles to the dlls hEngineModule = GetModuleHandle("engine.dll"); //Get a handle to the engine dll hClientModule = GetModuleHandle("client.dll"); //Get a handle to the client dll //Get the function pointers to the CreateInterface functions pEngineFactory = (CreateInterfaceFn)GetProcAddress(hEngineModule, "CreateInterface"); //Get the address of the CreateInterface function in engine.dll pClientFactory = (CreateInterfaceFn)GetProcAddress(hClientModule, "CreateInterface"); //Get the address of the CreateInterface function in client.dll //Nullpointer checks if(pEngineFactory == NULL || pClientFactory == NULL) //if any of the two function pointers is NULL { MessageBox(0, "A CreateInterface pointer was NULL, shutting down!", "Failure", MB_OK); //Warn us about it exit(0); //and exit the game } //Get pointers to the existing interfaces in client.dll pBaseClient = (IBaseClientDLL*)pClientFactory(CLIENT_DLL_INTERFACE_VERSION, 0); //CLIENT_DLL_INTERFACE_VERSION is defined as "VClient013" pClientEntityList = (IClientEntityList*)pClientFactory(VCLIENTENTITYLIST_INTERFACE_VERSION, 0); //VCLIENTENTITYLIST_INTERFACE_VERSION is defined as "VClientEntityList003" //Get pointers to the existing interfaces in engine.dll pEngineClient = (IVEngineClient*)pEngineFactory(VENGINE_CLIENT_INTERFACE_VERSION, 0); //VENGINE_CLIENT_INTERFACE_VERSION is defined as "VEngineClient012" pCvar = (ICvar*)pEngineFactory(VENGINE_CVAR_INTERFACE_VERSION, 0); //VENGINE_CVAR_INTERFACE_VERSION is defined as "VEngineCvar003" if(pBaseClient == NULL || pClientEntityList == NULL || pEngineClient == NULL || pCvar == NULL) //if any of the pointers is NULL { MessageBox(0, "One of the interface pointers is NULL, shutting down!", "Failure", MB_OK); //Warn us about it exit(0); //and exit the game } while(1) //We passed all the checks, so we can enter an infinite loop { if(GetAsyncKeyState(VK_NUMPAD1)&1) //if the first bit for numpad1 is set(initial press & repeats) { pEngineClient->ClientCmd("monster_attack_bonus_ratio -80"); //enable godmode using ClientCmd } if(GetAsyncKeyState(VK_NUMPAD3)&1) //if the first bit for numpad3 is set(initial press & repeats) { //Disable godmode using ConVars ConVar *pGodmode = pCvar->FindVar("monster_attack_bonus_ratio"); //get a pointer to the ConVar if(pGodmode != NULL) //make sure it isn't a NULL pointer! pGodmode->SetValue(pGodmode->GetDefault()); //Set the convar back to the default value } Sleep(100); //Sleep(pause) the thread for 100 miliseconds } }
bool BattleshipApp::IsGameReady(const std::string& id) { return IsGameReady((unsigned)std::stoi(id)); }