-1

I am looking for a way to pass a pointer address from cheat engine to a line of code.

The Cheat Engine address is P-> 0C86D240.

The Line of Code is as follows:

WriteProcessMemory(handle,(LPVOID)P->0C86D240,).

In the end i would like to change the pointer address' value.

Update: i changed P-> to 0x0C86D240 and i was able to write memory for THAT session of the game. When closed then opened again the hex number was different

Sollus
  • 11
  • 1
  • 6
  • i guess i am just wondering if removing the P-> and adding 0x in front would be the pointer address or if i have to do some other form of conversion. – Sollus Jul 23 '17 at 06:11
  • Google ASLR to understand why the address changes every time you run the game. – drescherjm Jul 23 '17 at 13:18

5 Answers5

5

P->0C86D240 in Cheat Engine means that the entry is a chain of pointers which finally resolves to the address 0x0C86D240. If you double click this part in Cheat Engine, you will see a popup dialog showing you what this pointer chain consists of. For example, let's call the starting pointer P0 and a series of offsets called offset0, offset1, offset2, .... A pointer chain is to take the value at the address P0 + offset0, use that as your next pointer P1, then take the value at the address P1 + offset1, use that as your next pointer P2 ... this chain will finally give you the address 0C86D240. If you reset your game, you hope your P0 will not change but everything afterwards will change dynamically (i.e. P1, P2, P3,...) and track all the way down to the desired value.

If you know how the pointer chain works, it is then trivial to convert this to C++. You just need to take note of the base pointer and all offsets (as shown in the popup dialog by double-clicking the P->0C86D240 part.) Then, track down until you use up all offset values.

3

You write a function which walks the multilevel pointer, each step it de-references the pointer and adds the relative offset.

For this example I will use a simple assault cube cheat I've made

FindDMAAddy function (Find Dynamic Memory Allocation Address):

uintptr_t FindDMAAddy(HANDLE hProc, uintptr_t ptr, std::vector<unsigned int> offsets)
{
    uintptr_t addr = ptr;
    for (unsigned int i = 0; i < offsets.size(); ++i)
    {
        ReadProcessMemory(hProc, (BYTE*)addr, &addr, sizeof(addr), 0);
        addr += offsets[i];
    }
    return addr;
}

The main code:

    uintptr_t moduleBase = GetModuleBaseAddress(procId, L"ac_client.exe");

    //Get Handle to Process
    HANDLE hProcess = 0;
    hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, procId);

    //Resolve base address of the pointer chain
    uintptr_t dynamicPtrBaseAddr = moduleBase + 0x10f4f4;

    std::cout << "DynamicPtrBaseAddr = " << "0x" << std::hex << dynamicPtrBaseAddr << std::endl;

    //Resolve our ammo pointer chain
    std::vector<unsigned int> ammoOffsets = { 0x374, 0x14, 0x0 };
    uintptr_t ammoAddr = FindDMAAddy(hProcess, dynamicPtrBaseAddr, ammoOffsets);

    std::cout << "ammoAddr = " << "0x" << std::hex << ammoAddr << std::endl;

You can find a more complete version of my answer here but you seemed to already know the rest.

GuidedHacking
  • 3,628
  • 1
  • 9
  • 59
1

Step 1: Search the value you want to change with cheat engine.

Step 2: If you have found the right address do right click on it and make a pointer scan for this address. Now you should get many base-addresses with some offsets.

Step 3: Close your game and repeat Step 1. Now copy the new address and click on rescan pointerscan (in the window that opened from step 2).Paste the new address in the rescan address field and rescan. Then you should only get the right base-addresses + offsets.

Step 4: To always find the right address do: readprocessmemory(baseaddress+offset)

-1

fist of all I can't figure out what the P-> means maybe remove that and make the value a 0x for hex

When closed then opened again the hex number was different

I guess that you are talking about the game if I'm wrong then don't continue reading

so the address you get from cheat engine is probably a dynamic one meaning that every time you close or open it that value will change sense the program will be allocated another place in the memory

so what should you do.....

you could find the static address this process is a bit complicated I will advise you to watch a tutorial https://www.youtube.com/watch?v=hfWOAFsYnFA

-1

Cheat engine tutorial built into the program covers multilevel Pointers. Do your work first. If you have the pointer already found, you have the address you are looking for: A static address that points to the address containing the value you want to modify.