Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- #include <string>
- #include <ctime> // needed for our timer clock
- void WriteToMemory(HANDLE hProcHandle);
- DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress);
- //CREATES the string used to determine the name of our target window e.g. Calculator
- std::string GameName = "AssaultCube";
- LPCSTR LGameWindow = "AssaultCube"; //<- MAKE SURE it matches the window name
- std::string GameStatus;
- //FUNCTION PROTOTYPES
- bool IsGameAvail;
- bool UpdateOnNextRun; //used to update the display menu only when something changed
- //-------AMMO VARS--------
- bool AmmoStatus;
- int AmmoValue = 500;
- DWORD AmmoBaseAddress = { 0x50f4f4 };
- DWORD AmmoOffsets[] = { 0x374, 0x14, 0x0 }; //3 LEVEL pointer
- //-------HEALTH VARS--------
- bool HealthStatus;
- int HealthValue = 500;
- DWORD HealthBaseAddress = { 0x109B74 };
- DWORD HealthOffsets[] = { 0xF8 }; // 1 level pointer
- int main()
- {
- HWND hGameWindow = NULL;
- int timeSinceLastUpdate = clock(); //forces status update every x seconds
- int GameAvailTMR = clock();
- int OnePressTMR;//used to limit keys input to only one per x ms
- DWORD dwProcId = NULL;
- HANDLE hProcHandle = NULL;
- UpdateOnNextRun = true;
- std::string sAmmoStatus;
- std::string sHealthStatus;
- sAmmoStatus = "OFF";
- sHealthStatus = "OFF";
- OnePressTMR = clock();
- while (!GetAsyncKeyState(VK_INSERT)) //Key is not = 'INSERT'
- {
- if (clock() - GameAvailTMR > 100)
- {
- GameAvailTMR = clock();
- IsGameAvail = false;
- hGameWindow = FindWindow(NULL, LGameWindow);
- if (hGameWindow)
- {
- GetWindowThreadProcessId(hGameWindow, &dwProcId);
- if (dwProcId != 0)
- {
- hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcId);
- if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
- {
- GameStatus = "Failed to open process for valid handle";
- }
- else
- {
- GameStatus = "AssaultCube Ready to hack";
- IsGameAvail = true;
- }
- }
- else GameStatus = "Failed to obtain process id";
- }
- else GameStatus = "AssaultCube NOT FOUND";
- if (UpdateOnNextRun || clock() - timeSinceLastUpdate > 5000)
- {
- system("cls");
- std::cout << "----------------------------------------------------" << std::endl;
- std::cout << " AssaultCube memory hacker" << std::endl;
- std::cout << "----------------------------------------------------" << std::endl << std::endl;
- std::cout << "GAME STATUS:" << GameStatus << " " << std::endl << std::endl;
- std::cout << "[F1] Unlimited ammo -> " << sAmmoStatus << " <-" << std::endl << std::endl;
- std::cout << "[F2] Unlimited Health ->" << sHealthStatus << "<-" << std::endl << std::endl;
- std::cout << "[INSERT] Exit" << std::endl;
- UpdateOnNextRun = false;
- timeSinceLastUpdate = clock();
- }
- if (IsGameAvail)
- {
- WriteToMemory(hProcHandle);
- }
- }
- if (clock() - OnePressTMR > 400)
- {
- if (IsGameAvail)
- {
- if (GetAsyncKeyState(VK_F1))
- {
- OnePressTMR = clock();
- AmmoStatus = !AmmoStatus;
- UpdateOnNextRun = true;
- if (AmmoStatus)sAmmoStatus = "ON";
- else sAmmoStatus = "OFF";
- }
- else if (GetAsyncKeyState(VK_F2))
- {
- OnePressTMR = clock();
- HealthStatus = !HealthStatus;
- UpdateOnNextRun = true;
- if (HealthStatus)sHealthStatus = "ON";
- else sHealthStatus = "OFF";
- }
- }
- }
- }
- return ERROR_SUCCESS;
- }
- DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress)
- {
- DWORD pointer = BaseAddress;
- DWORD pTemp;
- DWORD pointerAddr;
- for (int c = 0; c < PointerLevel; c++)
- {
- if (c == 0)
- {
- ReadProcessMemory(hProcHandle, (LPCVOID)pointer, &pTemp, 4, NULL);
- }
- pointerAddr = pTemp + Offsets[c];
- ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddr, &pTemp, 4, NULL);
- }
- return pointerAddr;
- }
- void WriteToMemory(HANDLE hProcHandle)
- {
- DWORD AddressToWrite;
- if (AmmoStatus)
- {
- AddressToWrite = FindDmaAddy(3, hProcHandle, AmmoOffsets, AmmoBaseAddress);
- WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &AmmoValue, sizeof(AmmoValue), NULL);
- }
- if (HealthStatus)
- {
- AddressToWrite = FindDmaAddy(1, hProcHandle, HealthOffsets, HealthBaseAddress);
- WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &HealthValue, sizeof(HealthValue), NULL);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement