 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
wongerlt How do I cheat?
Reputation: 0
Joined: 26 May 2015 Posts: 2
|
Posted: Tue May 26, 2015 11:30 am Post subject: C++ Read memory |
|
|
Hello,
I want to read memmory with pointer, me code without pointers:
Code: |
#include <windows.h>
#include <iostream>
int main()
{
SetConsoleTitle ("Test");
DWORD processId;
HANDLE hProcess;
DWORD address = 0x000AA768;
processId = 6336;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, processId);
int value;
ReadProcessMemory(hProcess, (LPVOID)address, &value, 4, 0);
std::cout<<"Value:"<<value<<std::endl;
return 0;
}
|
Cheat engine:
"game.exe"+00EE1C00
pointer = 320
so "game.exe"+00EE1C00+320 = address
how to get full address with ponter?
|
|
Back to top |
|
 |
P.EduC How do I cheat?
Reputation: 0
Joined: 15 May 2015 Posts: 2
|
Posted: Tue May 26, 2015 5:29 pm Post subject: |
|
|
Pointer: "game.exe"+00EE1C00
Offset1: 320
Code: | DWORD Pointer, Offset1, Resultado;
Pointer = ((DWORD)GetModuleBaseAddress(processId , "game.exe") + 0x00EE1C00);
printf("Pointer: 0x%08X \n", Pointer);
ReadProcessMemory(hProcess, (void*)Pointer, &Offset1, 4, NULL);
Offset1 += 0x320;
printf("Offset1: 0x%08X \n\n", Offset1);
ReadProcessMemory(hProcess, (void*)Offset1, &Result, 4, NULL);
printf("Result: %i \n\n", Result); |
|
|
Back to top |
|
 |
Krampus Cheater
Reputation: 0
Joined: 22 Nov 2014 Posts: 41
|
Posted: Wed May 27, 2015 12:03 am Post subject: |
|
|
Code: | template <class T>
void read(DWORD addy, T& var) {
ReadProcessMemory(m_prcHndl, (LPCVOID)addy, &var, sizeof(var), NULL);
}
template <class T>
T read(DWORD addy) {
T temp;
ReadProcessMemory(m_prcHndl, (LPCVOID)addy, &temp, sizeof(temp), NULL);
return temp;
}
template <class T>
void readPtr(int numOfOffsets, DWORD offsets[], DWORD base, T& var) {
DWORD temp = read<DWORD>(base);
int i;
for (i = 0; i < numOfOffsets - 1; i++) {
temp = read<DWORD>(temp + offsets[i]);
}
read<T>(temp + offsets[i], var);
} |
Just a snip from my simple memory class. Pseudo code for the usage:
Code: | DWORD address = 0xDEADBEEF;
DWORD offsets[] = { 0xFE, 0xBE, 0xAD, 0xDE };
DWORD result;
readPtr<DWORD>(4, offsets, address, result); |
Good luck,
Krampus
_________________
There is no spoon. |
|
Back to top |
|
 |
aasi888 How do I cheat?
Reputation: 0
Joined: 29 Jul 2009 Posts: 6
|
Posted: Sun Sep 20, 2015 3:33 pm Post subject: |
|
|
The code in the first post worked. I just don't want to search for the PID every time I restart the game.
1. How to grab PID from active window?
2. How to grab all PIDs from programs with certain window title?
I tried #1, but this code seems to be giving me random numbers (The PIDs I get do not match any process in my task manager). Each run gives a different result, even though cmd.exe window is focused every time.
read_test3.cpp
Code: |
#include <iostream>
#include <string>
#include <windows.h>
int main()
{
int pid = GetCurrentProcessId();
std::cout<< pid << "\n\n\n\n\n\n\n\n\n";
return 0;
} |
PS I'm fairly new in c++. Seems odd that I can't even add "sleep 2000;" in there w/o compiling errors.
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Sep 20, 2015 4:21 pm Post subject: |
|
|
You get a different PID because the executable is a different process than your command prompt.
If you look in your Task Manager, you'll notice cmd.exe is there and when you run your test, read_test3.exe pops up briefly.
Same can also be true for some games. The process you attach isn't necessarily the window.
To find the PID of a window, you can use:
Code: | HWND WindowHandle = FindWindow(nullptr, L"Window Title");
DWORD PID;
GetWindowThreadProcessId(WindowHandle, &PID);
PVOID hProcess = OpenProcess((0x0010) | (0x0400), 0, PID); |
You should have access to "Sleep(2000)" since you included <Windows.h>.
I do believe it needs to be capitalized.
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Sep 20, 2015 6:26 pm Post subject: |
|
|
If you want to get the active / foreground window there is:
- GetForegroundWindow
If you want to find all windows matching the same name, you can use:
- FindWindow
- GetWindow
You would call FindWindow with the name of the window title or class name you wish to look for, then inside of a loop you would call GetWindow with the GW_HWNDNEXT definition as the 2nd parameter. Like this:
Code: | auto hWnd = ::FindWindow(nullptr, "Minesweeper");
while (hWnd != 0)
{
hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
} |
_________________
- Retired. |
|
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
|
|