Can I get a notification when a process starts?

I need to know (preferably with the least delay) when running foo.exe .

Right now, I have a thread that sits in the light cycle (~ 10 Hz) and walks through the foo.exe process foo.exe .

This is less elegant, and I was wondering if I can register in some part of the Windows API to get a callback when starting any process.

If such a tool is not available, I, of course, open for other ways to accomplish this task more elegantly.

+3
source share
2 answers

You can register yourself as a debugger for foo.exe through the image file options . At any time when the system needs to run foo.exe, it will launch your application and pass foo.exe and its parameters to you. You will need to start the process yourself.

Note: as usual, Raymond Chen, words of caution .

You can also set a system-wide message crawl, and for each new process that your dll will be loaded into, check to see if it matches you, just pass it, for foo.exe you notify yourself, and then go through. Unfortunately, this means that you will enter code into each process, and you will slightly damage the system. Not to mention that you can actually push everyone if you have a bug in your code.

+3
source

Possible options:

Is foo.exe under your control? If so, change the source code to send the signal.

Is foo.exe not in your control? Write an injection DLL and send a signal when it loads into the process with the correct name.

0
source

All Articles