Calling WinUSB from an application

We’re developing a piece of test equipment that connects to a computer over
USB (high-speed). It has one HID endpoint (UI controls, LEDs, etc.) and two
bulk endpoints (data acquisition channels). I had planned to write a UMDF
driver to deal with the bulk endpoints, but I noticed in one of the WinHEC
PowerPoint decks that applications can call WinUSB directly to do this sort
of thing if only one app is going to be talking to the device. That’s our
scenario, so I’m thinking this is a good way to do it.

The in-the-box HID drivers already handle the HID endpoint, so no worries
there.

If I’m reading the docs correctly, I need to cook up an INF that loads
WinUSB for the two bulk endpoints (USB\VID_xxxx&PID_yyyy&MI_01/MI_02). I
have to include the WDF coinstaller and the WinUSB coinstaller (needed for
XP), and put in a unique DeviceInterfaceGUID for WinUSB to register. I use
that GUID with the SetupDiXxx APIs to find my device. I do a CreateFile on
the device path I get back from the SetupDiXxx APIs, call WinUsb_Initialize
with the device’s file handle, set up the pipe with WinUsb_SetPipePolicy,
and read the data with WinUsb_ReadPipe.

That sounds way too easy. I didn’t see any examples of calling WinUSB
directly in the WDK, so I just want to be sure this is still a supported
scenario and that I haven’t missed anything before I get too far down this
road. Is this really all there is to do?

Thanks,
-Dan

It is still a supported scenario. You might want to consider using IAD
to group your 2 bulke endpoints into one function (or declare both
endpoints in the same interface) if they are truly represent a singular
entity in hardware.

D

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Daniel E.
Germann
Sent: Friday, December 08, 2006 7:49 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Calling WinUSB from an application

We’re developing a piece of test equipment that connects to a computer
over
USB (high-speed). It has one HID endpoint (UI controls, LEDs, etc.) and
two
bulk endpoints (data acquisition channels). I had planned to write a
UMDF
driver to deal with the bulk endpoints, but I noticed in one of the
WinHEC
PowerPoint decks that applications can call WinUSB directly to do this
sort
of thing if only one app is going to be talking to the device. That’s
our
scenario, so I’m thinking this is a good way to do it.

The in-the-box HID drivers already handle the HID endpoint, so no
worries
there.

If I’m reading the docs correctly, I need to cook up an INF that loads
WinUSB for the two bulk endpoints (USB\VID_xxxx&PID_yyyy&MI_01/MI_02).
I
have to include the WDF coinstaller and the WinUSB coinstaller (needed
for
XP), and put in a unique DeviceInterfaceGUID for WinUSB to register. I
use
that GUID with the SetupDiXxx APIs to find my device. I do a CreateFile
on
the device path I get back from the SetupDiXxx APIs, call
WinUsb_Initialize
with the device’s file handle, set up the pipe with
WinUsb_SetPipePolicy,
and read the data with WinUsb_ReadPipe.

That sounds way too easy. I didn’t see any examples of calling WinUSB
directly in the WDK, so I just want to be sure this is still a supported

scenario and that I haven’t missed anything before I get too far down
this
road. Is this really all there is to do?

Thanks,
-Dan


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I’m happy you think it is “too easy”. That was kind of the point. It
is absolutely supported.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Daniel E.
Germann
Sent: Friday, December 08, 2006 7:49 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Calling WinUSB from an application

We’re developing a piece of test equipment that connects to a computer
over
USB (high-speed). It has one HID endpoint (UI controls, LEDs, etc.) and
two
bulk endpoints (data acquisition channels). I had planned to write a
UMDF
driver to deal with the bulk endpoints, but I noticed in one of the
WinHEC
PowerPoint decks that applications can call WinUSB directly to do this
sort
of thing if only one app is going to be talking to the device. That’s
our
scenario, so I’m thinking this is a good way to do it.

The in-the-box HID drivers already handle the HID endpoint, so no
worries
there.

If I’m reading the docs correctly, I need to cook up an INF that loads
WinUSB for the two bulk endpoints (USB\VID_xxxx&PID_yyyy&MI_01/MI_02).
I
have to include the WDF coinstaller and the WinUSB coinstaller (needed
for
XP), and put in a unique DeviceInterfaceGUID for WinUSB to register. I
use
that GUID with the SetupDiXxx APIs to find my device. I do a CreateFile
on
the device path I get back from the SetupDiXxx APIs, call
WinUsb_Initialize
with the device’s file handle, set up the pipe with
WinUsb_SetPipePolicy,
and read the data with WinUsb_ReadPipe.

That sounds way too easy. I didn’t see any examples of calling WinUSB
directly in the WDK, so I just want to be sure this is still a supported

scenario and that I haven’t missed anything before I get too far down
this
road. Is this really all there is to do?

Thanks,
-Dan


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Hi. I’m in a similar situation as Daniel. I am looking at having an application access a USB device through WinUSB only, but I’m having trouble finding a good INF file to do that. Anyone have a good INF template file for this or an actual working INF that they wouldn’t mind sharing?

Thanks,
–Brian

xxxxx@dalsemi.com wrote:

Hi. I’m in a similar situation as Daniel. I am looking at having an application access a USB device through WinUSB only, but I’m having trouble finding a good INF file to do that. Anyone have a good INF template file for this or an actual working INF that they wouldn’t mind sharing?

You can find a sample here:
http://msdn2.microsoft.com/en-us/library/aa939015.aspx
The key phrases are “include=winusb.inf” and “needs=winusb.nt”, and the
part that references WUDFCoInstaller.dll.

I’m kind of excited about WinUSB. I didn’t realize until two days ago
that this was available, and that it actually works on XP.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

To work on XP, you will also need the winusb coinstaller (also available
in the WDK).

You should be able to take a sample UMDF inf and strip out the UMDF
specific sections.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Thursday, December 14, 2006 11:45 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Calling WinUSB from an application

xxxxx@dalsemi.com wrote:

Hi. I’m in a similar situation as Daniel. I am looking at having an
application access a USB device through WinUSB only, but I’m having
trouble finding a good INF file to do that. Anyone have a good INF
template file for this or an actual working INF that they wouldn’t mind
sharing?

You can find a sample here:
http://msdn2.microsoft.com/en-us/library/aa939015.aspx
The key phrases are “include=winusb.inf” and “needs=winusb.nt”, and the
part that references WUDFCoInstaller.dll.

I’m kind of excited about WinUSB. I didn’t realize until two days ago
that this was available, and that it actually works on XP.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Hi. Thanks for the tips. From the links above, here is my “hack” at an inf file that uses WinUSB only. I took the sample WinUSB/UMDF inf file and tried to comment-out the UMDF section. Anybody see anything wrong with it? Do I need to create a GUID here? Or since I don’t have a UMDF driver, I don’t need one? Also, do I load WinUSB as a lower filter driver? I wouldn’t think so… Take a look and let me know.

Thanks,
–Brian

[Version]
Signature = “$Windows NT$”
ClassGuid = {997B5D8D-C442-4F2E-BAF3-9C8E671E9E21}
Provider = %MyProvider%
DriverVer = MM/DD/YYYY,n.n.n.n
;!!!CatalogFile = .cat

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

[Manufacturer]
%MyProvider% = ,NTx86,NTia64,NTamd64

[.NTx86]
%USB\MyDevice.DeviceDesc% =USB_InstallUSB\VID_xxxx&PID_xxxx

[.NTia64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[.NTamd64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
; =================== USB Install ===================

[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
;!!!CopyFiles = UMDriverCopy
AddProperty = DriverProperties

[USB_Install.CoInstallers]
AddReg = WUDF_CoInstallers_AddReg

;!!![USB_Install.Wdf]
;!!!UmdfService = ,_Install
;!!!UmdfServiceOrder =
;!!!UmdfImpersonationLevel = Impersonation

[USB_Install.HW]
AddReg = WINUSBTransport_AddReg

[USB_Install.Services]
Include = winusb.inf
AddService = WUDFRd, 0x000001fa, WUDFRD_ServiceInstall
AddService = WinUsb, 0x000001f8, WINUSB.AddService

[WINUSBTransport_AddReg]
HKR,“LowerFilters”,0x00010008,“WinUsb” ; FLG_ADDREG_TYPE_MULTI_SZ | FLG_ADDREG_APPEND

; =================== Driver Property section ===================

;!!![DriverProperties]
;!!!DeviceIcon,“%1%<mydriverdllname>.dll,-”
;!!!{BA554A34-3371-45b5-8DE9-B45E2A33D7DC},1,18,“%systemroot%\system32\rundll32.exe ;!!!devmgr.dll,DeviceProperties_RunDLL /DeviceID %DeviceID%”
;!!!{BA554A34-3371-45b5-8DE9-B45E2A33D7DC},2,18,“Additional Options”

; =================== UMDF Service Install section ===================

;!!![WUDF_CoInstallers_AddReg]
;!!!HKR,CoInstallers32,0x00010000,“WUDFCoInstaller.dll”
;!!!
;!!![_Install]
;!!!UmdfLibraryVersion = 1.0.0
;!!!ServiceBinary = “%12%\umdf<mydriverdllname>.dll”
;!!!DriverCLSID =
;!!!
;!!![UMDriverCopy]
;!!!.dll
;!!!
;!!![DestinationDirs]
;!!!UMDriverCopy=12,UMDF ; copy to drivers\umdf
;!!!
;!!![SourceDisksFiles]
;!!!.dll=1
;!!!
;!!![SourceDisksNames]
;!!!1 = %MediaDescription%

; =================== WUDFRd ===================

[WUDFRD_ServiceInstall]
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %12%\WUDFRd.sys

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

[Strings]
Provider = “My Device Provider”
MediaDescription = “My Device Installation Media”
USB\MyDevice.DeviceDesc = “My Device Description”

SERVICE_DEMAND_START = 0x3
SERVICE_KERNEL_DRIVER = 0x1
SERVICE_ERROR_NORMAL = 0x1

  1. You want winusb as the service, not a lower filter, so these 2
    sections go away

[USB_Install.HW]
AddReg = WINUSBTransport_AddReg

[WINUSBTransport_AddReg]
HKR,“LowerFilters”,0x00010008,“WinUsb” ; FLG_ADDREG_TYPE_MULTI_SZ |
FLG_ADDREG_APPEND

  1. you don’t need the UMDF redirector, so this goes away

[WUDFRD_ServiceInstall]
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %12%\WUDFRd.sys

AddService = WUDFRd, 0x000001fa, WUDFRD_ServiceInstall

  1. you need to install winusb as the FDO for the device, this section
    may do the trick w/out the winusb AddService

[USB_Install.Services]
Include = winusb.inf

But you might need to change it to this
AddService = WinUsb, 0x2, WINUSB.AddService

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@dalsemi.com
Sent: Thursday, December 14, 2006 8:24 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Calling WinUSB from an application

Hi. Thanks for the tips. From the links above, here is my “hack” at an
inf file that uses WinUSB only. I took the sample WinUSB/UMDF inf file
and tried to comment-out the UMDF section. Anybody see anything wrong
with it? Do I need to create a GUID here? Or since I don’t have a UMDF
driver, I don’t need one? Also, do I load WinUSB as a lower filter
driver? I wouldn’t think so… Take a look and let me know.

Thanks,
–Brian

[Version]
Signature = “$Windows NT$”
ClassGuid = {997B5D8D-C442-4F2E-BAF3-9C8E671E9E21}
Provider = %MyProvider%
DriverVer = MM/DD/YYYY,n.n.n.n
;!!!CatalogFile = .cat

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

[Manufacturer]
%MyProvider% = ,NTx86,NTia64,NTamd64

[.NTx86]
%USB\MyDevice.DeviceDesc% =USB_InstallUSB\VID_xxxx&PID_xxxx

[.NTia64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[.NTamd64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
; =================== USB Install ===================

[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
;!!!CopyFiles = UMDriverCopy
AddProperty = DriverProperties

[USB_Install.CoInstallers]
AddReg = WUDF_CoInstallers_AddReg

;!!![USB_Install.Wdf]
;!!!UmdfService = ,_Install
;!!!UmdfServiceOrder =
;!!!UmdfImpersonationLevel = Impersonation

[USB_Install.HW]
AddReg = WINUSBTransport_AddReg

[USB_Install.Services]
Include = winusb.inf
AddService = WUDFRd, 0x000001fa, WUDFRD_ServiceInstall
AddService = WinUsb, 0x000001f8, WINUSB.AddService

[WINUSBTransport_AddReg]
HKR,“LowerFilters”,0x00010008,“WinUsb” ; FLG_ADDREG_TYPE_MULTI_SZ |
FLG_ADDREG_APPEND

; =================== Driver Property section ===================

;!!![DriverProperties]
;!!!DeviceIcon,“%1%<mydriverdllname>.dll,-”
;!!!{BA554A34-3371-45b5-8DE9-B45E2A33D7DC},1,18,“%systemroot%\system32<br>rundll32.exe ;!!!devmgr.dll,DeviceProperties_RunDLL /DeviceID
%DeviceID%”
;!!!{BA554A34-3371-45b5-8DE9-B45E2A33D7DC},2,18,“Additional Options”

; =================== UMDF Service Install section ===================

;!!![WUDF_CoInstallers_AddReg]
;!!!HKR,CoInstallers32,0x00010000,“WUDFCoInstaller.dll”
;!!!
;!!![_Install]
;!!!UmdfLibraryVersion = 1.0.0
;!!!ServiceBinary = “%12%\umdf<mydriverdllname>.dll”
;!!!DriverCLSID =
;!!!
;!!![UMDriverCopy]
;!!!.dll
;!!!
;!!![DestinationDirs]
;!!!UMDriverCopy=12,UMDF ; copy to drivers\umdf
;!!!
;!!![SourceDisksFiles]
;!!!.dll=1
;!!!
;!!![SourceDisksNames]
;!!!1 = %MediaDescription%

; =================== WUDFRd ===================

[WUDFRD_ServiceInstall]
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %12%\WUDFRd.sys

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

[Strings]
Provider = “My Device Provider”
MediaDescription = “My Device Installation Media”
USB\MyDevice.DeviceDesc = “My Device Description”

SERVICE_DEMAND_START = 0x3
SERVICE_KERNEL_DRIVER = 0x1
SERVICE_ERROR_NORMAL = 0x1


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thanks a bunch Doron! That has reduced the size of my inf file greatly. I’ve included your suggestions and made a few more edits, which are the following:

Under [Version], I got rid of ClassGuid, DriverVer, and CatalogFile (as I don’t think I need them). I also got rid of the following co-installer section:

[USB_Install.CoInstallers]
AddReg = WUDF_CoInstallers_AddReg

Let me know if anyone sees a problem with the template inf file for a WinUSB-only install below (or if I actually need the items I deleted).

Thanks,
–Brian

;=================== Version section ====================

[Version]
Signature = “$Windows NT$”
Provider = %MyProvider%

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

[Manufacturer]
%MyProvider% = ,NTx86,NTia64,NTamd64

[.NTx86]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[.NTia64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[.NTamd64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

; =================== USB Install ===================

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

[USB_Install.Services]
Include = winusb.inf
;!!!AddService = WinUsb, 0x2, WINUSB.AddService

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

[Strings]
Provider = “My Device Provider”
MediaDescription = “My Device Installation Media”
USB\MyDevice.DeviceDesc = “My Device Description”

SERVICE_DEMAND_START = 0x3
SERVICE_KERNEL_DRIVER = 0x1
SERVICE_ERROR_NORMAL = 0x1

xxxxx@dalsemi.com wrote:

Hi. Thanks for the tips. From the links above, here is my “hack” at an inf file that uses WinUSB only. I took the sample WinUSB/UMDF inf file and tried to comment-out the UMDF section. Anybody see anything wrong with it? Do I need to create a GUID here?

Yes, otherwise you will not be able to find the device from user-mode.
WinUSB doesn’t expose a symbolic link; you have to search for the device
interface GUID, which you create in this INF.

Or since I don’t have a UMDF driver, I don’t need one? Also, do I load WinUSB as a lower filter driver?

No, WinUSB *IS* your driver.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim,

Thanks. Do I need any “co-installer” sections (I thought I might need one when installing under XP with WDK-supplied co-installers)? You mentioned that in an earlier post…

Also, just for completeness, I also commented-out the following:

  1. Under “[Strings]”, I commented-out the “MediaDescription =” line (as I don’t have any).
  2. Under “[USB_Install]”, I commented-out the “AddProperty =” line (as I don’t have any icons to load).

Thanks for all the great help!!!

–Brian

Hi, Brian.

It’s nice to see someone else is giving it a try, too. I’m still waiting
for hardware, so my INF is completely untested. I started with the .INX
file from the FX2 UMDF driver, and chopped out all the parts that looked
specific to the UMDF part of the driver. The main differences in mine are:

  1. KmdfService entry for WinUSB (same as UMDF INX file; not sure if I need
    it or not):

[Dev_Install.NT.Wdf]
KmdfService=WINUSB,WinUsb_Install

[WinUSB_Install]
KmdfLibraryVersion=1.0

  1. Both WDF and WinUSB coinstallers (needs to work on XP systems; same as
    UMDF INX file; not sure if I need the WDF coinstaller or not):

[Dev_Install.NT.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,CoInstallers32,0x00010000,“WdfCoInstaller01005.dll,WdfCoInstaller”,“WinUSBCoInstaller.dll”

[CoInstallers_CopyFiles]
WdfCoInstaller01005.dll
WinUSBCoInstaller.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

  1. Device interface GUID for WinUSB to register (so I can find my device
    with SetupAPI):

[Dev_Install.NT.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
HKR,DeviceInterfaceGUIDs,0x00010000,“{11111111-2222-3333-4444-555555555555}”

  1. Service entry for WinUSB (might not be needed, per Doron’s post):

[Dev_Install.NT.Services]
AddService=WinUSB,0x00000002,WinUSB_ServiceInstall

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

[Strings]
WinUSB_SvcDesc=“WinUSB Driver”

I did keep ClassGuid, DriverVer and CatalogFile. The ClassGuid specifies
the device class your device will install under (which determines where your
driver will show up in Device Manager (I used the USB GUID; same as UMDF INX
file)). You’re right that DriverVer is kind of meaningless for an INF like
this, but I think it’s required (as is CatalogFile) if you want to sign the
driver package.

A related question: Can I use an I/O completion port with WinUsb_ReadPipe?
The docs only talk about using an event in the OVERLAPPED structure, but I’m
assuming it all goes through the standard I/O path with ReadFile at some
point, so it seems like that ought to work. I’m planning to do I/O like the
UMDF FX2 driver’s .exe file did, by queuing a bunch of buffers and looping
on GetQueuedCompletionStatus. When it’s time to finish, my app will call
CancelIo on the device’s handle to cancel any pending WinUsb_ReadPipe calls.

-Dan

wrote in message news:xxxxx@ntdev…
> Thanks a bunch Doron! That has reduced the size of my inf file greatly.
> I’ve included your suggestions and made a few more edits, which are the
> following:
>
> Under [Version], I got rid of ClassGuid, DriverVer, and CatalogFile (as I
> don’t think I need them). I also got rid of the following co-installer
> section:
>
> [USB_Install.CoInstallers]
> AddReg = WUDF_CoInstallers_AddReg
>
> Let me know if anyone sees a problem with the template inf file for a
> WinUSB-only install below (or if I actually need the items I deleted).
>
> Thanks,
> --Brian
>
> ;=================== Version section ====================
>
> [Version]
> Signature = “$Windows NT$”
> Provider = %MyProvider%
>
> ; =================== Manufacturer/Models sections ===================
>
> [Manufacturer]
> %MyProvider% = ,NTx86,NTia64,NTamd64
>
> [.NTx86]
> %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
>
> [.NTia64]
> %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
>
> [.NTamd64]
> %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
>
> ; =================== USB Install ===================
>
> [USB_Install]
> Include = winusb.inf
> Needs = WINUSB.NT
> AddProperty = DriverProperties
>
> [USB_Install.Services]
> Include = winusb.inf
> ;!!!AddService = WinUsb, 0x2, WINUSB.AddService
>
> ;
> ; =================== Strings ===================
> ;
>
> [Strings]
> Provider = “My Device Provider”
> MediaDescription = “My Device Installation Media”
> USB\MyDevice.DeviceDesc = “My Device Description”
>
> SERVICE_DEMAND_START = 0x3
> SERVICE_KERNEL_DRIVER = 0x1
> SERVICE_ERROR_NORMAL = 0x1
>
>
>

xxxxx@dalsemi.com wrote:

Thanks. Do I need any “co-installer” sections (I thought I might need one when installing under XP with WDK-supplied co-installers)? You mentioned that in an earlier post…

Someone, somewhere, has to install WinUSB.sys. The co-installer in the
WDK is the easy way to do that. If you are only going to run this on
your system, for experimentation, then you can install WinUSB.sys by
hand (using rundll32 on the co-installer), but if you ever hope to
release this into the wild, you’ll want the co-installer in your inf.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Yes, you should have the .Wdf section, although the required library
version is v1.5, not v1.0

[WinUSB_Install]
KmdfLibraryVersion=1.5

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Daniel E.
Germann
Sent: Friday, December 15, 2006 12:20 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Calling WinUSB from an application

Hi, Brian.

It’s nice to see someone else is giving it a try, too. I’m still
waiting
for hardware, so my INF is completely untested. I started with the .INX

file from the FX2 UMDF driver, and chopped out all the parts that looked

specific to the UMDF part of the driver. The main differences in mine
are:

  1. KmdfService entry for WinUSB (same as UMDF INX file; not sure if I
    need
    it or not):

[Dev_Install.NT.Wdf]
KmdfService=WINUSB,WinUsb_Install

[WinUSB_Install]
KmdfLibraryVersion=1.0

  1. Both WDF and WinUSB coinstallers (needs to work on XP systems; same
    as
    UMDF INX file; not sure if I need the WDF coinstaller or not):

[Dev_Install.NT.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,CoInstallers32,0x00010000,“WdfCoInstaller01005.dll,WdfCoInstaller”,
“WinUSBCoInstaller.dll”

[CoInstallers_CopyFiles]
WdfCoInstaller01005.dll
WinUSBCoInstaller.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

  1. Device interface GUID for WinUSB to register (so I can find my device

with SetupAPI):

[Dev_Install.NT.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
HKR,DeviceInterfaceGUIDs,0x00010000,“{11111111-2222-3333-4444-555555555
555}”

  1. Service entry for WinUSB (might not be needed, per Doron’s post):

[Dev_Install.NT.Services]
AddService=WinUSB,0x00000002,WinUSB_ServiceInstall

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

[Strings]
WinUSB_SvcDesc=“WinUSB Driver”

I did keep ClassGuid, DriverVer and CatalogFile. The ClassGuid
specifies
the device class your device will install under (which determines where
your
driver will show up in Device Manager (I used the USB GUID; same as UMDF
INX
file)). You’re right that DriverVer is kind of meaningless for an INF
like
this, but I think it’s required (as is CatalogFile) if you want to sign
the
driver package.

A related question: Can I use an I/O completion port with
WinUsb_ReadPipe?
The docs only talk about using an event in the OVERLAPPED structure, but
I’m
assuming it all goes through the standard I/O path with ReadFile at some

point, so it seems like that ought to work. I’m planning to do I/O like
the
UMDF FX2 driver’s .exe file did, by queuing a bunch of buffers and
looping
on GetQueuedCompletionStatus. When it’s time to finish, my app will
call
CancelIo on the device’s handle to cancel any pending WinUsb_ReadPipe
calls.

-Dan

wrote in message news:xxxxx@ntdev…
> Thanks a bunch Doron! That has reduced the size of my inf file
greatly.
> I’ve included your suggestions and made a few more edits, which are
the
> following:
>
> Under [Version], I got rid of ClassGuid, DriverVer, and CatalogFile
(as I
> don’t think I need them). I also got rid of the following
co-installer
> section:
>
> [USB_Install.CoInstallers]
> AddReg = WUDF_CoInstallers_AddReg
>
> Let me know if anyone sees a problem with the template inf file for a
> WinUSB-only install below (or if I actually need the items I deleted).
>
> Thanks,
> --Brian
>
> ;=================== Version section ====================
>
> [Version]
> Signature = “$Windows NT$”
> Provider = %MyProvider%
>
> ; =================== Manufacturer/Models sections ===================
>
> [Manufacturer]
> %MyProvider% = ,NTx86,NTia64,NTamd64
>
> [.NTx86]
> %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
>
> [.NTia64]
> %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
>
> [.NTamd64]
> %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
>
> ; =================== USB Install ===================
>
> [USB_Install]
> Include = winusb.inf
> Needs = WINUSB.NT
> AddProperty = DriverProperties
>
> [USB_Install.Services]
> Include = winusb.inf
> ;!!!AddService = WinUsb, 0x2, WINUSB.AddService
>
> ;
> ; =================== Strings ===================
> ;
>
> [Strings]
> Provider = “My Device Provider”
> MediaDescription = “My Device Installation Media”
> USB\MyDevice.DeviceDesc = “My Device Description”
>
> SERVICE_DEMAND_START = 0x3
> SERVICE_KERNEL_DRIVER = 0x1
> SERVICE_ERROR_NORMAL = 0x1
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Here was the trick we discovered for UMDF:

  1. Always do the needs/includes bit so that you get the right sections
    from WINUSB.INF on Vista (specifically the CopyFiles directives). On XP
    these won’t have any effect, which brings us to step 2

  2. Always include the WinUSB co-installer. On Vista it won’t really do
    anything (unfortunately … I was hoping they’d install the WinUSB
    service on both platforms but no such luck). On XP it will install the
    service entries which get installed on Vista through Needs/Includes
    sections.

Also since you’re playing with this, you can try putting
Include=WINUSB.INF & Needs=WINUSB.NT.Services to your
DDInstall.NT.Services section instead of an AddService directive. The
device installer folks had a *theory* that this section would get parsed
after the WINUSB coinstaller had a chance to copy files onto the disk,
so WINUSB.INF would be in place at that point and the Include would be
able to bring the file in.

If not you’ll get an error because service is installed for the device
(probably saying the device isn’t configured properly).

Alternatively make sure you copy the contents of WINUSB.NT.Services &
WINUSB.AddService into your own INF.

Yes this is a mess. There are a lot of hoops we had to force everyone
through so that WINUSB could work with in-box Vista stuff, out-of-box
Vista stuff and out-of-box XP stuff.

-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Daniel E. Germann
Sent: Friday, December 15, 2006 12:20 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Calling WinUSB from an application

Hi, Brian.

It’s nice to see someone else is giving it a try, too. I’m still
waiting
for hardware, so my INF is completely untested. I started with the .INX

file from the FX2 UMDF driver, and chopped out all the parts that looked

specific to the UMDF part of the driver. The main differences in mine
are:

  1. KmdfService entry for WinUSB (same as UMDF INX file; not sure if I
    need
    it or not):

[Dev_Install.NT.Wdf]
KmdfService=WINUSB,WinUsb_Install

[WinUSB_Install]
KmdfLibraryVersion=1.0

  1. Both WDF and WinUSB coinstallers (needs to work on XP systems; same
    as
    UMDF INX file; not sure if I need the WDF coinstaller or not):

[Dev_Install.NT.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,CoInstallers32,0x00010000,“WdfCoInstaller01005.dll,WdfCoInstaller”,
“WinUSBCoInstaller.dll”

[CoInstallers_CopyFiles]
WdfCoInstaller01005.dll
WinUSBCoInstaller.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

  1. Device interface GUID for WinUSB to register (so I can find my device

with SetupAPI):

[Dev_Install.NT.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
HKR,DeviceInterfaceGUIDs,0x00010000,“{11111111-2222-3333-4444-555555555
555}”

  1. Service entry for WinUSB (might not be needed, per Doron’s post):

[Dev_Install.NT.Services]
AddService=WinUSB,0x00000002,WinUSB_ServiceInstall

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

[Strings]
WinUSB_SvcDesc=“WinUSB Driver”

I did keep ClassGuid, DriverVer and CatalogFile. The ClassGuid
specifies
the device class your device will install under (which determines where
your
driver will show up in Device Manager (I used the USB GUID; same as UMDF
INX
file)). You’re right that DriverVer is kind of meaningless for an INF
like
this, but I think it’s required (as is CatalogFile) if you want to sign
the
driver package.

A related question: Can I use an I/O completion port with
WinUsb_ReadPipe?
The docs only talk about using an event in the OVERLAPPED structure, but
I’m
assuming it all goes through the standard I/O path with ReadFile at some

point, so it seems like that ought to work. I’m planning to do I/O like
the
UMDF FX2 driver’s .exe file did, by queuing a bunch of buffers and
looping
on GetQueuedCompletionStatus. When it’s time to finish, my app will
call
CancelIo on the device’s handle to cancel any pending WinUsb_ReadPipe
calls.

-Dan

wrote in message news:xxxxx@ntdev…
> Thanks a bunch Doron! That has reduced the size of my inf file
greatly.
> I’ve included your suggestions and made a few more edits, which are
the
> following:
>
> Under [Version], I got rid of ClassGuid, DriverVer, and CatalogFile
(as I
> don’t think I need them). I also got rid of the following
co-installer
> section:
>
> [USB_Install.CoInstallers]
> AddReg = WUDF_CoInstallers_AddReg
>
> Let me know if anyone sees a problem with the template inf file for a
> WinUSB-only install below (or if I actually need the items I deleted).
>
> Thanks,
> --Brian
>
> ;=================== Version section ====================
>
> [Version]
> Signature = “$Windows NT$”
> Provider = %MyProvider%
>
> ; =================== Manufacturer/Models sections ===================
>
> [Manufacturer]
> %MyProvider% = ,NTx86,NTia64,NTamd64
>
> [.NTx86]
> %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
>
> [.NTia64]
> %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
>
> [.NTamd64]
> %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx
>
> ; =================== USB Install ===================
>
> [USB_Install]
> Include = winusb.inf
> Needs = WINUSB.NT
> AddProperty = DriverProperties
>
> [USB_Install.Services]
> Include = winusb.inf
> ;!!!AddService = WinUsb, 0x2, WINUSB.AddService
>
> ;
> ; =================== Strings ===================
> ;
>
> [Strings]
> Provider = “My Device Provider”
> MediaDescription = “My Device Installation Media”
> USB\MyDevice.DeviceDesc = “My Device Description”
>
> SERVICE_DEMAND_START = 0x3
> SERVICE_KERNEL_DRIVER = 0x1
> SERVICE_ERROR_NORMAL = 0x1
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Hi Doran/Peter/Daniel/Tim,

Thanks! Very nice of you guys to post! I think you cleared up quite a bit for me. I put most of your suggestions into my inf and finally hit paydirt – a working inf file (see below for a “free” version of the inf file I used). It at least works under Windows Vista Business x86 with my company’s USB device (but with real VIDs/PIDs/GUIDs/Strings). There are a few things missing (the .cat file entry and the driver version entry), but I’ll put them in next week when I get back to my test machine. There is a small duplication with the line “Include=winusb.inf” appearing twice (but for some reason everything still works). I also hope to start testing on Windows XP soon as well as 64-bit versions of everything.

Please check out the INF and let me know if I need to add anything, take out anything, etc. I also would like to know for OSes other than Vista, like XP, 2003, and their x64 versions (including x64 Vista), do I need to include anything other than the co-installer, WinUSBCoInstaller.dll? If I took a Windows XP box, put my inf file and the co-installer dll file in a directory and point to the directory when plugging in the USB device, would things get installed properly?

Peter, I’ll try your experiment to see what works next week and give a response. By the way, I caught your MSDN blog when using the Google “Blog Search” tool (with keywords “winusb” “inf” “umdf”). I got quite a bit of good documentation from following the links on your site. THANKS!

–Brian Hindman

[Version]
Signature = “$Windows NT$”
Class = MyDeviceClass
ClassGuid = {11111111-2222-3333-4444-555555555555}
Provider = %ProviderName%

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

[Manufacturer]
%ProviderName% = MyDevice_WinUSB,NTx86,NTia64,NTamd64

[MyDevice_WinUSB.NTx86]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[MyDevice_WinUSB.NTia64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[MyDevice_WinUSB.NTamd64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

; =================== 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

Hi. Looks like my last post with the working inf file got cut off. Here it is in its full glory:

[Version]
Signature = “$Windows NT$”
Class = MyDeviceClass
ClassGuid = {11111111-2222-3333-4444-555555555555}
Provider = %ProviderName%

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

[Manufacturer]
%ProviderName% = MyDevice_WinUSB,NTx86,NTia64,NTamd64

[MyDevice_WinUSB.NTx86]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[MyDevice_WinUSB.NTia64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[MyDevice_WinUSB.NTamd64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

; =================== 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.Wdf]
KmdfService=WINUSB, WinUsb_Install

[WinUSB_Install]
KmdfLibraryVersion=1.5

[USB_Install.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
HKR,DeviceInterfaceGUIDs,0x00010000,“{55555555-4444-3333-2222-111111111111}”

[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,CoInstallers32,0x00010000,“WinUSBCoInstaller.dll”

[CoInstallers_CopyFiles]
WinUSBCoInstaller.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

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

[Strings]
ProviderName=“MyCompany”
USB\MyDevice.DeviceDesc=“My Device using WinUSB only”
WinUSB_SvcDesc=“WinUSB driver”

You are also going to want to add the DeviceInterfaceGUIDs registry key so that winusb knows what interface guid to use so that your application can find the appropriate device. This part should be documented in the WDK.


From: xxxxx@lists.osr.com on behalf of xxxxx@dalsemi.com
Sent: Sun 12/17/2006 12:20 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Calling WinUSB from an application

Hi Doran/Peter/Daniel/Tim,

Thanks! Very nice of you guys to post! I think you cleared up quite a bit for me. I put most of your suggestions into my inf and finally hit paydirt – a working inf file (see below for a “free” version of the inf file I used). It at least works under Windows Vista Business x86 with my company’s USB device (but with real VIDs/PIDs/GUIDs/Strings). There are a few things missing (the .cat file entry and the driver version entry), but I’ll put them in next week when I get back to my test machine. There is a small duplication with the line “Include=winusb.inf” appearing twice (but for some reason everything still works). I also hope to start testing on Windows XP soon as well as 64-bit versions of everything.

Please check out the INF and let me know if I need to add anything, take out anything, etc. I also would like to know for OSes other than Vista, like XP, 2003, and their x64 versions (including x64 Vista), do I need to include anything other than the co-installer, WinUSBCoInstaller.dll? If I took a Windows XP box, put my inf file and the co-installer dll file in a directory and point to the directory when plugging in the USB device, would things get installed properly?

Peter, I’ll try your experiment to see what works next week and give a response. By the way, I caught your MSDN blog when using the Google “Blog Search” tool (with keywords “winusb” “inf” “umdf”). I got quite a bit of good documentation from following the links on your site. THANKS!

–Brian Hindman

[Version]
Signature = “$Windows NT$”
Class = MyDeviceClass
ClassGuid = {11111111-2222-3333-4444-555555555555}
Provider = %ProviderName%

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

[Manufacturer]
%ProviderName% = MyDevice_WinUSB,NTx86,NTia64,NTamd64

[MyDevice_WinUSB.NTx86]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[MyDevice_WinUSB.NTia64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

[MyDevice_WinUSB.NTamd64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx

; =================== 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


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Brian,

Glad to hear it’s working for you – and thanks for the “golden” INF!

I can think of a couple of things that you might need to add to your INF.

  1. Since the coinstaller binaries are different for the x86 and amd64
    platforms, you should have different CopyFiles sections that call out the
    appropriate DLLs for each platform.

  2. Since XP doesn’t come with WDF installed, I think you need the WDF
    coinstaller to get things to install there. I’ll know for sure later this
    week; that’s my target platform.

-Dan

----- Original Message -----

Subject: RE: Calling WinUSB from an application
From: xxxxx@dalsemi.com
Date: Sun, 17 Dec 2006 03:20:06 -0500 (EST)
X-Message-Number: 3

Hi Doran/Peter/Daniel/Tim,

Thanks! Very nice of you guys to post! I think you cleared up quite a bit
for me. I put most of your suggestions into my inf and finally hit
paydirt – a working inf file (see below for a “free” version of the inf
file I used). It at least works under Windows Vista Business x86 with my
company’s USB device (but with real VIDs/PIDs/GUIDs/Strings). There are a
few things missing (the .cat file entry and the driver version entry), but
I’ll put them in next week when I get back to my test machine. There is a
small duplication with the line “Include=winusb.inf” appearing twice (but
for some reason everything still works). I also hope to start testing on
Windows XP soon as well as 64-bit versions of everything.

Please check out the INF and let me know if I need to add anything, take
out anything, etc. I also would like to know for OSes other than Vista,
like XP, 2003, and their x64 versions (including x64 Vista), do I need to
include anything other than the co-installer, WinUSBCoInstaller.dll? If I
took a Windows XP box, put my inf file and the co-installer dll file in a
directory and point to the directory when plugging in the USB device,
would things get installed properly?

Peter, I’ll try your experiment to see what works next week and give a
response. By the way, I caught your MSDN blog when using the Google “Blog
Search” tool (with keywords “winusb” “inf” “umdf”). I got quite a bit of
good documentation from following the links on your site. THANKS!

–Brian Hindman

Well, supporting WinUSB from both Windows XP and Windows Vista is getting
more interesting.

I have a DLL that talks to our device on XP just fine (less the bulk
endpoints, which I’m going to use WinUSB for). I’ve been building the DLL
using the Windows Server 2003 SP1 DDK (3790.1830). I thought I’d cut over
to the Vista RTM WDK (6000) before tackling WinUSB to make sure there were
no “hiccups”.

Unfortunately, there were. I can build my DLL with the WDK, but it won’t
run on XP now because there are unsatisfied external references to
MSVCRT.DLL:
__CxxFrameHandler3
_except_handler4_common

It looks like these references are due to the new compiler version in the
WDK (Visual Studio 2005 vintage, I presume). On XP systems, the installed
version of MSVCRT.DLL doesn’t include these entry points.

It seems like my only option is to install Visual Studio 2005 and hope the
REDIST directory includes a copy of MSVCRT.DLL that I can install
side-by-side with my DLL. Is that the “official recommended” approach?

And, if so, what do I do when I start building my device co-installer and
“EnumPropPages32” DLLs from the WDK, and still need to support XP systems?
I don’t think WFP will let me update the MSVCRT.DLL in SYSTEM32…

-Dan