ReadProcessMemory:
WriteProcessMemory:
This example code was written by Stiju.
Code:
#include <windows.h>
#include <iostream>
int main()
{
// Find tibia and get the process id.
HWND hWnd;
DWORD processId;
HANDLE hProcess;
hWnd = FindWindow("TibiaClient", 0);
GetWindowThreadProcessId(hWnd, &processId);
// Get access to the process so we can read and write to it.
hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, processId);
int lvl; // int = 4 bytes;
// Read 4 bytes from 0x6059C0 in hProcess and save it in lvl variable.
ReadProcessMemory(hProcess, (LPVOID)0x6059C0, &lvl, 4, 0);
std::cout << "Current Level: " << lvl << std::endl;
char name[30]; // char = 1 byte; char[30] = 30 bytes;
// Read 30 bytes from 0x605A34 in hProcess and save it in name variable.
ReadProcessMemory(hProcess, (LPVOID)(0x605A34), &name, 30, 0);
std::cout << "First name in battlelist: " << name << std::endl;
return 0;
}
WriteProcessMemory:
Code:
#include <windows.h>
#include <iostream>
int main()
{
// Find tibia and get the process id.
HWND hWnd;
DWORD processId;
HANDLE hProcess;
hWnd = FindWindow("TibiaClient", 0);
GetWindowThreadProcessId(hWnd, &processId);
// Get access to the process so we can read and write to it.
hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, processId);
int lvl; // int = 4 bytes;
std::cout << "Enter a new value for level: ";
std::cin >> lvl;
// Write the value from lvl variable to 0x6059C0 in hProcess.
WriteProcessMemory(hProcess, (LPVOID)0x6059C0, &lvl, 4, 0);
char name[30]; // char = 1 byte; char[30] = 30 bytes;
std::cout << "Enter a new name for the first creature in battlelist: ";
std::cin >> name;
// Write the text from name variable to 0x605A34 in hProcess.
// Use strlen(name) to get the lenght of the text to write.
WriteProcessMemory(hProcess, (LPVOID)(0x605A34), &name, strlen(name)+1, 0);
This example code was written by Stiju.