How to catch exceptions from another program (for logging)?

I am working on a tool that controls a number of applications and ensures that they always work and are in a clean state. Some of these applications have unhandled exceptions that periodically occur and present the "Send crash report" window. I do not have source code for these applications.

Is there any mechanism that I could use to catch exceptions, or simply determine their type of exception, and also identify the main executable file of the application in which there was an exception.

I'm not trying to do something crazy like catch, and process it for the name of the application, I'm just trying to capture the type of exception, log it and then restart the application.

+3
source share
3 answers

The unhandled exception trap requires a call to SetUnhandledExceptionFilter () in the process. This will be difficult to do if you do not have the source code, although technically it is possible to inject the DLL into the process. However, this cannot be done with managed code; you cannot correctly initialize the CLR.

, Windows, WerFault.exe, Windows. , . , . , WER , JIT .

, . Process, , . Exited, ExitCode, , . , , . EventLog , WER Windows. , .

+2

DLL , . , , - . .

  • . (.ToString .GetType(). Name), .
  • , , , . , (, ).
  • - .
+1

If you want to track application crashes in the system as a whole, you can register as a debugger just in time. You can edit the registry to indicate which debugger starts when the application crashes. The example they give is Doctor Watson , but it could be your application.

+1
source

Source: https://habr.com/ru/post/1737801/


All Articles