获取 USBCAMD2 功能

必须先获取指向 USBCAMD_INTERFACE 结构的指针,然后才能使用新的 USBCAMD2 功能。 若要获取指针,请在 AdapterReceivePacket 回调函数中从相机微型驱动程序的SRB_INITIALIZATION_COMPLETE处理程序生成并发送IRP_MN_QUERY_INTERFACE请求。 USBCAMD2 微型驱动程序库处理此 IRP,并将USBCAMD_INTERFACE类型的直接调用接口返回到相机微型驱动程序。 接口实质上是一个函数指针表。

以下代码演示如何从相机微型驱动程序生成和发送IRP_MN_QUERY_INTERFACE请求:

KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = IoBuildSynchronousFsdRequest(
    IRP_MJ_PNP,
    pDeviceObject,
    NULL,
    0,
    NULL,
    &Event,
    &IoStatusBlock);

if (NULL != Irp)
{
    Irp->RequestorMode = KernelMode;
    IrpStackNext = IoGetNextIrpStackLocation(Irp);
    //
    // Create an interface query out of the Irp.
    //
    IrpStackNext->MinorFunction = IRP_MN_QUERY_INTERFACE;
    IrpStackNext->Parameters.QueryInterface.InterfaceType = (GUID*)&GUID_USBCAMD_INTERFACE;
    IrpStackNext->Parameters.QueryInterface.Size = sizeof(*pUsbcamdInterface);
    IrpStackNext->Parameters.QueryInterface.Version = USBCAMD_VERSION_200;
    IrpStackNext->Parameters.QueryInterface.Interface = (PINTERFACE)pUsbcamdInterface;
    IrpStackNext->Parameters.QueryInterface.InterfaceSpecificData = NULL;
    Status = IoCallDriver(pDeviceObject, Irp);
    if (STATUS_PENDING == Status)
    {
        //
        // This  waits using KernelMode so that the stack, and therefore the
        // event on that stack, is not paged out.
        //
        KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
        Status = IoStatusBlock.Status;
    }

}
else
{
    Status = STATUS_INSUFFICIENT_RESOURCES;
}