Windows Kernel I/O Subsystem

API Reference - Power Manager

Power Manager

The Power Manager is a core component of the Windows operating system responsible for managing power states, power events, and device power policies. This section provides the API reference for interacting with and controlling the Power Manager within the Windows Kernel.

Core Functions

PoRegisterPowerSettingCallback

NTSTATUS PoRegisterPowerSettingCallback( _In_ PCUNICODE_STRING SettingGuid, _In_ PPOWER_SETTING_CALLBACK Callback, _In_ PVOID CallbackContext );
Registers a callback routine to be invoked when a specific power setting changes.
Parameters:
  • SettingGuid: A pointer to a UNICODE_STRING that specifies the GUID of the power setting to monitor.
  • Callback: A pointer to the caller's callback routine.
  • CallbackContext: A pointer to a context supplied by the caller for the callback routine.
Return Value:
  • STATUS_SUCCESS: The callback routine was successfully registered.
  • STATUS_INSUFFICIENT_RESOURCES: Insufficient system resources are available.
  • STATUS_INVALID_PARAMETER: An invalid parameter was supplied.
Remarks:
  • This function is typically called by kernel-mode drivers to be notified of changes to system-wide power settings.
  • The callback routine receives a pointer to the GUID of the setting that changed and the new value.
See Also:
  • PoUnregisterPowerSettingCallback
  • PPOWER_SETTING_CALLBACK

PoRequestPowerIrp

NTSTATUS PoRequestPowerIrp( _In_ PDEVICE_OBJECT DeviceObject, _In_ UCHAR MinorFunction, _In_ PVOID Context, _In_ PREQUEST_POWER_IRP_COMPLETE CompletionRoutine, _In_ PVOID CompletionContext );
Requests a power I/O Request Packet (IRP) to be sent to a device.
Parameters:
  • DeviceObject: A pointer to the device object for which the power IRP is being requested.
  • MinorFunction: The minor function code of the power IRP to request (e.g., IRP_MN_SET_POWER, IRP_MN_QUERY_POWER).
  • Context: Context information for the power IRP. The meaning depends on the MinorFunction.
  • CompletionRoutine: A pointer to a completion routine that will be called when the IRP has been processed.
  • CompletionContext: Context information for the completion routine.
Return Value:
  • STATUS_SUCCESS: The power IRP was successfully requested.
  • STATUS_INVALID_DEVICE_STATE: The device is in an invalid state for the requested operation.
  • STATUS_INSUFFICIENT_RESOURCES: Insufficient system resources are available.
Remarks:
  • Drivers use this function to initiate power state transitions for their devices.
  • The system's Power Manager handles the actual IRP routing and processing.
See Also:
  • PoCallDriver
  • DEVICE_POWER_STATE
  • POWER_ACTION

PoSetSystemState

VOID PoSetSystemState( _In_ SYSTEM_POWER_STATE State );
Sets the system's power state.
Parameters:
  • State: The desired system power state (e.g., PowerSystemWorking, PowerSystemSleeping1, PowerSystemHibernate).
Return Value: None.
Remarks:
  • This function is typically used by the system to initiate system-wide power state changes. Kernel drivers generally should not call this function directly.
See Also:
  • SYSTEM_POWER_STATE

Utility Functions

PoRegisterDeviceForIdleDetection

NTSTATUS PoRegisterDeviceForIdleDetection( _In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG Components, _In_ ULONG Timeout, _In_ DEVICE_POWER_STATE State );
Registers a device to be monitored for idle time and potentially put into a low-power state.
Parameters:
  • DeviceObject: A pointer to the device object to register for idle detection.
  • Components: The number of components within the device that should be monitored for idle activity. Set to 0 to monitor the entire device.
  • Timeout: The idle timeout period in seconds.
  • State: The target device power state when the device becomes idle.
Return Value:
  • STATUS_SUCCESS: The device was successfully registered.
  • STATUS_INSUFFICIENT_RESOURCES: Insufficient system resources are available.
  • STATUS_INVALID_PARAMETER: An invalid parameter was supplied.
Remarks:
  • Drivers of devices that support idle power management should call this function during device initialization.
See Also:
  • PoUnregisterDeviceForIdleDetection
  • PoReportIdleDetected

PoReportIdleDetected

VOID PoReportIdleDetected( _In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG Components );
Reports that a registered device or its components are now idle.
Parameters:
  • DeviceObject: A pointer to the device object that is now idle.
  • Components: A bitmask indicating which components are idle. If 0, the entire device is considered idle.
Return Value: None.
Remarks:
  • Drivers should call this function after they have finished all activity on a device or its components.
See Also:
  • PoRegisterDeviceForIdleDetection