Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Watching for a process to start

Name: Anonymous 2008-07-09 12:25

Sup /prog/,

Trying to find an elegant way to watch for when a specific process/application starts in C++. Could of course do something like EnumProcesses() from the PSAPI and go through the list to see if the one I'm looking for is in it... and put that on a timer to poll for it every so often.

But that seems rather messy and polling is evil. Not to mention the process will show up there before it's fully loaded into memory if I'm not mistaken... And I need it to be completely loaded and running.

Anyone know of a better/cleaner way to do it?

Name: Anonymous 2008-07-09 17:23

>>17
Excellent, just what I was looking for. I'll get right on that.

No seriously; A callback would be dandy. But where do you see one discussed here? The global hook?

Well, sure, that's a callback. But a pretty massive/messy one. I mean... what kind of hook would you create? WH_CBT, right? And watch for HCBT_CREATEWND, right?

Sounds good on paper, but you have to realize how much overhead that creates. The DLL with the hook will now have to be loaded by each and every process that gets run on the system. Furthermore, the callback procedure gets called not only for HCBT_CREATEWND, but for every message that's covered by WH_CBT. So every time a window is created, destroyed, moved, resized, maximized, restored, et cetera your hook function is invoked. Sure, it returns without doing much. But it still gets called. For all of those events and more. For every process on the system.

That's a hell of a mess over just wanting to be notified when a process gets launched. Almost makes polling look more attractive.

Was hoping there'd be something specific to processes being launched.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List