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] Trainer with "process.exe" handle?

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

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

PostPosted: Sun Nov 25, 2007 1:54 pm    Post subject: [Delphi] Trainer with "process.exe" handle? Reply with quote

How to make a trainer in delphi with process handle?

Like the "window caption" method is:

Code:
begin
WindowTitle := pCHAR('Cool-Game');
WindowName := FindWindowA(nil, WindowTitle);

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


And yes ... we use here hProcess

How can this be done with a process like "cool.exe" ?

_________________

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 Nov 25, 2007 2:27 pm    Post subject: Reply with quote

http://www.swissdelphicenter.ch/torry/showcode.php?id=1364
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: Sun Nov 25, 2007 2:34 pm    Post subject: Reply with quote

rEakW0n wrote:
http://www.swissdelphicenter.ch/torry/showcode.php?id=1364


Thank you but i know this. I want to take a handle of the process not from the application caption but from the processname.exe in the taskbar.

_________________

Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Sun Nov 25, 2007 2:47 pm    Post subject: Reply with quote

here is my way:
Code:
var
MyHandle: THandle;
Struct: TProcessEntry32;
hProcess:THandle;
i:integer;
ProcessID:cardinal;
const
myprocess:pchar='Tests.exe';
begin
try
MyHandle:=CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
Struct.dwSize:=Sizeof(TProcessEntry32);
if Process32First(MyHandle, Struct) then
ListBox1.Items.Add(Struct.szExeFile);
while Process32Next(MyHandle, Struct) do
if Struct.szExeFile=myprocess then begin
ProcessID:=Struct.th32ProcessID;
break;
end;
except on exception do
ShowMessage('Error showing process list');
end;
hProcess := OpenProcess(PROCESS_ALL_ACCESS,FALSE,ProcessID);

You must add 'Tlhelp32' to uses list.

I took some code from:
~http://delphi.about.com/od/windowsshellapi/l/aa080304a.htm
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Sun Nov 25, 2007 7:24 pm    Post subject: Reply with quote

That works. But you should check the value of 'MyHandle' against INVALID_HANDLE_VALUE before calling Process32First. If your handle is invalid(CreateToolHelp32Snapshot is being hooked) then your application will crash.
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: Mon Nov 26, 2007 6:35 pm    Post subject: Reply with quote

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
MyHandle: THandle;
Struct: TProcessEntry32;
hProcess:THandle;
buf : pchar;
ProcessID:cardinal;
  write : cardinal;
const
myprocess:pchar='hl.exe';
begin
try
MyHandle:=CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
Struct.dwSize:=Sizeof(TProcessEntry32);
if Process32First(MyHandle, Struct) then
ListBox1.Items.Add(Struct.szExeFile);
while Process32Next(MyHandle, Struct) do
if Struct.szExeFile=myprocess then begin
ProcessID:=Struct.th32ProcessID;
break;
end;
except on exception do
ShowMessage('Error showing process list');
end;
hProcess := OpenProcess(PROCESS_ALL_ACCESS,FALSE,ProcessID);
GetMem(buf,1);
buf^ := Chr($75); // Sets the value of buf to 90(Hex).
WriteProcessMemory(hProcess,ptr(($7FE61E10)+0),buf,1,write);// Writes the value of buf to address 400000.
FreeMem(buf); // Resets buf.

CloseHandle(hProcess); // Closes the game handle.


end;


Like that looks the code but it still does not work. Crying or Very sad

Where is the mistake? Sad

_________________

Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Tue Nov 27, 2007 4:30 am    Post subject: Reply with quote

here is one thats work:
Code:
var
  MyHandle: THandle;
  Struct: TProcessEntry32;
  hProcess:THandle;
  i:integer;
  ProcessID:cardinal;
const
  myprocess:string='Tests.exe';
begin
  try
    MyHandle:=CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
    Struct.dwSize:=Sizeof(TProcessEntry32);
    if Process32First(MyHandle, Struct) then
      while Process32Next(MyHandle, Struct) do begin
        if myprocess=Struct.szExeFile then
          ProcessID:=Struct.th32ProcessID;
      end;
      if ProcessID<>null then
        hProcess := OpenProcess(PROCESS_ALL_ACCESS,FALSE,ProcessID);
  except on exception do
    ShowMessage('Error showing process list');
  end;
end;
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