Querying for Bus Driver Interfaces

Instead of using the I/O Request Packet (IRP) mechanism, a USB client driver can get a reference to a bus driver interface and use it to access bus driver routines.

Using a bus driver interface gives the client driver several advantages:

  • It can use the interface's services without allocating an IRP.

  • It can call the interface's routines at raised IRQL.

In Windows Vista USB, client drivers can themselves expose an interface to assist the USB Common Class Generic Parent Driver in defining interface collections for the device it manages.

To get a bus driver interface, the client driver must send an IRP_MN_QUERY_INTERFACE request to the bus driver. In your client driver:

  1. Create an IRP of the type IRP_MN_QUERY_INTERFACE in the next stack location.
    
    irpstack = IoGetNextIrpStackLocation(irp);
    irpstack->MajorFunction= IRP_MJ_PNP;
    irpstack->MinorFunction= IRP_MN_QUERY_INTERFACE;
    
    
  2. Allocate memory for the interface and make the stack point to the new memory. For example to allocate memory for the USB_BUS_INTERFACE_USBDI_V0 interface:
    
    irpstack->Parameters.QueryInterface.Interface = (USB_BUS_INTERFACE_USBDI_V0) newly allocated interface buffer;
    
    
  3. Set InterfaceSpecificData to NULL.
    
    irpstack->Parameters.QueryInterface.InterfaceSpecificData = NULL;
    
    
  4. Initialize the IRP stack with the appropriate interface GUID, the size of the interface, and the version of the interface.
    
    irpstack->Parameters.QueryInterface.InterfaceType = &USB_BUS_INTERFACE_USBDI_GUID;
    irpstack->Parameters.QueryInterface.Size = sizeof(USB_BUS_INTERFACE_USBDI_V0);
    irpstack->Parameters.QueryInterface.Version = USB_BUSIF_USBDI_VERSION_0;
    ntStatus = IoCallDriver(PDO that the client passes URBs to, irp);
    
    
  5. Call IoCallDriver to pass the query interface IRP down the stack.
    
    
    ntStatus = IoCallDriver(PDO that the client passes URBs to, irp);
    
    

For further information about USB interfaces see Bus Driver Interface Routines for USB Client Drivers.

Related topics

Developing Windows client drivers for USB devices

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.