From: Aric Stewart Subject: [11/12] hidclass.sys: Implement sending IRP_MJ_POWER to the minidriver Message-Id: <55A4FED5.5070909@codeweavers.com> Date: Tue, 14 Jul 2015 07:21:41 -0500 --- dlls/hidclass.sys/pnp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c index 673905c..5ff12f6 100644 --- a/dlls/hidclass.sys/pnp.c +++ b/dlls/hidclass.sys/pnp.c @@ -88,6 +88,22 @@ static NTSTATUS PNP_SendPnPIRP(DEVICE_OBJECT *device, UCHAR minor) return SendDeviceIRP(device, irp); } +static NTSTATUS PNP_SendPowerIRP(DEVICE_OBJECT *device, DEVICE_POWER_STATE power) +{ + IO_STATUS_BLOCK irp_status; + IO_STACK_LOCATION *irpsp; + + IRP *irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER, device, NULL, 0, NULL, NULL, &irp_status); + + irpsp = IoGetNextIrpStackLocation(irp); + irpsp->MinorFunction = IRP_MN_SET_POWER; + + irpsp->Parameters.Power.Type = DevicePowerState; + irpsp->Parameters.Power.State.DeviceState = power; + + return SendDeviceIRP(device, irp); +} + NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, void *native) { DEVICE_OBJECT *device = NULL; @@ -240,6 +256,7 @@ NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, void *native) ext->ring_buffer = RingBuffer_Create(sizeof(HID_XFER_PACKET) + ext->preparseData->caps.InputReportByteLength); HID_StartDeviceThread(device); + PNP_SendPowerIRP(device, PowerDeviceD0); return STATUS_SUCCESS; } @@ -254,6 +271,7 @@ void PNP_CleanupPNP(DRIVER_OBJECT *driver) if (tracked_device->minidriver->DriverObject == driver) { list_remove(&tracked_device->entry); + PNP_SendPowerIRP(tracked_device->device, PowerDeviceD3); PNP_SendPnPIRP(tracked_device->device, IRP_MN_REMOVE_DEVICE); HID_DeleteDevice(tracked_device->minidriver, tracked_device->device); HeapFree(GetProcessHeap(), 0, tracked_device);