在 C 代码中强制出现蓝屏(来自简单的驱动程序错误?)
可能的重复:
模拟蓝屏
你好,
我正在尝试以某种方式在我的 C 代码中内联引发 BSOD。我的主要背景是 Java,但很幸运得到了一些同事的指导,并正在帮助开发一个简单的 C 实用程序。
有两个部分:
1)写入硬盘(我完成了这个,还不错)
2) 发送最后一个 SCSI 写入命令后立即强制蓝屏
您现在可能可以轻松看出程序的意图。
到目前为止我已经尝试过两件事:
1)外部调用pskill.exe(Windows实用程序)手动崩溃csrss.exe,这会强制蓝屏,因为csrss.exe是Windows必需的服务。这不起作用,因为它不够快。对外部实用程序的调用花费的时间太长,因此我们需要内联代码与写入磁盘部分一起编译,以便足够快地使计算机崩溃。
2) 使用 windows.h API 调用 TerminateProcess: http://msdn.microsoft.com/en-us/library/ms686714%28v=vs.85%29.aspx 问题是这个函数无法结束系统相关任务,因此它无法关闭 csrss.exe
这让我缺乏选择。我需要一种巧妙的方法来在我们自己的本机代码中杀死 csrss.exe,而无需外部调用,或者一种巧妙的方法来强制内部代码中的蓝屏,或者我需要一个非常简单的驱动程序,我可以加载和调用该驱动程序,该驱动程序将立即蓝屏机器。调用 KeBugCheck 的长度可能只有 1 行 http://msdn.microsoft.com /en-us/library/ff551948.aspx
感谢您的时间和投入。
Possible Duplicate:
Simulating a BlueScreen
Hello SO,
I'm trying to induce a BSOD somehow inline in my C code. My main background is Java but have been fortunate to have been tutored by some coworkers and am helping out with a simple C utility.
There's two sections:
1) write to a hard drive (I finished this, wasn't too bad)
2) Force a blue screen immediately after sending the last SCSI write command
You can probably tell the intent of the program easily now.
I've tried two things so far:
1) Externally calling pskill.exe (windows utility) to manually crash csrss.exe which forces a blue screen every time since csrss.exe is a required service of windows. This doesn't work because it's not fast enough. The call to the external utility takes too long so we need inline code to compile with the write to disk section in order to crash the computer fast enough.
2) Use the windows.h API to call TerminateProcess: http://msdn.microsoft.com/en-us/library/ms686714%28v=vs.85%29.aspx
The problem is this function cannot end system related tasks so it can't close csrss.exe
This has left me short on options. I need a clever way to kill csrss.exe in our own native code without an external call or a clever way to force a blue screen in internal code OR I need a very simple driver I can load and call which will blue screen the machine immediately. Could be as short as 1 line calling KeBugCheck http://msdn.microsoft.com/en-us/library/ff551948.aspx
Thanks for your time and input.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最好的选择是编写一个简单的驱动程序,调用
KeBugCheck()
正如您自己所建议的。您可以从 Windows 驱动程序工具包中获取最简单的示例,把它削减到最简单的程度。
Your best bet is to write a trivial driver that calls
KeBugCheck()
as you yourself suggest. You can take the most simple example from the Windows Driver Kit and cut it down to the barebones.我推荐 sysinternals 的不是我的错。
I recomment Not My Fault from sysinternals.
在内核模式下运行时出现蓝屏的方法有两种:
Here are two ways to get a blue screen when running in kernel mode: