Helpc++ need help about read/write process memory

Posts 115 of 16 · Page 1 of 2
c++ need help about read/write process memory
hey guys!

firstly i am not american or something so my English isn't good.sorry about it.I want to make bots,hacks for games.I met with c++,read/write process memory.I tried first money,hp,mana shower.but as you guess i couldn't.so i want to help from you.actually i made a video about what i did but video was 4gb so i couldn't upload it to youtube.whatever;

i'm opening game,cheat engine and c++ as administrator,i'm searching my money on cheat engine then i found.i found one adress.then i went to game.I spent my money some.I looked at Cheat Engine and value is changed correctly.then i'm going to c++ writing this codes and run;
Code:
#include <windows.h>
#include <iostream>

using namespace std;

int main()
{
	DWORD address = 0x100579C; // This is the address that we want to read from
int value = 0; // This will store our value. In my case, its an integer, which is the timer
DWORD pid; //This will store our Process ID, used to read/write into the memory
HWND hwnd; //Finally a handle to our window
hwnd = FindWindow(NULL,"EpicDuel - PvP MMORPG Play Now - Opera"); //Finds the Window
	if(!hwnd) //If none, display an error
	{
	cout <<"Window not found!\n";
	cin.get();
	}
	GetWindowThreadProcessId(hwnd,&pid); //Get the process id and place it in pid
	HANDLE phandle = OpenProcess(PROCESS_VM_READ,0,pid); //Get permission to read
if(!phandle) //Once again, if it fails, tell us
		{
		cout <<"Could not get handle!\n";
		cin.get();
		}
		while(1)  //Forever, or until you force close the program
		{
		ReadProcessMemory(phandle,(void*)0x068474A8,&value,sizeof(value),0); //i changed adress with what i found on cheat engine.
		cout << value << "\n"; //Display it
		Sleep(1000); //I was reading the timer which increases every second, so I made my program go through that loop every second
	}
		return 0;
		}
and my c++ program is showing value 0 or 503150133 something like this.cheat engine is working finely.but c++ is not.help me please.
i cant write code for you, but if the Pointer in CE is "green" (static) you need the Process Entry Point of the Memory too.
In CE it Looks like:
Code:
Process.exe + 2B11810
In Pascal it looks like this:
Code:
uses Classes, SysUtils, StdCtrls, Windows, JwaTlHelp32; 
...
function GetBasePointerOfModule(ProcessId: DWORD; Modulename: string): Int64;
var
  FSnapshotHandle: THandle;
  FModulEntry32: MODULEENTRY32;
begin
  Result := 0;
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessId);
  try
    if FSnapshotHandle <> INVALID_HANDLE_VALUE then
    begin
      FModulEntry32.dwSize := SizeOf(FModulEntry32);
      if Module32First(FSnapshotHandle, FModulEntry32) then
      repeat
        if FModulEntry32.szModule = Modulename then
        begin
          Result := Int64(FModulEntry32.modBaseAddr);
          break;
        end;
      until (not Module32Next(FSnapshotHandle, FModulEntry32));
    end;
  finally
    closeHandle(FSnapshotHandle);
  end;
end;
On 32 Bit Processes you need integer instead of int64
thank you.that adress wasn't static.All i want to do making bots.bot firstable i want to make showers.like mp,hp,money and something like these.For this i'm trying to learn read process memory.After i make showers i will make bots.

I want to understand what's probblem of my program.
Taking a quick look I think u used the dynamic address read the address from. Basically everytime you start up the program that address will be a different one.

So you will have to find a (multilevel)pointer to health to have a consequent reading on it.

Quote Originally Posted by nepafter37 View Post
thank you.that adress wasn't static.All i want to do making bots.bot firstable i want to make showers.like mp,hp,money and something like these.For this i'm trying to learn read process memory.After i make showers i will make bots.

I want to understand what's probblem of my program.
Quote Originally Posted by Sammy View Post
Taking a quick look I think u used the dynamic address read the address from. Basically everytime you start up the program that address will be a different one.

So you will have to find a (multilevel)pointer to health to have a consequent reading on it.
i actually knew that.but i don't know how to code with pointers.i know just with dynamic addresses.could you help me? if i start searching i will confuse.i read sometopics from here.people of here are knowledge i think.
I'm not simular with C++ but i just tried your Code example in VS 2015 with another Game, which is 64 Bit and with a Float Value of 20.59332275 on Address 0x162D9A53C
There was a problem with the constant String Title, i have fixed with google.
Code:
#include "stdafx.h"
#include <windows.h>
#include <iostream>

using namespace std;
wchar_t *convertCharArrayToLPCWSTR(const char* charArray)
{
	wchar_t* wString = new wchar_t[4096];
	MultiByteToWideChar(CP_ACP, 0, charArray, -1, wString, 4096);
	return wString;
}
int main()
{
	DWORD address = 0x100579C; // This is the address that we want to read from
	float value = 0; // This will store our value. In my case, its an integer, which is the timer
	DWORD pid; //This will store our Process ID, used to read/write into the memory
	HWND hwnd; //Finally a handle to our window#
	char* WindowName = "Batman™: Arkham Knight";


	hwnd = FindWindow(NULL, convertCharArrayToLPCWSTR(WindowName)); //Finds the Window
	if (!hwnd) //If none, display an error
	{
		cout << "Window not found!\n";
		cin.get();
	}
	GetWindowThreadProcessId(hwnd, &pid); //Get the process id and place it in pid
	HANDLE phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); //Get permission to read
	if (!phandle) //Once again, if it fails, tell us
	{
		cout << "Could not get handle!\n";
		cin.get();
	}
	while (1)  //Forever, or until you force close the program
	{
		ReadProcessMemory(phandle, (void*)0x162D9A53C, &value, sizeof(value), 0); //i changed adress with what i found on cheat engine.
		cout << value << "\n"; //Display it
		Sleep(1000); //I was reading the timer which increases every second, so I made my program go through that loop every second
	}
	return 0;
}
This was the output of the Process:
Code:
20.5933
20.5933
20.5933
20.5933
20.5933
I think your Code works
Quote Originally Posted by nepafter37 View Post
i actually knew that.but i don't know how to code with pointers.i know just with dynamic addresses.could you help me? if i start searching i will confuse.i read sometopics from here.people of here are knowledge i think.
Easiest way would be
Code:
ReadProcessMemory(phandle,(void*)(((clienbase + value) + offset1) + offset2), &value, sizeof (value), 0)

Quote Originally Posted by MikeRohsoft View Post
I'm not simular with C++ but i just tried your Code example in VS 2015 with another Game, which is 64 Bit and with a Float Value of 20.59332275 on Address 0x162D9A53C
There was a problem with the constant String Title, i have fixed with google.
Code:
#include "stdafx.h"
#include <windows.h>
#include <iostream>

using namespace std;
wchar_t *convertCharArrayToLPCWSTR(const char* charArray)
{
	wchar_t* wString = new wchar_t[4096];
	MultiByteToWideChar(CP_ACP, 0, charArray, -1, wString, 4096);
	return wString;
}
int main()
{
	DWORD address = 0x100579C; // This is the address that we want to read from
	float value = 0; // This will store our value. In my case, its an integer, which is the timer
	DWORD pid; //This will store our Process ID, used to read/write into the memory
	HWND hwnd; //Finally a handle to our window#
	char* WindowName = "Batman™: Arkham Knight";


	hwnd = FindWindow(NULL, convertCharArrayToLPCWSTR(WindowName)); //Finds the Window
	if (!hwnd) //If none, display an error
	{
		cout << "Window not found!\n";
		cin.get();
	}
	GetWindowThreadProcessId(hwnd, &pid); //Get the process id and place it in pid
	HANDLE phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); //Get permission to read
	if (!phandle) //Once again, if it fails, tell us
	{
		cout << "Could not get handle!\n";
		cin.get();
	}
	while (1)  //Forever, or until you force close the program
	{
		ReadProcessMemory(phandle, (void*)0x162D9A53C, &value, sizeof(value), 0); //i changed adress with what i found on cheat engine.
		cout << value << "\n"; //Display it
		Sleep(1000); //I was reading the timer which increases every second, so I made my program go through that loop every second
	}
	return 0;
}
This was the output of the Process:
Code:
20.5933
20.5933
20.5933
20.5933
20.5933
I think your Code works
Change this:
Code:
char* WindowName = "Batman™: Arkham Knight";
To:
Code:
w_char* WindowName = L"Batman™: Arkham Knight";
And there is no need to convert
Quote Originally Posted by Sammy View Post
Easiest way would be
Code:
ReadProcessMemory(phandle,(void*)(((clienbase + value) + offset1) + offset2), &value, sizeof (value), 0)



Change this:
Code:
char* WindowName = "Batman™: Arkham Knight";
To:
Code:
w_char* WindowName = L"Batman™: Arkham Knight";
And there is no need to convert
ReadProcessMemory(phandle,(void*)(((clienbase + value) + offset1) + offset2), &value, sizeof (value), 0)

how should i change the codes? for example my pointer is 24124125 and offset is 14 how should put these to code?

thank you again
Quote Originally Posted by nepafter37 View Post
ReadProcessMemory(phandle,(void*)(((clienbase + value) + offset1) + offset2), &value, sizeof (value), 0)

how should i change the codes? for example my pointer is 24124125 and offset is 14 how should put these to code?

thank you again
Something like this?

Code:
ReadProcessMemory(phandle,(void*)(( 0x24124125 ) + 0x14), &value, sizeof (value), 0)
Code:
int value = 0;
int pAddress = 0;
ReadProcessMemory(phandle, (void*)24124125, &pAddress, sizeof(pAddress), 0); // If 24124125 is Hex Value, you need to modify
printf("0x%X Points to -> 0x%X\n", 24124125, pAddress);
ReadProcessMemory(phandle, (void*)(pAddress + 0x14), &value , sizeof(value), 0);
- - - Updated - - -

Quote Originally Posted by Sammy View Post
Easiest way would be
[CODE]
Change this:
Code:
char* WindowName = "Batman™: Arkham Knight";
To:
Code:
w_char* WindowName = L"Batman™: Arkham Knight";
And there is no need to convert
My fail, thx, but i will anyway prefer Pascal ^^
Quote Originally Posted by Sammy View Post
Something like this?

Code:
ReadProcessMemory(phandle,(void*)(( 0x24124125 ) + 0x14), &value, sizeof (value), 0)
thank you very very much both of you.i want to last thing from you.i'm having problem with founding pointers.most of time i can't find even adress.i'm writing value but Cheat Engine doesn't show me.I have ollydbg too but i don't know how to use this.
guys i can't find pointer .s i hacked paint but samething happened.


when i started program with just adress.its okay.but i can't with pointer.and i guess i don't know how to find pointer.i looked at google i'm doing samething i guess but there is a problem.if you tell me once more maybe i can.please guys.

bytheway if you are know too i want to learn ollydbg.but cheat engine is okay too.
Just do Cheat Engine Tutorial
Youtube for stephen chapman cheat engine tutorial. They are great.
Quote Originally Posted by MikeRohsoft View Post
Just do Cheat Engine Tutorial
guys for example i just tried find pointer of login's id place.i couldn't again.i found adress this time with string search.then i clicked "find who writes to this adress" then i wrote something to login place.then things came.i clicked them they said your pointer is probably ...... i searched at 2 byte hex that pointer.and there was so many results.i will look at your channel now bytheway.

and once i did cheat engine tutorial.but i still can't. i guess i am not smart.

- - - Updated - - -

Quote Originally Posted by Sammy View Post
Youtube for stephen chapman cheat engine tutorial. They are great.
man i wasn't know that unknown thing.thanks really. i will watch all of them.tomorrow i will wrtie results here both of you thanks so much.i loved this forum.
Posts 115 of 16 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?