Problem with passing URB to lower driver

Problem with passing URB to lower driver

Hi All,

I am working on a USB driver for win2k. It seems to be having a problem when I pass a urb from my driver to the next lower driver. I’m calling it with the function IoCallDriver.

and from my debugger I get this error message:

"Second chance exception c0000005 (Access Violation) occurred

Thread stopped."

My driver is based on the ddk bulkusb example, this particular function is based on the ocrwblk.c function: BulkUsb_SingleUrbReadWrite

I think the error has to do with my urb because when I setup my Irp and comment out the line:

pNextStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB;

my function goes thru and returns a status pending result. (with that line in I get the error stated above), Is my assumption that the problem is in the urb that I created?

I have outputted some of the data from the urb and they seem to be in order though, and the way I set everything is identical to the example.

any help would be appreciated,

Matthew Tse


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)

To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Problem with passing URB to lower driverIt seems that you have a problem in the buffer that you want to transfer data with it (Access Violation)
you must include the IOCTL_INTERNAL_USB_SUBMIT_URB line since this is the command of telling the USB bus driver about your request.
so it will not crash by commenting this out because no operation will be performed.
You must check your buffer size and allocation and make sure it is nonpaged pool allocated buffer.
also make sure it large enough to hold your request of data.
Anyy further help you want I will be glad to offer it
thanks

Hesham
----- Original Message -----
From: Mattew Tse
To: NT Developers Interest List
Sent: Thursday, May 31, 2001 3:06 AM
Subject: [ntdev] Problem with passing URB to lower driver

Hi All,

I am working on a USB driver for win2k. It seems to be having a problem when I pass a urb from my driver to the next lower driver. I’m calling it with the function IoCallDriver.

and from my debugger I get this error message:
“Second chance exception c0000005 (Access Violation) occurred
Thread stopped.”

My driver is based on the ddk bulkusb example, this particular function is based on the ocrwblk.c function: BulkUsb_SingleUrbReadWrite

I think the error has to do with my urb because when I setup my Irp and comment out the line:
pNextStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB;
my function goes thru and returns a status pending result. (with that line in I get the error stated above), Is my assumption that the problem is in the urb that I created?

I have outputted some of the data from the urb and they seem to be in order though, and the way I set everything is identical to the example.

any help would be appreciated,

Matthew Tse


You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi

The URB is set like this:

size = sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER);
pUrb = ExAllocatePoolWithTag(NonPagedPool, size, (ULONG) “UraB”);

if (pUrb)
{
// fill the newly allocated block with 0’s
RtlZeroMemory(pUrb, size);

// set urb properties
pUrb->UrbBulkOrInterruptTransfer.Hdr.Length = (USHORT) size;
pUrb->UrbBulkOrInterruptTransfer.Hdr.Function =
URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER;
pUrb->UrbBulkOrInterruptTransfer.PipeHandle = pUSBDPipe->PipeHandle;
pUrb->UrbBulkOrInterruptTransfer.TransferFlags = read ?
USBD_TRANSFER_DIRECTION_IN : 0;
pUrb->UrbBulkOrInterruptTransfer.TransferFlags |= USBD_SHORT_TRANSFER_OK;

pUrb->UrbBulkOrInterruptTransfer.UrbLink = NULL;
pUrb->UrbBulkOrInterruptTransfer.TransferBuffer = NULL;
pUrb->UrbBulkOrInterruptTransfer.TransferBufferMDL = pIrp->MdlAddress;
pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength = length;

}

currently I am trying to write to the USB device, and I’m sure the length
is correct, as TransferBufferLength is the same as the number of bytes to
be written in the write file function.

pIrp is created by the I/O Manager and as I am using DO_DIRECT_IO,so I
think the Mdl descibes a user-mode buffer. does this mean that it is
nonpaged since user mode memory is pagable? If so is there a way to change
it to be nonpaged?

regards

Matthew Tse


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com