How to get process id from process name?

delphi package - easy access to kernel objects etc.
Post Reply
Teerayoot
Posts: 10
Joined: Tue May 18, 2004 5:04 pm

How to get process id from process name?

Post by Teerayoot »

I want process id to inject libary into using madchook,i just know only process name (ex notepad.exe)??
How to get process id from process name using madshi's tool.


Thank in advance.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Are you using Delphi or C++? Does it have to work under NT4, too?
Jay
Posts: 13
Joined: Thu Apr 29, 2004 9:34 am

Post by Jay »

hi!

may be i'm wrong, but i think you just have to use following kernelobject property:

Code: Select all

var NeededProcessID: Cardinal;
...
NeededProcessID := Process( 'notepad.exe').ID;
for further details look at the "madKernel - IProcess Reference".


bye!

Jay
Teerayoot
Posts: 10
Joined: Tue May 18, 2004 5:04 pm

Why this not work!

Post by Teerayoot »

InjectLibrary(Process("Notepad.exe")->Handle,"empty.dll")
I need to inject empty.dll to opend process (notepad.exe).

// error
[C++ Error] Unit1.cpp(24): E2034 Cannot convert '_di_IHandle' to 'unsigned int' :?

What's wrong,and how to solve,Thank for any answer?
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

IProcess->Handle returns a IHandle interface. You need the Windows dword handle, so you need to use Process("notepad.exe")->Handle->Handle.
Teerayoot
Posts: 10
Joined: Tue May 18, 2004 5:04 pm

Worked.

Post by Teerayoot »

Oops,it's my confussion .:oops:
Anyway Thak Q,it's working now.
Post Reply