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 


Plz explain me this code

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
wofo
Expert Cheater
Reputation: 0

Joined: 12 Aug 2007
Posts: 211

PostPosted: Mon Dec 10, 2007 1:13 pm    Post subject: Plz explain me this code Reply with quote

Hi, I am starting in delphi and wanting to learn how to make trainers. Some1 gave me this code
Code:
var
Form1: TForm1;
WindowName : integer;
ProcessId : integer;
ThreadId : integer;
buf : PChar;
HandleWindow : Integer;
write : cardinal;

implementation

{$R WindowsXP.RES}

Const
WindowTitle = 'GTA: Vice City';
Address = 8223480;
NumberOfBytes = 2;
Banshee = 159;

{$R *.dfm}

procedure TForm1.ListBox1Click(Sender: TObject);
begin
If ListBox1.Selected [0] then
begin
WindowName := FindWindow(nil,WindowTitle);
If WindowName = 0 then
begin
MessageDlg('Vice City must be running. Run it now, and then try again.', mtwarning,[mbOK],0)
end
else
ThreadId := GetWindowThreadProcessId(WindowName,@ProcessId);
HandleWindow := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);

GetMem(buf,1);
buf^ := Chr(Banshee);
WriteProcessMemory(HandleWindow,ptr(Address),buf,N umberOfBytes,write);
FreeMem(buf);
closehandle(HandleWindow);
end;

I tried to use it but cant modify addresses wich have characters, could some1 explain me how to do it?
Thanks in advance.

_________________
! 10\/3 1337

Happy Cheating guys
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Dec 10, 2007 1:22 pm    Post subject: Reply with quote

i recommend actually learning the language before going into anything advanced...
_________________
Back to top
View user's profile Send private message
Devilizer
Master Cheater
Reputation: 0

Joined: 22 Jun 2007
Posts: 451

PostPosted: Mon Dec 10, 2007 1:24 pm    Post subject: Reply with quote

lurc wrote:
i recommend actually learning the language before going into anything advanced...
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Mon Dec 10, 2007 2:29 pm    Post subject: Reply with quote

var
Form1: TForm1; // doesnt have to be here
WindowName : integer; // window name declared as an integer
ProcessId : integer; // process declared as integer
ThreadId : integer; // ThreadIddeclared as integer
buf : PChar; // bug declared as a Pchar
HandleWindow : Integer; // Handle Window declared as integer
write : cardinal; // write declared as cardinal

implementation

{$R WindowsXP.RES}

Const // constants, ie symbol = XXX
WindowTitle = 'GTA: Vice City'; // WindowTitle's value
Address = 8223480; // address to write to
NumberOfBytes = 2; // bytes for room
Banshee = 159; // a random name with value, ie: the value to get banshee is 159?

{$R *.dfm}

procedure TForm1.ListBox1Click(Sender: TObject);
begin
If ListBox1.Selected [0] then
begin
WindowName := FindWindow(nil,WindowTitle); // WindowName's value = result of FindWindow 'GTA: Vice City'

If WindowName = 0 then // if the window cannot be found
begin
MessageDlg('Vice City must be running. Run it now, and then try again.', mtwarning,[mbOK],0) // show an error message
end
else // if window is found
ThreadId := GetWindowThreadProcessId(WindowName,@ProcessId); // ThreadId's value is result of GetWindowThreadProcessId, gets the PID of the WindowName.

HandleWindow := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);
// Handle Window is the resulting value of Opening the process, PID, and giving you all access
GetMem(buf,1); // get memory, into buf
buf^ := Chr(Banshee); // puts the value of banshee into buf
WriteProcessMemory(HandleWindow,ptr(Address),buf,N umberOfBytes,write); // Writes the process's memory, the address and the buf value.

FreeMem(buf); // freememory of bug
closehandle(HandleWindow); // close the window's handle
end;
Back to top
View user's profile Send private message AIM Address MSN Messenger
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Mon Dec 10, 2007 7:01 pm    Post subject: Reply with quote

Lmao no wonder it doesn't work... I can find like 10 places where this code, if compiled, would totally bomb.

HandleWindow not declared as THandle,
ProcessID doesn't have a value...
ThreadID doesn't need to be declared at all
WindowName should be compared to NULL not 0
Improper parameters for APIs
Closing a handle that isn't valid will crash
No block after the else statement so all code after 1 line after else will run.



Conclusion, no way this will work. Learn the language first, not just follow one of Kaspersky's tutorials and replace stuff.
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Tue Dec 11, 2007 7:02 am    Post subject: Reply with quote

rapion124 wrote:


1. HandleWindow not declared as THandle,
2. ProcessID doesn't have a value...
3. ThreadID doesn't need to be declared at all
4. WindowName should be compared to NULL not 0
5. Improper parameters for APIs
run.

1. Thandle is dword - Integer.
2.
Code:
 GetWindowThreadProcessId(WindowName,@ProcessId);//Move the process ID to ProcessId

3. Kaspersky code.
4. WindowName value is the window handle - integer.
5. all parameters are right.
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Tue Dec 11, 2007 7:22 am    Post subject: Reply with quote

slippp, Form1: TForm1; // doesnt have to be here, wtf ?
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
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