Inconsistency in Set Interface call in Usb audio Client driver.

hi

i am implementing a USB audio client driver in XP.

there is a inconsistency problem for my set interface function.

if i check it for continue three or four time it works but after that its not work.

in my set interface function i am doing this

MySetInterface(IN PKSDEVICE m_Device,UINT8 interface_no,UINT8 alt_setting)
{
PURB urb;
NTSTATUS status=STATUS_SUCCESS;
RtlZeroMemory(&urb,sizeof(struct _URB));

UsbBuildSelectInterfaceRequest(&urb, (USHORT)GET_SELECT_INTERFACE_REQUEST_SIZE(1),
config_handle,
interface_no,
alt_setting);

urb.UrbSelectInterface.Interface.Length = GET_USBD_INTERFACE_SIZE(1);
urb.UrbSelectInterface.Interface.Pipes[0].MaximumTransferSize = USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE;

status = SendUrb(m_Device, &urb)

if (!NT_SUCCESS(status))
{
KdPrint((“SetInterface:Failed to fetch config \n”));

}
pipe_handle2=urb.UrbSelectInterface.Interface.Pipes[0].PipeHandle;
ULONG pt = urb.UrbSelectInterface.Interface.Pipes[0].PipeType;

return status;

}

and in my sendUrb function

SendUrb (
IN PKSDEVICE mdevice,
IN PURB urb,
)
{
PAGED_CODE();
PURB urb;
ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);

KEVENT event;
KeInitializeEvent(&event,
NotificationEvent,
FALSE);

IO_STATUS_BLOCK iostatus;

PIRP Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB,
mdevice->NextDeviceObject ,
NULL,
0,
NULL,
0,
TRUE,
&event,
&iostatus);

if (!Irp)
{
KdPrint(( " - Unable to allocate IRP for sending URB\n"));
return STATUS_INSUFFICIENT_RESOURCES;
}

PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);
stack->Parameters.Others.Argument1 = (PVOID) urb;
NTSTATUS status = IoCallDriver(mdevice->NextDeviceObject,
Irp);

if (status == STATUS_PENDING)
{

KeWaitForSingleObject(&event,
Executive,
KernelMode,
FALSE,
NULL);

status = iostatus.Status;

}

return status;
}

the problem is that when its call sendurb.
in sendurb i call IoCallDriver(mdevice->NextDeviceObject,
Irp);

some times its not goes further.

can anyone knows why its like that??

xxxxx@lntinfotech.com wrote:

i am implementing a USB audio client driver in XP.

there is a inconsistency problem for my set interface function.

if i check it for continue three or four time it works but after that its not work.

What happens? What exactly do you see? An error code?

in my set interface function i am doing this

MySetInterface(IN PKSDEVICE m_Device,UINT8 interface_no,UINT8 alt_setting)
{
PURB urb;
NTSTATUS status=STATUS_SUCCESS;
RtlZeroMemory(&urb,sizeof(struct _URB));

Is this an exact cut-and-paste from your code? If so, I see the problem
right now. You need:
URB urb;
not
PURB urb;

You’re only allocating 4 bytes of space, then trying to write something
like 48 bytes of data into it.


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

Sorry Tim
its not PURB urb in my code i posted this line wrong.

actually its URB urb in my code.

some time i got this

*** Fatal System Error: 0x00000019 (0x00000020,0x839EFFF9,0x839F07B9,0x0AF86E07)

some time access violation error

some time nothing its wait after the IoCallDriver driver.

still i am not able to figure out the problem.

xxxxx@lntinfotech.com wrote:

its not PURB urb in my code i posted this line wrong.

actually its URB urb in my code.

So, you’re asking us to debug your code, but you don’t show us the real
code?

some time i got this

*** Fatal System Error: 0x00000019 (0x00000020,0x839EFFF9,0x839F07B9,0x0AF86E07)

some time access violation error

some time nothing its wait after the IoCallDriver driver.

still i am not able to figure out the problem.

You are overwriting memory somewhere – running off the end of a buffer,
writing on freed memory, using a stack buffer after the routine had
returned – that kind of thing. That is a tricky kind of problem to
chase down. Show us the real code, and I’ll take another look.


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