How to retrieve USBD_INTERFACE_HANDLE?

Hi all,
I am working one usb composite driver. In my composite driver while handling URB_FUNCTION_SELECT_CONFIGURATION i need to fill up USBD_INTERFACE_INFORMATION structure as well as USBD_PIPE_INFORMATION stucture. There i am suppose to give handles for interfaces as well as for respective pipes. I could able to retrieve pipe handle by calling WdfUsbTargetPipeWdmGetPipeHandle(pipe);
But i could not find any function for retrieving interface handle.
Does WdfUsbTargetDeviceGetInterface work as interface handle.?

Please let me know.

Amit

xxxxx@gmail.com wrote:

I am working one usb composite driver. In my composite driver while handling URB_FUNCTION_SELECT_CONFIGURATION i need to fill up USBD_INTERFACE_INFORMATION structure as well as USBD_PIPE_INFORMATION stucture. There i am suppose to give handles for interfaces as well as for respective pipes. I could able to retrieve pipe handle by calling WdfUsbTargetPipeWdmGetPipeHandle(pipe);
But i could not find any function for retrieving interface handle.
Does WdfUsbTargetDeviceGetInterface work as interface handle.?

Haven’t you looked through the source code for usb.h in the DDK? There
are comments in all of these structures. The Class, SubClass, Protocol,
InterfaceHandle, and NumberOfPipes fields in USBD_INTERFACE_INFORMATION
are all outputs from that request. USBD will set them, not you. All
you set are InterfaceNumber and AlternateSetting.

By the same token, YOU are acting as USBD for the clients above you.
That means when a client app sends a SELECT_CONFIGURATION or
SELECT_INTERFACE request to you, YOU have to fill in those fields. You
can use whatever you want for the InterfaceHandle in that case – it’s a
private conversation between you and your client. It might be
convenient to use the same InterfaceHandle you got from below, but
that’s not required.


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

Hi Tim,

Actually i am setting value returned by WdfUsbTargetDeviceGetInterface , to InterfaceHandle , member of USBD_INTERFACE_INFORMATION received from select config urb. Code snippet as shown below:
urb->ConfigurationHandle=
WdfUsbTargetDeviceWdmGetConfigurationHandle(deviceData->UsbDevice);

urb=(struct _URB_SELECT_CONFIGURATION*)params.Parameters.Others.Arg1;
interfaceHandle=
WdfUsbTargetDeviceGetInterface (fdoDeviceData->UsbDevice,urb->Interface.InterfaceNumber);

WdfUsbInterfaceGetDescriptor (interfaceHandle, 0, &usbInterfaceDesc );

urb->Interface.InterfaceHandle=interfaceHandle;
urb->Interface.AlternateSetting =usbInterfaceDesc.bAlternateSetting;
urb->Interface.Class =usbInterfaceDesc.bInterfaceClass;
urb->Interface.SubClass =usbInterfaceDesc.bInterfaceSubClass;
urb->Interface.Protocol =usbInterfaceDesc.bInterfaceProtocol;

for(i=0;i{
WDF_USB_PIPE_INFORMATION_INIT (&pipeInfo );
pipe = WdfUsbInterfaceGetConfiguredPipe (interfaceHandle,i,&pipeInfo );

urb->Interface.Pipes[i].MaximumPacketSize =(USHORT )pipeInfo.MaximumPacketSize;
urb->Interface.Pipes[i].EndpointAddress =pipeInfo.EndpointAddress;
urb->Interface.Pipes[i].Interval =pipeInfo.Interval ;

if(pipeInfo.PipeType ==WdfUsbPipeTypeInterrupt)
urb->Interface.Pipes[i].PipeType =UsbdPipeTypeInterrupt ;

urb->Interface.Pipes[i].MaximumTransferSize =pipeInfo.MaximumTransferSize ;
urb->Interface.Pipes[i].PipeHandle =WdfUsbTargetPipeWdmGetPipeHandle(pipe);

}

In this case i could see configuration pipe handle in my child driver when i print them but when i try to print value returned by WdfUsbTargetDeviceGetInterface for same interface number that value is coming out to be different.

Amit

The WDFUSBINTERFACE is not a USBD_INTERFACE_HANDLE. WDFUSBINTERFACE has a function which lets you select a setting on an interface, figure out how to use that function instead of rolling your own URB

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, March 10, 2010 8:53 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] How to retrieve USBD_INTERFACE_HANDLE?

Hi Tim,

Actually i am setting value returned by WdfUsbTargetDeviceGetInterface , to InterfaceHandle , member of USBD_INTERFACE_INFORMATION received from select config urb. Code snippet as shown below:
urb->ConfigurationHandle=
WdfUsbTargetDeviceWdmGetConfigurationHandle(deviceData->UsbDevice);

urb=(struct _URB_SELECT_CONFIGURATION*)params.Parameters.Others.Arg1;
interfaceHandle=
WdfUsbTargetDeviceGetInterface (fdoDeviceData->UsbDevice,urb->Interface.InterfaceNumber);

WdfUsbInterfaceGetDescriptor (interfaceHandle, 0, &usbInterfaceDesc );

urb->Interface.InterfaceHandle=interfaceHandle;
urb->Interface.AlternateSetting =usbInterfaceDesc.bAlternateSetting;
urb->Interface.Class =usbInterfaceDesc.bInterfaceClass;
urb->Interface.SubClass =usbInterfaceDesc.bInterfaceSubClass;
urb->Interface.Protocol =usbInterfaceDesc.bInterfaceProtocol;

for(i=0;i{
WDF_USB_PIPE_INFORMATION_INIT (&pipeInfo );
pipe = WdfUsbInterfaceGetConfiguredPipe (interfaceHandle,i,&pipeInfo );

urb->Interface.Pipes[i].MaximumPacketSize =(USHORT )pipeInfo.MaximumPacketSize;
urb->Interface.Pipes[i].EndpointAddress =pipeInfo.EndpointAddress;
urb->Interface.Pipes[i].Interval =pipeInfo.Interval ;

if(pipeInfo.PipeType ==WdfUsbPipeTypeInterrupt)
urb->Interface.Pipes[i].PipeType =UsbdPipeTypeInterrupt ;

urb->Interface.Pipes[i].MaximumTransferSize =pipeInfo.MaximumTransferSize ;
urb->Interface.Pipes[i].PipeHandle =WdfUsbTargetPipeWdmGetPipeHandle(pipe);

}

In this case i could see configuration pipe handle in my child driver when i print them but when i try to print value returned by WdfUsbTargetDeviceGetInterface for same interface number that value is coming out to be different.

Amit


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

Hi Doron,
Is there any way to retrieve interface handles set by usb hub driver. As i am calling WdfUsbTargetDeviceSelectConfig in composite driver. So i could get configuration handle and pipe handle by doing this. As child drivers are expecting interface handle of type USBD_INTERFACE_HANDLE and i am assigning handle of type WDFUSBINTERFACE , so there are some request from child driver which are getting failed when it arrives to that interface. e.g. Set Dtr is getting failed with STATUS_INVALID_PARAMETER in Modem driver .

Amit

xxxxx@gmail.com wrote:

Is there any way to retrieve interface handles set by usb hub driver. As i am calling WdfUsbTargetDeviceSelectConfig in composite driver. So i could get configuration handle and pipe handle by doing this. As child drivers are expecting interface handle of type USBD_INTERFACE_HANDLE and i am assigning handle of type WDFUSBINTERFACE , so there are some request from child driver which are getting failed when it arrives to that interface.

The value that you give to your child devices as an interface handle is
a private communication between you and them. You can send them the
WDFUSBINTERFACE handle, if you want, as long as you intercept all of
their requests on the way back down and rewrite them.

Now, if you expect to pass your client requests directly through to your
parent, then you have a problem. In that case, you may have to do the
use WdfUsgTargetDeviceSelectConfigTypeUrb and create the URB yourself.


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