开发者

Monitor start and close of process?

开发者 https://www.devze.com 2023-04-07 07:09 出处:网络
Is there a way to monitor processes in the Mac OS X before they Start & End? I have a dynamic which I would like to inject in few selected processes before the start, so that hooking can be perfo

Is there a way to monitor processes in the Mac OS X before they Start & End?

I have a dynamic which I would like to inject in few selected processes before the start, so that hooking can be performed. And would开发者_StackOverflow社区 like to do the reverse when application quits, i.e. when application quits I want to unload that library from those process & thus perform unhooking.

What can be the best solution for my situation?


In Carbon, you can register for the kEventClassApplication/kEventAppLaunched event. For quitting, I think looking for an event might not be the best approach; you may not be able to respond in time before the process actually ends. It may be better to have your injected code install an atexit handler or something.


When application quits it unload's that library from those process automatically. I had a bug which prevented calling of destructor from dylib.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号