Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results
The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.
Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/
Hi,
I am trying to write a Pci Bus filter driver that attaches itself below PCI Express Root Port(pci.sys) and above
PCI Express Upstream Switch Port(pci.sys).When we install my Upper filter driver on PEUSP, it seem to affect(restart) other
PCI Express Root Ports(that attached pci devices).Then system hang for a few seconds before it complete.Maybe soon or thirty seconds based on platforms.
Is the behavior of restarting other PCI Express Root Ports correctily?or i just need to modify my INF file correctilly?
Any help regarding the cause of this behavior or any steps that I have missed that would cause this would be greatly appreciated.
I create a sample filter driver according to
https://github.com/microsoft/Windows-driver-samples/tree/main/general/toaster/toastDrv/kmdf/filter
I create and test two INF files, see below
[Version]
Signature="$WINDOWS NT$"
Class=System
ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
Provider=%TEST%
CatalogFile=filter64.cat
DriverVer = 06/15/2023,10.16.46.97
PnpLockdown=1
;*************************
; Source file information
;*************************
[SourceDisksNames]
1 = %DiskName%,,,""
[SourceDisksFiles]
asmfilter64.sys = 1,,
[DestinationDirs]
DefaultDestDir = 12 ;system32/drivers
[ControlFlags]
ExcludeFromSelect=*
;*****************************************
; filter Install Section
;*****************************************
[Manufacturer]
%TEST%=Standard,NTamd64
[Standard.NTamd64]
%filter.DeviceDesc%=FilterInstall, PCI\VEN_XXXX&DEV_XXXX
[FilterInstall]
Include=machine.inf
Needs=PCI_DRV
CopyFiles=FilterInstall.Copy
[FilterInstall.Copy]
filter64.sys
[FilterInstall.HW]
Include=machine.inf
Needs=PCI_DRV.HW
AddReg=FilterInstall.HW.AddReg
[FilterInstall.HW.AddReg]
HKR,,"UpperFilters",0x00010008,"filter64"
[FilterInstall.Services]
;Do not specify SPSVCINST_ASSOCSERVICE on filter drivers.
Include=machine.inf
Needs=PCI_DRV.Services
AddService=filter64,,ufilter_Service_Inst
[ufilter_Service_Inst]
DisplayName = %ufilter.SvcName%
Description = %ufilter.SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\filter64.sys
LoadOrderGroup = "PnP Filter"
[Strings]
TEST="Technology Inc."
DiskName = "Filter Installation Disk"
filter.DeviceDesc = "PCI Upstream Port"
ufilter.SvcName = "PCI Upper Filter"
ufilter.SvcDesc = "PCI Upper Filter Service"
or
[Version]
Signature="$WINDOWS NT$"
Class=System
ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
Provider=%TEST%
CatalogFile=filter64.cat
DriverVer = 06/15/2023,13.39.37.918
;*************************
; Source file information
;*************************
[SourceDisksNames]
1 = %DiskName%,,,""
[SourceDisksFiles]
filter64.sys = 1,,
[DestinationDirs]
DefaultDestDir = 12 ;system32/drivers
[ControlFlags]
ExcludeFromSelect=*
;*****************************************
; filter Install Section
;*****************************************
[Manufacturer]
%TEST%=Standard,NTamd64
[Standard.NTamd64]
%filter.DeviceDesc%=FilterInstall, PCI\VEN_XXXX&DEV_XXXX
[FilterInstall]
Include=machine.inf
Needs=PCI_DRV_ROOT
CopyFiles=FilterInstall.Copy
[FilterInstall.Copy]
filter64.sys
[FilterInstall.HW]
Include=machine.inf
Needs=PCI_DRV_ROOT.HW
AddReg=FilterInstall.HW.AddReg
[FilterInstall.HW.AddReg]
HKR,,"UpperFilters",0x00010008,"filter64"
[FilterInstall.Services]
;Do not specify SPSVCINST_ASSOCSERVICE on filter drivers.
Include=machine.inf
Needs=PCI_DRV_ROOT.Services
AddService=filter64,,ufilter_Service_Inst
[ufilter_Service_Inst]
DisplayName = %ufilter.SvcName%
Description = %ufilter.SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 0 ; SERVICE_BOOT_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\filter64.sys
LoadOrderGroup = "Boot Bus Extender"
[Strings]
TEST="ASMedia Technology Inc."
DiskName = "Filter Installation Disk"
filter.DeviceDesc = "PCI Upstream Port"
ufilter.SvcName = "PCI Upper Filter"
ufilter.SvcDesc = "PCI Upper Filter Service"
Upcoming OSR Seminars | ||
---|---|---|
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead! | ||
Kernel Debugging | 13-17 May 2024 | Live, Online |
Developing Minifilters | 1-5 Apr 2024 | Live, Online |
Internals & Software Drivers | 11-15 Mar 2024 | Live, Online |
Writing WDF Drivers | 26 Feb - 1 Mar 2024 | Live, Online |
Comments
What on earth to you hope to accomplish by this? "pci.sys" writes directly to hardware registers. You can't intercept anything it does.
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
There are good reasons, for example accessing the config space for specific root bus devices based on what child devices they have attached. Or to manage the visible child device enumerations above your filter.
Probably. But look in the system event log and other device state related logs and see what is going on. You could avoid the rebalancing or whatever it is doing by attaching your filter at boot time.
Yes,i need to access specific config space(vendor definition) for specific PCI Express Upstream Switch Port.
We use application to install filter driver and hope it to be attached immediately. We will try to look in the system event log and try to avoid the rebalancing
Thank you for your good suggestion!
When you install the inf, all devices that match the PCI service name are restarted. For example, the network card driver is a child device in the hierarchy domain, resulting in downtime for a few seconds. Windows\INF\Setupapi.dev.log contains a wealth of information.
Thanks Calin_Iaru, sorry for late response to this. When we installed filter driver, it caused in downtime about 60s, and keyboard, mouse or else USB device could not be used until installation is complete. And we seeing some error message in the setupapi.dev log about "Device request reboot fail". This happends after filter driver installation is complete and request a restart. Is the error affect installation processing time ? (The APS-SL3N-128 is our OS device can't restart.)
See below for {Restarting Devices} part of Setupapi.dev.log
! dvi: Query-removal vetoed by 'SCSI\Disk&Ven_&Prod_APS-SL3N-128\7&446742e&0&010000' (veto type 6: PNP_VetoDevice).
! dvi: Device required reboot: Query remove failed : 0x17: CR_REMOVE_VETOED.
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&6800400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&4000400011
dvi: Query-remove: PCI\VEN_1022&DEV_14DD&SUBSYS_88771043&REV_00\3&11583659&0&41
dvi: Query-remove: PCI\VEN_1022&DEV_14DD&SUBSYS_88771043&REV_00\3&11583659&0&43
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&2800400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&0000400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F4&SUBSYS_33281B21&REV_01\6&2F84F693&0&00400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&000011
dvi: Query-remove: ACPI\PNP0A08\0
! dvi: Query-removal vetoed by 'SCSI\Disk&Ven_&Prod_APS-SL3N-128\7&446742e&0&010000' (veto type 6: PNP_VetoDevice).
! dvi: Device required reboot: Query remove failed : 0x17: CR_REMOVE_VETOED.
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&6000400011
dvi: Query-remove: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A000
dvi: Query-remove: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A008
dvi: Query-remove: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A010
dvi: Query-remove: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A018
dvi: Query-remove: PCI\VEN_1022&DEV_43F4&SUBSYS_33281B21&REV_01\4&383DA6B1&0&0011
! dvi: Query-removal vetoed by 'SCSI\Disk&Ven_&Prod_APS-SL3N-128\7&446742e&0&010000' (veto type 6: PNP_VetoDevice).
! dvi: Device required reboot: Query remove failed : 0x17: CR_REMOVE_VETOED.
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&2000400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&600011
dvi: Query-remove: PCI\VEN_1022&DEV_14DB&SUBSYS_88771043&REV_00\3&11583659&0&11
! dvi: Query-removal vetoed by 'SCSI\Disk&Ven_&Prod_APS-SL3N-128\7&446742e&0&010000' (veto type 6: PNP_VetoDevice).
! dvi: Device required reboot: Query remove failed : 0x17: CR_REMOVE_VETOED.
dvi: Start: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&680011
dvi: Start: PCI\VEN_1022&DEV_14DD&SUBSYS_88771043&REV_00\3&11583659&0&41
dvi: Start: PCI\VEN_1022&DEV_14DD&SUBSYS_88771043&REV_00\3&11583659&0&43
dvi: Start: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&000011
dvi: Start: ACPI\PNP0A08\0
dvi: Start: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A000
dvi: Start: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A008
dvi: Start: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A010
dvi: Start: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A018
dvi: Start: PCI\VEN_1022&DEV_43F4&SUBSYS_33281B21&REV_01\4&383DA6B1&0&0011
dvi: Start: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&400011
dvi: Start: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&600011
dvi: Start: PCI\VEN_1022&DEV_14DB&SUBSYS_88771043&REV_00\3&11583659&0&11
dvi: {Restarting Devices exit} 14:49:32.410
Thanks Calin_Iaru, sorry for late response to this. When we installed filter driver, it caused in downtime about 60s, and keyboard, mouse or else USB device could not be used until installation is complete. And we seeing some error message in the setupapi.dev log about "Device request reboot fail". This happends after filter driver installation is complete and request a restart. Is the error affect installation processing time ?
(The APS-SL3N-128 is our OS device so can't restart.)
See below for {Restarting Devices} part of Setupapi.dev.log
Restart required for any devices using this driver.
dvi: Install Device: Configuring device. 14:48:25.333
dvi: Configuration: oem8.inf:PCI\VEN_1B21&DEV_2421,*
dvi: Install Device: Configuring device completed. 14:48:25.340
dvi: Device Status: 0x0180200a
dvi: {Restarting Devices} 14:48:25.340
dvi: Needs Reinstall: PCI\VEN_8086&DEV_06B0&SUBSYS_86941043&REV_F0\3&11583659&0&E8
dvi: Needs Respecialize: Hardware configuration {d6321e65-321a-e227-b7b4-244bfe4c8c0d} (Id = 1).
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2423&SUBSYS_44231022&REV_01\451ECAFFFF5177A008
dvi: Needs Reinstall: PCI\VEN_8086&DEV_06B8&SUBSYS_86941043&REV_F0\3&11583659&0&E0
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2423&SUBSYS_44221022&REV_01\451ECAFFFF5177A000
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\5&15CFF502&0&0000DC
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2421&SUBSYS_24211B21&REV_01\4&1FBC7869&0&00DC
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\5&15CFF502&0&1000DC
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\5&15CFF502&0&0800DC
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2423&SUBSYS_442D1022&REV_01\451ECAFFFF5177A018
dvi: Needs Reinstall: PCI\VEN_8086&DEV_06C0&SUBSYS_86941043&REV_F0\3&11583659&0&D8
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\5&15CFF502&0&1800DC
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2423&SUBSYS_442B1022&REV_01\451ECAFFFF5177A010
dvi: Needs Reinstall: PCI\VEN_8086&DEV_06AC&SUBSYS_86941043&REV_F0\3&11583659&0&DC
dvi: Needs Reinstall: PCI\VEN_1B21&DEV_2421&SUBSYS_44201022&REV_01\U451ECAFFFF5177A000
dvi: Needs Reinstall: PCI\VEN_8086&DEV_06BC&SUBSYS_86941043&REV_F0\3&11583659&0&E4
dvi: Query-remove: PCI\VEN_1B21&DEV_2421&SUBSYS_24211B21&REV_01\U451ECAFFFF5177A000
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&680011
! dvi: Query-removal vetoed by 'SCSI\Disk&Ven_&Prod_APS-SL3N-128\7&446742e&0&010000' (veto type 6: PNP_VetoDevice).
! dvi: Device required reboot: Query remove failed : 0x17: CR_REMOVE_VETOED.
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&6800400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&4000400011
dvi: Query-remove: PCI\VEN_1022&DEV_14DD&SUBSYS_88771043&REV_00\3&11583659&0&41
dvi: Query-remove: PCI\VEN_1022&DEV_14DD&SUBSYS_88771043&REV_00\3&11583659&0&43
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&2800400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&0000400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F4&SUBSYS_33281B21&REV_01\6&2F84F693&0&00400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&000011
dvi: Query-remove: ACPI\PNP0A08\0
! dvi: Query-removal vetoed by 'SCSI\Disk&Ven_&Prod_APS-SL3N-128\7&446742e&0&010000' (veto type 6: PNP_VetoDevice).
! dvi: Device required reboot: Query remove failed : 0x17: CR_REMOVE_VETOED.
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&6000400011
dvi: Query-remove: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A000
dvi: Query-remove: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A008
dvi: Query-remove: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A010
dvi: Query-remove: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A018
dvi: Query-remove: PCI\VEN_1022&DEV_43F4&SUBSYS_33281B21&REV_01\4&383DA6B1&0&0011
! dvi: Query-removal vetoed by 'SCSI\Disk&Ven_&Prod_APS-SL3N-128\7&446742e&0&010000' (veto type 6: PNP_VetoDevice).
! dvi: Device required reboot: Query remove failed : 0x17: CR_REMOVE_VETOED.
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\7&28EFB71B&0&2000400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&400011
dvi: Query-remove: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&600011
dvi: Query-remove: PCI\VEN_1022&DEV_14DB&SUBSYS_88771043&REV_00\3&11583659&0&11
! dvi: Query-removal vetoed by 'SCSI\Disk&Ven_&Prod_APS-SL3N-128\7&446742e&0&010000' (veto type 6: PNP_VetoDevice).
! dvi: Device required reboot: Query remove failed : 0x17: CR_REMOVE_VETOED.
dvi: Start: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&680011
dvi: Start: PCI\VEN_1022&DEV_14DD&SUBSYS_88771043&REV_00\3&11583659&0&41
dvi: Start: PCI\VEN_1022&DEV_14DD&SUBSYS_88771043&REV_00\3&11583659&0&43
dvi: Start: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&000011
dvi: Start: ACPI\PNP0A08\0
dvi: Start: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A000
dvi: Start: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A008
dvi: Start: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A010
dvi: Start: PCI\VEN_1B21&DEV_2423&SUBSYS_24231B21&REV_01\451ECAFFFF5177A018
dvi: Start: PCI\VEN_1022&DEV_43F4&SUBSYS_33281B21&REV_01\4&383DA6B1&0&0011
dvi: Start: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&400011
dvi: Start: PCI\VEN_1022&DEV_43F5&SUBSYS_33281B21&REV_01\5&26BE588C&1&600011
dvi: Start: PCI\VEN_1022&DEV_14DB&SUBSYS_88771043&REV_00\3&11583659&0&11
dvi: {Restarting Devices exit} 14:49:32.410
You need to rethink on demand installation and instead always have your filter installed, but with on demand activation.