|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
gavrielsinvani Cheater Reputation: 0
Joined: 29 May 2019 Posts: 32
|
Posted: Sun May 17, 2020 3:47 pm Post subject: how to write pointer in C++ ... |
|
|
i have pointers without offset,
HP Max Address:
TimeLapse.dll+B05BC
MP Max Address:
TimeLapse.dll+B05C4
I want to get their value in c ++.
thanks.
|
|
Back to top |
|
|
explicity How do I cheat? Reputation: 0
Joined: 20 May 2020 Posts: 1
|
Posted: Wed May 20, 2020 11:05 pm Post subject: |
|
|
Those aren't pointers you posted, that is the module name and offset. You would need the address(location) of that module and add the offset to get the value you want.
HP Max Address:
TimeLapse.dll+B05BC
MP Max Address:
TimeLapse.dll+B05C4
You could do something like :
unsigned int base = reinterpret_cast<unsigned int>(GetModuleHandleA(TimeLapse.dll)) + 0xB05BC;
Retrieve the value by casting and then dereferencing it as the type you expect it to be, for example:
unsigned int hpMax = *reinterpret_cast<unsigned int*>(base);
Writing is similar: *reinterpret_cast<unsigned int*>(base) = some_value;
The above code requires you have direct access to the process's memory. If you don't, you'd need to replace GetModuleHandleA with another function or iterate through the Module List using MODULEENTRY32 and use ReadProcessMemory.
|
|
Back to top |
|
|
Astaroth4256 Advanced Cheater Reputation: 0
Joined: 25 May 2014 Posts: 59
|
Posted: Fri Jun 19, 2020 10:09 am Post subject: |
|
|
1. Find process
Code: |
vector<UINT> GetProcessList(const char* exeName) {
vector<UINT> aprocessList;
aprocessList.clear();
PROCESSENTRY32 entry;
ZeroMemory(&entry, sizeof(entry));
entry.dwSize = sizeof(PROCESSENTRY32);
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(snapshot == NULL) {
printf("Null snapshot\n");
getchar();
CloseHandle(snapshot);
return aprocessList;
}
if(snapshot == INVALID_HANDLE_VALUE) {
printf("INVALID_HANDLE_VALUE);
aprocessList.clear();
CloseHandle(snapshot);
return aprocessList;
}
if(Process32First(snapshot, &entry) == TRUE) {
while (Process32Next(snapshot, &entry) == TRUE) {
if (_stricmp(entry.szExeFile, exeName) == 0) {
aprocessList.push_back(entry.th32ProcessID);
}
}
} else {
printf("Error ");
cout<<GetLastError()<<endl;
CloseHandle(snapshot);
getchar();
}
CloseHandle(snapshot);
return aprocessList;
}
|
2. Get process handle
Code: |
processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
|
3. Get module base
Code: |
void MEMORY::GetModuleBaseAddress(UINT PID) {
const char* moduleName = "game.exe";
MODULEENTRY32 module32;
module32.dwSize = sizeof(MODULEENTRY32);
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID);
Module32First(hSnap, &module32);
do {
if(!strcmp(module32.szModule, moduleName)) {
moduleBase = (DWORD64)module32.modBaseAddr;
break;
}
} while(Module32Next(hSnap, &module32));
CloseHandle(hSnap);
}
|
4. Traverse pointer path
Can't give you an example of code for this cause mine is a quickfix. The general idea for this is:
-add base address to module base (now you get a static address - green in CE)
-add offset to result from up there^
-read memory at result from up there^
-if you have another offset, add offset to result from up there^
-read memory at result from up there^
-if you don't have more offsets, this is your desired address
|
|
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
|
|