https://git.reactos.org/?p=reactos.git;a=commitdiff;h=29b49c36ffcbfe043ffc2…
commit 29b49c36ffcbfe043ffc2beed07f91d759261b59
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sun Jun 21 10:18:19 2020 +0200
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Sun Jun 21 10:39:49 2020 +0200
[KBDCLASS][MOUCLASS] Properly stub power IRP handling. CORE-12148 CORE-17136
---
drivers/input/kbdclass/kbdclass.c | 43 +++++++++++++++------------------------
drivers/input/mouclass/mouclass.c | 43 +++++++++++++++------------------------
2 files changed, 32 insertions(+), 54 deletions(-)
diff --git a/drivers/input/kbdclass/kbdclass.c b/drivers/input/kbdclass/kbdclass.c
index c18b0c72a5e..1ba29a2bbdb 100644
--- a/drivers/input/kbdclass/kbdclass.c
+++ b/drivers/input/kbdclass/kbdclass.c
@@ -20,7 +20,7 @@ static DRIVER_DISPATCH ClassClose;
static DRIVER_DISPATCH ClassCleanup;
static DRIVER_DISPATCH ClassRead;
static DRIVER_DISPATCH ClassDeviceControl;
-static DRIVER_DISPATCH IrpStub;
+static DRIVER_DISPATCH ClassPower;
static DRIVER_ADD_DEVICE ClassAddDevice;
static DRIVER_STARTIO ClassStartIo;
static DRIVER_CANCEL ClassCancelRoutine;
@@ -188,39 +188,31 @@ ClassDeviceControl(
}
static NTSTATUS NTAPI
-IrpStub(
+ClassPower(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- NTSTATUS Status = STATUS_NOT_SUPPORTED;
+ NTSTATUS Status;
PPORT_DEVICE_EXTENSION DeviceExtension;
DeviceExtension = DeviceObject->DeviceExtension;
if (!DeviceExtension->Common.IsClassDO)
{
- /* Forward some IRPs to lower device */
- switch (IoGetCurrentIrpStackLocation(Irp)->MajorFunction)
- {
- case IRP_MJ_POWER:
- PoStartNextPowerIrp(Irp);
- IoSkipCurrentIrpStackLocation(Irp);
- return PoCallDriver(DeviceExtension->LowerDevice, Irp);
- default:
- {
- ERR_(CLASS_NAME, "Port DO stub for major function 0x%lx\n",
- IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
- ASSERT(FALSE);
- }
- }
+ /* Forward port DO IRPs to lower device */
+ PoStartNextPowerIrp(Irp);
+ IoSkipCurrentIrpStackLocation(Irp);
+ return PoCallDriver(DeviceExtension->LowerDevice, Irp);
}
- else
+
+ switch (IoGetCurrentIrpStackLocation(Irp)->MinorFunction)
{
- ERR_(CLASS_NAME, "Class DO stub for major function 0x%lx\n",
- IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
- ASSERT(FALSE);
+ case IRP_MN_SET_POWER:
+ case IRP_MN_QUERY_POWER:
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
}
-
- Irp->IoStatus.Status = Status;
+ Status = Irp->IoStatus.Status;
+ PoStartNextPowerIrp(Irp);
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
@@ -1047,7 +1039,6 @@ DriverEntry(
IN PUNICODE_STRING RegistryPath)
{
PCLASS_DRIVER_EXTENSION DriverExtension;
- ULONG i;
NTSTATUS Status;
Status = IoAllocateDriverObjectExtension(
@@ -1094,13 +1085,11 @@ DriverEntry(
DriverObject->DriverExtension->AddDevice = ClassAddDevice;
DriverObject->DriverUnload = DriverUnload;
- for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
- DriverObject->MajorFunction[i] = IrpStub;
-
DriverObject->MajorFunction[IRP_MJ_CREATE] = ClassCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ClassClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = ClassCleanup;
DriverObject->MajorFunction[IRP_MJ_READ] = ClassRead;
+ DriverObject->MajorFunction[IRP_MJ_POWER] = ClassPower;
DriverObject->MajorFunction[IRP_MJ_PNP] = ClassPnp;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ClassDeviceControl;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;
diff --git a/drivers/input/mouclass/mouclass.c b/drivers/input/mouclass/mouclass.c
index 8628c582b2e..3f0f56b1b40 100644
--- a/drivers/input/mouclass/mouclass.c
+++ b/drivers/input/mouclass/mouclass.c
@@ -20,7 +20,7 @@ static DRIVER_DISPATCH ClassClose;
static DRIVER_DISPATCH ClassCleanup;
static DRIVER_DISPATCH ClassRead;
static DRIVER_DISPATCH ClassDeviceControl;
-static DRIVER_DISPATCH IrpStub;
+static DRIVER_DISPATCH ClassPower;
static DRIVER_ADD_DEVICE ClassAddDevice;
static DRIVER_STARTIO ClassStartIo;
static DRIVER_CANCEL ClassCancelRoutine;
@@ -165,39 +165,31 @@ ClassDeviceControl(
}
static NTSTATUS NTAPI
-IrpStub(
+ClassPower(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- NTSTATUS Status = STATUS_NOT_SUPPORTED;
+ NTSTATUS Status;
PPORT_DEVICE_EXTENSION DeviceExtension;
DeviceExtension = DeviceObject->DeviceExtension;
if (!DeviceExtension->Common.IsClassDO)
{
- /* Forward some IRPs to lower device */
- switch (IoGetCurrentIrpStackLocation(Irp)->MajorFunction)
- {
- case IRP_MJ_POWER:
- PoStartNextPowerIrp(Irp);
- IoSkipCurrentIrpStackLocation(Irp);
- return PoCallDriver(DeviceExtension->LowerDevice, Irp);
- default:
- {
- ERR_(CLASS_NAME, "Port DO stub for major function 0x%lx\n",
- IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
- ASSERT(FALSE);
- }
- }
+ /* Forward port DO IRPs to lower device */
+ PoStartNextPowerIrp(Irp);
+ IoSkipCurrentIrpStackLocation(Irp);
+ return PoCallDriver(DeviceExtension->LowerDevice, Irp);
}
- else
+
+ switch (IoGetCurrentIrpStackLocation(Irp)->MinorFunction)
{
- ERR_(CLASS_NAME, "Class DO stub for major function 0x%lx\n",
- IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
- ASSERT(FALSE);
+ case IRP_MN_SET_POWER:
+ case IRP_MN_QUERY_POWER:
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ break;
}
-
- Irp->IoStatus.Status = Status;
+ Status = Irp->IoStatus.Status;
+ PoStartNextPowerIrp(Irp);
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
@@ -1023,7 +1015,6 @@ DriverEntry(
IN PUNICODE_STRING RegistryPath)
{
PCLASS_DRIVER_EXTENSION DriverExtension;
- ULONG i;
NTSTATUS Status;
Status = IoAllocateDriverObjectExtension(
@@ -1070,13 +1061,11 @@ DriverEntry(
DriverObject->DriverExtension->AddDevice = ClassAddDevice;
DriverObject->DriverUnload = DriverUnload;
- for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
- DriverObject->MajorFunction[i] = IrpStub;
-
DriverObject->MajorFunction[IRP_MJ_CREATE] = ClassCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ClassClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = ClassCleanup;
DriverObject->MajorFunction[IRP_MJ_READ] = ClassRead;
+ DriverObject->MajorFunction[IRP_MJ_POWER] = ClassPower;
DriverObject->MajorFunction[IRP_MJ_PNP] = ClassPnp;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ClassDeviceControl;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;