Legacy device objects created for USB keyboard and mouse support should be treated...
authorHervé Poussineau <hpoussin@reactos.org>
Fri, 5 May 2006 10:12:59 +0000 (10:12 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Fri, 5 May 2006 10:12:59 +0000 (10:12 +0000)
svn path=/trunk/; revision=21797

reactos/drivers/usb/miniport/common/fdo.c
reactos/drivers/usb/miniport/common/main.c

index 3ccaf63..ed642ce 100644 (file)
@@ -211,7 +211,11 @@ UsbMpPnpFdo(
        {
                case IRP_MN_START_DEVICE: /* 0x00 */
                {
-                       Status = ForwardIrpAndWait(DeviceObject, Irp);
+                       if (((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->NextDeviceObject != NULL)
+                               /* HACK due to the lack of lower device for legacy USB keyboard and mouse */
+                               Status = ForwardIrpAndWait(DeviceObject, Irp);
+                       else
+                               Status = STATUS_SUCCESS;
                        if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
                                Status = UsbMpFdoStartDevice(DeviceObject, Irp);
                        break;
@@ -227,7 +231,11 @@ UsbMpPnpFdo(
                case IRP_MN_STOP_DEVICE: /* 0x04 */
                case IRP_MN_SURPRISE_REMOVAL: /* 0x17 */
                {
-                       Status = ForwardIrpAndWait(DeviceObject, Irp);
+                       if (((PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->NextDeviceObject != NULL)
+                               /* HACK due to the lack of lower device for legacy USB keyboard and mouse */
+                               Status = ForwardIrpAndWait(DeviceObject, Irp);
+                       else
+                               Status = STATUS_SUCCESS;
                        if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
                                Status = STATUS_SUCCESS;
                        IoDeleteDevice(DeviceObject); // just delete device for now
index b401031..e42f795 100644 (file)
@@ -118,6 +118,7 @@ AddDevice_Keyboard(
        IN PDEVICE_OBJECT Pdo)
 {
        UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\KeyboardPortUSB");
+       PUSBMP_DEVICE_EXTENSION DeviceExtension;
        PDEVICE_OBJECT Fdo;
        NTSTATUS Status;
 
@@ -129,7 +130,7 @@ AddDevice_Keyboard(
        }
 
        Status = IoCreateDevice(DriverObject,
-               8, // debug
+               sizeof(USBMP_DEVICE_EXTENSION),
                &DeviceName,
                FILE_DEVICE_KEYBOARD,
                FILE_DEVICE_SECURE_OPEN,
@@ -141,6 +142,9 @@ AddDevice_Keyboard(
                DPRINT1("USBMP: IoCreateDevice() for usb keyboard driver failed with status 0x%08lx\n", Status);
                return Status;
        }
+       DeviceExtension = (PUSBMP_DEVICE_EXTENSION)Fdo->DeviceExtension;
+       RtlZeroMemory(DeviceExtension, sizeof(USBMP_DEVICE_EXTENSION));
+       DeviceExtension->IsFDO = TRUE;
        KeyboardFdo = Fdo;
        Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
        DPRINT("USBMP: Created keyboard Fdo: %p\n", Fdo);
@@ -154,6 +158,7 @@ AddDevice_Mouse(
        IN PDEVICE_OBJECT Pdo)
 {
        UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\PointerPortUSB");
+       PUSBMP_DEVICE_EXTENSION DeviceExtension;
        PDEVICE_OBJECT Fdo;
        NTSTATUS Status;
 
@@ -165,7 +170,7 @@ AddDevice_Mouse(
        }
 
        Status = IoCreateDevice(DriverObject,
-               8, // debug
+               sizeof(USBMP_DEVICE_EXTENSION),
                &DeviceName,
                FILE_DEVICE_MOUSE,
                FILE_DEVICE_SECURE_OPEN,
@@ -177,6 +182,9 @@ AddDevice_Mouse(
                DPRINT1("USBMP: IoCreateDevice() for usb mouse driver failed with status 0x%08lx\n", Status);
                return Status;
        }
+       DeviceExtension = (PUSBMP_DEVICE_EXTENSION)Fdo->DeviceExtension;
+       RtlZeroMemory(DeviceExtension, sizeof(USBMP_DEVICE_EXTENSION));
+       DeviceExtension->IsFDO = TRUE;
        MouseFdo = Fdo;
        Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
        DPRINT("USBMP: Created mouse Fdo: %p\n", Fdo);