Zebediah Figura : ntoskrnl/tests: Handle IRP_MJ_POWER requests.

Alexandre Julliard julliard at winehq.org
Mon Apr 12 16:11:25 CDT 2021


Module: wine
Branch: master
Commit: 8417f634a6844cc8232caf27bc29c3c8ceceec72
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8417f634a6844cc8232caf27bc29c3c8ceceec72

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Sat Apr 10 21:57:19 2021 -0500

ntoskrnl/tests: Handle IRP_MJ_POWER requests.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntoskrnl.exe/tests/driver_pnp.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/dlls/ntoskrnl.exe/tests/driver_pnp.c b/dlls/ntoskrnl.exe/tests/driver_pnp.c
index 34b21e4de48..75b03e17f47 100644
--- a/dlls/ntoskrnl.exe/tests/driver_pnp.c
+++ b/dlls/ntoskrnl.exe/tests/driver_pnp.c
@@ -308,6 +308,34 @@ static NTSTATUS WINAPI driver_pnp(DEVICE_OBJECT *device, IRP *irp)
     return pdo_pnp(device, irp);
 }
 
+static NTSTATUS WINAPI driver_power(DEVICE_OBJECT *device, IRP *irp)
+{
+    IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp);
+    NTSTATUS ret = STATUS_NOT_SUPPORTED;
+
+    /* We do not expect power IRPs as part of normal operation. */
+    ok(0, "unexpected call\n");
+
+    if (device == bus_fdo)
+    {
+        PoStartNextPowerIrp(irp);
+        IoSkipCurrentIrpStackLocation(irp);
+        return PoCallDriver(bus_pdo, irp);
+    }
+
+    if (stack->MinorFunction == IRP_MN_SET_POWER)
+    {
+        if (stack->Parameters.Power.Type == DevicePowerState)
+            PoSetPowerState(device, DevicePowerState, stack->Parameters.Power.State);
+        ret = STATUS_SUCCESS;
+    }
+
+    PoStartNextPowerIrp(irp);
+    irp->IoStatus.Status = ret;
+    IoCompleteRequest(irp, IO_NO_INCREMENT);
+    return ret;
+}
+
 static void test_bus_query_caps(DEVICE_OBJECT *top_device)
 {
     DEVICE_CAPABILITIES caps;
@@ -633,6 +661,7 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *registry)
     driver->DriverExtension->AddDevice = driver_add_device;
     driver->DriverUnload = driver_unload;
     driver->MajorFunction[IRP_MJ_PNP] = driver_pnp;
+    driver->MajorFunction[IRP_MJ_POWER] = driver_power;
     driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = driver_ioctl;
     driver->MajorFunction[IRP_MJ_CREATE] = driver_create;
     driver->MajorFunction[IRP_MJ_CLOSE] = driver_close;




More information about the wine-cvs mailing list