Windows驱动安装info和调试

http://blog.csdn.net/blog_index/article/details/6012054    ----参考
http://blog.csdn.net/coc_k/article/details/52034927
http://blog.csdn.net/eqera/article/details/8237991  ---windbg下
  • 中断(CTRL-BREAK ) — 该快捷键总是中断系统,只要系统正在运行并与WinDbg 处于通信状态 (在KD 快捷键是CTRL-C)。
  • 步过(F10)     — 每按一次运行一条语句(如果C 或者C++     和     WinDbg处于“source     mode”, 可通过DebugàSource     Mode切换),或者一条指,
  • 并且规定如果遇到一个函数调用,将会运行过该函数,而不会进入它。
  • 步进(F11) — 就象步过那样,除了运行到一个函数调用时,会进入该调用例程。
  • 步出     (SHIFT-F11) — 这会使程序运行直到完成当前例程(在call stack中的当前地址)。如果你对该例程已经了解得足够多,这个快捷键很有用。
  • 运行到光标(F7 or CRTL-F10) — 当你想运行到该处中断,你可以将光标放到源代码窗口或者反汇编窗口中相应的位置,按下F7;程序将会运行到该位置。
  • 有一点要注意,然而:如果运行流程与该处不匹配(例如,一个IF语句不运行),WinDbg 将不会中断,因为并没有运行到指定地方。
  • 运行 (F5) — 运行直到遇到断点或者错误事件被检测到。你可以将“运行”想象为正常执行状态。
  • 将指令设置在当前行(CTRL-SHIFT-I) — 在源代码窗口,你可以把光标放在一行中,使用该快捷键,只要你允许(例如 F5或者F10),程序便从该处开始运行。
  • 在你想重复一些指令序列时,这很有用。但是要注意一些事情。例如,寄存器和变量的数据不会象你正常运行到该处时看到那样。
  • 直接设置Eip — 你可以为Eip寄存器设置一个数值,然后按下F5(或者F10或者其他的什么),运行开始于该地址。显然易见,该功能就象将指令设置在当前行
  • ,除非你指定了一个汇编指令的地址。

https://code.msdn.microsoft.com/windowshardware/windows-driver-kit-wdk-80-e3161626?f%5B0%5D.Type=Topic&f%5B0%5D.Value=File%20Systems&f%5B0%5D.Text=File%20Systems    ------微软自己提供的sample代码,
http://microsoft.github.io/windows/    ---这个也是

根据经验: 代码还是选用7600的WDK包中的 例子

然后inf文件,就把内部的工程的相关名字,都修改替换为新建工程的名称即可,就可以安装和启动成功了。


添加符号路径 打开 File->Symbol file path

SRV*d:\localsymbols*http://msdl.microsoft.com/download/symbols



举例:
以WDK7600\src\filesys\miniFilter\passThrough下的为例子
新建一个WDM空的工程,取名为MyDriver1,那么将这个例子中的*.c和passThrough.inf拷贝内容进行拷贝
修改MyDriver1.inf文件如下:
;;;;
;;; PassThrough
;;;
;;;
;;; Copyright (c) 1999 - 2001, Microsoft Corporation
;;;

[Version]
Signature   = "$Windows NT$"
Class       = "ActivityMonitor"                         ;This is determined by the work this filter driver does
ClassGuid   = {b86dff51-a31e-4bac-b3cf-e8cfe75c9fc2}    ;This value is determined by the Class
Provider    = %Msft%
DriverVer   = 06/16/2007,1.0.0.1
CatalogFile = passthrough.cat


[DestinationDirs]
DefaultDestDir          = 12
MyDriver1.DriverFiles  = 12            ;%windir%\system32\drivers

;;
;; Default install sections
;;

[DefaultInstall]
OptionDesc          = %ServiceDescription%
CopyFiles           = MyDriver1.DriverFiles

[DefaultInstall.Services]
AddService          = %ServiceName%,,MyDriver1.Service

;;
;; Default uninstall sections
;;

[DefaultUninstall]
DelFiles   = MyDriver1.DriverFiles

[DefaultUninstall.Services]
DelService = %ServiceName%,0x200      ;Ensure service is stopped before deleting

;
; Services Section
;

[MyDriver1.Service]
DisplayName      = %ServiceName%
Description      = %ServiceDescription%
ServiceBinary    = %12%\%DriverName%.sys        ;%windir%\system32\drivers\
Dependencies     = "FltMgr"
ServiceType      = 2                            ;SERVICE_FILE_SYSTEM_DRIVER
StartType        = 3                            ;SERVICE_DEMAND_START
ErrorControl     = 1                            ;SERVICE_ERROR_NORMAL
LoadOrderGroup   = "FSFilter Activity Monitor"
AddReg           = MyDriver1.AddRegistry

;
; Registry Modifications
;

[MyDriver1.AddRegistry]
HKR,,"DebugFlags",0x00010001 ,0x0
HKR,"Instances","DefaultInstance",0x00000000,%DefaultInstance%
HKR,"Instances\"%Instance1.Name%,"Altitude",0x00000000,%Instance1.Altitude%
HKR,"Instances\"%Instance1.Name%,"Flags",0x00010001,%Instance1.Flags%

;
; Copy Files
;

[MyDriver1.DriverFiles]
%DriverName%.sys

[SourceDisksFiles]
MyDriver1.sys = 1,,

[SourceDisksNames]
1 = %DiskId1%,,,

;;
;; String Section
;;

[Strings]
Msft                    = "My Driver Test"
ServiceDescription      = "MyDriver1 Mini-Filter Driver"
ServiceName             = "MyDriver1"
DriverName              = "MyDriver1"
DiskId1                 = "MyDriver1 Device Installation Disk"

;Instances specific information.
DefaultInstance         = "MyDriver1 Instance"
Instance1.Name          = "MyDriver1.Instance"
Instance1.Altitude      = "370030"
Instance1.Flags         = 0x0              ; Allow all attachments

为了调试方面,我们在passThrough.c中的DriverEntry中新增了一点内容, 其它都不用动:
KdPrint(("PassThrough!DriverEntry111"));
    
DbgBreakPoint();

KdPrint(("PassThrough!DriverEntry222"));

DbgBreakPoint();

KdPrint(("PassThrough!DriverEntry3333"));

DbgBreakPoint();

然后主要是设置工程属性,只能先在win32上玩,关闭告警, 选择平台为WIN7....
编译,生成了MyDriver1.inf, MyDriver1.sys, 右键安装,会出现NT服务,sc query MyDriver1.sys

接下来可以调试了,主要是在弹出的WinDbg中,设置符号表路径和Source File路径:
SRV*d:\localsymbols*http://msdl.microsoft.com/download/symbols;;D:\Work\code\testProject\filefilterDrvier\Debug

D:\Work\code\testProject\MyDriver1
然后打开一个DriverEntry的源文件.c
好,这样监控好以后,在VM中运行后,就会自动打开.c文件的断点处,开始运行sc start mydriver1。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值