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 


[Delphi]Making a simple standalone trainer using Hex / AOB
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Oct 26, 2007 5:20 am    Post subject: [Delphi]Making a simple standalone trainer using Hex / AOB Reply with quote

Hexadecimal / Array Of Byte

Credits:
Renko
Noz
Kas

btw, in this method i used Mahjong Blocks @ ijji to make a trainer, but delphi failed so i made it in C Smile

Let's begin !

First of all, lets mange that we need to get the pID (Process ID) and the handle of it, after that we can access it's memory and start making modifications Smile.

Before we start, make sure you have opend a new delphi project and this in your GLOBAL var decliration (The first "var" where the TForm is declared)

Code:
  MainForm: TMainForm;
  hProcess : THandle;
  ProcessID, ThreadID, Rights : DWORD;
  WindowTitle : PChar;
  BUF : pCHAR;
  Write : DWORD;
  WindowName : THandle;
  ToBeWritten : DWORD;


thanks to renko for the AOB method

now, to get the pID, we need to target the window, right ?
using the function FindWindowA(); will be simple, it uses to find running apps and them take action by using PostMessageA(); to close/minimize/maximize/simulate keystrokes and more

Code:
WindowTitle := pCHAR('Mahjong Block');
WindowName := FindWindowA(nil, WindowTitle);


Now that we have our window !, we need to get its pID and Access it !

Code:
ThreadId := GetWindowThreadProcessId(WindowName, @ProcessId);
hProcess := OpenProcess(PROCESS_ALL_ACCESS,FALSE,ProcessID);


now that we got access, we can start patching a address.

Code:
GetMem(BUF, sizeof(ToBeWritten));
BUF^ := CHR(Sizeof(ToBeWritten));


Make a const (Global)
PatchAddy = The address we wanna patch (edit)
NumOfBytes = The Number of bytes we're using (3, right ?!) (3 wont allways work don't be a smart ass, bytes are the uh... *thinks how to explain* is like the modified signature of the assembly Confused (i guess that'll do it lol)
iNjectArry is just a method using AOB (thanks to renko)
ToBeWritten is the edited Hexadecimal that i added, much more easier.

Code:
const
    PatchAddy = $0042120A;
    NumberOfBytes = 3;
  //  iNJECTArray: Array [0..3] of Byte =($FF,$58,$45,$FF);
    ToBeWritten = $FF4558FF; //FF584DFF is the normal address


You can use VPEx if you wish, but it's not neccesery

Msdn wrote:
BOOL WINAPI VirtualProtectEx(
__in HANDLE hProcess,
__in LPVOID lpAddress,
__in SIZE_T dwSize,
__in DWORD flNewProtect,
__out PDWORD lpflOldProtect
);


Finally, we write the memory to the process using WriteProcessMemory();

Code:
WriteProcessMemory(
hProcess, ptr(PatchAddy),
BUF, NumberOfBytes, Write);


let's not forget to close the handle

Code:
FreeMem(BUF);
CloseHandle(hProcess);


This simple method will not 100% work on everything, use it widly.

i hate delphi for this things...

Source is added



The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.


Look.JPG
 Description:
 Filesize:  13.3 KB
 Viewed:  12518 Time(s)

Look.JPG




Last edited by DeletedUser14087 on Mon Nov 19, 2007 6:30 am; edited 1 time in total
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Oct 26, 2007 8:30 am    Post subject: Reply with quote

Nice tutorial kaspersky. I havn't used delphi in about 6 months and I understood every single thing in this tutorial.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Oct 26, 2007 8:35 am    Post subject: Reply with quote

oib111 wrote:
Nice tutorial kaspersky. I havn't used delphi in about 6 months and I understood every single thing in this tutorial.


Thanks, btw i forgot to mention, if you want to use the AOB method, replace all the strings "ToBeWritten" to "InjectArray" (Do not include the variable).
Back to top
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Sat Oct 27, 2007 5:45 am    Post subject: Reply with quote

Nice tutorial Kaspersky! I want to ask what do we "earn" when we use VPEx?
_________________

Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sat Oct 27, 2007 5:53 am    Post subject: Reply with quote

h4c0r-BG wrote:
Nice tutorial Kaspersky! I want to ask what do we "earn" when we use VPEx?


Msdn wrote:
Changes the protection on a region of committed pages in the virtual address space of a specified process.


I, myself use it to avoid errors in my process
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Sat Oct 27, 2007 4:59 pm    Post subject: Reply with quote

I have to say:
Damn nice, and THX!!!

And btw, I found a lil mistake in the source where it checks if the window is running or not on the Shuffles button:

This:
Code:
if WindowName = 0 then
begin
    MessageDlg('Game Not Running!', mtWarning, [mbOK], 0);
    uShuffle.Caption := 'Unlimited Hints [OFF]';
end;


Should be this:
Code:
if WindowName = 0 then
begin
    MessageDlg('Game Not Running!', mtWarning, [mbOK], 0);
    uShuffle.Caption := 'Unlimited Shuffles [OFF]';
end;


Ohh and the thing above:

This:
Code:
uShuffle.Caption := 'Unlimited Hints [ON]';


To:
Code:
uShuffle.Caption := 'Unlimited Shuffles [ON]';



edit:
ohwell, I tried something.
Im using GGles and I try to inject pin typer with this, because its a simple script.
Code:
[Enable]
//V45 Pin Typer Updated by ReVeNgEx
00488699:
jae 0048025c


[Disable]
00488699:
jbe 0048025c


I tried this (idk if it's the right way xD)
Code:
    PatchAddy = $00488699;
    NumberOfBytes = 3;
    iNJECTArray: Array [0..2] of Byte =($0F, $83, $BD);
   //  ToBeWritten = ; //FF584DFF is the normal address


But this does something weird (I always check on a engine what it does).

halp pl0x
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sat Oct 27, 2007 5:47 pm    Post subject: Reply with quote

Hold on rEakW0n, i'll check it for you.

Edit: ok !, by the look of it, you forgot 1 byte !

Code:
0F 83 BD 7B
7B Very Happy

good luck bro !, btw make the Number Of Byte = 4.
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Sun Oct 28, 2007 3:52 am    Post subject: Reply with quote

Well me and Kaspersky tried out many things, but we can't get it working, can someone help us?

edit:
So I want to inject pin type in it (as you may know Rolling Eyes ).

Well here's the enable part:
Code:
00488699:
jae 0048025c


So is this correct for it?
Code:
    PatchAddy = $00488699;
    NumberOfBytes = 6;
   iNJECTArray: Array [0..2] of Byte =($49, $42, $45);


Help please!
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Oct 28, 2007 5:24 am    Post subject: Reply with quote

omg, NumberOfByte = 4;

and the array isn't correcy :S
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Sun Oct 28, 2007 7:07 am    Post subject: Reply with quote

ok so I tried this:
Code:
    PatchAddy = $00488699;
    NumberOfBytes = 4;
    iNJECTArray: Array [0..2] of Byte =($0f, $83, $6c);


But its still not working....
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Oct 28, 2007 7:24 am    Post subject: Reply with quote

Try using Hexadecimal method and post results
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Sun Oct 28, 2007 7:39 am    Post subject: Reply with quote

still not working....I tried out so much things.
I guess we need help from someone else.
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Oct 28, 2007 8:18 am    Post subject: Reply with quote

rEakW0n wrote:
still not working....I tried out so much things.
I guess we need help from someone else.


"we" ? i don't need help since i'm not using Delphi for it.

It's you who needs help -.-"
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Sun Oct 28, 2007 8:19 am    Post subject: Reply with quote

Kaspersky wrote:
rEakW0n wrote:
still not working....I tried out so much things.
I guess we need help from someone else.


"we" ? i don't need help since i'm not using Delphi for it.

It's you who needs help -.-"


oh yea...I -.-
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Sun Oct 28, 2007 9:31 am    Post subject: Reply with quote

You only need to change the byte at 0048869A from 86 to 83. Any other modifications are pointless.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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