How to add a new upper class filter above another?

Dear Sirs,
Today, I’m trying to add a new upper class filter to the top of the original upper class filter. Its architecture is like:

new class filter(toaster upper class filter)
^
|
|
original class filter(a upper class filter given by other company)
^
|
|
function driver(camera driver, for example: UVC driver)

In fact, the original upper class driver and the function driver are given by other company and both work well.

Now, I want to develop a new upper class filter in order to do something myself. The sample of upper class filter I would like to use is toaster upper class filter in the WDK.(Is it suitable? Is there other beter samples?)

But I failed to add the toaster upper class filter on the top of the original class filter. My inf is like:

//////////////////////////////////////////////////////////////

[Version]
Signature=“$WINDOWS NT$”
Class=Image
ClassGuid={6bdd1fc6-810f-11d0-bec7-08002be2092f}
Provider=%MSFT%
DriverVer=09/21/2006,6.0.5736.1
CatalogFile=toaster.cat

[DestinationDirs]
DefaultDestDir = 12
ToasterClassInstallerCopyFiles = 11

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

[ClassInstall32]
Addreg=ToasterClassReg
CopyFiles=ToasterClassInstallerCopyFiles

[ToasterClassReg]
HKR,0,%ClassName%
HKR,Icon,100
HKR,“UpperFilters”,0x00010000,“clsupper”
HKR,Installer32,“tostrcls.dll,ToasterClassInstaller”
HKR,DeviceCharacteristics,0x10001,0x100 ; Use same security checks on relative opens
HKR,Security,“D:P(A;;GA;;;SY)(A;;GA;;;BA)” ;Allow generic all access to system and built-in Admin.
;This one overrides the security set by the driver

[ToasterClassInstallerCopyFiles]
tostrcls.dll

;*****************************************
; Toaster Device Install Section
;*****************************************

[Manufacturer]
%StdMfg%=Standard

[Standard]
; DisplayName Section DeviceId
; ----------- ------- --------
%ToasterDevice.DeviceDesc%=Toaster_Device, USB\VID_0C45&PID_62C0

[Toaster_Device.NT]
CopyFiles=Toaster_Device.NT.Copy

[Toaster_Device.NT.HW]
AddReg=Toaster_Device.NT.HW.AddReg

[Toaster_Device.NT.Copy]
clsupper.sys

[Toaster_Device.NT.HW.AddReg]

;-------------- Service installation

[Toaster_Device.NT.Services]
AddService = clsupper, classupper_Service_Inst

; -------------- class upper Driver install section
[classupper_Service_Inst]
DisplayName = %classupper.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\clsupper.sys
LoadOrderGroup = PNP Filter

[MySection]
MySpecialFlag

[SourceDisksNames]
1 = %DiskId1%,“”

[SourceDisksFiles]
clsupper.sys = 1,
tostrcls.dll = 1,

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
MSFT = “Microsoft”
StdMfg = “(Standard system devices)”
ClassName = “Toaster”
DiskId1 = “Toaster Device Installation Disk #1
ToasterDevice.DeviceDesc = “MY Toaster with class filters”
toaster.SVCDESC = “Microsoft Toaster Device Driver”
devupper.SVCDESC = “Toaster Device Upper Filter”
devlower.SVCDESC = “Toaster Device Lower Filter”
classupper.SVCDESC = “Toaster Class Upper Filter”
classlower.SVCDESC = “Toaster Class Lower Filter”

//////////////////////////////////////////////////////////////
Why? What should I do to add the new upper class filter?(this is my focused question.)

In fact, Device Manager show I have installed the toaster filter to the device stack. But I think it doesn’t work. Because the original filter can get IRPs, even if I modify the toaster filter driver so that the new toaster filter driver does not send IRPs to the original filter driver. Why?

Another question is that I don’t know whether the new filter above the original one or below. How to tell the difference? How to determine class filter A is above class filter B?

My last question is that when I install the new toaster upper class filter, device manager show that many things disappear, such as ks.sys, ksproxy.ax and so on. Why? How to avoid this situation?

Thank you for your reading and answering.

In general you can not do this. You can not guarentee to be the topmost upper filter. There is no solution nor can
there be. Filter A is designed to be top. Filter B is designed to be top. Both can not be. Fundamental design
mistake.

In practice filters are loaded in the order they appear in the upper filters registry key so you may be able to
insinuate yourself in first but it remains bad design.

Quoting xxxxx@gmail.com:

Dear Sirs,
Today, I’m trying to add a new upper class filter to the top of the
original upper class filter. Its architecture is like:

new class filter(toaster upper class filter)
^
|
|
original class filter(a upper class filter given by other company)
^
|
|
function driver(camera driver, for example: UVC driver)

In fact, the original upper class driver and the function driver are given by
other company and both work well.

Now, I want to develop a new upper class filter in order to do something
myself. The sample of upper class filter I would like to use is toaster upper
class filter in the WDK.(Is it suitable? Is there other beter samples?)

But I failed to add the toaster upper class filter on the top of the original
class filter. My inf is like:

//////////////////////////////////////////////////////////////

[Version]
Signature=“$WINDOWS NT$”
Class=Image
ClassGuid={6bdd1fc6-810f-11d0-bec7-08002be2092f}
Provider=%MSFT%
DriverVer=09/21/2006,6.0.5736.1
CatalogFile=toaster.cat

[DestinationDirs]
DefaultDestDir = 12
ToasterClassInstallerCopyFiles = 11

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

[ClassInstall32]
Addreg=ToasterClassReg
CopyFiles=ToasterClassInstallerCopyFiles

[ToasterClassReg]
HKR,0,%ClassName%
HKR,Icon,100
HKR,“UpperFilters”,0x00010000,“clsupper”
HKR,Installer32,“tostrcls.dll,ToasterClassInstaller”
HKR,DeviceCharacteristics,0x10001,0x100 ; Use same security checks on
relative opens
HKR,Security,“D:P(A;;GA;;;SY)(A;;GA;;;BA)” ;Allow generic all access to
system and built-in Admin.
;This one overrides the security
set by the driver

[ToasterClassInstallerCopyFiles]
tostrcls.dll

;*****************************************
; Toaster Device Install Section
;*****************************************

[Manufacturer]
%StdMfg%=Standard

[Standard]
; DisplayName Section DeviceId
; ----------- ------- --------
%ToasterDevice.DeviceDesc%=Toaster_Device, USB\VID_0C45&PID_62C0

[Toaster_Device.NT]
CopyFiles=Toaster_Device.NT.Copy

[Toaster_Device.NT.HW]
AddReg=Toaster_Device.NT.HW.AddReg

[Toaster_Device.NT.Copy]
clsupper.sys

[Toaster_Device.NT.HW.AddReg]

;-------------- Service installation

[Toaster_Device.NT.Services]
AddService = clsupper, classupper_Service_Inst

; -------------- class upper Driver install section
[classupper_Service_Inst]
DisplayName = %classupper.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\clsupper.sys
LoadOrderGroup = PNP Filter

[MySection]
MySpecialFlag

[SourceDisksNames]
1 = %DiskId1%,“”

[SourceDisksFiles]
clsupper.sys = 1,
tostrcls.dll = 1,

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
MSFT = “Microsoft”
StdMfg = “(Standard system devices)”
ClassName = “Toaster”
DiskId1 = “Toaster Device Installation Disk #1
ToasterDevice.DeviceDesc = “MY Toaster with class filters”
toaster.SVCDESC = “Microsoft Toaster Device Driver”
devupper.SVCDESC = “Toaster Device Upper Filter”
devlower.SVCDESC = “Toaster Device Lower Filter”
classupper.SVCDESC = “Toaster Class Upper Filter”
classlower.SVCDESC = “Toaster Class Lower Filter”

//////////////////////////////////////////////////////////////
Why? What should I do to add the new upper class filter?(this is my focused
question.)

In fact, Device Manager show I have installed the toaster filter to the
device stack. But I think it doesn’t work. Because the original filter can
get IRPs, even if I modify the toaster filter driver so that the new toaster
filter driver does not send IRPs to the original filter driver. Why?

Another question is that I don’t know whether the new filter above the
original one or below. How to tell the difference? How to determine class
filter A is above class filter B?

My last question is that when I install the new toaster upper class filter,
device manager show that many things disappear, such as ks.sys, ksproxy.ax
and so on. Why? How to avoid this situation?

Thank you for your reading and answering.


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

I think the OP was just talking about adding his filter in *addition* to
the existing filter, not specifically on top of it. If he’s trying to
ensure that he’s specifically on the top of the stack, that is, indeed,
more or less impossible.

Anyway, the answer is that it depends a little bit on the stack. The
PS/2 stack, for example, uninstalls any existing filters whenever you
try to add one, so you need a coinstaller to add your filter.

For many stacks, though, all you have to do is specify FLG_ADDREG_APPEND
as one of the flags in your AddReg of the UpperFilters value. I’m
guessing that would work for this stack.

xxxxx@dsl.pipex.com wrote:

In general you can not do this. You can not guarentee to be the topmost upper filter. There is no solution nor can
there be. Filter A is designed to be top. Filter B is designed to be top. Both can not be. Fundamental design
mistake.

In practice filters are loaded in the order they appear in the upper filters registry key so you may be able to
insinuate yourself in first but it remains bad design.

Quoting xxxxx@gmail.com:

> Dear Sirs,
> Today, I’m trying to add a new upper class filter to the top of the
> original upper class filter. Its architecture is like:
>
> new class filter(toaster upper class filter)
> ^
> |
> |
> original class filter(a upper class filter given by other company)
> ^
> |
> |
> function driver(camera driver, for example: UVC driver)
>
> In fact, the original upper class driver and the function driver are given by
> other company and both work well.
>
> Now, I want to develop a new upper class filter in order to do something
> myself. The sample of upper class filter I would like to use is toaster upper
> class filter in the WDK.(Is it suitable? Is there other beter samples?)
>
> But I failed to add the toaster upper class filter on the top of the original
> class filter. My inf is like:
>
> //////////////////////////////////////////////////////////////
>
> [Version]
> Signature=“$WINDOWS NT$”
> Class=Image
> ClassGuid={6bdd1fc6-810f-11d0-bec7-08002be2092f}
> Provider=%MSFT%
> DriverVer=09/21/2006,6.0.5736.1
> CatalogFile=toaster.cat
>
> [DestinationDirs]
> DefaultDestDir = 12
> ToasterClassInstallerCopyFiles = 11
>
> ; ================= Class section =====================
>
> [ClassInstall32]
> Addreg=ToasterClassReg
> CopyFiles=ToasterClassInstallerCopyFiles
>
> [ToasterClassReg]
> HKR,0,%ClassName%
> HKR,Icon,100
> HKR,“UpperFilters”,0x00010000,“clsupper”
> HKR,Installer32,“tostrcls.dll,ToasterClassInstaller”
> HKR,DeviceCharacteristics,0x10001,0x100 ; Use same security checks on
> relative opens
> HKR,Security,“D:P(A;;GA;;;SY)(A;;GA;;;BA)” ;Allow generic all access to
> system and built-in Admin.
> ;This one overrides the security
> set by the driver
>
> [ToasterClassInstallerCopyFiles]
> tostrcls.dll
>
> ;*****************************************
> ; Toaster Device Install Section
> ;*****************************************
>
> [Manufacturer]
> %StdMfg%=Standard
>
> [Standard]
> ; DisplayName Section DeviceId
> ; ----------- ------- --------
> %ToasterDevice.DeviceDesc%=Toaster_Device, USB\VID_0C45&PID_62C0
>
> [Toaster_Device.NT]
> CopyFiles=Toaster_Device.NT.Copy
>
> [Toaster_Device.NT.HW]
> AddReg=Toaster_Device.NT.HW.AddReg
>
> [Toaster_Device.NT.Copy]
> clsupper.sys
>
>
>
> [Toaster_Device.NT.HW.AddReg]
>
> ;-------------- Service installation
>
> [Toaster_Device.NT.Services]
> AddService = clsupper, classupper_Service_Inst
>
>
> ; -------------- class upper Driver install section
> [classupper_Service_Inst]
> DisplayName = %classupper.SVCDESC%
> ServiceType = 1 ; SERVICE_KERNEL_DRIVER
> StartType = 3 ; SERVICE_DEMAND_START
> ErrorControl = 1 ; SERVICE_ERROR_NORMAL
> ServiceBinary = %12%\clsupper.sys
> LoadOrderGroup = PNP Filter
>
> [MySection]
> MySpecialFlag
>
>
> [SourceDisksNames]
> 1 = %DiskId1%,“”
>
> [SourceDisksFiles]
> clsupper.sys = 1,
> tostrcls.dll = 1,
>
> [Strings]
> SPSVCINST_ASSOCSERVICE= 0x00000002
> MSFT = “Microsoft”
> StdMfg = “(Standard system devices)”
> ClassName = “Toaster”
> DiskId1 = “Toaster Device Installation Disk #1
> ToasterDevice.DeviceDesc = “MY Toaster with class filters”
> toaster.SVCDESC = “Microsoft Toaster Device Driver”
> devupper.SVCDESC = “Toaster Device Upper Filter”
> devlower.SVCDESC = “Toaster Device Lower Filter”
> classupper.SVCDESC = “Toaster Class Upper Filter”
> classlower.SVCDESC = “Toaster Class Lower Filter”
>
>
> //////////////////////////////////////////////////////////////
> Why? What should I do to add the new upper class filter?(this is my focused
> question.)
>
> In fact, Device Manager show I have installed the toaster filter to the
> device stack. But I think it doesn’t work. Because the original filter can
> get IRPs, even if I modify the toaster filter driver so that the new toaster
> filter driver does not send IRPs to the original filter driver. Why?
>
> Another question is that I don’t know whether the new filter above the
> original one or below. How to tell the difference? How to determine class
> filter A is above class filter B?
>
> My last question is that when I install the new toaster upper class filter,
> device manager show that many things disappear, such as ks.sys, ksproxy.ax
> and so on. Why? How to avoid this situation?
>
> Thank you for your reading and answering.
>
>
>
> —
> 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
>


Ray
(If you want to reply to me off list, please remove “spamblock.” from my
email address)