Beispiel in C++ (Quelle: mpcforum.com)
Alles was der Code macht ist, sich das Prozesshandle von dem Prozess holen, der ein Fenster mit dem Titel "MapleStory" hat. Anschließend schreibt er die Bytes 0x72, 0x65, 0x64, 0x70, 0x6F, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 in das Offset 0x5C6600.
Code:
HWND hWnd = FindWindow(0, "MapleStory");
{
MessageBox(0, "Error cannot find window!", "Error!", MB_OK + MB_ICONERROR);
}
else
{
DWORD proc_id;
GetWindowThreadProcessId(hWnd, &proc_id);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id);
if(!hProcess)
{
MessageBox(NULL, "Cannot open process!", "Error!", MB_OK + MB_ICONERROR);
}
else
{
BYTE newdata[]={0x72, 0x65, 0x64, 0x70, 0x6F, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
DWORD newdatasize = sizeof(newdata);
if(WriteProcessMemory(hProcess, (LPVOID)0x5C6600, &newdata, newdatasize, NULL))
{
MessageBox(NULL, "WriteProcessMemory is a success!", "Success!", MB_OK + MB_ICONINFORMATION);
}
else
{
MessageBox(NULL, "Error cannot WriteProcessMemory!", "Error!", MB_OK + MB_ICONERROR);
}
CloseHandle(hProcess);
}
}