Smanettone83 Expert Cheater
Reputation: 3
Joined: 21 Feb 2011 Posts: 146 Location: Italia
|
Posted: Sun Mar 06, 2011 3:04 pm Post subject: Problem to create trainer with Delphi |
|
|
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
|
|