Install a driver with devcon.exe

12,130

Solution 1

*.inf has no target for ROOT\UNKNOWN\0000, use devcon install hidriver.inf root\hidriver


On VirtualBox 5.2.8 + Win7 Pro SP1 x64, I installed EcoTUIODriver (based on vmulti), and setup succeeded w/o any unknown device. I further built vmulti with WDK 7.1.0 (w/o Visual Studio), and setup succeeded too. I suggest checking your build and test environments.

View Devices by connection:

Solution 2

Various parts of your inf file seem somewhat doubtful, but I don't know enough to suggest a fix. But there might be another way of generating a viable inf file from your project.

I would suggest to use Visual Studio 2017, trial version if required, then create the inf file from your solution as described in the Microsoft article Creating a Driver Package. The Windows Driver Kit (WDK) needs to be installed after Visual Studio is installed.

If you have two such packages that you need to install as one, you might combine them as described in Using an Extension INF File.

Share:
12,130

Related videos on Youtube

hedgar2017
Author by

hedgar2017

Hello, I'm Alex! I am an expert back-end and desktop software developer with over 5 years of experience. I create fast, reliable, and safe Rust applications taking advantage of the full power of modern multi-core machines. Before moving to Rust I used to develop system, desktop, and back-end applications in C/C++ for Linux and Windows. My personal goal is to use the most robust software architecture and write clean code. Feel free to hire me if you want your project to be done in time and using high-end technologies and frameworks. My expertises: Rust (Tokio, Actix, diesel etc.) C (libc, Unix, WinAPI) C++ (Qt, Boost, C++11) Databases (PostgreSQL, MongoDB, Redis) FFmpeg (libav, video/audio transcoding and delivery) fluent in Linux and Windows administration some basic understanding of Python and Go

Updated on September 18, 2022

Comments

  • hedgar2017
    hedgar2017 over 1 year

    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 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:\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]

    No HWID here, only the device instance path

    [Update with setupapi.dev.log]

    I removed the driver completely, then removed the log, then installed the driver and copied all log contents.

    setupapi.dev.log

    • guest
      guest almost 6 years
      You'd have better support from OSR Online(NTDEV List)
    • harrymc
      harrymc almost 6 years
      Could you post the messages for your installation from %windir%\inf\setupapi.dev.log?
    • hedgar2017
      hedgar2017 almost 6 years
      Yeap, posted on pastebin. Link is above.
  • guest
    guest almost 6 years
    I'm sorry I'm not a developer. I answered based on experience with inf-modded driver installer. Check this HID driver on github for starter (the inf appears to be vmulti/sys/vmulti.inx).
  • hedgar2017
    hedgar2017 almost 6 years
    I use exactly MVS2017 Community and WDK 10. I guess the INF file generation is not available in Community edition. Anyway, thanks for your hint, I'll look into it. I know the problem is with the INF, but I don't know how to fix it either.
  • guest
    guest almost 6 years
    OP had trouble building drivers with WDK10 for Win7. HID-enumerated child devices have no HwID and installation failed thereof.