任我行

一天一个脚印......
每日一句:
posts - 54, comments - 218, trackbacks - 1, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

驱动开程序发—安装

Posted on 2006-01-03 10:11 任我行 阅读(2283) 评论(4)  编辑 收藏 引用 所属分类: 驱动开发

作为一个完整的例子,你开发出来驱动还必须要能安装。所以下面我讲一下安装。

如果前面的编译过程没有错误的话,现在我们应该已经得到了一个HelloWDM.sys文件,假设它是放在D:\HelloWDM\objfre\i386中。

安装WDM驱动程序可以用两种方法,一种是利用注册表,还有一种是利用INF文件。我们一般是采用INF文件(这是微软推荐的)。INF文件可以在 WINNT\INF 目录中找到很多。为了顺利安装,我在这里先给出 HelloWDM 所需要的 HelloWDM.INF 文件:

;; The Win2K DDK documentation contains an excellent INF reference.

;--------- Version Section ---------------------------------------------------

[Version]
Signature="$CHICAGO$"
Provider=LC_Device
DriverVer=8/21/2002,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=Unknown
ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b}

;--------- 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 = "HelloWDM",Disk1,,

[SourceDisksFiles]
HelloWDM.sys = 1,objfre\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,,"-5"

;--------- 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,,HelloWDM.sys
HKR, "Parameters", "BreakOnEntry", 0x00010001, 0

; --------- Windows NT -----------------

[YouMark_DDI.NT]
CopyFiles=YouMark_Files_Driver
AddReg=YouMark_NT_AddReg

[YouMark_DDI.NT.Services]
Addservice = HelloWDM, 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\HelloWDM.sys

[YouMark_NT_AddReg]
HKLM, "System\CurrentControlSet\Services\HelloWDM\Parameters",\
"BreakOnEntry", 0x00010001, 0


; --------- Files (common) -------------

[YouMark_Files_Driver]
HelloWDM.sys

;--------- Strings Section ---------------------------------------------------

[Strings]
ProviderName="Flying L Co.,Ltd."
MfgName="LC Soft"
DeviceDesc="Hello World WDM!"
DeviceClassName="LC_Device"
SvcDesc="???"



注意它可以同时在Win98或者Win2000中使用(系统会通过这个INF文件里面的字段名称,自动选择适合当前系统的安装方法的)。关于INF文件的各个字段含义现在我也不知道,所以也没有办法说清楚,如果谁看到这篇文章,而又知道的话,不妨为我一份。

准备好这个 HelloWDM.INF 文件后,让我们打开控制面板,双击“添加/删除硬件”,选择“添加/排除设备故障”->“添加新设备”->“否,我想从列表选择硬件”->“其它设备”->“从磁盘安装”,选择 HelloWDM.INF 所在的路径,然后安装。

当安装完成后,系统就会添加上你写好的驱动程序了。(可以在“设备管理器”中查看到)。然后重启电脑,这个驱动程序就投入使用啦。

关于安装,我也只知道这么多,到底安装驱动程序时,操作系统都作了些什么,我也不是很清楚,等我弄明白了我再贴上。

Feedback

# 无  回复  更多评论   

2006-08-28 11:29 by 大师
十分坦诚,钻研精神令人敬佩

# re: 驱动开程序发—安装   回复  更多评论   

2006-09-28 14:48 by 路过
谢谢.

# re: 驱动开程序发—安装   回复  更多评论   

2007-08-09 19:24 by 2left
非常好的入门,谢谢了

# re: 驱动开程序发—安装   回复  更多评论   

2008-04-03 23:24 by yilian
我很喜欢

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理