|
Writing Windows WDM Device DriversUnfortunately, there is no simple call to discover the current device power state. Instead, it must remember the last device power state from a Set Power IRP. The Power IRP handler can easily be enhanced to note any changes of power state if the minor function code is IRP_MN_SET_POWER. The IRP stack Parameters.Power.Type field is either SystemPowerState or DevicePowerState. The Parameters.Power.State field gives the system or device power state. The following code snippet shows how to check for a Set Device Power IRP and store the new device power state in a DEVICE_POWER_STATE PowerState field in the device extension. PIO_STACK_LOCATION IrpStack = IoGetCurrentIrpStackLocation(Irp); POWER_STATE_TYPE PowerType = IrpStack->Parameters.Power.Type; POWER_STATE PowerState = IrpStack->Parameters.Power.State; if (IrpStack->MinorFunction==IRP_MN_SET_POWER && PowerType==DevicePowerState) dx->PowerState = PowerState.DeviceState; Device Power Policy Owner In most device stacks, there is one driver that knows if the device is being used and its power state ...» | Код для вставки книги в блог HTML
phpBB
текст
|
|