5

将 Windows 驱动程序 sys 文件保留在 system32\drivers 目录之外是否合法?看来,如果驱动程序是通过 CreateService 使用 driver.sys 文件的绝对路径“手动”配置的。但是,当 INF 文件用于使用 InstallHinfSection 安装驱动程序并且驱动程序位置不是 system32\drivers InstallHinfSection 将失败并出现错误

!!!dvi:驱动程序路径不在系统根目录中!inf: {Install Inf Section [DefaultInstall.NT.Services] exit(0xe0000217)} !!! inf:错误 0xe0000217:此 INF 中的服务安装部分无效。inf: {Install Inf Section [DefaultInstall.NT]} 当 ServiceBinary = %1%\MyDriverdrv.sys ; 当前目录并在 ServiceBinary = %12%\MyDriverdrv.sys 时成功;system32\驱动程序

INf 文件:

;
; INF file to install MyDriver registry filter driver
;

[Version]
signature = "$Windows NT$"
Provider    = %MyDriverInc%
CatalogFile =

; Distribution Media information
;
[SourceDisksNames]
1 = %MyDriverdrv.MediaDesc%

[SourceDisksFiles]
MyDriverdrv.sys = 1

[DestinationDirs]
DefaultDestDir = 12
MyDriver.DriverFiles = 12

[DefaultInstall.NT]
CopyFiles = MyDriver.DriverFiles

[DefaultUninstall.NT]
DelFiles = MyDriver.DriverFiles

[MyDriver.DriverFiles]
MyDriverdrv.sys

[DefaultInstall.NT.Services]
AddService = %ServiceName%, , MyDriverdrv_Service_Inst

[DefaultUninstall.NT.Services]
AddService = %ServiceName%, 0x200

[MyDriverdrv_Service_Inst]
DisplayName    = %MyDriverdrv.SvcDesc%
ServiceType    = 1; SERVICE_KERNEL_DRIVER
StartType      = 3; SERVICE_DEMAND_START
ErrorControl   = 1; SERVICE_ERROR_NORMAL
ServiceBinary  = %1%\MyDriverdrv.sys

[Strings]
MyDriverInc        = "MyDriver, Inc"
ServiceName = "MyDriverdrv"
MyDriverdrv.SvcDesc = "MyDriver Trace Kernel Mode Driver"
MyDriverdrv.MediaDesc = "MyDriver Trace Kernel Mode Driver"

由于 INF 文件是现在安装驱动程序的官方方式,我看不到将驱动程序文件保存在本地的方法。

谢谢!

4

0 回答 0