Search code examples
visual-studio-2013usbdevice-driverwinusb

winusb device driver application not being executed


I am developing WinUSB application which does basic reads through Interrupt endpoint with a generic USB device. The device driver has installed fine. But the applications t_main function is not being triggered at all when the device connects. It gets triggered ONLY in visual studio debugger and works fine.

What am i missing here? Winusbtrace detects the device and logs entry and exit of WinUSB_InitControlPipe and WinUSB_DOEntry. Logs in Windows/inf/*.log are not helpful as they log only installs. Any other log I can refer to ?

I would really appreciate any inputs. Thanks in advance. Below is my INF file and I am using visual studio 2013 on Win 7 x64

;
; Test.inf
;
; Installs WinUsb
;

[Version]
Signature = "$Windows NT$"
Class     = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile=Test.cat

; ========== Manufacturer/Models sections ===========

[Manufacturer]
%ManufacturerName% = Standard,NT$ARCH$

[Standard.NT$ARCH$]
%DeviceName% =USB_Install, USB\VID_0457&PID_0500

; ========== Class definition ===========

[ClassInstall32]
AddReg = ClassInstall_AddReg

[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%\system32\setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2

; =================== Installation ===================

[USB_Install]
Include=winusb.inf
Needs=WINUSB.NT

[USB_Install.Services]
Include=winusb.inf
AddService=WinUsb,0x00000002,WinUsb_ServiceInstall

[WinUsb_ServiceInstall]
DisplayName     = %WinUsb_SvcDesc%
ServiceType     = 1
StartType       = 3
ErrorControl    = 1
ServiceBinary   = %12%\WinUSB.sys

[USB_Install.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
; By default, USBDevice class uses iProduct descriptor to name the device in
; Device Manager on Windows 8 and higher.
; Uncomment for this device to use %DeviceName% on Windows 8 and higher:
;HKR,,FriendlyName,,%DeviceName%
HKR,,DeviceInterfaceGUIDs,0x10000,"{2753294b-5128-4a42-be6a-d7818234ea9c}"

[USB_Install.Wdf]
KmdfService=WINUSB, WinUsb_Install

[WinUsb_Install]
KmdfLibraryVersion=1.9

[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller"

[CoInstallers_CopyFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

; ================= Source Media Section =====================

[SourceDisksNames]
1 = %DiskName%

[SourceDisksFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1

; =================== Strings ===================

[Strings]
ManufacturerName="Test"
ClassName="Universal Serial Bus devices"
DiskName="Device Installation Disk"
WinUsb_SvcDesc="WinUSB Driver"
DeviceName="Test Device"
REG_MULTI_SZ = 0x00010000

Solution

  • The winusb application is not a driver. You have to tell it when to run. If you are trying to get the application to run when the device is plugged in, you can attempt to bind the application to the connection event described in this post: https://superuser.com/questions/219401/starting-scheduled-task-by-detecting-connection-of-usb-drive