Handle multiple physical HID Devices

Is it possible to write a Driver that is able to handle multiple physical HID devices?
If yes, what king of driver should I write? (Busdriver, PDO, FDO, Filter)

Best regards!

Multiple INSTANCES of a given HID device (like multiple mouses plugged in at the same time)? If yes, then this is true for all (properly written) Windows drivers.

One INSTANCE that surfaces multiple individual DEVICES? If yes, then this is a bus driver.

Peter
OSR
@OSRDrivers

Actually both… I have multiple mouses, from which I have to collect the HID report data and one HID touchscreen which should korrelate the mouse data with his own data.

xxxxx@gmail.com wrote:

Actually both… I have multiple mouses, from which I have to collect the HID report data and one HID touchscreen which should korrelate the mouse data with his own data.

So you need a FILTER driver. You can install a “class filter” that gets
loaded for all HID class devices. Your initialization can then decide,
based on the report descriptor, whether you really need to do anything
with the information. One driver, multiple instances.


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

Thanks you Tim,

it sounds like a good plan, but how do I install a class filter? I read this article :
http://www.osronline.com/article.cfm?article=446
but I didn’t really understood what I have to do.

I already have a class Filter, but I always installed the filter from the device manager by right clicking the device and “Update Driver” But in this way I install the filter only for that particular device and not for the whole HID class.

Maybe my INF file is not complete, so can you please take a look at my INF file?
(I used the Toaster INF as a reference)
[Version]
Signature = “$WINDOWS NT$”
Class = HIDClass
ClassGuid = {745a17a0-74d3-11d0-b6fe-00a0c90f57da}
Provider = %VENDOR%
LayoutFile = layout.inf
DriverVer = 01/10/2007,1.0.0.0
CatalogFile = kmdfsamples.cat

;
; Layout.inf (etc.) list all files shipped with the operating system so the
; source description sections are only needed if other files are needed.
;
; In order to use IHV drivers, the SourceDisksNames section must list the
; disk(s) containing the drivers and the SourceDisksFiles section must list
; which disk number each file to be copied is found on.
; Disk number 99 is used to avoid a conflict with the disk numbers defined
; in layout.inf
;
; Files used in a driver installation need to be digitally signed otherwise
; installation may fail. See documentation elsewhere in the DDK regarding
; driver signing.

[SourceDisksFiles]
QPenFilter.sys = 99
;hidkmdf.sys = 99

[SourceDisksNames]
99 = %DISK_NAME%,“”

[DestinationDirs]
;CopyFunctionDriver = 12
CopyFilterDriver = 12

[Manufacturer]
%VENDOR%=Vendor, NT$ARCH$, NT$ARCH$.6.1

; For XP and later
[Vendor.NT$ARCH$]
%hidusbfx2% = hidusbfx2.Inst, HID\VID_0458&PID_00CA
%hidusbfx2% = hidusbfx2.Inst, HID\VID_10C4&PID_889F

; For Win7 and later so that we can use inbox HID-KMDF mapper
[Vendor.NT$ARCH$.6.1]
%hidusbfx2% = hidusbfx2.Inst.Win7, HID\VID_0458&PID_00CA
%hidusbfx2% = hidusbfx2.Inst.Win7, HID\VID_10C4&PID_889F

;===============================================================
; Install section for XP thru Vista
;===============================================================
[hidusbfx2.Inst.NT]
;CopyFiles = CopyFunctionDriver, CopyFilterDriver
CopyFiles = CopyFilterDriver

[hidusbfx2.Inst.NT.HW]
AddReg = hidusbfx2_Parameters.AddReg

;
; hidkmdf is the function driver and hidusbfx2 is the lower filter
;
[hidusbfx2.Inst.NT.Services]
;AddService = hidkmdf,0x00000002,hidkmdf_Service_Inst,
AddService = hidusbfx2, hidusbfx2_Service_Inst

;[CopyFunctionDriver]
;hidkmdf.sys

[hidusbfx2_Parameters.AddReg]
HKR,“LowerFilters”,0x00010000,“hidusbfx2”

;[hidkmdf_Service_Inst]
;DisplayName = %hidkmdf.SVCDESC%
;ServiceType = 1 ; SERVICE_KERNEL_DRIVER
;StartType = 3 ; SERVICE_DEMAND_START
;ErrorControl = 1 ; SERVICE_ERROR_NORMAL
;ServiceBinary = %12%\hidkmdf.sys
;LoadOrderGroup = PNP Filter

;===============================================================
; Install section for Win7 and later
; Use the inbox mshidkmdf.sys as the shim
;===============================================================
[hidusbfx2.Inst.Win7.NT]
; Just copy the driver. No neeed to copy other system binaries.
CopyFiles = CopyFilterDriver

[hidusbfx2.Inst.Win7.NT.HW]
AddReg = hidusbfx2_Win7_Parameters.AddReg

;
; mshidkmdf is the function driver and hidusbfx2 is the lower filter
;
[hidusbfx2.Inst.Win7.NT.Services]
AddService = hidusbfx2, hidusbfx2_Service_Inst
;AddService = mshidkmdf, 0x000001fa, mshidkmdf.AddService ;flag 0x2 sets this as the service for the device

[CopyFilterDriver]
QPenFilter.sys

;[mshidkmdf.AddService]
;ServiceType = 1 ; SERVICE_KERNEL_DRIVER
;StartType = 3 ; SERVICE_DEMAND_START
;ErrorControl = 1 ; SERVICE_ERROR_NORMAL
;ServiceBinary = %10%\System32\Drivers\mshidkmdf.sys

[hidusbfx2_Win7_Parameters.AddReg]
HKR,“LowerFilters”,0x00010000,“hidusbfx2”
HKR,“AllowIdleIrpInD3”,0x00010001,0x1

;===============================================================
; Service section (common to all OS versions)
;===============================================================

[hidusbfx2_Service_Inst]
DisplayName = %hidusbfx2%
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_IGNORE%
ServiceBinary = %12%\QPenFilter.sys

;================================================================
; WDF Coinstaller installation
;===============================================================

[DestinationDirs]
hidusbfx2.Inst_CoInstaller_CopyFiles = 11

[hidusbfx2.Inst.NT.CoInstallers]
AddReg=hidusbfx2.Inst_CoInstaller_AddReg
CopyFiles=hidusbfx2.Inst_CoInstaller_CopyFiles

[hidusbfx2.Inst_CoInstaller_AddReg]
HKR,CoInstallers32,0x00010000, “WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller”

[hidusbfx2.Inst_CoInstaller_CopyFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,0x00000010 ;COPYFLG_NO_OVERWRITE (for win2k)

[SourceDisksFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=99 ; make sure the number matches with SourceDisksNames

[hidusbfx2.Inst.NT.Wdf]
KmdfService = hidusbfx2, hidusbfx2_wdfsect

[hidusbfx2_wdfsect]
KmdfLibraryVersion = $KMDFVERSION$

;================================================================
; Strings section
;===============================================================

[Strings]
;Localizable
VENDOR = “IsiQiri”
hidusbfx2 = “QPenfilter”
DISK_NAME = “QPenfilter Install Disk”

;Non-Localizable
SERVICE_BOOT_START = 0x0
SERVICE_SYSTEM_START = 0x1
SERVICE_AUTO_START = 0x2
SERVICE_DEMAND_START = 0x3
SERVICE_DISABLED = 0x4

SERVICE_KERNEL_DRIVER = 0x1
SERVICE_ERROR_IGNORE = 0x0
SERVICE_ERROR_NORMAL = 0x1
SERVICE_ERROR_SEVERE = 0x2
SERVICE_ERROR_CRITICAL = 0x3

REG_EXPAND_SZ = 0x00020000
REG_DWORD = 0x00010001
REG_MULTI_SZ = 0x00010000
REG_BINARY = 0x00000001
REG_SZ = 0x00000000

Thank you!

I installed the filter with devcon and it seems to word so far :slight_smile:

Thank you!

xxxxx@gmail.com wrote:

it sounds like a good plan, but how do I install a class filter? I read this article :
http://www.osronline.com/article.cfm?article=446
but I didn’t really understood what I have to do.

I already have a class Filter, but I always installed the filter from the device manager by right clicking the device and “Update Driver” But in this way I install the filter only for that particular device and not for the whole HID class.

Then you do NOT have a “class filter”. You have a “device filter”.

In implementation, there is actually very little difference. For both
types of filter, you need to copy the file in place and create a
service. The difference is where you make your registry entry. For a
device filter, you need a “LowerFilters” entry in one of the Enum
subkeys. For a class filter, you need a “LowerFilters” entry in one of
the Control\Class subkeys.

You don’t need to do Update Driver for a class filter. You can write a
[DefaultInstall] INF, because unlike the device case, the registry entry
for a class filter is fixed.


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