#StackBounty: #windows #drivers #installation #device-manager #hid Install a driver with devcon.exe

Bounty: 100

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 "ROOTUNKNOWN000"

Output:

Device node created. Install is complete when drivers are installed...
Updating drivers for ROOTUNKNOWN000 from D:shareoptKMDFDriverhidriver.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,roothidriver

[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 managers 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:shareoptKMDFDriverhidriver.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.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.