diff --git a/reactos/drivers/ksfilter/ks/device.c b/reactos/drivers/ksfilter/ks/device.c index 49d5787820e..a382c4e87d3 100644 --- a/reactos/drivers/ksfilter/ks/device.c +++ b/reactos/drivers/ksfilter/ks/device.c @@ -605,6 +605,16 @@ IKsDevice_Create( /* get device header */ DeviceHeader = DeviceExtension->DeviceHeader; + if (IoStack->FileObject->FileName.Buffer == NULL) + { + // ReactOS PnPMgr still sucks + ASSERT(IoStack->FileObject->FileName.Length == 0); + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + DPRINT1("ReactOS PnP hack\n"); + return STATUS_SUCCESS; + } + /* acquire list lock */ IKsDevice_fnAcquireDevice((IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown); diff --git a/reactos/drivers/usb/usbhub/fdo.c b/reactos/drivers/usb/usbhub/fdo.c index 0da1934b4d0..ec56674fc09 100644 --- a/reactos/drivers/usb/usbhub/fdo.c +++ b/reactos/drivers/usb/usbhub/fdo.c @@ -1198,6 +1198,10 @@ CreateUsbChildDeviceObject( UsbChildExtension->ParentDeviceObject = UsbHubDeviceObject; UsbChildExtension->PortNumber = PortId; + // copy device interface + RtlCopyMemory(&UsbChildExtension->DeviceInterface, &HubDeviceExtension->DeviceInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2)); + + // // Create the UsbDeviceObject // @@ -1212,6 +1216,12 @@ CreateUsbChildDeviceObject( goto Cleanup; } + // copy device interface + RtlCopyMemory(&UsbChildExtension->DeviceInterface, &HubDeviceExtension->DeviceInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2)); + + // FIXME replace buscontext + UsbChildExtension->DeviceInterface.BusContext = UsbChildExtension->UsbDeviceHandle; + // // Initialize UsbDevice // @@ -1807,6 +1817,9 @@ USBHUB_FdoStartDevice( HubDeviceExtension->PipeHandle = ConfigUrb->UrbSelectConfiguration.Interface.Pipes[0].PipeHandle; DPRINT("Configuration Handle %x\n", HubDeviceExtension->ConfigurationHandle); + FDO_QueryInterface(DeviceObject, &HubDeviceExtension->DeviceInterface); + + // free urb ExFreePool(ConfigUrb); diff --git a/reactos/drivers/usb/usbhub/misc.c b/reactos/drivers/usb/usbhub/misc.c index a9a3f0ec6be..f81d424ad9a 100644 --- a/reactos/drivers/usb/usbhub/misc.c +++ b/reactos/drivers/usb/usbhub/misc.c @@ -208,3 +208,84 @@ SubmitRequestToRootHub( return Status; } + +NTSTATUS +NTAPI +FDO_QueryInterfaceCompletionRoutine( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PVOID Context) +{ + /* Set event */ + KeSetEvent((PRKEVENT)Context, 0, FALSE); + + /* Completion is done in the HidClassFDO_QueryCapabilities routine */ + return STATUS_MORE_PROCESSING_REQUIRED; +} + +NTSTATUS +FDO_QueryInterface( + IN PDEVICE_OBJECT DeviceObject, + IN OUT PUSB_BUS_INTERFACE_USBDI_V2 Interface) +{ + PIRP Irp; + KEVENT Event; + NTSTATUS Status; + PIO_STACK_LOCATION IoStack; + PHUB_DEVICE_EXTENSION HubDeviceExtension; + + /* Get device extension */ + HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + ASSERT(HubDeviceExtension->Common.IsFDO); + + /* Init event */ + KeInitializeEvent(&Event, NotificationEvent, FALSE); + + /* Now allocte the irp */ + Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE); + if (!Irp) + { + /* No memory */ + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Get next stack location */ + IoStack = IoGetNextIrpStackLocation(Irp); + + /* Init stack location */ + IoStack->MajorFunction = IRP_MJ_PNP; + IoStack->MinorFunction = IRP_MN_QUERY_INTERFACE; + IoStack->Parameters.QueryInterface.Interface = (PINTERFACE)Interface; + IoStack->Parameters.QueryInterface.InterfaceType = &USB_BUS_INTERFACE_USBDI_GUID; + IoStack->Parameters.QueryInterface.Version = USB_BUSIF_USBDI_VERSION_2; + IoStack->Parameters.QueryInterface.Size = sizeof(USB_BUS_INTERFACE_USBDI_V2); + + + /* Set completion routine */ + IoSetCompletionRoutine(Irp, + FDO_QueryInterfaceCompletionRoutine, + (PVOID)&Event, + TRUE, + TRUE, + TRUE); + + /* Pnp irps have default completion code */ + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + + /* Call lower device */ + Status = IoCallDriver(HubDeviceExtension->LowerDeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait for completion */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + } + + /* Get status */ + Status = Irp->IoStatus.Status; + + /* Complete request */ + IoFreeIrp(Irp); + + /* Done */ + return Status; +} diff --git a/reactos/drivers/usb/usbhub/pdo.c b/reactos/drivers/usb/usbhub/pdo.c index 28b4c7a4676..21bea27bf46 100644 --- a/reactos/drivers/usb/usbhub/pdo.c +++ b/reactos/drivers/usb/usbhub/pdo.c @@ -713,6 +713,21 @@ USBHUB_PdoHandlePnp( Information = 0; break; } + case IRP_MN_QUERY_INTERFACE: + { + DPRINT1("IRP_MN_QUERY_INTERFACE\n"); + if (IsEqualGUIDAligned(Stack->Parameters.QueryInterface.InterfaceType, &USB_BUS_INTERFACE_USBDI_GUID)) + { + DPRINT1("USB_BUS_INTERFACE_USBDI_GUID\n"); + RtlCopyMemory(Stack->Parameters.QueryInterface.Interface, &UsbChildExtension->DeviceInterface, Stack->Parameters.QueryInterface.Size); + Status = STATUS_SUCCESS; + break; + } + + // pass irp down + IoSkipCurrentIrpStackLocation(Irp); + return IoCallDriver(UsbChildExtension->ParentDeviceObject, Irp); + } default: { DPRINT1("PDO IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction); diff --git a/reactos/drivers/usb/usbhub/usbhub.h b/reactos/drivers/usb/usbhub/usbhub.h index f221ec4f17b..23337755e74 100644 --- a/reactos/drivers/usb/usbhub/usbhub.h +++ b/reactos/drivers/usb/usbhub/usbhub.h @@ -67,6 +67,7 @@ typedef struct _HUB_CHILDDEVICE_EXTENSION USB_DEVICE_DESCRIPTOR DeviceDesc; PUSB_CONFIGURATION_DESCRIPTOR FullConfigDesc; UNICODE_STRING SymbolicLinkName; + USB_BUS_INTERFACE_USBDI_V2 DeviceInterface; } HUB_CHILDDEVICE_EXTENSION, *PHUB_CHILDDEVICE_EXTENSION; typedef struct _HUB_DEVICE_EXTENSION @@ -100,6 +101,8 @@ typedef struct _HUB_DEVICE_EXTENSION USBD_CONFIGURATION_HANDLE ConfigurationHandle; USBD_PIPE_HANDLE PipeHandle; PVOID RootHubHandle; + USB_BUS_INTERFACE_USBDI_V2 DeviceInterface; + UNICODE_STRING SymbolicLinkName; } HUB_DEVICE_EXTENSION, *PHUB_DEVICE_EXTENSION; @@ -149,6 +152,11 @@ SubmitRequestToRootHub( OUT PVOID OutParameter1, OUT PVOID OutParameter2); +NTSTATUS +FDO_QueryInterface( + IN PDEVICE_OBJECT DeviceObject, + IN OUT PUSB_BUS_INTERFACE_USBDI_V2 Interface); + // pdo.c NTSTATUS USBHUB_PdoHandlePnp(