以编程方式在 Windows 7 x64 上安装系统驱动程序

以编程方式在 Windows 7 x64 上安装系统驱动程序

我正在尝试使用 WinDDK,并尝试在 Windows 7 (x64) 虚拟盒上安装系统驱动程序。我有一个 .inf 文件:

; testdriver.inf - install information file
[Version] 
Signature = "$Windows NT$" 
Class=System
ClassGUID={4d36e97d-e325-11ce-bfc1-08002be10318} 
Provider=%tester% 
DriverVer= 12/12/2012,1.0.0

[Manufacturer]
%DRV% = TestDriver.DRV

[TestDriver.DRV]
%Tst1%=Tst1.Install, *testdriver\TST1

[DestinationDirs]
Tst1.Files.Driver.NTx86=10,System32\Drivers

[SourceDisksNames]
1="Wdm1 build directory",,,

[SourceDisksFiles.x86]
testdriver.sys=1,objfre_wxp_x86\i386

[DestinationDirs]
DefaultDestDir           = 12
Tst1.DriverFiles         = 12           ;%windir%\system32\drivers
[DefaultInstall]
OptionDesc          = %Tst1%
CopyFiles           = Tst1.DriverFiles
[DefaultInstall.Services]

[DefaultUninstall]

[DefaultUninstall.Services]

[Tst1.Install.NTx86]
CopyFiles=Tst1.Files.Driver.NTx86

[Tst1.Files.Driver.NTx86]
testdriver.sys,,,%COPYFLG_NOSKIP%

[Tst1.Install.NTx86.Services]
AddService = Tst1, %SPSVCINST_ASSOCSERVICE%, Tst1.Service

[Tst1.Service]
DisplayName    = %Tst1.ServiceName%
ServiceType    = %SERVICE_KERNEL_DRIVER%
StartType      = %SERVICE_DEMAND_START%
ErrorControl   = %SERVICE_ERROR_NORMAL%
ServiceBinary  = %10%\System32\Drivers\testdriver.sys
[Tst1.DriverFiles]
testdriver.sys

[Strings]
tester="Tester"
DRV="Driver Development"
Tst1="TST1"
Tst1.ServiceName="TestDriver"
SPSVCINST_ASSOCSERVICE=0x00000002   ; Driver service is associated with device being   installed
COPYFLG_NOSKIP=2    ; Do not allow user to skip file
SERVICE_KERNEL_DRIVER=1
SERVICE_AUTO_START=2
SERVICE_DEMAND_START=3
SERVICE_ERROR_NORMAL=1

该驱动程序是使用“x64 免费构建环境”构建的。在目标平台上手动安装驱动程序时,二进制文件将复制到 System32\drivers。但是,不会创建注册表项,因此无法通过设备管理器管理驱动程序(因为它不会显示在“非即插即用驱动程序”中)。应该修改 .inf 文件中的哪些条目才能成功安装驱动程序?此外,只需将二进制文件移动到 System32\drivers 并以编程方式创建正确的注册表项,就可以自动执行此过程吗?

相关内容