Monitor start and close of process?

孤街浪徒 提交于 2019-12-12 22:33:40

问题


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 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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/7553355/monitor-start-and-close-of-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!