开发者

Hide an access violation on another application

开发者 https://www.devze.com 2022-12-23 06:20 出处:网络
I have an application that sometimes causes an 开发者_如何学编程access violation on exit. This is quite unpredictable and all attempts to locate the bug have been unsuccesful so far. The bug is harmle

I have an application that sometimes causes an 开发者_如何学编程access violation on exit. This is quite unpredictable and all attempts to locate the bug have been unsuccesful so far. The bug is harmless, as no data is lost, so I was thinking if it might be possible to just hide it.

Is it possible to have another app launch the buggy one and catch the Access Violation exception if it occurs? If yes, how?

Thanks in advance!


Yes, if the other application is a debugger. This is a non-trivial amount of work, To become a debugger, you create the process with DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS flag, see CreateProcess flags for more information.

Once you are the debugger of the process, you will get first chance to handle all exceptions.

You could also attach to the process as a debugger just before it shuts down (assuming that you know when this is going to happen) with DebugActiveProcess


Call SetErrorMode(SEM_NOGPFAULTERRORBOX) before launching the buggy application as a child process.

The error mode is inherited to child processes and this particular flag will prevent the crash dialog from appearing.

0

精彩评论

暂无评论...
验证码 换一张
取 消