USBD_UrbAllocate function

The USBD_UrbAllocate routine allocates a USB Request Block (URB).


  _Out_ PURB        *Urb



USBD handle that is retrieved by the client driver in a previous call to the USBD_CreateHandle routine.


Pointer to the newly allocated URB structure. All members of the structure are set to zero. The client driver must free the URB when the driver has finished using it by calling USBD_UrbFree.

Return Value

The USBD_UrbAllocate routine returns STATUS_SUCCESS if the request is successful. Otherwise, USBD_UrbAllocate sets Urb to NULL and returns a failure code.

Possible values include, but are not limited to, STATUS_INVALID_PARAMETER, which indicates the caller passed in NULL to USBDHandle or Urb.


The USBD_UrbAllocate routine enables the underlying USB driver stack to allocate an opaque URB context for the URB. By using the URB context, the USB driver stack can process requests more efficiently and reliably. Those optimizations are provided by the USB 3.0 driver stack that is included in Windows 8. The client driver cannot access the URB context; the context is used internally by the bus driver.

Regardless of the USB protocol version of the host controller, the underlying USB driver stack, the target operating system, the client driver must always call USBD_UrbAllocate to allocate an URB structure. USBD_UrbAllocate replaces earlier allocation mechanisms, such as ExAllocatePoolWithTag, or allocating them on the stack.

The client driver must not use USBD_UrbAllocate,

For more information about replacement routines, see Allocating and Building URBs.

You must call USBD_UrbFree to release the URB allocated by USBD_UrbAllocate.

The following code example shows how to allocate, submit, and release a URB. The example submits the URB synchronously.


Windows Driver kit version
Target platform Desktop
Minimum KMDF version
Minimum UMDF version
Header usbdlib.h
DDI compliance rules

See Also

Allocating and Building URBs
Sending Requests to a USB Device

Send comments about this topic to Microsoft