ReadProcessMemory
ReadProcessMemory
Hi, I would like to know how to read a value from another process's memory. I have the address and window handle and I would like to display the value in an edit box. Do you think you could help me with this? I am quite new to Delphi so your help would be greatly appreciated.
Regards Turkey
Regards Turkey
I have already made code to alter the time in a game of minesweepers. Here it is
I would like to also be able to read the value of the memory address into an edit box. I think i have to use Readprocessmemory. Could you help me? Thanks
Code: Select all
var
Form1: TForm1;
WindowName : integer;
ProcessId : integer;
ThreadId : integer;
buf : PChar;
HandleWindow : Integer;
write : cardinal;
Const
WindowTitle = 'Minesweeper';
Address = $100579C;
PokeValue = $0;
NumberOfBytes = 4;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
WindowName := FindWindow(nil,WindowTitle);
If WindowName = 0 then
begin
MessageDlg('The game must be running in the background. Run it now, and then try again.', mtwarning,[mbOK],0);
end;
ThreadId := GetWindowThreadProcessId(WindowName,@ProcessId);
HandleWindow := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);
GetMem(buf,1);
buf^ := Chr(PokeValue);
WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);
FreeMem(buf);
closehandle(HandleWindow);
end;
I would like to also be able to read the value of the memory address into an edit box. I think i have to use Readprocessmemory. Could you help me? Thanks
Hi, i am having soem problems with ReadProcessmemory. Could you tell me what is the problem with this code?
Sorry I am quite new to delphi. Thanks for your help
Code: Select all
var
Form1: TForm1;
WindowName : integer;
ProcessId : integer;
ThreadId : integer;
buf : PChar;
HandleWindow : Integer;
write : cardinal;
Const
WindowTitle = 'Minesweeper';
Address = $100579C;
PokeValue = $0;
NumberOfBytes = 1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
WindowName := FindWindow(nil,WindowTitle);
If WindowName = 0 then
begin
MessageDlg('The game must be running in the background. Run it now, and then try again.', mtwarning,[mbOK],0);
end;
ThreadId := GetWindowThreadProcessId(WindowName,@ProcessId);
HandleWindow := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);
GetMem(buf,1);
buf^ := Chr(PokeValue);
readProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);
TimeEdit.text := buf;
FreeMem(buf);
closehandle(HandleWindow);
end;