Index: power.c =================================================================== --- ntoskrnl/po/power.c (revision 71384) +++ ntoskrnl/po/power.c (working copy) @@ -153,6 +153,7 @@ PVOID Context) { PPOWER_STATE_TRAVERSE_CONTEXT PowerStateContext = Context; + PDEVICE_OBJECT Fdo; NTSTATUS Status; DPRINT("PopQuerySystemPowerStateTraverse(%p, %p)\n", DeviceNode, Context); @@ -163,7 +164,9 @@ if (DeviceNode->Flags & DNF_LEGACY_DRIVER) return STATUS_SUCCESS; - Status = PopSendQuerySystemPowerState(DeviceNode->PhysicalDeviceObject, + Fdo = IoGetAttachedDeviceReference(DeviceNode->PhysicalDeviceObject); + + Status = PopSendQuerySystemPowerState(Fdo, PowerStateContext->SystemPowerState, PowerStateContext->PowerAction); if (!NT_SUCCESS(Status)) @@ -170,6 +173,7 @@ { DPRINT1("Device '%wZ' failed IRP_MN_QUERY_POWER\n", &DeviceNode->InstancePath); } + ObDereferenceObject(Fdo); #if 0 return Status; @@ -183,6 +187,7 @@ PVOID Context) { PPOWER_STATE_TRAVERSE_CONTEXT PowerStateContext = Context; + PDEVICE_OBJECT Fdo; NTSTATUS Status; DPRINT("PopSetSystemPowerStateTraverse(%p, %p)\n", DeviceNode, Context); @@ -196,14 +201,24 @@ if (DeviceNode->Flags & DNF_LEGACY_DRIVER) return STATUS_SUCCESS; - Status = PopSendSetSystemPowerState(DeviceNode->PhysicalDeviceObject, + Fdo = IoGetAttachedDeviceReference(DeviceNode->PhysicalDeviceObject); + if (Fdo == PowerStateContext->PowerDevice) + { + ObDereferenceObject(Fdo); + return STATUS_SUCCESS; + } + + Status = PopSendSetSystemPowerState(Fdo, PowerStateContext->SystemPowerState, PowerStateContext->PowerAction); if (!NT_SUCCESS(Status)) { DPRINT1("Device '%wZ' failed IRP_MN_SET_POWER\n", &DeviceNode->InstancePath); + ASSERT(NT_SUCCESS(Status)); } + ObDereferenceObject(Fdo); + #if 0 return Status; #else