Witam wiem że temat był powielany wiele razy ale cały czas ale nigdzie NIE MA napisanego jasno a mianowicie jak dokładnie pobrać wartość z pamięci innego okna…
- Potrzebujemy jego uchwyt
- Używamy polecania readprocessmemory
A tak wygląda sprawa w praktyce :/ a to mój kod zastanawiam się co źle zrobiłem na początku dałem value:=111; by sprawdzić jaka będzie wartość wyjściowa na labelach i jest niestety taka sama… nie pobiera nic z pamięci jakaś sugestia? A oto kod:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
testa:integer;
implementation
{$R *.dfm}
function ReadMemInteger(Address: Cardinal): Cardinal; //Read adress:value
var
ProcId: Cardinal;
tProc: THandle;
NBR: Cardinal;
value:Cardinal;
begin
value:=111;
GetWindowThreadProcessId(FindWindow('Notepad.exe',Nil), @ProcId); //uchwyt notepad
tProc:= OpenProcess(PROCESS_ALL_ACCESS, False, ProcId); //otwarcie pamieci
ReadProcessMemory(tProc, Ptr(Address), @value, 4, NBR); //pobranie wartosc z adresu
CloseHandle(tProc); //zamniecie
Result:=value; //value jako wynik funcji
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption:=inttostr(ReadMeminteger($00010000));
label2.Caption:=inttostr(ReadMeminteger($00010010));
label3.Caption:=inttostr(ReadMeminteger($00010020));
label4.Caption:=inttostr(ReadMeminteger($00010030));
label5.Caption:=inttostr(ReadMeminteger($00010040));
end;
end.