Process termination callback

I wrote a code that is able to create data about the coverage of myself with a map file without having to debug another application, and also able to generate an xml report compatible with Cobertura and OpenCover for further analytical and graphical reports.

However, so far I need to call the function to create the report manually, and the idea is to automatically generate it as soon as the process exits.

My first approach was to try writing hooks in RtlExitUserProcess / RtlExitUserThread / ExitProcess, but each function closes a specific case if you force the process to terminate (for example, kill it with taskkill) or close the application console window using CTRL + C behavior changes.

Is there a way to create a reliable callback that will always be called when the application is about to end? Just as if you are debugging another application and when the process dies, you get a debugging event with detailed information.

Thanks in advance

+4
source share
1 answer

No, you cannot intercept the completion of your own process. If you could, then a malicious (or just buggy) program could hook it, and then refuse to complete it. This is different for the debugger, because the debugger is a separate program.

, finalization . Delphi RTL , , , , , . , , .

+5

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


All Articles