 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
pakeke80 How do I cheat?
Reputation: 0
Joined: 26 Sep 2011 Posts: 4
|
Posted: Sun Dec 28, 2014 7:54 am Post subject: [C++] WriteProcessMemory Multi-level Pointer |
|
|
Hi, good day,
i just wan't to ask if why is my code not working.
Im very new in coding :/
Please help me :/
This code compiles but it can't change the value :/
Please Help me T_T
| Code: |
#include "stdafx.h"
#include <windows.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include "tlhelp32.h"
using namespace std;
DWORD GetModuleBase(LPSTR lpModuleName, DWORD dwProcessId)
{
MODULEENTRY32 lpModuleEntry = { 0 };
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId);
if (!hSnapShot)
return NULL;
lpModuleEntry.dwSize = sizeof(lpModuleEntry);
BOOL bModule = Module32First(hSnapShot, &lpModuleEntry);
while (bModule)
{
if (!strcmp(lpModuleEntry.szModule, lpModuleName))
{
CloseHandle(hSnapShot);
return (DWORD)lpModuleEntry.modBaseAddr;
}
bModule = Module32Next(hSnapShot, &lpModuleEntry);
}
CloseHandle(hSnapShot);
return NULL;
}
int main()
{
int newValue = 1000;
HWND hWnd = FindWindowA(0, "Plants vs. Zombies");
if (hWnd == 0){
cerr << "Window not found." << endl;
}
else{
DWORD pId;
GetWindowThreadProcessId(hWnd, &pId);
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, pId);
if (!hProc){
cerr << "Process not found." << endl;
}
else{
DWORD BaseAddress = GetModuleBase("popcapgames1.exe",pId);
DWORD buffer;
ReadProcessMemory(hProc, (LPCVOID)(BaseAddress + 0x2A9EC0), &buffer, sizeof(buffer), NULL);
ReadProcessMemory(hProc, (LPCVOID)(buffer + 0x768), &buffer, sizeof(buffer), NULL);
buffer += 0x5560;
int isSuccessful = WriteProcessMemory(hProc, (LPVOID)buffer, &newValue, sizeof(newValue), NULL);
if (isSuccessful > 0){
cerr << "Memory hacked." << endl;
}
else{
cerr << "Memory can't be hacked." << endl;
}
CloseHandle(hProc);
}
}
}
|
_________________
THE END!!! |
|
| Back to top |
|
 |
dm0000 Newbie cheater
Reputation: 0
Joined: 09 Nov 2014 Posts: 16
|
Posted: Sun Dec 28, 2014 2:57 pm Post subject: |
|
|
Try this:
ReadProcessMemory(hProc, (LPCVOID*)(BaseAddress + 0x2A9EC0), &buffer, sizeof(buffer), NULL);
ReadProcessMemory(hProc, (LPCVOID*)(buffer + 0x768), &buffer, sizeof(buffer), NULL);
ReadProcessMemory(hProc, (LPCVOID*)(buffer + 0x5560), &buffer, sizeof(buffer), NULL);
Now you Write.
WriteProcessMemory(hProc, (LPVOID*)buffer, &newValue, sizeof(newValue), NULL);
BTW, make sure your GetModuleBase function is not returning NULL. You never check for it.
|
|
| Back to top |
|
 |
Krampus Cheater
Reputation: 0
Joined: 22 Nov 2014 Posts: 41
|
Posted: Mon Dec 29, 2014 2:53 am Post subject: |
|
|
You can also use the FindDmaAddy function.
| Code: | 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, sizeof(pTemp), NULL);
}
pointerAddr = pTemp + Offsets[c];
ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddr, &pTemp, sizeof(pTemp), NULL);
}
return pointerAddr;
} |
Credits to Fleep.
An example of the use for this code is:
| Code: | DWORD AddressToWrite;
DWORD dw_ARifleClipOffset[] = { 0x150 };
BYTE InfAmmo[] = { 0x64, 0x0, 0x0, 0x0 };
AddressToWrite = FindDmaAddy(1, hProcHandle, dw_ARifleClipOffset, Player_Base);
WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &InfAmmo, sizeof(InfAmmo), NULL); |
One is the number of offsets, hProcHandle is the handle to the game, dw_ARifleClipOffset is the Assault Rifle's clip offset, and the Player_Base is the base address that the offset(s) are being added to.
_________________
There is no spoon. |
|
| Back to top |
|
 |
pakeke80 How do I cheat?
Reputation: 0
Joined: 26 Sep 2011 Posts: 4
|
Posted: Tue Dec 30, 2014 12:48 pm Post subject: |
|
|
Thanks so much guys,
i luv you <3
_________________
THE END!!! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|