From ae4c5b9a8d96e437c1cdde4f4ea12b5aca377e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 7 Sep 2025 21:34:13 +0200 Subject: [PATCH] [NDK] potypes.h: Add useful macros for SYSTEM_POWER_CAPABILITIES (#8386) Add useful macros, similar to the powrprof.dll `IsPwr*()` functions, but that are suitable when one has a `SYSTEM_POWER_CAPABILITIES` structure initialized from `NtPowerInformation(SystemPowerCapabilities)`. - `IS_PWR_SUSPEND_ALLOWED()`, equivalent to `IsPwrSuspendAllowed()`, indicating whether any of the S1, S2, S3 sleep states are supported. - `IS_PWR_HIBERNATE_ALLOWED()`, equivalent to `IsPwrHibernateAllowed()`, indicating whether the S4 sleep state is supported and the hibernation file is present. - `IS_PWR_POWEROFF_ALLOWED()`, equivalent to `IsPwrShutdownAllowed()`, indicating whether the S5 "soft-off" state is supported. --- sdk/include/ndk/potypes.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sdk/include/ndk/potypes.h b/sdk/include/ndk/potypes.h index 9c67881085f..ccb99ea2162 100644 --- a/sdk/include/ndk/potypes.h +++ b/sdk/include/ndk/potypes.h @@ -51,6 +51,33 @@ typedef enum _SYSTEM_DOCK_STATE SystemDocked } SYSTEM_DOCK_STATE, *PSYSTEM_DOCK_STATE; +// +// Some useful macros for SYSTEM_POWER_CAPABILITIES, +// similar to the powrprof.dll IsPwr*() functions. +// + +/* + * BOOLEAN WINAPI + * IsPwrSuspendAllowed(VOID); + */ +#define IS_PWR_SUSPEND_ALLOWED(PowerCaps) \ + ((PowerCaps)->SystemS1 || (PowerCaps)->SystemS2 || (PowerCaps)->SystemS3) + +/* + * BOOLEAN WINAPI + * IsPwrHibernateAllowed(VOID); + */ +#define IS_PWR_HIBERNATE_ALLOWED(PowerCaps) \ + ((PowerCaps)->SystemS4 && (PowerCaps)->HiberFilePresent) + +/* + * BOOLEAN WINAPI + * IsPwrShutdownAllowed(VOID); + */ +#define IS_PWR_POWEROFF_ALLOWED(PowerCaps) \ + (!!(PowerCaps)->SystemS5) + + #ifndef NTOS_MODE_USER //