Hi all,
I'm trying to get USB Alt Interface. When i tried i'm getting BlueScreen error.
Plz give me your suggesstion.

The Code:

interfaceDescriptor = USBD_ParseConfigurationDescriptorEx(
ConfigurationDescriptor,
ConfigurationDescriptor,
1,
5, -1,-1,-1);

if (!interfaceDescriptor)
{
return STATUS_UNSUCCESSFUL;
}

siz = GET_SELECT_INTERFACE_REQUEST_SIZE(interfaceDescriptor->bNumEndpoints);

urb = ExAllocatePool(NonPagedPool, siz);

if (!urb)
return STATUS_NO_MEMORY;

urb->UrbHeader.Function = URB_FUNCTION_SELECT_INTERFACE;
urb->UrbHeader.Length = (USHORT)siz;
urb->UrbSelectInterface.ConfigurationHandle = urb->UrbSelectConfiguration.ConfigurationHandle;

urb->UrbSelectInterface.Interface.Length = sizeof(struct _USBD_INTERFACE_INFORMATION);

if (interfaceDescriptor->bNumEndpoints > 1)
{
urb->UrbSelectInterface.Interface.Length +=(interfaceDescriptor->bNumEndpoints-1)* sizeof(struct _USBD_PIPE_INFORMATION);
}
urb->UrbSelectInterface.Interface.InterfaceNumber = 1;
urb->UrbSelectInterface.Interface.AlternateSetting = 5;
urb->UrbSelectInterface.Interface.Class = interfaceDescriptor->bInterfaceClass;
urb->UrbSelectInterface.Interface.SubClass = interfaceDescriptor->bInterfaceSubClass;
urb->UrbSelectInterface.Interface.Protocol = interfaceDescriptor->bInterfaceProtocol;
urb->UrbSelectInterface.Interface.NumberOfPipes = interfaceDescriptor->bNumEndpoints;


Interface = &urb->UrbSelectConfiguration.Interface;
( ==> Interface is not stored all information from &urb->UrbSelectConfiguration.Interface.)


for (i=0; i<urb->UrbSelectInterface.Interface.NumberOfPipes; i++)
{
// perform pipe initialization here
// set the transfer size and any pipe flags we use
// USBD sets the rest of the Interface struct members
urb->UrbSelectInterface.Interface.Pipes[i].MaximumTransferSize = USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE;
}

ntStatus = CallUSBD(DeviceObject, urb); (Bluescreen Error is coming)

After calling above function., immediately Bluescreen is appeared.

Blue Scereen Info:

0x0000008E : (0xC0000005, 0xF81AF878,0xF4C81A00, 0x00000000)

USBPORT.SYS ==> Address 0xF81AF878 Base At 0xF8195000, DataStamp 0x3F04CF17


Could you plz any one tell me why this problem is happening. How should i resolve this problem.
--
Thanks & Regards,
NagarajuS

Re: Probelm with Selecting Alt Interface in USB by Ray

Ray
Wed Jul 21 18:00:51 CDT 2004

I'm not sure what CallUSBD does (I can't find that in the DDK, though
maybe I'm just blind), but you might want to consider using
UsbBuildSelectInterfaceRequest rather than building up your own urb.

NagarajuS wrote:

> Hi all,
> I'm trying to get USB Alt Interface. When i tried i'm getting BlueScreen error.
> Plz give me your suggesstion.
>
> The Code:
>
> interfaceDescriptor = USBD_ParseConfigurationDescriptorEx(
> ConfigurationDescriptor,
> ConfigurationDescriptor,
> 1,
> 5, -1,-1,-1);
>
> if (!interfaceDescriptor)
> {
> return STATUS_UNSUCCESSFUL;
> }
>
> siz = GET_SELECT_INTERFACE_REQUEST_SIZE(interfaceDescriptor->bNumEndpoints);
>
> urb = ExAllocatePool(NonPagedPool, siz);
>
> if (!urb)
> return STATUS_NO_MEMORY;
>
> urb->UrbHeader.Function = URB_FUNCTION_SELECT_INTERFACE;
> urb->UrbHeader.Length = (USHORT)siz;
> urb->UrbSelectInterface.ConfigurationHandle = urb->UrbSelectConfiguration.ConfigurationHandle;
>
> urb->UrbSelectInterface.Interface.Length = sizeof(struct _USBD_INTERFACE_INFORMATION);
>
> if (interfaceDescriptor->bNumEndpoints > 1)
> {
> urb->UrbSelectInterface.Interface.Length +=(interfaceDescriptor->bNumEndpoints-1)* sizeof(struct _USBD_PIPE_INFORMATION);
> }
> urb->UrbSelectInterface.Interface.InterfaceNumber = 1;
> urb->UrbSelectInterface.Interface.AlternateSetting = 5;
> urb->UrbSelectInterface.Interface.Class = interfaceDescriptor->bInterfaceClass;
> urb->UrbSelectInterface.Interface.SubClass = interfaceDescriptor->bInterfaceSubClass;
> urb->UrbSelectInterface.Interface.Protocol = interfaceDescriptor->bInterfaceProtocol;
> urb->UrbSelectInterface.Interface.NumberOfPipes = interfaceDescriptor->bNumEndpoints;
>
>
> Interface = &urb->UrbSelectConfiguration.Interface;
> ( ==> Interface is not stored all information from &urb->UrbSelectConfiguration.Interface.)
>
>
> for (i=0; i<urb->UrbSelectInterface.Interface.NumberOfPipes; i++)
> {
> // perform pipe initialization here
> // set the transfer size and any pipe flags we use
> // USBD sets the rest of the Interface struct members
> urb->UrbSelectInterface.Interface.Pipes[i].MaximumTransferSize = USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE;
> }
>
> ntStatus = CallUSBD(DeviceObject, urb); (Bluescreen Error is coming)
>
> After calling above function., immediately Bluescreen is appeared.
>
> Blue Scereen Info:
>
> 0x0000008E : (0xC0000005, 0xF81AF878,0xF4C81A00, 0x00000000)
>
> USBPORT.SYS ==> Address 0xF81AF878 Base At 0xF8195000, DataStamp 0x3F04CF17
>
>
> Could you plz any one tell me why this problem is happening. How should i resolve this problem.

RE: Probelm with Selecting Alt Interface in USB by snraj_2002

snraj_2002
Thu Jul 22 00:45:02 CDT 2004

Hi all,
Herewith i'm giving some more info. Plz tell me where is my mistake. I was solved the first problem., and i'm getting the Bluescreen error at CallUSBD function. Presently i'm using Win XP DDK USB Sample Code.

Code:

NTSTATUS SelectAltInterfaces(IN PDEVICE_OBJECT DeviceObject, IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
{
LONG numberOfInterfaces, interfaceNumber, interfaceindex;
ULONG i;
PURB urb;
PUCHAR pInf;
NTSTATUS ntStatus;
PDEVICE_EXTENSION deviceExtension;
PUSB_INTERFACE_DESCRIPTOR interfaceDescriptor;
PUSBD_INTERFACE_INFORMATION Interface;
PUSB_ENDPOINT_DESCRIPTOR endpointDescriptor = NULL;
ULONG siz = 0;
ULONG length = 0;

urb = NULL;
Interface = NULL;
interfaceDescriptor = NULL;
deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
numberOfInterfaces = ConfigurationDescriptor->bNumInterfaces;
interfaceindex = interfaceNumber = 1;

interfaceDescriptor = USBD_ParseConfigurationDescriptorEx(
ConfigurationDescriptor,
ConfigurationDescriptor,
interfaceindex,
5, -1,-1,-1);

if (!interfaceDescriptor)
{
return STATUS_UNSUCCESSFUL;
}

siz = GET_SELECT_INTERFACE_REQUEST_SIZE(interfaceDescriptor->bNumEndpoints);

urb = ExAllocatePool(NonPagedPool, siz);

if (!urb)
return STATUS_NO_MEMORY;

urb->UrbHeader.Function = URB_FUNCTION_SELECT_INTERFACE;
urb->UrbHeader.Length = (USHORT)siz;
urb->UrbSelectInterface.ConfigurationHandle = urb->UrbSelectConfiguration.ConfigurationHandle;

urb->UrbSelectInterface.Interface.Length = sizeof(struct _USBD_INTERFACE_INFORMATION);

if (interfaceDescriptor->bNumEndpoints > 1)
{
urb->UrbSelectInterface.Interface.Length +=(interfaceDescriptor->bNumEndpoints-1)* sizeof(struct _USBD_PIPE_INFORMATION);
}
urb->UrbSelectInterface.Interface.InterfaceNumber = 1;
urb->UrbSelectInterface.Interface.AlternateSetting = 5;
urb->UrbSelectInterface.Interface.Class = interfaceDescriptor->bInterfaceClass;
urb->UrbSelectInterface.Interface.SubClass = interfaceDescriptor->bInterfaceSubClass;
urb->UrbSelectInterface.Interface.Protocol = interfaceDescriptor->bInterfaceProtocol;
urb->UrbSelectInterface.Interface.NumberOfPipes = interfaceDescriptor->bNumEndpoints;


Interface = &urb->UrbSelectInterface.Interface;

endpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG)interfaceDescriptor + (ULONG)interfaceDescriptor->bLength);

for (i = 0; i < interfaceDescriptor->bNumEndpoints; i++)
{
Interface->Pipes[i].MaximumPacketSize = endpointDescriptor->wMaxPacketSize;
Interface->Pipes[i].EndpointAddress = endpointDescriptor->bEndpointAddress;
Interface->Pipes[i].Interval = endpointDescriptor->bInterval;

switch (endpointDescriptor->bmAttributes)
{
case 0x00: Interface->Pipes[i].PipeType = UsbdPipeTypeControl; break;
case 0x01: Interface->Pipes[i].PipeType = UsbdPipeTypeIsochronous; break;
case 0x02: Interface->Pipes[i].PipeType = UsbdPipeTypeBulk; break;
case 0x03: Interface->Pipes[i].PipeType = UsbdPipeTypeInterrupt; break;
}
endpointDescriptor++;
// PipeHandle is opaque and is not to be filled in
Interface->Pipes[i].MaximumTransferSize = 64*1023;
Interface->Pipes[i].PipeFlags = 0;
}
ntStatus = CALLUSBD(DeviceObject, urb);
if(!ntStatus)
{
KdPrint(("CALLUSBD Failed\n"));
return STATUS_UNSUCCESSFUL;
}
else
{
KdPrint(("CALLUSBD Success\n"));
return STATUS_SUCCESS;
}
} // For Testing purpose i stoped in this stage.

In CALLUSBD function error is accuring at
ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, irp);

Looking forward for your valuable reply.

--
Thanks & Regards,
NagarajuS


"NagarajuS" wrote:

> Hi all,
> I'm trying to get USB Alt Interface. When i tried i'm getting BlueScreen error.
> Plz give me your suggesstion.
>
> The Code:
>
> interfaceDescriptor = USBD_ParseConfigurationDescriptorEx(
> ConfigurationDescriptor,
> ConfigurationDescriptor,
> 1,
> 5, -1,-1,-1);
>
> if (!interfaceDescriptor)
> {
> return STATUS_UNSUCCESSFUL;
> }
>
> siz = GET_SELECT_INTERFACE_REQUEST_SIZE(interfaceDescriptor->bNumEndpoints);
>
> urb = ExAllocatePool(NonPagedPool, siz);
>
> if (!urb)
> return STATUS_NO_MEMORY;
>
> urb->UrbHeader.Function = URB_FUNCTION_SELECT_INTERFACE;
> urb->UrbHeader.Length = (USHORT)siz;
> urb->UrbSelectInterface.ConfigurationHandle = urb->UrbSelectConfiguration.ConfigurationHandle;
>
> urb->UrbSelectInterface.Interface.Length = sizeof(struct _USBD_INTERFACE_INFORMATION);
>
> if (interfaceDescriptor->bNumEndpoints > 1)
> {
> urb->UrbSelectInterface.Interface.Length +=(interfaceDescriptor->bNumEndpoints-1)* sizeof(struct _USBD_PIPE_INFORMATION);
> }
> urb->UrbSelectInterface.Interface.InterfaceNumber = 1;
> urb->UrbSelectInterface.Interface.AlternateSetting = 5;
> urb->UrbSelectInterface.Interface.Class = interfaceDescriptor->bInterfaceClass;
> urb->UrbSelectInterface.Interface.SubClass = interfaceDescriptor->bInterfaceSubClass;
> urb->UrbSelectInterface.Interface.Protocol = interfaceDescriptor->bInterfaceProtocol;
> urb->UrbSelectInterface.Interface.NumberOfPipes = interfaceDescriptor->bNumEndpoints;
>
>
> Interface = &urb->UrbSelectConfiguration.Interface;
> ( ==> Interface is not stored all information from &urb->UrbSelectConfiguration.Interface.)
>
>
> for (i=0; i<urb->UrbSelectInterface.Interface.NumberOfPipes; i++)
> {
> // perform pipe initialization here
> // set the transfer size and any pipe flags we use
> // USBD sets the rest of the Interface struct members
> urb->UrbSelectInterface.Interface.Pipes[i].MaximumTransferSize = USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE;
> }
>
> ntStatus = CallUSBD(DeviceObject, urb); (Bluescreen Error is coming)
>
> After calling above function., immediately Bluescreen is appeared.
>
> Blue Scereen Info:
>
> 0x0000008E : (0xC0000005, 0xF81AF878,0xF4C81A00, 0x00000000)
>
> USBPORT.SYS ==> Address 0xF81AF878 Base At 0xF8195000, DataStamp 0x3F04CF17
>
>
> Could you plz any one tell me why this problem is happening. How should i resolve this problem.
> --
> Thanks & Regards,
> NagarajuS