Simply example for using that:
Simba Code:
program new;
{$loadlib rwmem.dll}
var
trnForm:TForm;
lblPid,lblpvalue,lblHandle,lblhvalue,lblval,lbl1val,lbladdr2,lbladdr2val: TLabel;
TButton0: TButton;
Values: array of byte;//Values for memory writing
WinMine: integer;//WinMine PID
MineHandle: integer;//WinMine window handle
Addr1,Addr2: integer;
const
default = 'Comic Sans MS';
{Trainer procedures}
Procedure InitAndFill;
begin
SetLength(Values,1);
Values[0]:=StrToInt('$90');
Addr1:=StrToInt('$1003830');
Addr2:=StrToInt('$1002ff5');
WinMine:=GetProcessIdByName('WinMine.exe');
lblpvalue.Caption:=IntToStr(WinMine);
MineHandle:=GetWindowName('Minesweeper');
lblhvalue.CAPTION:=IntToStr(MineHandle);
lbl1val.CAPTION:=IntToStr(ReadFromMemory(MineHandle,addr1,1));
lbladdr2val.CAPTION:=IntToStr(ReadFromMemory(MineHandle,addr2,1));
end;
procedure Patch(Sender: TObject);
begin
WriteMemoryToPID(WinMine,Addr1,Values,1);
WriteMemoryToPID(WinMine,Addr2,Values,1);
lbl1val.CAPTION:=ToStr(ReadFromMemoryFromPID(WinMine,addr1,1));
lbladdr2val.CAPTION:=ToStr(ReadFromMemoryFromPID(WinMine,addr2,1));
end;
procedure InitForm;
begin
//trnForm\\
trnForm:=TForm.Create(nil);
with trnForm do
begin
Caption:='MineSweeper';
Left:=401;
Top:=201;
Width:=217;
Height:=149;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//lblPid\\
lblPid:=TLabel.Create(trnForm);
with lblPid do
begin
Parent:=trnForm;
Caption:='Minesweeper PID:';
Left:=13;
Top:=7;
Width:=95;
Height:=16;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//lblpvalue\\
lblpvalue:=TLabel.Create(trnForm);
with lblpvalue do
begin
Parent:=trnForm;
Caption:='lblpvalue';
Left:=150;
Top:=7;
Width:=49;
Height:=16;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//lblHandle\\
lblHandle:=TLabel.Create(trnForm);
with lblHandle do
begin
Parent:=trnForm;
Caption:='MS handle:';
Left:=12;
Top:=25;
Width:=60;
Height:=16;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//lblhvalue\\
lblhvalue:=TLabel.Create(trnForm);
with lblhvalue do
begin
Parent:=trnForm;
Caption:='lblhvalue';
Left:=130;
Top:=25;
Width:=49;
Height:=16;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//lblval\\
lblval:=TLabel.Create(trnForm);
with lblval do
begin
Parent:=trnForm;
Caption:='Address 1 value:';
Left:=12;
Top:=42;
Width:=86;
Height:=16;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//lbl1val\\
lbl1val:=TLabel.Create(trnForm);
with lbl1val do
begin
Parent:=trnForm;
Caption:='lbl';
Left:=130;
Top:=42;
Width:=14;
Height:=16;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//lbladdr2\\
lbladdr2:=TLabel.Create(trnForm);
with lbladdr2 do
begin
Parent:=trnForm;
Caption:='Address 2 value:';
Left:=11;
Top:=58;
Width:=86;
Height:=16;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//lbladdr2val\\
lbladdr2val:=TLabel.Create(trnForm);
with lbladdr2val do
begin
Parent:=trnForm;
Caption:='Addr2val';
Left:=130;
Top:=58;
Width:=48;
Height:=16;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TButton0\\
TButton0:=TButton.Create(trnForm);
with TButton0 do
begin
Parent:=trnForm;
Caption:='Modify';
Left:=11;
Top:=76;
Width:=75;
Height:=25;
OnClick:=@Patch;
Font.Name:='Arial Rounded MT Bold';
Font.Color:=clPurple;
Font.Size:=12;
end;
end;
procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;
procedure ShowFormModal;
begin
trnForm.ShowModal;
end;
procedure SafeShowFormModal;
var
v: TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;
begin
SafeInitForm;
InitAndFill;
SafeShowFormModal;
end.