是否可以在不重新启动的情况下卸载内核驱动程序?
我正在研究 Win7 DDK 中的内核驱动程序示例之一。我可以修改编译并构建我的 *.sys 文件。我也可以使用其 INF(使用设备管理器或 devcon)或直接使用服务控制管理器来安装它。当我进行下一个更改并生成更新的 *.sys 文件时,我似乎在这个新文件和我现在停止的驱动程序之间发生冲突(我尝试使用 Servcie Control Manager“停止”和“删除服务”等)。如果重新启动,我可以安装新驱动程序并正常运行。同样,如果我在设备管理器中选择卸载,Windows 会提示我重新启动。
那么,如何轻松测试对内核驱动程序的增量修改呢? 谢谢
I'm playing about with one of the kernel driver examples in the Win7 DDK. I can modify compile and build my *.sys file. I can install it too with its INF (using device manager or devcon) or using the Service control manager directly. When I make the next change though and generate an updated *.sys file I seem to get a conflict between this new file and my now stopped driver (I've tried using Servcie Control Manager 'stop' and 'delete service' etc). If I reboot, I can install the new driver and run it fine. Similarly, if I choose uninstall in Device Manager, Windows prompts me to reboot.
So, how can one easily test incremental modifications to a kernal driver easily?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看安装 API 日志可能是一个不错的起点:http://msdn.microsoft.com/en-us/library/ff550887%28v=VS.85%29.aspx
如果 devcon 提示重新启动,您可以查看 DDK 中的代码,调试它为什么这么问并以这种方式深入研究问题。
Looking at the Setup API logs might be a good place to start: http://msdn.microsoft.com/en-us/library/ff550887%28v=VS.85%29.aspx
If devcon prompts for a reboot, you could look at the code in the DDK, debug why it's asking and dig into the issue that way as well.
是的。
sc stop
应该停止您的驱动程序。如果您的驱动程序与特定的 PnP devnode 关联,则应在删除 devnode 后卸载它。Yes.
sc stop <driver name>
should stop your driver. If your driver is associated with a particular PnP devnode, it should be unloaded after the devnode is removed.如果您希望能够卸载驱动程序,则必须设置一个基本上在每次卸载驱动程序时执行的函数 - 最有可能的是您将放置释放分配的缓冲区和生命周期中可能“活动”的任何其他资源的代码司机的。这是一个示例代码:
If you want to be able to unload your driver you have to set up a function which basically executes each time the driver is unloaded - most likely you will put code which frees allocated buffers and any other resource which might be "alive" during the lifecycle of the of the driver. Here is an example code:
尝试编译、签名并加载此代码:
然后下载 DebugView,解压以管理员身份运行它,然后“捕获”菜单项下的“捕获内核”。下载、解压并运行OSR Driver Loader,注册驱动程序,“启动服务”。您将在 DbgView 中观察到“DriverEntry”日志消息。现在,在 OSR 驱动程序加载程序中,“停止服务”并观察 Unload 消息。希望这能让你继续前进。
Try compiling, signing, and loading this code:
Then download DebugView, unzip it, run it as administrator, and then "Capture Kernel" under the "Capture" menu item. Download, unzip, and run the OSR Driver Loader, register the driver, the "Start Service". You will observe a "DriverEntry" log message in DbgView. Now in the the OSR Driver loader, "Stop Service" and observe an Unload message. Hopefully that gets you going.