none
WIA Micro driver DLL will not load RRS feed

  • Question

  • I'm working with with the WIA micro drive sample code from here

    https://code.msdn.microsoft.com/windowshardware/WIA-Microdriver-1972b1c5

    I'm trying to change the sample code from a serial device to a USB device.

    so far I have successfully updated the INF file so it will at least install the INf, dll, and cat files succesfully

    see below

    ; TESTMCRO.INF  -- WIA sample MicroDriver scanner setup file
    
    [Version]
    Signature="$WINDOWS NT$"
    Class=Image
    ClassGUID={6bdd1fc6-810f-11d0-bec7-08002be2092f}
    Provider=%Mfg%
    DriverVer=12/09/2014,1.0.0.5
    CatalogFile=testmcro.cat
    
    [SourceDisksFiles.x86]
    testmcro.dll=1
    [SourceDisksNames.x86]
    1=%Location%,,,
    
    [SourceDisksFiles.ia64]
    testmcro.dll=1
    [SourceDisksNames.ia64]
    1=%Location%,,,
    
    [SourceDisksFiles.amd64]
    testmcro.dll=1
    [SourceDisksNames.amd64]
    1=%Location%,,,
    
    [Manufacturer]
    %Mfg%=Models, NTx86, NTamd64, NTia64
    
    ; This is the models section for the x86 driver
    [Models.NTx86]
    %WIASample.DeviceDesc% = WIASample.Scanner, USB\VID_1234&PID_1234
    
    ; This is the models section for the amd64 driver
    [Models.NTamd64]
    %WIASample.DeviceDesc% = WIASample.Scanner, USB\VID_1234&PID_1234
    
    ; This is the models section for the ia64 driver
    [Models.NTia64]
    %WIASample.DeviceDesc% = WIASample.Scanner, USB\VID_1234&PID_1234
    
    [WIASample.Scanner]
    Include=sti.inf
    Needs=STI.USBSection, STI.MICRODRIVERSection
    ;Needs=STI.USBSection
    SubClass=StillImage
    DeviceType=1
    DeviceSubType=0x1
    Capabilities=0x30
    ;Events=WIASample.Events
    DeviceData=WIASample.DeviceData
    AddReg=WIASample.AddReg
    CopyFiles=WIASample.CopyFiles
    ICMProfiles="sRGB Color Space Profile.icm"
    
    [WIASample.Scanner.Services]
    Include=sti.inf
    Needs=STI.USBSection.Services
    
    ;[WIASample.Events]
    ;ScanEvent=%ScanEvent.Desc%,{B760CA1B-6B26-4704-B6CA-282235E9338B},*
    
    [WIASample.DeviceData]
    Server=local
    UI Class ID={4DB1AD10-3391-11D2-9A33-00C04FA36145}
    MicroDriver=testmcro.dll
    Sample Entry=1,1
    Resolutions="75, 100, 300, 600, 1200"
    
    [WIASample.AddReg]
    HKR,,HardwareConfig,1,4  ; USB Device
    ;HKR,,USDClass,,"{BB6CF8E2-1511-40bd-91BA-80D43C53064E}"
    
    [WIASample.CopyFiles]
    testmcro.dll
    
    [Strings]
    DeviceName="My Device"
    Mfg="My company"
    Location="Install Source"
    WIASample.DeviceDesc="WIA Sample MicroDriver Scanner Device"
    ScanEvent.Desc="Scan"

    However, when I try to connect to the device, it will never successfully connect.

    inspecting the wiatrace.log file I always get these Errors

    MicroDriver::LoadMicroDriverDLL, MicroDriver DLL (testmcro.dll) could not be loaded
    MicroDriver::SetSTIDeviceRegistryKey, Microdriver failed the CMD_SETSTIDEVICEHKEY command, hr = 0x8007007F
    MicroDriver::InitializeMicroDriver, Microdriver failed the CMD_SETSTIDEVICEHKEY command, hr = 0x8007007F
    CWIADevice::Initialize, Could NOT initialize the MICRODRIVER dll (testmcro.dll)
    CWIADevice::Initialize, IStiUsd interface method ::Initialize failed, hr = 8007007f
    USDWrapper::LoadDriver, Error loading driver for (WIA Sample MicroDriver Scanner Device): IStiUSD::Initialize failed with hr = 0x8007007F
    USDWrapper::LoadDriver, We encountered an error attempting to load driver for (WIA Sample MicroDriver Scanner Device), error (0x8007007f)


    the key seems to be around the MicroDriver=testmcro.dll entry in the INF file.

    If i intentionally misspell "testmcro.dll" I get the same error with the misspelled name in the log files.  

    The dll is also successfully copied to the C:\windows\system32\drivers folder when installing the driver. I have also tried copying the DLL to the system32 folder.

    This has been driving me nuts

    I have tried attaching the VS debugger to the svhost running the WIA service with my DLL code, but it never event hits the entry point of the dll

    Tuesday, December 9, 2014 10:17 PM

Answers

  • Please note that in general WIA micro-drivers are obsolete for Windows Vista and newer Windows OS versions and remain supported for legacy device support reasons only. These micro-drivers are only WIA 1.0 (Windows XP).

    For recent Windows versions scanner drivers should be WIA 2.0 mini-drivers, such as the wiadriverex and prodscan samples listed at:

    https://code.msdn.microsoft.com/windowshardware/WIA-Microdriver-1972b1c5

    In particular for your error, looking at the trace error message, quote:

    MicroDriver::LoadMicroDriverDLL, MicroDriver DLL (testmcro.dll) could not be loaded MicroDriver::SetSTIDeviceRegistryKey, Microdriver failed the CMD_SETSTIDEVICEHKEY command, hr = 0x8007007F

    … note the last part: the micro-driver failed the CMD_SETSTIDEVICEKEY command, with ERROR_PROC_NOT_FOUND (procedure not found) .

    MSDN:

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff546016(v=vs.85).aspx

    CMD_SETSTIDEVICEHKEY

    Called by the WIA Flatbed Driver to allow the microdriver to read registry entries in the installed registry section. This command provides the STI device's installed registry HKEY to the microdriver, so that it can access private registry values for its device. The pHandle member of the VAL structure will contain a pointer to the HKEY given to the WIA Flatbed Driver during STI's IStiUSD::Initialize method. This is the top-level HKEY of the installed device section. The DeviceData key can be opened directly using this HKEY. See INF Files for WIA Devices for more information.

    Note: This key is opened and closed only by the WIA Flatbed Driver. It is also valid only during this command and CMD_INITIALIZE (see Required Commands). After those commands return, the key is no longer valid. The HKEY value must not be cached.

    See here in MSDN and also at other real USB scanner device INFs:

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff542770(v=vs.85).aspx

    Monday, December 15, 2014 9:31 PM