1, INF 文件
WDM的驱动程序是可以使用INF文件来进行安装的
首先奉上一个关于INF格式的MSDN链接
从《驱动开发技术详解》管盘中找到的INF的例子, 封号(;)表示注释
HelloWDMChapter01.inf
;; The Win2K DDK documentation contains an excellent INF reference.
;--------- Version Section ---------------------------------------------------
[Version]
Signature="$CHICAGO$"
Provider=RenRen_Device
DriverVer=11/1/2007,3.0.0.3
; If device fits one of the standard classes, use the name and GUID here,
; otherwise create your own device class and GUID as this example shows.
Class=RenRenDevice
ClassGUID={B988F087-B147-4626-9CC7-D83B7EB9D53A} ; Generated by GUID tool.
;IMPLEMENT_OLECREATE(<<class>>, <<external_name>>,
;0xb988f087, 0xb147, 0x4626, 0x9c, 0xc7, 0xd8, 0x3b, 0x7e, 0xb9, 0xd5, 0x3a);
;{B988F087-B147-4626-9CC7-D83B7EB9D53A}
;--------- SourceDiskNames and SourceDiskFiles Section -----------------------
; These sections identify source disks and files for installation. They are
; shown here as an example, but commented out.
[SourceDisksNames]
1 = "HelloWDMChapter01",Disk1,,
[SourceDisksFiles]
HelloWDMChapter01.sys = 1,objchk_win7_x86/i386,
;--------- ClassInstall/ClassInstall32 Section -------------------------------
; Not necessary if using a standard class
; 9X Style
[ClassInstall]
Addreg=Class_AddReg
; NT Style
[ClassInstall32]
Addreg=Class_AddReg
[Class_AddReg]
HKR,,,,%DeviceClassName%
HKR,,Icon,,"-19"
;--------- DestinationDirs Section -------------------------------------------
[DestinationDirs]
YouMark_Files_Driver = 10,System32/Drivers
;--------- Manufacturer and Models Sections ----------------------------------
[Manufacturer]
%MfgName%=Mfg0
[Mfg0]
; PCI hardware Ids use the form
; PCI/VEN_aaaa&DEV_bbbb&SUBSYS_cccccccc&REV_dd
;改成你自己的ID
%DeviceDesc%=YouMark_DDI, PCI/VEN_9999&DEV_9999
;---------- DDInstall Sections -----------------------------------------------
; --------- Windows 9X -----------------
; Experimentation has shown that DDInstall root names greater than 19 characters
; cause problems in Windows 98
[YouMark_DDI]
CopyFiles=YouMark_Files_Driver
AddReg=YouMark_9X_AddReg
[YouMark_9X_AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,HelloWDMChapter01.sys
HKR, "Parameters", "BreakOnEntry", 0x00010001, 0
; --------- Windows NT -----------------
[YouMark_DDI.NT]
CopyFiles=YouMark_Files_Driver
AddReg=YouMark_NT_AddReg
[YouMark_DDI.NT.Services]
Addservice = HelloWDMChapter01, 0x00000002, YouMark_AddService
[YouMark_AddService]
DisplayName = %SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %10%/System32/Drivers/HelloWDMChapter01.sys
[YouMark_NT_AddReg]
HKLM, "System/CurrentControlSet/Services/HelloWDMChapter01/Parameters",/
"BreakOnEntry", 0x00010001, 0
; --------- Files (common) -------------
[YouMark_Files_Driver]
HelloWDMChapter01.sys
;--------- Strings Section ---------------------------------------------------
[Strings]
ProviderName="RenRen."
MfgName="RenRen Soft"
DeviceDesc="Hello World WDM!"
DeviceClassName="RenRen_Device"
SvcDesc="RenRen"
2, 注册表
INF文件中的内容会在注册表中有所体现
硬件子键
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Enum/{设备管理器该设备属性的详细信息}
类子键
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Class/{GUID}
服务子键
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/{Driver名称}
3, 安装流程
Step 1
Step 2
Step 3
Step 4
Step 5
注 * 从磁盘安装
Step 6
Step 7
Step 8
Step 9
安装完成
Step 10
在设备管理器中查看
Step 11
查看属性
4, 给出一个已经编译好的驱动(包括INF文件,符号文件和源代码)
代码就是《驱动开发技术详解》光盘中第一章的代码。
可以使用WinDBG和VMWare进行简单的调试练习。
关于WinDBG的使用会在下一篇Blog中描述。