I have developed a multi-device HID driver, which consists of two devices: a virtual mouse driver and a proxy for it.
The proxy is required for accepting output reports from clients, because mouses are opened exclusively by the Windows kernel.
This is my report descriptor:
HID_REPORT_DESCRIPTOR g_reportDescriptor[] = {
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // USAGE (Mouse)
0xA1, 0x01, // COLLECTION (Application)
0x85, REPORT_ID_MOUSE_INPUT,
0x09, 0x01, // USAGE_PAGE (Pointer)
0xA1, 0x00, // COLLECTION (Physical)
0x05, 0x09, // USAGE_PAGE (Buttons)
0x19, 0x01, // USAGE_MINIMUM (1)
0x29, 0x03, // USAGE_MAXIMUM (3)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x03, // REPORT_COUNT (3)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data, Variable, Absolute)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x05, // REPORT_SIZE (5)
0x81, 0x01, // INPUT (Constant)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7F, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x06, // Input (Data, Variable, Relative)
0xC0, // END_COLLECTION
0xC0, // END_COLLECTION(8)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x00, // USAGE (Undefined)
0xa1, 0x01, // COLLECTION (Application)
0x85, REPORT_ID_MOUSE_OUTPUT,
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x95, 0x0b, // REPORT_COUNT (11)
0x75, 0x08, // REPORT_SIZE (8)
0x09, 0x00, // USAGE (Undefined)
0x91, 0x02, // OUTPUT (Data, Variable, Absolute)
0xc0 // END_COLLECTION
};
I have got a trouble with installing my driver with devcon.exe
.
It always fails, no matter what I do. I have been playing with my *.inf
file for eternity and I don't know what to do next. That's how I run devcon.exe
:
.\devcon.exe install .\hidriver.inf "ROOT\UNKNOWN\0000"
Output:
Device node created. Install is complete when drivers are installed...
Updating drivers for ROOT\UNKNOWN\0000 from D:\share\opt\KMDFDriver\hidriver.inf.
devcon.exe failed.
As a result of the operation, it creates a new device named Unknown device
without children.
When I install my driver from Device Manager -> Add Legacy Hardware
, everything is fine and a new SampleClass device with two children (a generic mouse and a HID compliant device) is created, so I don't think it is because my *.inf
file lacks something.
Here is my *.inf
file:
[Version]
Signature="$WINDOWS NT$"
Class=%ClassName%
ClassGuid={78A1C341-4539-11d3-B88D-00C04FAD5171}
Provider=%ProviderName%
CatalogFile=hidriver.cat
DriverVer=01/07/2018
[ClassInstall32]
Addreg=ClassReg
[ClassReg]
HKR,,,0,%ClassName%
HKR,,Icon,,-24
[SourceDisksNames]
1=%DiskName%,,,
[SourceDisksFiles]
hidriver.sys=1
[DestinationDirs]
DefaultDestDir=12
[Manufacturer]
%ManufacturerName%=Microsoft,NT$ARCH$.6.1
[Microsoft.NT$ARCH$.6.1]
%DeviceName%=DefaultInstall,root\hidriver
[DefaultInstall.NT]
CopyFiles=Files
[Files]
hidriver.sys
[DefaultInstall.NT.HW]
AddReg=HWAddReg
[HWAddReg]
HKR,,"LowerFilters",0x00010008,"hidriver"
[DefaultInstall.NT.Services]
AddService=hidriver,0x00000000,hidriverService
AddService=mshidkmdf,0x00000002,mshidkmdfService
[hidriverService]
DisplayName=%ServiceName%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\hidriver.sys
[mshidkmdfService]
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\mshidkmdf.sys
[DefaultInstall.NT.Wdf]
KmdfService=hidriver,KmdfLibrary
[KmdfLibrary]
KmdfLibraryVersion=$KMDFVERSION$
[Strings]
DeviceName="VARIABLE_1"
DiskName="VARIABLE_2"
ProviderName="VARIABLE_3"
ManufacturerName="VARIABLE_4"
ServiceName="VARIABLE_5"
ClassName="VARIABLE_6"
I have also tried to capture Device manager
s activity with Process Monitor
, but it does some magic with DrvInst.exe
and a dozen of temporary files, so I don't think it's the right way to go.
What should I do, guys?
[Update the next day]
I have also tried pnputil.exe
:
pnputil.exe /add-driver D:\share\opt\KMDFDriver\hidriver.inf /install
Microsoft PnP Utility
Adding driver package: hidriver.inf
Driver package added successfully.
Published Name: oem40.inf
Driver package installed on matching devices.
Total driver packages: 1
Added driver packages: 1
Despite of the sweet output, it has no effect.
[Update after the first answer]
devcon.exe install hidriver.inf root\hidriver
works on win10 and win8.1, but has a small issue on win7. On win7 children device classes are not detected automatically, so I end up with two child unknown devices.
While my HID proxy is able to accept reports being an unknown device, the mouse doesn't work. To fix this I have to manually set the driver for the mouse child via
Update driver
-> Browse for driver software on this computer
-> Let me pick from a list of device drivers on this computer
-> Mice and pointing devices
-> Microsoft
-> HID-compliant mouse
Is there a robust way of adding such instructions to the INF file to make it automatic?
[Update after some time]
I captured Device manager
's activity by procmon
and I have got a DrvInst.exe
:
DrvInst.exe "2" "211" "HID\VARIABLE_6&COL01\1&1302B6B5&12&0000" "C:\Windows\INF\msmouse.inf" "msmouse.inf:MSMfg.NTamd64:HID_Mouse_Inst:6.1.7600.16385::hid_device_system_mouse" "6fe2f36b3" "0000000000000060" "00000000000005F8" "00000000000005F0"
I'll report the experiment's results after a while.
[Device screenshot]
[Update with setupapi.dev.log]
I removed the driver completely, then removed the log, then installed the driver and copied all log contents.
%windir%\inf\setupapi.dev.log
?