UnrealSkill-VIP
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

[Tutorial] Reading And Writing Memory in C++ | Game Hacking Tutorial

Ir em baixo

[Tutorial] Reading And Writing Memory in C++ | Game Hacking Tutorial Empty [Tutorial] Reading And Writing Memory in C++ | Game Hacking Tutorial

Mensagem por uNreal 3/7/2020, 02:21



Código:
#include <Windows.h>
#include<TlHelp32.h>
#include <iostream>
#include <tchar.h> // _tcscmp
#include <vector>


DWORD GetModuleBaseAddress(TCHAR* lpszModuleName, DWORD pID) {
   DWORD dwModuleBaseAddress = 0;
   HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pID); // make snapshot of all modules within process
   MODULEENTRY32 ModuleEntry32 = { 0 };
   ModuleEntry32.dwSize = sizeof(MODULEENTRY32);

   if (Module32First(hSnapshot, &ModuleEntry32)) //store first Module in ModuleEntry32
   {
      do {
         if (_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0) // if Found Module matches Module we look for -> done!
         {
            dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
            break;
         }
      } while (Module32Next(hSnapshot, &ModuleEntry32)); // go through Module entries in Snapshot and store in ModuleEntry32


   }
   CloseHandle(hSnapshot);
   return dwModuleBaseAddress;
}


int main() {

   HWND hGameWindow = FindWindow(NULL, "Zuma Deluxe 1.1.0.0");
   if (hGameWindow == NULL) {
      std::cout << "Start the game!" << std::endl;
      return 0;
   }
   DWORD pID = NULL; // ID of our Game
   GetWindowThreadProcessId(hGameWindow, &pID);
   HANDLE processHandle = NULL;
   processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
   if (processHandle == INVALID_HANDLE_VALUE || processHandle == NULL) { // error handling
      std::cout << "Failed to open process" << std::endl;
      return 0;
   }

   char gameName[] = "Zuma.exe";
   DWORD gameBaseAddress = GetModuleBaseAddress(_T(gameName),pID);
   DWORD offsetGameToBaseAdress = 0x001F4FC0;
   std::vector<DWORD> pointsOffsets{ 0x68,0x88,0x08,0x00,0x08,0xA0,0x90,0x10,0xE8 };
   DWORD baseAddress = NULL;
   //Get value at gamebase+offset -> store it in baseAddress
   ReadProcessMemory(processHandle, (LPVOID)(gameBaseAddress+ offsetGameToBaseAdress), &baseAddress, sizeof(baseAddress), NULL);
   std::cout << "debugginfo: baseaddress = " << std::hex << baseAddress << std::endl;
   DWORD pointsAddress = baseAddress; //the Adress we need -> change now while going through offsets
   for (int i = 0; i < pointsOffsets.size() - 1; i++) // -1 because we dont want the value at the last offset
   {
      ReadProcessMemory(processHandle, (LPVOID)(pointsAddress + pointsOffsets.at(i)), &pointsAddress, sizeof(pointsAddress), NULL);
      std::cout << "debugginfo: Value at offset = " << std::hex << pointsAddress << std::endl;
   }
   pointsAddress += pointsOffsets.at(pointsOffsets.size() - 1); //Add Last offset -> done!!

   //"UI"
   std::cout << "Zuma Deluxe 1.1.0.0 H4CKs" << std::endl;
   std::cout << "Press Numpad 0 to EXIT" << std::endl;
   std::cout << "Press Numpad 1 to set Points" << std::endl;
   while (true) {
      Sleep(50);
      if (GetAsyncKeyState(VK_NUMPAD0)) { // Exit
         return 0;
      }
      if (GetAsyncKeyState(VK_NUMPAD1)) {//Mouseposition
         std::cout << "How many points you want?" << std::endl;
         int newPoints = 0;
         std::cin >> newPoints;
         WriteProcessMemory(processHandle, (LPVOID)(pointsAddress), &newPoints, 4, 0);
      }
   }

}
uNreal
uNreal
ADM
ADM


Voltar ao Topo Ir em baixo

Voltar ao Topo


 
Permissão neste fórum:
Você não pode responder aos tópicos neste fórum