unit MemCheater;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TMemCheater = class(TComponent)
private
FValue : Integer;
FWindowTitle : PChar;
FAddress : Integer;
protected
{ Protected declarations }
published public
Procedure UpdateMemory;
Property Address : Integer read FAddress write FAddress;
Property Value : Integer read FValue write FValue;
Property WindowTitle : PChar read FWindowTitle write FWindowTitle;
end;
Var WindowName : integer;
ProcessId : integer;
ThreadId : integer;
buf : PChar;
HandleWindow : Integer;
write : cardinal;
wWindowTitle: pchar;
Address :integer;
PokeValue :integer;
NumberOfBytes: integer;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('JPSoft', [TMemCheater]);
end;
Procedure TMemCheater.UpdateMemory;
begin
wwindowtitle:= FWindowTitle;
address := FAddress;
pokevalue := FValue;
numberofbytes := 1;
WindowName := FindWindow(nil,wWindowTitle);
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;
end.