Nacho Modding
Nacho Modding

Reputation: 19

I don´t know how i can get the pid of an process by process name

I want to get the process id for example of the process "notepad.exe".

I only found threads etc. for how to get process by PID. But I want to get the PID by process name (in this scenario "notepad.exe"). And this with my kernel driver.

Upvotes: -1

Views: 582

Answers (1)

datenwolf
datenwolf

Reputation: 162297

There can be more than one process with a process image coming from a file notepad.exe. You must enumerate all the running processes and retrieve the module name from that. It's described in the MSDN: https://learn.microsoft.com/en-us/windows/desktop/psapi/enumerating-all-processes

From the list of processes you then extract all the processes with a module name notepad.exe and get the list of matching PIDs.

Upvotes: 1

Related Questions