Is it possible for a process to catch an unhandled exception of another process on windows?

走远了吗. 提交于 2020-01-06 06:47:28

问题


Is it possible for a process to catch an unhandled exception of another process on the system?

If possible, under which circumstances is it possible? Is it for instance possible if the second process is not started by the first?

I am mainly looking for an answer regarding native c++.


回答1:


Native (AKA standard) C++ has no real concept of multiple processes, and has no means of catching exceptions thrown across process boundaries. And no means of throwing exceptions across such boundaries, come to that.




回答2:


Windows Exceptions: Structured Exception Handling (SEH) is per thread. Another thread in the process might be able to manipulate the stack of the target thread to insert its own handler, but that is going to be hard to get right (especially with the lack of consistent calling convention on x86). Another process could inject a dll & thread into a process to do this. This will be hard to get right, especially without close coupling to the details of the target process (what functions are called and how).

On second thoughts debuggers can do this, so the Win32 debugger APIs must have this capability. A process can debug other processes in the same session (with lower or equal integrity level), or if the user has the "debug process" privileged any process.




回答3:


Yes. Matt Pietrek explains how. Scroll down to the "VectoredExceptionHandling is a clean, easily extensible way to see all exceptions" part. There's example code as well.



来源:https://stackoverflow.com/questions/2385859/is-it-possible-for-a-process-to-catch-an-unhandled-exception-of-another-process

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