Writing float to process memory

From: Daniel Hjerholm (hjerth_at_frisurf.no)
Date: 10/10/04


Date: Sun, 10 Oct 2004 01:26:16 +0200

Hi group

I am trying to make a trainer for Age of Empires Expansion that gives me
t.ex. 10000 wood. I have found the address with ArtMoney, and i can also
change the value from ArtMoney, but not from Delphi. The problem is that the
value is a 4 byte float variable, and I only know how to write integer
variables to the memory. If i change the value to an integer I get 0 woon in
AoE.

Here is my code:

procedure TForm1.Button1Click(Sender: TObject);
const
  PokeValue = 10000;
var
  h: hwnd;
  ThreadId: Integer;
  ProcessId: Integer;
  MemHandle: Integer;
  buf: PChar;
  write: cardinal;
begin
  h := FindWindow(nil, 'Age of Empires Expansion');
  if h = 0 then Exit;
  ThreadId := GetWindowThreadProcessId(h,@ProcessId);
  MemHandle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId);
  GetMem(buf, 8);
  buf^ := Chr(PokeValue);
  WriteProcessMemory(MemHandle, Pointer($00F675B4), buf, NumberOfBytes,
write);
  CloseHandle(MemHandle);
end;

Any helpt would be appreciated.

Daniel
- http://www.brettshaping.com -