Filter Driver for USB-RS232 driver.

Hi All,

I am making use of USB-RS232 convertor, I need to attach a filter driver over the
virtual serial port created.
For this i think we need to modify the AddReg section of the INF file. Also currently
the serenum section in the vendor specified driver has been commented
I couldn’t modify this entry since it was protected by security catlog file.

But I have observed that PortMon is able to attach to the virtual serial port created.
Doesn’t PortMon makes use of Serenum?
So my questions is what would be a good approach to attach a filter driver to serial
port driver whenever i plug the USB-RS232 convertor, when the option to modify the
USB-RS232 inf file is not possible?

Thanks in advance

You can install a filter using a seperate inf withoutn touching the orig inf…but can you explain why you think you need a filter to begin with?

Portmon does not use pnp to attach to the port device object. Rather it attaches to the devobj by using the fixed name of the devobj. This is not a method that should be used by production code though.

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@gmail.com
Sent: Friday, October 24, 2008 2:43 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Filter Driver for USB-RS232 driver.

Hi All,

I am making use of USB-RS232 convertor, I need to attach a filter driver over the
virtual serial port created.
For this i think we need to modify the AddReg section of the INF file. Also currently
the serenum section in the vendor specified driver has been commented
I couldn’t modify this entry since it was protected by security catlog file.

But I have observed that PortMon is able to attach to the virtual serial port created.
Doesn’t PortMon makes use of Serenum?
So my questions is what would be a good approach to attach a filter driver to serial
port driver whenever i plug the USB-RS232 convertor, when the option to modify the
USB-RS232 inf file is not possible?

Thanks in advance


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

Hi Doran,

Thanks for your reply.

We have a monolithic driver where by serial driver is extended to provide certain custom ioctl
interface, now thought of providing these interface in the filter and reframe the request using
standard read ,write IRP’s. Since we don’t have access to the user application and change the
interface there, we are left with this choice of going for the filter.
Also went through this link http://www.osronline.com/showThread.cfm?link=66001
on attching the upper filter driver for serial.
So basically i need a port class filter driver that provides PnP functionality for loading &
unloading and custom ioctl to attaches particular device.

  • Thanks and Regards
    Narahari

Be aware that if you create a ports class upper filter that you will also be filtering parallel ports and all sorts if weird virtual serial port drivers. I hope with your reference to load and unload you do not mean performing these actions on already started stacks, rather just supporting load and unload as dictated to you by pnp.

d

-----Original Message-----
From: xxxxx@gmail.com
Sent: Saturday, October 25, 2008 12:24 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Filter Driver for USB-RS232 driver.

Hi Doran,

Thanks for your reply.

We have a monolithic driver where by serial driver is extended to provide certain custom ioctl
interface, now thought of providing these interface in the filter and reframe the request using
standard read ,write IRP’s. Since we don’t have access to the user application and change the
interface there, we are left with this choice of going for the filter.
Also went through this link http://www.osronline.com/showThread.cfm?link=66001
on attching the upper filter driver for serial.
So basically i need a port class filter driver that provides PnP functionality for loading &
unloading and custom ioctl to attaches particular device.

- Thanks and Regards
Narahari


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

Hi Doran,

Sorry for delay in response…

i meant in my PnP dispatch routine, for minor function the IRP_MN_REMOVE_DEVICE
i need to detach my filter and also in the AddDevice routine i would attach
my filter… so correct words are “attach and detach” rather then “loading and unloading”.

Now i have come up with filter skeleton driver…
Now to make this device specific filter instead of class filter,
in the inf file i need to make the following entry in the AddReg section
HKR,“UpperFilters”,0x00010000,“vspDevUpr” and have followed the filter.inf
sample from the Toaster example to come up with independent inf file there by to attach
to the underlying the virtual serial port driver.

The Key things i thought were, AddReg and AddService section in INF file.
Am i missing some thing here?

When i install the driver through the my INF File,
AddDevice routine do get called but it is not attaching to the right target device,
Physical device object I am getting is not one which intended to get attached?

My INf File look like this:

[Version]
Signature=$CHICAGO$
Class=PORTS
ClassGUID={4d36e97e-e325-11ce-bfc1-08002be10318} ;got from the vendor given inf file
Provider=%MFGNAME%

[Manufacturer]
%MFGNAME%=DeviceList

[DestinationDirs]
DefaultDestDir=10,System32\Drivers

[SourceDisksFiles]
vspDevUpr.sys=1

[SourceDisksNames]
1=%INSTDISK%,i386

[DeviceList]
%DESCRIPTION%=DriverInstall, vspDevUpr

;------------------------------------------------------------------------------
; Windows 2000 Sections
;------------------------------------------------------------------------------

[DriverInstall.NT]
CopyFiles=DriverCopyFiles

[DriverCopyFiles]
vspDevUpr.sys,2

[DriverInstall.nt.hw]
AddReg=DriverHwAddReg
;
; Service installation
;
[DriverInstall.NT.Services]
AddService = USA19H2KP, 0x00000002, USA19HPORT.AddService
AddService = vspDevUpr,0x00000002,vspDevUprService.AddService

[DriverHwAddReg]
HKR,“UpperFilters”,0x00010000,“vspDevUpr”

[USA19HPORT.AddService]
DisplayName = %USA19HPORT.SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\USA19H2kp.SYS

[vspDevUprService.AddService]
ServiceType=1 ; SERVICE_KERNEL_DRIVER
StartType=3 ; SERVICE_DEMAND_START
ErrorControl=1 ; SERVICE_ERROR_NORMAL
ServiceBinary=%12%\system32\drivers\vspDevUpr.sys
;LoadOrderGroup = Extended Base

;------------------------------------------------------------------------------
; String Definitions
;------------------------------------------------------------------------------

[Strings]
MFGNAME=“xxx”
INSTDISK=“xxx Installation Disc”
DESCRIPTION=“vspDevUpr Driver”
FRIENDLYNAME=“vspDevUpr Driver”

-Thanks and regards
Narahari


Doron Holan
xxxxx@microsoft.com Join Date: 08 Sep 2005
Posts To This List: 3041

RE: Filter Driver for USB-RS232 driver.


You can install a filter using a seperate inf withoutn touching the orig
inf…but can you explain why you think you need a filter to begin with?

Portmon does not use pnp to attach to the port device object. Rather it
attaches to the devobj by using the fixed name of the devobj. This is not a
method that should be used by production code though.

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@gmail.com
Sent: Friday, October 24, 2008 2:43 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Filter Driver for USB-RS232 driver.

Hi All,

I am making use of USB-RS232 convertor, I need to attach a filter driver
over the
virtual serial port created.
For this i think we need to modify the AddReg section of the INF file. Also
currently
the serenum section in the vendor specified driver has been commented
I couldn’t modify this entry since it was protected by security catlog file.

But I have observed that PortMon is able to attach to the virtual serial
port created.
Doesn’t PortMon makes use of Serenum?
So my questions is what would be a good approach to attach a filter driver
to serial
port driver whenever i plug the USB-RS232 convertor, when the option to
modify the
USB-RS232 inf file is not possible?

Thanks in advance

xxxxx@gmail.com wrote:

i meant in my PnP dispatch routine, for minor function the IRP_MN_REMOVE_DEVICE
i need to detach my filter and also in the AddDevice routine i would attach
my filter… so correct words are “attach and detach” rather then “loading and unloading”.

Now i have come up with filter skeleton driver…
Now to make this device specific filter instead of class filter,
in the inf file i need to make the following entry in the AddReg section
HKR,“UpperFilters”,0x00010000,“vspDevUpr” and have followed the filter.inf
sample from the Toaster example to come up with independent inf file there by to attach
to the underlying the virtual serial port driver.

The Key things i thought were, AddReg and AddService section in INF file.
Am i missing some thing here?

When i install the driver through the my INF File,
AddDevice routine do get called but it is not attaching to the right target device,
Physical device object I am getting is not one which intended to get attached?

My INf File look like this:

[DriverInstall.NT.Services]
AddService = USA19H2KP, 0x00000002, USA19HPORT.AddService
AddService = vspDevUpr,0x00000002,vspDevUprService.AddService

The value “2” in the AddService directive says “make this the primary
PnP function driver for the device being installed INF”". If vspDevUpr
is just a filter driver, then you do NOT want to specify 0x00000002 for it.

[USA19HPORT.AddService]
DisplayName = %USA19HPORT.SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\USA19H2kp.SYS

[vspDevUprService.AddService]
ServiceType=1 ; SERVICE_KERNEL_DRIVER
StartType=3 ; SERVICE_DEMAND_START
ErrorControl=1 ; SERVICE_ERROR_NORMAL
ServiceBinary=%12%\system32\drivers\vspDevUpr.sys
;LoadOrderGroup = Extended Base

%12% expands to system32\drivers. So, you end up with
c:\windows\system32\drivers\system32\drivers\vspDevUpr.sys. You should
either use %12%\vspDevUpr.sys, or %10%\system32\drivers\vspDevUpr.sys.


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

HI All,

I have corrected the mistakes in the INF FIle and ran the chkInf tool,
i got an error saying that cannot include 19hp.inf file and only system inf file can be specified.
How do i go about it if i want to install some other inf file?

But the other main problem which i am facing is whenever i install driver through the below inf file, the driver installs as separate driver and can be seen under ports category in device manager
and also resulting in new COM port creation.

I am not able to attach my driver as device upper filter driver.
I want to attach (vspDevUpr) to the to function driver as specified by 19HP.INF file.

Where should actually the registry section goes when i specify,
HKR,“UpperFilters”,0x00010000,“vspDevUpr” so that it enables PnP to call my driver?

I am looking forward for any response which would help me out in understanding the how PnP Filters works and help me to resolve how can i attach a device specific filter through independent INF file.

  • Thanks and Regards
    Narahari

My modified INF File below:

[Version]
Signature=“$CHICAGO$”
Class=PORTS
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
DriverVer=01/10/2008,1.0.0.1
Provider=%MFGNAME%
CatalogFile.NT=USA19H2kp.cat

[Manufacturer]
%MFGNAME%=DeviceList

[SourceDisksNames]
1 = %INSTDISK%,“”

[SourceDisksFiles]
vspDevUpr.sys = 1,

[DestinationDirs]
DefaultDestDir=12

[DeviceList]
%DESCRIPTION%=DriverInstall, {4D36E978-E325-11CE-BFC1-08002BE10318}\vspDevUpr

;------------------------------------------------------------------------------
; Windows 2000 Sections
;------------------------------------------------------------------------------
[DriverInstall.NT]
;=============== Get the standard stuff from Toaster.inf==============
Include =19hp.inf
Needs=USA19HPORT.NT
CopyFiles=DriverInstall.NT.CopyFiles
AddReg=DriverInstall.NT.HW.AddReg

[DriverInstall.NT.CopyFiles]
vspDevUpr.sys

;
; Service installation
;
[DriverInstall.NT.Services]
AddService = vspDevUpr,vspDevUprService.AddService
Include=19hp.inf
Needs=USA19HPORT.Install.NT.Services

[DriverInstall.NT.HW.AddReg]
HKR,“UpperFilters”,0x00010000,“vspDevUpr”

[vspDevUprService.AddService]
ServiceType=1 ; SERVICE_KERNEL_DRIVER
StartType=3 ; SERVICE_DEMAND_START
ErrorControl=1 ; SERVICE_ERROR_NORMAL
ServiceBinary=%12%\vspDevUpr.sys
LoadOrderGroup = Extended Base

;------------------------------------------------------------------------------
; String Definitions
;------------------------------------------------------------------------------

[Strings]
MFGNAME=“_ _ _”
INSTDISK=" _ _ _ Installation Disc"
DESCRIPTION=“vspDevUpr Driver”
FRIENDLYNAME=“vspDevUpr Driver”

xxxxx@gmail.com wrote:

I have corrected the mistakes in the INF FIle and ran the chkInf tool,
i got an error saying that cannot include 19hp.inf file and only system inf file can be specified.
How do i go about it if i want to install some other inf file?

You can’t use needs/include on a non-system INF **IF** you want a WHQL
signature. Remember that 3rd-party INF files don’t get copied with
their original names. They’ll end up as something like oem22.inf. If
you know the file will be present with the name “19hp.inf”, then just
use that. If not, then you’ll have to copy the sections into your INF
by cut-and-paste.

But the other main problem which i am facing is whenever i install driver through the below inf file, the driver installs as separate driver and can be seen under ports category in device manager
and also resulting in new COM port creation.

So, how are you installing this? Are you using “devcon”? The INF now
looks like it has been a root-enumerated driver, with the plug-and-play
ID “{4D36E978-E325-11CE-BFC1-08002BE10318}\vspDevUpr”. That will
install a brand-new device will that name, and try to apply your driver
to it. Your [DeviceList] section should mention the same PnP identifier
that the original INF specified. That’s the device you want to affect.

I am not able to attach my driver as device upper filter driver.
I want to attach (vspDevUpr) to the to function driver as specified by 19HP.INF file.

Where should actually the registry section goes when i specify,
HKR,“UpperFilters”,0x00010000,“vspDevUpr” so that it enables PnP to call my driver?

You need to get this into the Enum key for the device you want to
filter. You connect to that using your [DeviceList] section.


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

To add my spin to this. A device filter install via an INF can only target the hardware ID(s) listed in the INF. If you want a generic INF that can add your driver as an upper filter to any serial/virtual com port device, you are out of luck. There is no unifying common compatible/hw ID set that you can use in the INF to install your filter and reliably install the FDO below you.

My best guess is that your best bet is to install the device upper filter programmatically (using setupapi.dll) on an already installed device and then restarting the device.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Monday, November 03, 2008 12:58 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Filter Driver for USB-RS232 driver.

xxxxx@gmail.com wrote:

I have corrected the mistakes in the INF FIle and ran the chkInf tool,
i got an error saying that cannot include 19hp.inf file and only system inf file can be specified.
How do i go about it if i want to install some other inf file?

You can’t use needs/include on a non-system INF **IF** you want a WHQL
signature. Remember that 3rd-party INF files don’t get copied with
their original names. They’ll end up as something like oem22.inf. If
you know the file will be present with the name “19hp.inf”, then just
use that. If not, then you’ll have to copy the sections into your INF
by cut-and-paste.

But the other main problem which i am facing is whenever i install driver through the below inf file, the driver installs as separate driver and can be seen under ports category in device manager
and also resulting in new COM port creation.

So, how are you installing this? Are you using “devcon”? The INF now
looks like it has been a root-enumerated driver, with the plug-and-play
ID “{4D36E978-E325-11CE-BFC1-08002BE10318}\vspDevUpr”. That will
install a brand-new device will that name, and try to apply your driver
to it. Your [DeviceList] section should mention the same PnP identifier
that the original INF specified. That’s the device you want to affect.

I am not able to attach my driver as device upper filter driver.
I want to attach (vspDevUpr) to the to function driver as specified by 19HP.INF file.

Where should actually the registry section goes when i specify,
HKR,“UpperFilters”,0x00010000,“vspDevUpr” so that it enables PnP to call my driver?

You need to get this into the Enum key for the device you want to
filter. You connect to that using your [DeviceList] section.


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


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

Hi Doran,

Thanks a lot, now i am able to attach my filter driver over the virtual serial port,
using api’s of the setupapi.dll after i was able to add Upper filter entry…

Also will give a try of whatever Tim has suggested on modification to be done on the Inf file…
Thanks again,let me focus on the other tasks in hand…

  • Regards
    Narahari

Doron Holan
xxxxx@microsoft.com Join Date: 08 Sep 2005
Posts To This List: 3046

RE: Filter Driver for USB-RS232 driver.


To add my spin to this. A device filter install via an INF can only target the
hardware ID(s) listed in the INF. If you want a generic INF that can add your
driver as an upper filter to any serial/virtual com port device, you are out of
luck. There is no unifying common compatible/hw ID set that you can use in the
INF to install your filter and reliably install the FDO below you.

My best guess is that your best bet is to install the device upper filter
programmatically (using setupapi.dll) on an already installed device and then
restarting the device.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Monday, November 03, 2008 12:58 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Filter Driver for USB-RS232 driver.

xxxxx@gmail.com wrote:

I have corrected the mistakes in the INF FIle and ran the chkInf tool,
i got an error saying that cannot include 19hp.inf file and only system inf
file can be specified.
How do i go about it if i want to install some other inf file?

You can’t use needs/include on a non-system INF **IF** you want a WHQL
signature. Remember that 3rd-party INF files don’t get copied with
their original names. They’ll end up as something like oem22.inf. If
you know the file will be present with the name “19hp.inf”, then just
use that. If not, then you’ll have to copy the sections into your INF
by cut-and-paste.

But the other main problem which i am facing is whenever i install driver
through the below inf file, the driver installs as separate driver and can be
seen under ports category in device manager
and also resulting in new COM port creation.

So, how are you installing this? Are you using “devcon”? The INF now
looks like it has been a root-enumerated driver, with the plug-and-play
ID “{4D36E978-E325-11CE-BFC1-08002BE10318}\vspDevUpr”. That will
install a brand-new device will that name, and try to apply your driver
to it. Your [DeviceList] section should mention the same PnP identifier
that the original INF specified. That’s the device you want to affect.

I am not able to attach my driver as device upper filter driver.
I want to attach (vspDevUpr) to the to function driver as specified by
19HP.INF file.

Where should actually the registry section goes when i specify,
HKR,“UpperFilters”,0x00010000,“vspDevUpr” so that it enables PnP to call my
driver?

You need to get this into the Enum key for the device you want to
filter. You connect to that using your [DeviceList] section.


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

> -----------------------------------------------------------------------

Doron Holan
xxxxx@microsoft.com Join Date: 08 Sep 2005
Posts To This List: 3046

RE: Filter Driver for USB-RS232 driver.

To add my spin to this. A device filter install via an INF can only target the
hardware ID(s) listed in the INF. If you want a generic INF that can add your
driver as an upper filter to any serial/virtual com port device, you are out of
luck. There is no unifying common compatible/hw ID set that you can use in the
INF to install your filter and reliably install the FDO below you.

My best guess is that your best bet is to install the device upper filter
programmatically (using setupapi.dll) on an already installed device and then
restarting the device.

d
Beside setupapi.dll you may set you filter driver directly into key
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E978-E325-11CE-BFC1-08002BE10318}]

Value: LowerFilters or UpperFilters, what you want.
Pay attention only, it is multi string line!

It is work for us well for a lot of filters, including Ports, USB etc. :slight_smile:

Regards,
MG.

This creates a class filter, not a device filter which is what the OP wanted.

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: Michael Grabelkovsky
Sent: Wednesday, November 05, 2008 1:22 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Filter Driver for USB-RS232 driver.

> -----------------------------------------------------------------------
> Doron Holan
> xxxxx@microsoft.com Join Date: 08 Sep 2005
> Posts To This List: 3046
>
> RE: Filter Driver for USB-RS232 driver.
> -----------------------------------------------------------------------
>
> To add my spin to this. A device filter install via an INF can only target the
> hardware ID(s) listed in the INF. If you want a generic INF that can add your
> driver as an upper filter to any serial/virtual com port device, you are out of
> luck. There is no unifying common compatible/hw ID set that you can use in the
> INF to install your filter and reliably install the FDO below you.
>
> My best guess is that your best bet is to install the device upper filter
> programmatically (using setupapi.dll) on an already installed device and then
> restarting the device.
>
> d
Beside setupapi.dll you may set you filter driver directly into key
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E978-E325-11CE-BFC1-08002BE10318}]

Value: LowerFilters or UpperFilters, what you want.
Pay attention only, it is multi string line!

It is work for us well for a lot of filters, including Ports, USB etc. :slight_smile:

Regards,
MG.


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