为我的进程禁用Windows错误报告(Dr. Watson) [英] Disabling Windows error reporting (Dr. Watson) for my process

查看:139
本文介绍了为我的进程禁用Windows错误报告(Dr. Watson)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,在其中托管了一些不稳定的第三方代码,这些代码在外部进程中无法控制,以保护我的主应用程序免受其显示的讨厌的错误的影响.我的父进程正在监视另一个进程,并在失败时执行正确的操作(tm)".

我遇到的问题是,Watson博士仍然在隔离的进程中检测到崩溃,并附加到下一个进程以进行崩溃转储.这有两个问题: 1.极大地减慢了我检测故障所需的时间,因为在进行故障转储时,该过程仍然有效. 2.向用户显示烦人的弹出窗口,询问他们是否要将错误报告提交给Microsoft.

很明显,我希望修复子进程中的错误,但是鉴于这不是一个选择,我希望能够有选择地为该进程禁用Dr. Watson(以及Vista +中的Windows错误报告).

在切换到不受信任的位之前,我正在流程中运行一些自己的代码,因此,如果有一个我可以调用的API可以影响当前流程,就可以了.

我知道: http://support.microsoft.com/default.aspx/kb/188296 会禁用整个计算机的Watson博士.我不想这样做,因为这会让我很糟糕,浪费整个机器范围的设置.

我也知道Vista +中的WerSetFlags选项似乎会禁用当前进程的Windows错误报告,但是我需要在早期OS版本上禁用Dr.Watson的功能.

解决方案

当进程未处理某些异常时,将调用好医生.因此,常见的处理方法是自己处理所有异常.在您的情况下,这要困难得多,因为您不拥有崩溃的过程代码.然后,您可以做的是在运行时将代码注入到另一个进程中,并安装一个异常处理程序,它将吞下导致崩溃的异常.被捕获时,请优雅地关闭该过程.

这里有很多关于将代码注入另一个进程的问题.至于崩溃处理程序,您可以设置未处理的异常过滤器,或添加矢量化异常处理程序.请注意,对于后者,您必须注意不要吞下实际上在另一个进程中处理的合法异常,即找到一种方法来识别崩溃的异常并确保它是您唯一处理的异常.

I have an application that is hosting some unstable third-party code which I can't control in an external process to protect my main application from nasty errors it exhibits. My parent process is monitoring the other process and doing "the right thing (tm)" when it fails.

The problem that I have is that Dr. Watson is still detecting crashes in the isolated process and attaching to the processes on the way down to take a crash dump. This has the two problems of: 1. Dramatically slowing down the time that it takes for me to detect a failure because the process stays alive while the crash dump is being taken. 2. Showing annoying popups to the user asking if they want to submit the error reports to Microsoft.

Clearly I would prefer to fix the bugs in the child process, but given that it isn't an option, I would like to be able to selectively disable Dr. Watson (and Windows Error Reporting in Vista+) for that process.

I am running some of my own code in the process before handing off to the untrusted bit, so if there is an API that I can call that affects the current process that would be fine.

I am aware of: http://support.microsoft.com/default.aspx/kb/188296 which would disable Dr. Watson for the entire machine. I don't want to do that because it would make me a bad citizen to trash a machine-wide setting.

I am also aware of the WerSetFlags option in Vista+ that would seem to disable windows error reporting for the current process, but I need something that will disable Dr.Watson on earlier OS versions.

解决方案

The good doctor is invoked when a process does not handle a certain exception. Therefore, the common way to go would be to handle all exceptions yourself. In your case, it is much harder since you don't own the crashing process code. What you can do then, is to inject your code into the other process at runtime, and install an exception handler that will swallow the exception causing the crash. When caught, gracefully shut down the process.

There are quite a few questions here talking about injecting code into another process. As for the crash handler, you can either set an unhandled exception filter, or add a vectored exception handler. Note that for the latter, you'll have to be careful not to swallow legit exceptions that are in fact handled inside the other process, namely find a way to recognize the crashing exception and make sure it is the only one you handle.

这篇关于为我的进程禁用Windows错误报告(Dr. Watson)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆