Aric Stewart : ntoskrnl.exe: Send PnP and Power IRPs to plug and play devices.

Alexandre Julliard julliard at winehq.org
Mon Sep 19 10:32:13 CDT 2016


Module: wine
Branch: master
Commit: d39d1464f3df755729e30c1883267812bc33adaa
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d39d1464f3df755729e30c1883267812bc33adaa

Author: Aric Stewart <aric at codeweavers.com>
Date:   Thu Sep 15 06:58:21 2016 -0500

ntoskrnl.exe: Send PnP and Power IRPs to plug and play devices.

Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntoskrnl.exe/ntoskrnl.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index aebb3de..bc7ac86 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2927,6 +2927,44 @@ static BOOL get_driver_for_id( const WCHAR *id, WCHAR *driver )
 }
 
 
+static NTSTATUS send_pnp_irp( DEVICE_OBJECT *device, UCHAR minor )
+{
+    IO_STACK_LOCATION *irpsp;
+    IO_STATUS_BLOCK irp_status;
+    IRP *irp;
+
+    if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, device, NULL, 0, NULL, NULL, &irp_status )))
+        return STATUS_NO_MEMORY;
+
+    irpsp = IoGetNextIrpStackLocation( irp );
+    irpsp->MinorFunction = minor;
+
+    irpsp->Parameters.StartDevice.AllocatedResources = NULL;
+    irpsp->Parameters.StartDevice.AllocatedResourcesTranslated = NULL;
+
+    return send_device_irp( device, irp, NULL );
+}
+
+
+static NTSTATUS send_power_irp( DEVICE_OBJECT *device, DEVICE_POWER_STATE power )
+{
+    IO_STATUS_BLOCK irp_status;
+    IO_STACK_LOCATION *irpsp;
+    IRP *irp;
+
+    if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_POWER, device, NULL, 0, NULL, NULL, &irp_status )))
+        return STATUS_NO_MEMORY;
+
+    irpsp = IoGetNextIrpStackLocation( irp );
+    irpsp->MinorFunction = IRP_MN_SET_POWER;
+
+    irpsp->Parameters.Power.Type = DevicePowerState;
+    irpsp->Parameters.Power.State.DeviceState = power;
+
+    return send_device_irp( device, irp, NULL );
+}
+
+
 static void handle_bus_relations( DEVICE_OBJECT *device )
 {
     static const WCHAR driverW[] = {'\\','D','r','i','v','e','r','\\',0};
@@ -2990,7 +3028,13 @@ static void handle_bus_relations( DEVICE_OBJECT *device )
     ObDereferenceObject( driver_obj );
 
     if (status != STATUS_SUCCESS)
+    {
         ERR_(plugplay)( "AddDevice failed for driver %s\n", debugstr_w(driver) );
+        return;
+    }
+
+    send_pnp_irp( device, IRP_MN_START_DEVICE );
+    send_power_irp( device, PowerDeviceD0 );
 }
 
 




More information about the wine-cvs mailing list