diff --git a/drivers/ksfilter/swenum/swenum.c b/drivers/ksfilter/swenum/swenum.c index cbff01509de..2f3c46ecfa5 100644 --- a/drivers/ksfilter/swenum/swenum.c +++ b/drivers/ksfilter/swenum/swenum.c @@ -43,6 +43,9 @@ SwDispatchPnp( PIO_STACK_LOCATION IoStack; PDEVICE_OBJECT PnpDeviceObject = NULL; + /* get current stack location */ + IoStack = IoGetCurrentIrpStackLocation(Irp); + /* check if the device object is a child device */ Status = KsIsBusEnumChildDevice(DeviceObject, &ChildDevice); @@ -55,10 +58,30 @@ SwDispatchPnp( return Status; } + DPRINT1("SwDispatchPnp ChildDevice %u Request %x\n", ChildDevice, IoStack->MinorFunction); + /* let ks handle it */ Status = KsServiceBusEnumPnpRequest(DeviceObject, Irp); - if (!NT_SUCCESS(Status)) + /* check if the request was for a pdo */ + if (!ChildDevice) + { + if (Status != STATUS_NOT_SUPPORTED) + { + /* store result */ + Irp->IoStatus.Status = Status; + } + + /* complete request */ + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + /* done */ + return Status; + } + + DPRINT1("SwDispatchPnp KsServiceBusEnumPnpRequest Status %x\n", Status); + + if (NT_SUCCESS(Status)) { /* invalid request or not supported */ Irp->IoStatus.Status = Status; @@ -69,6 +92,8 @@ SwDispatchPnp( /* get bus enum pnp object */ Status = KsGetBusEnumPnpDeviceObject(DeviceObject, &PnpDeviceObject); + DPRINT1("SwDispatchPnp KsGetBusEnumPnpDeviceObject Status %x\n", Status); + /* check for success */ if (!NT_SUCCESS(Status)) { @@ -89,11 +114,49 @@ SwDispatchPnp( /* delete the device */ IoDeleteDevice(DeviceObject); } + else + { + if (IoStack->MinorFunction == IRP_MN_QUERY_RESOURCES || IoStack->MinorFunction == IRP_MN_QUERY_RESOURCE_REQUIREMENTS) + { + /* no resources required */ + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_SUCCESS; - /* skip current location */ - IoSkipCurrentIrpStackLocation(Irp); - /* call the pnp device object */ - return IoCallDriver(PnpDeviceObject, Irp); + /* skip current location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* call the pnp device object */ + return IoCallDriver(PnpDeviceObject, Irp); + } + + if (IoStack->MajorFunction == IRP_MN_QUERY_PNP_DEVICE_STATE) + { + /* device cannot be disabled */ + Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE; + Irp->IoStatus.Status = STATUS_SUCCESS; + + /* skip current location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* call the pnp device object */ + return IoCallDriver(PnpDeviceObject, Irp); + } + + if (Status == STATUS_NOT_SUPPORTED) + { + /* skip current location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* call the pnp device object */ + return IoCallDriver(PnpDeviceObject, Irp); + } + } + + /* complete the request */ + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return Status; } NTSTATUS @@ -149,7 +212,7 @@ SwDispatchDeviceControl( IN PIRP Irp) { PIO_STACK_LOCATION IoStack; - NTSTATUS Status = STATUS_SUCCESS; + NTSTATUS Status; /* get current stack location */ IoStack = IoGetCurrentIrpStackLocation(Irp); @@ -158,16 +221,25 @@ SwDispatchDeviceControl( { /* install interface */ Status = KsInstallBusEnumInterface(Irp); + DPRINT1("SwDispatchDeviceControl IOCTL_SWENUM_INSTALL_INTERFACE %x\n", Status); } else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_SWENUM_REMOVE_INTERFACE) { /* remove interface */ Status = KsRemoveBusEnumInterface(Irp); + DPRINT1("SwDispatchDeviceControl IOCTL_SWENUM_REMOVE_INTERFACE %x\n", Status); + } else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_SWENUM_GET_BUS_ID) { /* get bus id */ - return KsGetBusEnumIdentifier(Irp); + Status = KsGetBusEnumIdentifier(Irp); + DPRINT1("SwDispatchDeviceControl IOCTL_SWENUM_GET_BUS_ID %x\n", Status); + } + else + { + DPRINT1("SwDispatchDeviceControl Unknown IOCTL %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode); + Status = STATUS_INVALID_PARAMETER; } /* store result */ @@ -193,6 +265,8 @@ SwDispatchCreate( /* check if the device object is a child device */ Status = KsIsBusEnumChildDevice(DeviceObject, &ChildDevice); + DPRINT1("SwDispatchCreate %x\n", Status); + /* check for success */ if (NT_SUCCESS(Status)) { @@ -205,6 +279,7 @@ SwDispatchCreate( } /* perform the create request */ Status = KsServiceBusEnumCreateRequest(DeviceObject, Irp); + DPRINT1("SwDispatchCreate %x\n", Status); } /* check the irp is pending */ @@ -246,7 +321,6 @@ SwAddDevice( PDEVICE_OBJECT FunctionalDeviceObject; DPRINT1("SWENUM AddDevice\n"); - DbgBreakPoint(); /* create the device */ Status = IoCreateDevice(DriverObject, sizeof(KSDEVICE_HEADER), NULL, FILE_DEVICE_BUS_EXTENDER, 0, FALSE, &FunctionalDeviceObject); @@ -307,7 +381,6 @@ DriverEntry( DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = SwDispatchSystemControl; DPRINT1("SWENUM loaded\n"); - DbgBreakPoint(); return STATUS_SUCCESS; }