天天看點

DDK&WDM學習 - HelloWDM,WDM驅動加載,INF檔案

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

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

Step 2

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

Step 3

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

Step 4

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

Step 5

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

注 * 從磁盤安裝

Step 6

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

Step 7

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

Step 8

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

Step 9

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

安裝完成

Step 10

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

在裝置管理器中檢視

Step 11

DDK&amp;WDM學習 - HelloWDM,WDM驅動加載,INF檔案

檢視屬性

4, 給出一個已經編譯好的驅動(包括INF檔案,符号檔案和源代碼)

代碼就是《驅動開發技術詳解》CD光牒中第一章的代碼。

可以使用WinDBG和VMWare進行簡單的調試練習。

關于WinDBG的使用會在下一篇Blog中描述。

下一篇: DDK的版本

繼續閱讀