安装筛选器驱动程序

PnP 筛选器驱动程序可以支持设备 设置类 中的特定设备或所有设备,并且可以在设备的功能驱动程序下方附加 (较低筛选器) 或高于设备的功能驱动程序 (高筛选器) 。 有关 PnP 驱动程序层的详细信息,请参阅 WDM 驱动程序的类型 。

安装特定于设备的筛选器驱动程序

在Windows 10版本 1903 及更高版本上,可以使用 INF DDInstall.Filters 部分中的 INF AddFilter 指令注册特定于设备的筛选器驱动程序。 有关详细信息 ,请参阅设备筛选器驱动程序排序 。

对于早期版本的 Windows,若要注册特定于设备的筛选器驱动程序,请通过 DDInstall 中的 AddReg 条目创建注册表项。设备的 INF 文件的 HW 部分。 对于特定于设备的上限筛选器,请创建名为 UpperFilters 的条目。 对于特定于设备的较低筛选器,请创建名为 LowerFilters 的条目。 例如,以下 INF 摘录将 ExampleFilterDriver 作为 ExampleFunctionDriver 驱动程序的上层筛选器安装:

[Example_install]
CopyFiles=Filter_copyfiles, Function_copyfiles

[Example_install.HW]
AddReg=Filter_addreg

[Example_install.Services]
AddService=ExampleFunctionDriver,0x00000002,Function_ServiceInstallSection
AddService=ExampleFilterDriver,,Filter_ServiceInstallSection

[Filter_addreg]
HKR,,"UpperFilters",0x00010000,"ExampleFilterDriver" ; REG_MULTI_SZ value

[Filter_ServiceInstallSection]
DisplayName    = %Filter_ServiceDesc%
ServiceType    = 1     ; SERVICE_KERNEL_DRIVER
StartType      = 3     ; SERVICE_DEMAND_START
ErrorControl   = 1     ; SERVICE_ERROR_NORMAL
ServiceBinary  = %13%\ExampleFilterDriver.sys

安装类筛选器驱动程序

若要为 设备安装类安装类的类范围的上下筛选器,可以提供安装必要服务 的设备安装应用程序 。 然后,应用程序可以将服务注册为所需设备安装类的上限或下限筛选器。 若要复制服务二进制文件,应用程序可以使用 SetupInstallFilesFromInfSection。 若要安装服务,应用程序可以使用 SetupInstallServicesFromInfSection。 若要将服务注册为特定设备安装类的上限和/或下限筛选器,应用程序将使用从 RelativeKeyRoot 参数的 SetupDiOpenClassRegKey 中检索到的注册表项句柄,为每个感兴趣的设备安装程序类调用 SetupInstallFromInfSection。 例如,请考虑以下 INF 部分:

[DestinationDirs]
upperfilter_copyfiles = 13

[upperfilter_inst]
CopyFiles = upperfilter_copyfiles
AddReg = upperfilter_addreg

[upperfilter_copyfiles]
upperfilt.sys,,,0x00004000  ; COPYFLG_IN_USE_RENAME

[upperfilter_addreg]
; append this service to existing REG_MULTI_SZ list, if any
HKR,,"UpperFilters",0x00010008,"upperfilt"

[upperfilter_inst.Services]
AddService = upperfilt,,upperfilter_service

[upperfilter_service]
DisplayName   = %upperfilter_ServiceDesc%
ServiceType   = 1   ; SERVICE_KERNEL_DRIVER
StartType     = 3   ; SERVICE_DEMAND_START
ErrorControl  = 1   ; SERVICE_ERROR_NORMAL
ServiceBinary = %13%\upperfilt.sys

设备安装应用程序将:

  1. 调用 [upperfilter_inst] 节的 SetupInstallFilesFromInfSection 。

  2. 调用 [upperfilter_inst的 SetupInstallServicesFromInfSection 。“服务]”部分。

  3. 为 [upperfilter_inst] 节调用 SetupInstallFromInfSection ,为要为其注册 upperfilt 服务的每个类键调用一次。

每个调用都会为 Flags 参数指定SPINST_REGISTRY,以指示只需要执行注册表修改。