USBD_AssignUrbToIoStackLocation function

The USBD_AssignUrbToIoStackLocation routine is called by a client driver to associate an URB with the IRP's next stack location.


void USBD_AssignUrbToIoStackLocation(
  _In_ USBD_HANDLE        USBDHandle,
  _In_ PIO_STACK_LOCATION IoStackLocation,
  _In_ PURB               Urb



A USBD handle that is retrieved in a previous call to the USBD_CreateHandle routine.


Pointer to the IRP's next stack location (IO_STACK_LOCATION). The client driver received a pointer to the stack location in a previous call to IoGetNextIrpStackLocation.


Pointer to the URB structure that is allocated by USBD_UrbAllocate, USBD_IsochUrbAllocate, USBD_SelectConfigUrbAllocateAndBuild, or USBD_SelectInterfaceUrbAllocateAndBuild.

Return Value

This routine does not return a value.


If the client driver allocated an URB by calling USBD_UrbAllocate, USBD_IsochUrbAllocate, USBD_SelectConfigUrbAllocateAndBuild, or USBD_SelectInterfaceUrbAllocateAndBuild, then the driver must call USBD_AssignUrbToIoStackLocation to associate the URB with IO_STACK_LOCATION associated with the IRP. For URBs that are allocated by those routines, USBD_AssignUrbToIoStackLocation replaces setting Parameters.Others.Argument1 of IO_STACK_LOCATION to the URB. (see IOCTL_INTERNAL_USB_SUBMIT_URB).

The client driver must not call USBD_AssignUrbToIoStackLocation for an URB that is allocated by using other mechanisms, such as allocating the URB on the stack. Otherwise, the USB driver stack generates a bugcheck.

The client driver must call USBD_AssignUrbToIoStackLocation before calling IoCallDriver to send the request. USBD_AssignUrbToIoStackLocation populates the IRP's next stack location with the URB. The routine also updates the FileObject member of IO_STACK_LOCATION.

For a code example, see How to Submit an URB.


Windows version Requires WDK for Windows 8. Targets Windows Vista and later versions of the Windows operating system.
Target Platform Desktop
Header usbdlib.h
Library Usbdex.lib

See Also




How to Submit an URB