如何调试 Windows 中的内核驱动程序崩溃?

发布于 2024-10-11 22:45:05 字数 157 浏览 5 评论 0原文

我编写了一个内核驱动程序,它挂接到一个进程并隐藏一个文件夹。这个驱动程序运行得很好,直到我连接了外部硬盘。

此时,我的操作系统(Windows XP 或 Server 2003)崩溃并出现蓝屏死机 (BSOD)。

导致此崩溃的原因是什么?如何修改驱动程序来解决该问题?

I wrote a kernel driver that hooks into a process and hides a folder. This driver works very well, until I connect an external hard disk.

At this point, my OS (either Windows XP or Server 2003) crashes with a blue screen of death (BSOD).

What could be causing this crash, and how can I modify my driver to solve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心舞飞扬 2024-10-18 22:45:05

一般来说有两种方法:

  1. 事后调试。当您没有可用的本地计算机来重现崩溃时,通常会执行此操作。在这种情况下,您将检查故障转储文件(完整转储或小型转储)。
  2. 现场调试。在这种情况下,如果您知道系统将崩溃,您可以准备一台机器来使用 WinDbg 控制该机器并通过串行或火线电缆连接。后者要快得多。

不过,我同意你透露的细节太少了。你“上钩”吗?嗯,怎么样? SSDT挂钩?或者您是否使用编写过滤器驱动程序的正确方法?如果有过滤驱动程序,哪个型号?迷你过滤器还是传统过滤器?

我刚刚注意到您的评论,您挂钩“NtOpenProcess 和 NtQueryDirectoryFile”,所以听起来像是 SSDT 挂钩。 您在实施过程中具体做了什么?我知道很多驱动程序都进行了不正确的 SSDT 挂钩。它从用于将钩子安装到位的方法开始,通常不会以大胆的实现结束。

请注意,对于实时调试,WinDbg 提供了一些优秀的功能来在启动时传输和加载最新的驱动程序版本。因此您无需额外准备即可调试最新版本。远程端的内核调试器和您计算机上的 WinDbg 将处理它。

另外,您可能想将您的问题发布到 OSR(即 NTDEV)的列表中。

There would be two ways in general:

  1. post-mortem debugging. This is usually what you do when you have no local machine available to reproduce the crash. In this case you're inspecting the crashdump file (either full or mini dump).
  2. live debugging. In this case, if you know the system is going to crash, you prepare one machine to control this machine using WinDbg and connect via serial or FireWire cable. The latter is much faster.

However, I agree that you give way too few details. You "hook"? Well, how? SSDT-hooking? Or do you use the proper way of writing a filter driver? If a filter driver, which model? Mini-filter or legacy filter?

I just noticed your comment that you hook "NtOpenProcess and NtQueryDirectoryFile", so it sounds like SSDT-hooking. What exactly are you doing in your implementation? I know plenty of drivers that do improper SSDT-hooking. It starts with the method used to get the hook in place and usually does not end with a daring implementation.

Please note that for live debugging WinDbg offers some fine features to transfer and load your latest driver version at boot time. So you can debug your latest version without extra preparation. The kernel debugger on the remote end and WinDbg on your machine will take care of it.

Also, you may want to post your question to the lists over at OSR (namely NTDEV).

爱的那么颓废 2024-10-18 22:45:05

开发内核驱动程序时,通常您希望使用内核调试器连接(主机是调试器,VM 是被调试器)在虚拟机中测试它们。一些虚拟机环境提供对调试的直接支持。

当然,之后您需要在各种物理和虚拟硬件上进行调试。

When developing kernel drivers, typically you want to test them in a virtual machine, with a kernel debugger connection (host is debugger, VM is debuggee). Some of the virtual machine environments provide direct support for debugging.

Afterward of course you need to debug on a variety of physical and virtual hardware.

梦情居士 2024-10-18 22:45:05

您几乎没有发布 BSOD 的技术细节,或者您的代码如何工作,因此不可能提供具体的答案。作为一般起点,我建议您分析小型转储以获取触发 BSOD 错误的一些具体信息。这是一个很好的入门指南。

http://forums.majorgeeks.com/showthread.php?p=1418737

You have posted almost no technical details of the BSOD, or how your code works, so it is impossible to provide a specific answer. As a general starting point, I would suggest you analyze the minidump to get some specifics of what went wrong to trigger the BSOD. Here is a good getting started guide.

http://forums.majorgeeks.com/showthread.php?p=1418737

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文