voila j'ai un probleme je desire ecrire dans memoire d'un autre programme.
j'utilise donc ce petit progamme , mais voila a place d'avoir
en 10B40 : A1 A2 A3 A4 A5 A6 A7 A8 F1 F2 F3 F4 45 90 00 00
j'ai 10B40 : A8 00 00 00 46 6F 72 6D F4 00 00 00 45 90 00 00
pour test j'ai pris le Démineur .
voici le source , quel est mon erreur ???
merci d'avance de vos réponses
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
Procedure Patchmem(WindowTitle:Pchar;Address:integer;NumberOfBytes:integer;PokeValue:Int64);
var
WindowName: Integer;
ProcessId: Integer;
ThreadId: Integer;
buf: PChar;
HandleWindow: Integer;
Write: Cardinal;
begin
WindowName := FindWindow(nil, WindowTitle);
ThreadId := GetWindowThreadProcessId(WindowName, @ProcessId);
HandleWindow := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId);
GetMem(buf, NumberOfBytes);
buf^ := Chr(PokeValue);
WriteProcessMemory(HandleWindow, ptr(Address), buf, NumberOfBytes, Write);
FreeMem(buf);
CloseHandle(HandleWindow);
end;
Procedure InjectDMA;
begin
patchmem('Démineur',$10B40,8,$A1A2A3A4A5A6A7A8);
patchmem('Démineur',$10B48,4,$F1F2F3F4);
patchmem('Démineur',$10B4C,1,$45);
patchmem('Démineur',$10B4,1,$90);
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
InjectDMA;
end;
end.