tags:

views:

106

answers:

1

Hello,

currently I am trying to develop a game trainer in delphi. I've got the following code:

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

Const  WindowTitle  =  'Starcraft';  //Whatever

Those are my variables, and now my function:

const v1 = $90
begin
 WindowName  :=  FindWindow(nil,WindowTitle);
    If  WindowName  =  0  then MessageDlg('The game has not been started yet..',  mtwarning,[mbOK],0);
    ThreadId  :=  GetWindowThreadProcessId(WindowName,@ProcessId);
    HandleWindow  :=  OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);
    GetMem(buf,1);
    buf^  :=  Chr(v1);
    WriteProcessMemory(HandleWindow,ptr(/*$whatever*/),buf,1,write);
    FreeMem(buf);
    closehandle(HandleWindow);
end;

Now I have got some questions:

Let's say I found an adress, with a programm to check processes, that will be responsible for my ingame money. Somebody told me the constant v1 = $90 will make my money freeze. Why does that constant do that, and how do I implement it in my code? I already tried inserting my adress for the money where I wrote /$whatever/, but that doesn't work.

I hope you can help me.

Thank you for any help.

+1  A: 

$90 is the assembler NOP instruction which does nothing on a Intel processor. It looks like your program is designed to write into the program memory of the running game and replace the instruction at a specific address with the NOP instruction to change program behavior. In this case modify the part of the program that subtracts money for the user playing the game. A kind of in-memory patching.

Note that since Delphi 2009 and Unicode support the size of a character is no longer 1 which is a problem when you want to use it for modifying a single byte. Try changing the type of buf to AnsiChar and the assignment of buf^ to AnsiChar(v1).

Ville Krumlinde