Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Problem to create trainer with Delphi

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Smanettone83
Expert Cheater
Reputation: 3

Joined: 21 Feb 2011
Posts: 146
Location: Italia

PostPosted: Sun Mar 06, 2011 3:04 pm    Post subject: Problem to create trainer with Delphi Reply with quote

i've this code:



Code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,tlhelp32, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Written: Cardinal;
  ChangeValue: array of byte;
  PidHandle: integer;
  PidID: integer;
  ContinueLoop: BOOL;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
  Temp: Integer;
  ProcessId: DWORD;
  HandleWindow: THandle;
  ThreadID: Cardinal;

implementation

{$R *.dfm}

Function GetProcessID(Const ExeFileName: string; var ProcessId: integer;Const ProcessNo :Integer = 1): boolean;
begin
result := false;
temp:=1;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
 while integer(ContinueLoop) <> 0 do
  begin
   if (StrIComp(PChar(ExtractFileName(FProcessEntry32.szExeFile)), PChar(ExeFileName)) = 0)
     or (StrIComp(FProcessEntry32.szExeFile, PChar(ExeFileName)) = 0)  then
      begin
       If Temp = ProcessNo then
        begin
        ProcessId:= FProcessEntry32.th32ProcessID;
        result := true;
        break;
       end else inc(Temp);
      end;
     ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
    end;
  CloseHandle(FSnapshotHandle);
end;

procedure WriteArray(Address: Cardinal; ChangeValues: array of byte);
Begin
 if GetProcessID('Game.exe', PidID, 1) then
  Begin
    PidHandle:= OpenProcess(PROCESS_ALL_ACCESS,False,PidId);
    WriteProcessMemory(PidHandle, Pointer(Address), @ChangeValues, SizeOf(ChangeValues), Written);
    Closehandle(PidHandle);
  End;
End;

procedure TForm1.ButtonApplyPatchClick(Sender: TObject);
const
 Value_array:  Array [1..5]  Of Byte = ($e9,$3d,$ae,$a6,$ff);
begin
 if GetProcessID('Game.exe', PidID, 1) then Begin
 WriteArray($010051BE,Value_array);
 end;

end;

procedure TForm1.ButtonRemovePatchClick(Sender: TObject);
const
 Value_array:  Array [1..3]  Of Byte = ($89,$46,$34);
begin
 if GetProcessID('Game.exe', PidID, 1) then Begin
 WriteArray($010051BE,Value_array);
 end;
end;

end.


These are the originals bytes that i see on address 010051BE (unlimited ammo): 89 46 34
Now i use cheat engine to enabled my script and view the bytes that change in memory viewer.. when i activate my trainer i see these byte that changes: e9 3d ae a6 ff

later i put these bytes on delphi on applyPatch \ RemovePatch button... but when i click on apply button the game go to crash... why?

sorry for my english
Back to top
View user's profile Send private message MSN Messenger
Smanettone83
Expert Cheater
Reputation: 3

Joined: 21 Feb 2011
Posts: 146
Location: Italia

PostPosted: Mon Mar 07, 2011 3:55 pm    Post subject: Reply with quote

anybody can help me? Sad
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites