View Single Post
  #1   Spotlight this post!  
Unread 25-05-2004, 16:08
ModelingMan's Avatar
ModelingMan ModelingMan is offline
Registered User
no team
 
Join Date: May 2004
Location: Scotland
Posts: 2
ModelingMan is an unknown quantity at this point
Delphi programming help...

Hi, I'm new to these forums.

I need some help, I am making a game trainer in Delphi and having a problem writing the correct value to a processes memory.

Here is some souce:

Code:
var
Form1: TForm1;
WindowName : integer;
ProcessId : integer;
ThreadId : integer;
buf : PChar;
HandleWindow : Integer;
write : cardinal;

implementation

{$R WindowsXP.RES}

uses colors, aboutbox;

Const 
WindowTitle = 'GTA: Vice City';
Address = 8223480;
NumberOfBytes = 2;
Banshee = 159;

{$R *.dfm}

procedure TForm1.ListBox1Click(Sender: TObject);
begin
If ListBox1.Selected [0] then
begin
WindowName := FindWindow(nil,WindowTitle);
If WindowName = 0 then
begin
MessageDlg('Vice City must be running. Run it now, and then try again.', mtwarning,[mbOK],0)
end
else
ThreadId := GetWindowThreadProcessId(WindowName,@ProcessId);
HandleWindow := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);

GetMem(buf,1);
buf^ := Chr(Banshee);
WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);
FreeMem(buf);
closehandle(HandleWindow);
end;
What this program will be doing is editing which car is in a garage in game, in that source the car value is 159 but when I run the program it writes the value 22943 which causes the game to crash. I have the NumberOfBytes correct. I think it's something to do with
Code:
WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);
I would like to get it to write the correct values.

Any help is greatly appreciated.
__________________

Last edited by ModelingMan : 25-05-2004 at 16:15.