Mathias
Mathias

Reputation: 34251

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

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++.

Upvotes: 0

Views: 2046

Answers (3)

MSalters
MSalters

Reputation: 179799

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.

Upvotes: 1

Richard
Richard

Reputation: 108995

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.

Upvotes: 3

anon
anon

Reputation:

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.

Upvotes: 3

Related Questions