是否有可能在不出现 Windows 错误报告 (WER) 对话框的情况下使 Windows-7 上的常规用户模式进程崩溃? (当 WER 正常启用且未应用任何特定标志时。)
注:我是not有兴趣禁用WER,我对崩溃场景感兴趣WER 尚未启动,尽管它应该启动Windows“静默”终止应用程序。
在 Windows XP 上,编写一个 C 或 C++ 应用程序(在用户模式下)非常简单,它会弄乱自己的地址空间,这样当最终引发访问冲突(或其他未处理的 Win32 异常)时,Windows XP 将只是默默地终止进程而不通知用户:
...
void stackbreaker() {
printf("%s\n", __FUNCTION__);
// global/static buffer
static char buf[128] = "In a hole in the ground there lived a hobbit. And it burrowed through your stack. It even built a round door into you function.";
// Get address on the stack
char local;
char* stack = &local;
// nuke the stack:
memcpy(stack - 64, buf, sizeof(buf));
// Kaboom. No user defined unhandled exception filter will be called. Stack nuked.
// Process will terminate silently on Windows XP.
// But on Windows-7 you still get the WER dialog.
}
...
在一个简单的 C++ 项目中调用上述函数(在发布模式下——测试时注意那些编译器优化——而不是在调试器下运行)将:
- 在 XP 下,静默终止该进程。
- 在 Windows-7 下显示 WER 崩溃对话框。
- 旁白:在任何情况下,它都不会调用您自己的未处理的异常过滤器,即使您通过
SetUnhandledExceptionFilter
What I am wondering now is whether - under Windows 7 - the WER mechanism has been implemented in a way that I always get an error dialog for a crash[a] in my application, or whether there exist process corruption scenarios even in Windows 7, that will prevent the WER dialog from popping up?
我将添加一些我所做的阅读:
在书里通过 C/C++ 的 Windows(第五版,Richter,Nasarre) http://www1.wintellect.com/Resources/Details/86他们描述了“故障过程”中发生的情况(第 711 页):
- 异常过滤器。
- ...
- ...
- 内核检测到未处理的异常
- 阻止 ALPC 调用 Wer Service
- WER 报告开始生效。
- ...
现在,他们指出 Win7 的做法与 Windows XP 不同(引用本书第 710 页:)
...从 Windows Vista 开始,UnhandledExceptionFilter
函数不再向 MS 的服务器发送错误报告。反而。内核检测到异常不是由用户模式线程处理的(步骤4)...
所以这意味着,有根本没办法一个进程“崩溃”——在 Vista 及更高版本中——以一种阻止 WER 启动的方式。我试图确认或反驳这一点。
[a]:显然,通过调用各种方法之一,可以轻松地“杀死”进程而不留下任何痕迹*exit
or terminate*
功能。问题是,如果您可以排除这样的终止原因,(如何)可能以阻止显示 WER 对话框的方式使 Win7 上的用户模式进程“崩溃”。