1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| var
WindowName : integer;
ProcessId : integer;
ThreadId : integer;
buf2 : PChar;
HandleWindow : Integer;
write : cardinal;
Const
WindowTitle = 'Calculatrice';
Address = $100579C;
PokeValue = $0;
NumberOfBytes = 1;
procedure TForm1.Button2Click(Sender: TObject);
begin
WindowName := FindWindow(nil, WindowTitle);
If WindowName = 0 then
MessageDlg('The game must be running in the background. Run it now, and then try again.', mtwarning,[mbOK],0);
ThreadId := GetWindowThreadProcessId(WindowName, @ProcessId);
HandleWindow := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId);
GetMem(buf2, 1);
buf2^ := Chr(PokeValue);
readProcessMemory(HandleWindow, ptr(Address), buf2, NumberOfBytes, write);
Label1.caption := IntToStr(ord(buf2^));
FreeMem(buf2);
closehandle(HandleWindow);
end; |
Partager