Remove Ads

Share on Facebook Share on Twitter

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Editing Memory Addresses
#1
This will be an example on editing a memory address.

For this example I will demonstrate using the cheat engine tutorial which you can download at their website.

For editing you obviously need an address. You can search yourself by using ReadProccessMemory().
However I don't believe in reinventing the wheel, so I use cheat engine/tsearch to find the addresses.

The proccess is simple, so i'll let the code explain it.
[code]
//Memory editing by Scorch
#include <iostream>
#include <windows.h>

int main()
{
HWND hwnd;
HANDLE handle;
DWORD id;
DWORD parameter;
BYTE data = 0x9AE;//Write hex value to the proccess

/* Depending on the program or your OS you may need to uncomment this
HANDLE Token;
LUID Priv;
TOKEN_PRIVILEGES tkp;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &Token);//This is necessary for getting priviledges
LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &Priv);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = Priv;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(Token, false, &tkp, sizeof tkp, NULL, NULL);
CloseHandle(Token);*/

hwnd = FindWindow(NULL, "Cheat Engine Tutorial");//Name of window to find
if (hwnd != 0) {
GetWindowThreadProcessId(hwnd, &id);
handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);

}
else
{
std::cout << "Could not find the window.";
std::cin.get();
return 0;
}
if (handle != 0)
{
if(WriteProcessMemory(handle, (int*)(0x006D5168)/*This address will be different*/,&data, sizeof(data), &parameter))
{
std::cout << "Memory wrote successfully.";
std::cin.ignore();
std::cin.get();
}
else
{
std::cout<<"\nError writing to memory\n"<<GetLastError();
std::cin.get();
}
}
else
{
std::cout << "Couldn't get a handle";
std::cin.get();
}
return 0;
}
[/code]
Reply
#2
Will come useful once I start C++.
Reply
#3
You can always just post a thread or shoot me a pm if you have any problems with C++.
Reply
#4
Thank you, will do so Wink
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)