Delphi - Readprocessmemory

0

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…

  1. Potrzebujemy jego uchwyt
  2. 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.
0

Błędnie używasz funkcji FindWindow powinno być:

GetWindowThreadProcessId(FindWindow(nil, 'Bez tytułu - Notatnik'), @ProcId); 

1 użytkowników online, w tym zalogowanych: 0, gości: 1