| View previous topic :: View next topic |
| Author |
Message |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Sun Nov 25, 2007 1:54 pm Post subject: [Delphi] Trainer with "process.exe" handle? |
|
|
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 |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
|
| Back to top |
|
 |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Sun Nov 25, 2007 2:34 pm Post subject: |
|
|
| 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 |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Sun Nov 25, 2007 2:47 pm Post subject: |
|
|
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 |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Sun Nov 25, 2007 7:24 pm Post subject: |
|
|
| 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 |
|
 |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Mon Nov 26, 2007 6:35 pm Post subject: |
|
|
| 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.
Where is the mistake?  _________________
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Tue Nov 27, 2007 4:30 am Post subject: |
|
|
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 |
|
 |
|