Device Filter Driver on COM Port (ACPI\PNP0501\2)

I’m having a little trouble installing an upper filter driver on COM2 and am looking for a little advice. What steps do I need to go through for setup and install? So far I have written the filter driver in KMDF, created the .inf, created a .cat file and test signed the driver. I tried installing with devcon (devcon update fltrcom.inf ACPI\PNP0501\2 and devcon update fltrcom.inf ACPI\PNP0501). I also tried updating the driver from the device manager but still no luck.

Here is an exceprt from my setupapi.dev.log:

>> [Device Install (UpdateDriverForPlugAndPlayDevices) - ACPI\PNP0501\2]
>> Section start 2011/05/08 02:47:34.873
cmd: devcon.exe update fltrcom.inf ACPI\PNP0501\2
<<< Section end 2011/05/08 02:47:35.013
<<< [Exit status: SUCCESS]

>> [Device Install (UpdateDriverForPlugAndPlayDevices) - ACPI\PNP0501]
>> Section start 2011/05/08 02:47:39.930
cmd: devcon.exe update fltrcom.inf ACPI\PNP0501
dvi: Set selected driver complete.
dvi: {Build Driver List} 02:47:40.130
dvi: Searching for hardware ID(s):
dvi: acpi\pnp0501
dvi: *pnp0501
cpy: Policy is set to make all digital signatures equal.
dvi: Processing a single INF: ‘c:\drivershare\com\signed\fltrcom.inf’
inf: Opened INF: ‘c:\drivershare\com\signed\fltrcom.inf’ ([strings])
dvi: {Build Driver List - exit(0x00000000)} 02:47:40.230
dvi: {DIF_SELECTBESTCOMPATDRV} 02:47:40.240
dvi: Using exported function ‘PortsClassInstaller’ in module ‘C:\Windows\system32\MsPorts.Dll’.
dvi: Class installer == MsPorts.Dll,PortsClassInstaller
dvi: No CoInstallers found
dvi: Class installer: Enter 02:47:40.311
dvi: Class installer: Exit
dvi: Default installer: Enter 02:47:40.331
dvi: {Select Best Driver}
! dvi: Selecting driver failed(0xe0000228)
dvi: {Select Best Driver - exit(0xe0000228)}
! dvi: Default installer: failed!
! dvi: Error 0xe0000228: There are no compatible drivers for this device.
dvi: {DIF_SELECTBESTCOMPATDRV - exit(0xe0000228)} 02:47:40.381
dvi: {DIF_DESTROYPRIVATEDATA} 02:47:40.391
dvi: Class installer: Enter 02:47:40.401
dvi: Class installer: Exit
dvi: Default installer: Enter 02:47:40.421
dvi: Default installer: Exit
dvi: {DIF_DESTROYPRIVATEDATA - exit(0xe000020e)} 02:47:40.441
<<< Section end 2011/05/08 02:47:40.461
<<< [Exit status: SUCCESS]

My install directory contains the driver .sys file, the .inf, the .cat, and the Wdf coinstaller dll. I’ve also tried installing the filter on a software only test driver I worked on and it worked fine.

Here is my .inf:
[Version]
Signature = “$Windows NT$”
Class = Ports
ClassGUID = {4d36e978-e325-11ce-bfc1-08002be10318}
Provider = “SomeCompany”
CatalogFile = fltrcomcat.cat ; WHQL checksum file
DriverVer = 04/29/2011,1.0.0.0 ; Driver date and version

[DestinationDirs]
DefaultDestDir = 12 ; DIRID_DRIVERS

; ================= Class section =====================

[SourceDisksNames]
1 = %DiskId1%,“”

[SourceDisksFiles]
fltrcom.sys = 1

;*****************************************
; Filter Install Section
;*****************************************

[Manufacturer]
%StdMfg%=Standard,NTx86

[Standard]
;
; Hw Id is ACPI\PNP0501\2 for COM2
;
%ComFilter.DeviceDesc%=COM_Filter_Device, ACPI\PNP0501\2

[Standard.NTx86]
%ComFilter.DeviceDesc%=COM_Filter_Device, ACPI\PNP0501\2

[COM_Filter_Device.NT]
CopyFiles=Drivers_Dir
AddReg=COM_Filter_Device.NT.AddReg

[COM_Filter_Device.NT.AddReg]
HKR,EnumPropPages32,“MsPorts.dll,SerialPortPropPageProvider”

[COM_Filter_Device.NT.HW]
AddReg=COM_Filter_Device.NT.HW.AddReg

[COM_Filter_Device.NT.HW.AddReg]
HKR,“UpperFilters”,0x00010008,“fltrcom”

[Drivers_Dir]
fltrcom.sys

;-------------- Service installation
[COM_Filter_Device.NT.Services]
AddService = fltrcom, , fltrcom_Service_Inst

; -------------- Filter driver install sections
[fltrcom_Service_Inst]
DisplayName = %ComFilter.SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START (3) SERVICE_SYSTEM_START (1)
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\fltrcom.sys

[DestinationDirs]
ECHO_Device_CoInstaller_CopyFiles = 11

[COM_Filter_Device.NT.CoInstallers]
AddReg=ECHO_Device_CoInstaller_AddReg
CopyFiles=ECHO_Device_CoInstaller_CopyFiles

[ECHO_Device_CoInstaller_AddReg]
HKR,CoInstallers32,0x00010000, “WdfCoInstaller01009.dll,WdfCoInstaller”

[ECHO_Device_CoInstaller_CopyFiles]
WdfCoInstaller01009.dll

[SourceDisksFiles]
WdfCoInstaller01009.dll=1 ; make sure the number matches with SourceDisksNames

[COM_Filter_Device.NT.Wdf]
KmdfService = fltrcom, fltrcom_wdfsect
[fltrcom_wdfsect]
KmdfLibraryVersion = 1.9

[Strings]
DiskId1 = “COM Port 2 Filter Driver”
StdMfg = “(Standard system devices)”
ComFilter.DeviceDesc = “Upper Filter Driver for COM Port 2”
ComFilter.SvcDesc = “Upper Filter Driver for COM Port 2”

Thanks,
Saad

xxxxx@gmail.com wrote:

I’m having a little trouble installing an upper filter driver on COM2 and am looking for a little advice. What steps do I need to go through for setup and install? So far I have written the filter driver in KMDF, created the .inf, created a .cat file and test signed the driver. I tried installing with devcon (devcon update fltrcom.inf ACPI\PNP0501\2 and devcon update fltrcom.inf ACPI\PNP0501). I also tried updating the driver from the device manager but still no luck.

Here is an exceprt from my setupapi.dev.log:

dvi: Set selected driver complete.
dvi: {Build Driver List} 02:47:40.130
dvi: Searching for hardware ID(s):
dvi: acpi\pnp0501
dvi: *pnp0501

OK, so it’s looking for ACPI\PNP0501.

[Standard.NTx86]
%ComFilter.DeviceDesc%=COM_Filter_Device, ACPI\PNP0501\2

But your INF file matches ACPI\PNP0501\2. That’s a device instance ID.
INF files do not match device instances, they match device types. Your
INF cannot match a specific instance. You must match all COM ports
(that is, all ACPI\PNP0501). It’s then up to your filter to reject
devices it doesn’t want. You wouldn’t want to release this in the wild,
because COM2 means different things to different computers.

Alternatively, you can skip the INF altogether and just install the
filter driver in the registry. You CAN do that on a specific instance,
just by adding the UpperFilters registry key, or by using the equivalent
SetupDiSetDeviceRegistryProperty call.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks for the quick response Tim! I’ll try matching to the device type instead of the device instance but where do I reject the devices I don’t want? I’m guessing its in the EvtDriverDeviceAdd and then a call to WdfFdoInitWdmGetPhysicalDevice to get info on the device? And I’m just making a “proof of concept” on my Win7 VPC image so it’ll always be COM2 and the instance ID will always be the same.

As far as registry changes goes, is that the only key I’ll have to change? I think I tried this route a while back but wasn’t too clear on what to change =(.

Last but not least, is my INF file ok? ChkInf passes successfully but have I listed the ClassInstaller and CoInstallers correctly? Are they both needed for what I’m trying to do?

Thanks,
Saad

Oh and I forgot to ask… Does anything change b/c of the fact that serenum is an upper class filter that sits on top of serial.sys? I thought I would install my filter on top of it but maybe that doesnt make sense?

xxxxx@gmail.com wrote:

Thanks for the quick response Tim! I’ll try matching to the device type instead of the device instance but where do I reject the devices I don’t want? I’m guessing its in the EvtDriverDeviceAdd and then a call to WdfFdoInitWdmGetPhysicalDevice to get info on the device? And I’m just making a “proof of concept” on my Win7 VPC image so it’ll always be COM2 and the instance ID will always be the same.

WdfFdoInitQueryProperty with DevicePropertyHardwareID should give you
the ID string.

As far as registry changes goes, is that the only key I’ll have to change? I think I tried this route a while back but wasn’t too clear on what to change =(.

In the HKLM\System\CurrentControlSet\Enum\ACPI\PNP0501\2, you want to
change the UpperFilters key. Assuming you have already created a
Services entry, that’s all it takes to “install” a filter driver.

Last but not least, is my INF file ok? ChkInf passes successfully but have I listed the ClassInstaller and CoInstallers correctly? Are they both needed for what I’m trying to do?

You didn’t show a class installer. The co-installer section looks OK.
You’ll need that, since you are KMDF. But, if you just tweak the
registry, you won’t need an INF at all. The system is always going to
choose the stock COM port driver anyway, so you’ll never get automatic
installation. It’s always going to take some manual steps.

Oh and I forgot to ask… Does anything change b/c of the fact that serenum is an upper class filter that sits on top of serial.sys? I thought I would install my filter on top of it but maybe that doesnt make sense?

A driver can have multiple upper and lower filters. The ordering comes
from the order of their names in the UpperFilters registry key.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

>but where do I reject the devices I don’t want?

You probably dont want to “reject” any devices because I think that will
shut down the entire device stack for that device. You probably just want to
flag that you are not interested in that device and go into passthrough mode
for it.

On Tue, May 10, 2011 at 5:30 AM, wrote:

> Thanks for the quick response Tim! I’ll try matching to the device type
> instead of the device instance but where do I reject the devices I don’t
> want? I’m guessing its in the EvtDriverDeviceAdd and then a call to
> WdfFdoInitWdmGetPhysicalDevice to get info on the device? And I’m just
> making a “proof of concept” on my Win7 VPC image so it’ll always be COM2
> and the instance ID will always be the same.
>
> As far as registry changes goes, is that the only key I’ll have to change?
> I think I tried this route a while back but wasn’t too clear on what to
> change =(.
>
> Last but not least, is my INF file ok? ChkInf passes successfully but have
> I listed the ClassInstaller and CoInstallers correctly? Are they both
> needed for what I’m trying to do?
>
> Thanks,
> Saad
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

>You probably dont want to “reject” any devices because I think that will shut down the entire device stack for that

device. You probably just want to flag that you are not interested in that device and go into passthrough mode for it.

Or you can return STATUS_SUCCESS from AddDevice without doing anything.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com