1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 typedef struct _GLOBAL_MACHINE_POWER_POLICY{ 11 ULONG Revision; 12 SYSTEM_POWER_STATE LidOpenWakeAc; 13 SYSTEM_POWER_STATE LidOpenWakeDc; 14 ULONG BroadcastCapacityResolution; 15 } GLOBAL_MACHINE_POWER_POLICY,*PGLOBAL_MACHINE_POWER_POLICY; 16 17 typedef struct _GLOBAL_USER_POWER_POLICY{ 18 ULONG Revision; 19 POWER_ACTION_POLICY PowerButtonAc; 20 POWER_ACTION_POLICY PowerButtonDc; 21 POWER_ACTION_POLICY SleepButtonAc; 22 POWER_ACTION_POLICY SleepButtonDc; 23 POWER_ACTION_POLICY LidCloseAc; 24 POWER_ACTION_POLICY LidCloseDc; 25 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES]; 26 ULONG GlobalFlags; 27 } GLOBAL_USER_POWER_POLICY,*PGLOBAL_USER_POWER_POLICY; 28 29 typedef struct _GLOBAL_POWER_POLICY{ 30 GLOBAL_USER_POWER_POLICY user; 31 GLOBAL_MACHINE_POWER_POLICY mach; 32 } GLOBAL_POWER_POLICY,*PGLOBAL_POWER_POLICY; 33 34 typedef struct _MACHINE_POWER_POLICY{ 35 ULONG Revision; 36 SYSTEM_POWER_STATE MinSleepAc; 37 SYSTEM_POWER_STATE MinSleepDc; 38 SYSTEM_POWER_STATE ReducedLatencySleepAc; 39 SYSTEM_POWER_STATE ReducedLatencySleepDc; 40 ULONG DozeTimeoutAc; 41 ULONG DozeTimeoutDc; 42 ULONG DozeS4TimeoutAc; 43 ULONG DozeS4TimeoutDc; 44 UCHAR MinThrottleAc; 45 UCHAR MinThrottleDc; 46 UCHAR pad1[2]; 47 POWER_ACTION_POLICY OverThrottledAc; 48 POWER_ACTION_POLICY OverThrottledDc; 49 } MACHINE_POWER_POLICY,*PMACHINE_POWER_POLICY; 50 51 typedef struct _MACHINE_PROCESSOR_POWER_POLICY { 52 ULONG Revision; 53 PROCESSOR_POWER_POLICY ProcessorPolicyAc; 54 PROCESSOR_POWER_POLICY ProcessorPolicyDc; 55 } MACHINE_PROCESSOR_POWER_POLICY,*PMACHINE_PROCESSOR_POWER_POLICY; 56 57 typedef struct _USER_POWER_POLICY{ 58 ULONG Revision; 59 POWER_ACTION_POLICY IdleAc; 60 POWER_ACTION_POLICY IdleDc; 61 ULONG IdleTimeoutAc; 62 ULONG IdleTimeoutDc; 63 UCHAR IdleSensitivityAc; 64 UCHAR IdleSensitivityDc; 65 UCHAR ThrottlePolicyAc; 66 UCHAR ThrottlePolicyDc; 67 SYSTEM_POWER_STATE MaxSleepAc; 68 SYSTEM_POWER_STATE MaxSleepDc; 69 ULONG Reserved[2]; 70 ULONG VideoTimeoutAc; 71 ULONG VideoTimeoutDc; 72 ULONG SpindownTimeoutAc; 73 ULONG SpindownTimeoutDc; 74 BOOLEAN OptimizeForPowerAc; 75 BOOLEAN OptimizeForPowerDc; 76 UCHAR FanThrottleToleranceAc; 77 UCHAR FanThrottleToleranceDc; 78 UCHAR ForcedThrottleAc; 79 UCHAR ForcedThrottleDc; 80 } USER_POWER_POLICY,*PUSER_POWER_POLICY; 81 82 typedef struct _POWER_POLICY{ 83 USER_POWER_POLICY user; 84 MACHINE_POWER_POLICY mach; 85 } POWER_POLICY,*PPOWER_POLICY; 86 87 #define EnableSysTrayBatteryMeter 0x01 88 #define EnableMultiBatteryDisplay 0x02 89 #define EnablePasswordLogon 0x04 90 #define EnableWakeOnRing 0x08 91 #define EnableVideoDimDisplay 0x10 92 93 #define NEWSCHEME (UINT)-1 94 95 typedef BOOLEAN (CALLBACK *PWRSCHEMESENUMPROC)(UINT,DWORD,LPTSTR,DWORD,LPTSTR,PPOWER_POLICY,LPARAM); 96 typedef BOOLEAN (CALLBACK *PFNNTINITIATEPWRACTION)(POWER_ACTION,SYSTEM_POWER_STATE,ULONG,BOOLEAN); 97 98 BOOLEAN WINAPI GetPwrDiskSpindownRange(PUINT,PUINT); 99 BOOLEAN WINAPI EnumPwrSchemes(PWRSCHEMESENUMPROC,LPARAM); 100 BOOLEAN WINAPI ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY); 101 BOOLEAN WINAPI ReadPwrScheme(UINT,PPOWER_POLICY); 102 BOOLEAN WINAPI WritePwrScheme(PUINT,LPTSTR,LPTSTR,PPOWER_POLICY); 103 BOOLEAN WINAPI WriteGlobalPwrPolicy(PGLOBAL_POWER_POLICY); 104 BOOLEAN WINAPI DeletePwrScheme(UINT); 105 BOOLEAN WINAPI GetActivePwrScheme(PUINT); 106 BOOLEAN WINAPI SetActivePwrScheme(UINT,PGLOBAL_POWER_POLICY,PPOWER_POLICY); 107 BOOLEAN WINAPI GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES); 108 BOOLEAN WINAPI IsPwrSuspendAllowed(VOID); 109 BOOLEAN WINAPI IsPwrHibernateAllowed(VOID); 110 BOOLEAN WINAPI IsPwrShutdownAllowed(VOID); 111 BOOLEAN WINAPI IsAdminOverrideActive(PADMINISTRATOR_POWER_POLICY); 112 BOOLEAN WINAPI SetSuspendState(BOOLEAN,BOOLEAN,BOOLEAN); 113 BOOLEAN WINAPI GetCurrentPowerPolicies(PGLOBAL_POWER_POLICY,PPOWER_POLICY); 114 BOOLEAN WINAPI CanUserWritePwrScheme(VOID); 115 BOOLEAN WINAPI ReadProcessorPwrScheme(UINT,PMACHINE_PROCESSOR_POWER_POLICY); 116 BOOLEAN WINAPI WriteProcessorPwrScheme(UINT,PMACHINE_PROCESSOR_POWER_POLICY); 117 BOOLEAN WINAPI ValidatePowerPolicies(PGLOBAL_POWER_POLICY,PPOWER_POLICY); 118 119 #if (_WIN32_WINNT >= 0x0600) 120 #define DEVICEPOWER_HARDWAREID 0x80000000 121 #define DEVICEPOWER_FILTER_DEVICES_PRESENT 0x20000000 122 #define DEVICEPOWER_AND_OPERATION 0x40000000 123 #define DEVICEPOWER_FILTER_WAKEENABLED 0x08000000 124 #define DEVICEPOWER_FILTER_ON_NAME 0x02000000 125 126 #define PDCAP_D0_SUPPORTED 0x00000001 127 #define PDCAP_D1_SUPPORTED 0x00000002 128 #define PDCAP_D2_SUPPORTED 0x00000004 129 #define PDCAP_D3_SUPPORTED 0x00000008 130 #define PDCAP_S0_SUPPORTED 0x00010000 131 #define PDCAP_S1_SUPPORTED 0x00020000 132 #define PDCAP_S2_SUPPORTED 0x00040000 133 #define PDCAP_S3_SUPPORTED 0x00080000 134 #define PDCAP_S4_SUPPORTED 0x01000000 135 #define PDCAP_S5_SUPPORTED 0x02000000 136 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 137 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 138 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 139 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 140 #define PDCAP_WAKE_FROM_S0_SUPPORTED 0x00100000 141 #define PDCAP_WAKE_FROM_S1_SUPPORTED 0x00200000 142 #define PDCAP_WAKE_FROM_S2_SUPPORTED 0x00400000 143 #define PDCAP_WAKE_FROM_S3_SUPPORTED 0x00800000 144 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 145 146 #define DEVICEPOWER_SET_WAKEENABLED 0x00000001 147 #define DEVICEPOWER_CLEAR_WAKEENABLED 0x00000002 148 149 typedef enum _POWER_DATA_ACCESSOR { 150 ACCESS_AC_POWER_SETTING_INDEX = 0, // 0x0 151 ACCESS_DC_POWER_SETTING_INDEX = 1, // 0x1 152 ACCESS_SCHEME = 16, // 0x10 153 ACCESS_SUBGROUP = 17, // 0x11 154 ACCESS_INDIVIDUAL_SETTING = 18, // 0x12 155 ACCESS_ACTIVE_SCHEME = 19, // 0x13 156 ACCESS_CREATE_SCHEME = 20 // 0x14 157 } POWER_DATA_ACCESSOR, *PPOWER_DATA_ACCESSOR; 158 159 BOOLEAN WINAPI DevicePowerClose(void); 160 BOOLEAN WINAPI DevicePowerEnumDevices( 161 ULONG QueryIndex, 162 ULONG QueryInterpretationFlags, 163 ULONG QueryFlags, 164 PBYTE pReturnBuffer, 165 PULONG pBufferSize 166 ); 167 168 BOOLEAN WINAPI DevicePowerOpen( 169 ULONG Flags 170 ); 171 172 DWORD WINAPI DevicePowerSetDeviceState( 173 LPCWSTR DeviceDescription, 174 ULONG SetFlags, 175 LPCVOID SetData 176 ); 177 178 DWORD WINAPI PowerCanRestoreIndividualDefaultPowerScheme( 179 const GUID *SchemeGuid 180 ); 181 182 DWORD WINAPI PowerCreatePossibleSetting( 183 HKEY RootSystemPowerKey, 184 const GUID *SubGroupOfPowerSettingsGuid, 185 const GUID *PowerSettingGuid, 186 ULONG PossibleSettingIndex 187 ); 188 189 DWORD WINAPI PowerCreateSetting( 190 HKEY RootSystemPowerKey, 191 const GUID *SubGroupOfPowerSettingsGuid, 192 const GUID *PowerSettingGuid 193 ); 194 195 DWORD WINAPI PowerDeleteScheme( 196 HKEY RootPowerKey, 197 const GUID *SchemeGuid 198 ); 199 200 POWER_PLATFORM_ROLE WINAPI PowerDeterminePlatformRole(void); 201 202 DWORD WINAPI PowerDuplicateScheme( 203 HKEY RootPowerKey, 204 const GUID *SourceSchemeGuid, 205 GUID **DestinationSchemeGuid 206 ); 207 208 DWORD WINAPI PowerEnumerate( 209 HKEY RootPowerKey, 210 const GUID *SchemeGuid, 211 const GUID *SubGroupOfPowerSettingsGuid, 212 POWER_DATA_ACCESSOR AccessFlags, 213 ULONG Index, 214 UCHAR *Buffer, 215 DWORD *BufferSize 216 ); 217 218 DWORD WINAPI PowerGetActiveScheme( 219 HKEY UserRootPowerKey, 220 GUID **ActivePolicyGuid 221 ); 222 223 DWORD WINAPI PowerImportPowerScheme( 224 HKEY RootPowerKey, 225 LPCWSTR ImportFileNamePath, 226 GUID **DestinationSchemeGuid 227 ); 228 229 DWORD WINAPI PowerReadACDefaultIndex( 230 HKEY RootPowerKey, 231 const GUID *SchemePersonalityGuid, 232 const GUID *SubGroupOfPowerSettingsGuid, 233 const GUID *PowerSettingGuid, 234 LPDWORD AcDefaultIndex 235 ); 236 237 DWORD WINAPI PowerReadACValue( 238 HKEY RootPowerKey, 239 const GUID *SchemeGuid, 240 const GUID *SubGroupOfPowerSettingsGuid, 241 const GUID *PowerSettingGuid, 242 PULONG Type, 243 LPBYTE Buffer, 244 LPDWORD BufferSize 245 ); 246 247 DWORD WINAPI PowerReadACValueIndex( 248 HKEY RootPowerKey, 249 const GUID *SchemeGuid, 250 const GUID *SubGroupOfPowerSettingsGuid, 251 const GUID *PowerSettingGuid, 252 LPDWORD AcValueIndex 253 ); 254 255 DWORD WINAPI PowerReadDCDefaultIndex( 256 HKEY RootPowerKey, 257 const GUID *SchemePersonalityGuid, 258 const GUID *SubGroupOfPowerSettingsGuid, 259 const GUID *PowerSettingGuid, 260 LPDWORD DcDefaultIndex 261 ); 262 263 DWORD WINAPI PowerReadDCValue( 264 HKEY RootPowerKey, 265 const GUID *SchemeGuid, 266 const GUID *SubGroupOfPowerSettingsGuid, 267 const GUID *PowerSettingGuid, 268 PULONG Type, 269 PUCHAR Buffer, 270 LPDWORD BufferSize 271 ); 272 273 DWORD WINAPI PowerReadDCValueIndex( 274 HKEY RootPowerKey, 275 const GUID *SchemeGuid, 276 const GUID *SubGroupOfPowerSettingsGuid, 277 const GUID *PowerSettingGuid, 278 LPDWORD DcValueIndex 279 ); 280 281 DWORD WINAPI PowerReadDescription( 282 HKEY RootPowerKey, 283 const GUID *SchemeGuid, 284 const GUID *SubGroupOfPowerSettingsGuid, 285 const GUID *PowerSettingGuid, 286 PUCHAR Buffer, 287 LPDWORD BufferSize 288 ); 289 290 DWORD WINAPI PowerReadFriendlyName( 291 HKEY RootPowerKey, 292 const GUID *SchemeGuid, 293 const GUID *SubGroupOfPowerSettingsGuid, 294 const GUID *PowerSettingGuid, 295 PUCHAR Buffer, 296 LPDWORD BufferSize 297 ); 298 299 DWORD WINAPI PowerReadIconResourceSpecifier( 300 HKEY RootPowerKey, 301 const GUID *SchemeGuid, 302 const GUID *SubGroupOfPowerSettingsGuid, 303 const GUID *PowerSettingGuid, 304 PUCHAR Buffer, 305 LPDWORD BufferSize 306 ); 307 308 DWORD WINAPI PowerReadPossibleDescription( 309 HKEY RootPowerKey, 310 const GUID *SubGroupOfPowerSettingsGuid, 311 const GUID *PowerSettingGuid, 312 ULONG PossibleSettingIndex, 313 PUCHAR Buffer, 314 LPDWORD BufferSize 315 ); 316 317 DWORD WINAPI PowerReadPossibleFriendlyName( 318 HKEY RootPowerKey, 319 const GUID *SubGroupOfPowerSettingsGuid, 320 const GUID *PowerSettingGuid, 321 ULONG PossibleSettingIndex, 322 PUCHAR Buffer, 323 LPDWORD BufferSize 324 ); 325 326 DWORD WINAPI PowerReadPossibleValue( 327 HKEY RootPowerKey, 328 const GUID *SubGroupOfPowerSettingsGuid, 329 const GUID *PowerSettingGuid, 330 PULONG Type, 331 ULONG PossibleSettingIndex, 332 PUCHAR Buffer, 333 LPDWORD BufferSize 334 ); 335 336 DWORD WINAPI PowerReadSettingAttributes( 337 const GUID *SubGroupGuid, 338 const GUID *PowerSettingGuid 339 ); 340 341 DWORD WINAPI PowerReadValueIncrement( 342 HKEY RootPowerKey, 343 const GUID *SubGroupOfPowerSettingsGuid, 344 const GUID *PowerSettingGuid, 345 LPDWORD ValueIncrement 346 ); 347 348 DWORD WINAPI PowerReadValueMax( 349 HKEY RootPowerKey, 350 const GUID *SubGroupOfPowerSettingsGuid, 351 const GUID *PowerSettingGuid, 352 LPDWORD ValueMaximum 353 ); 354 355 DWORD WINAPI PowerReadValueMin( 356 HKEY RootPowerKey, 357 const GUID *SubGroupOfPowerSettingsGuid, 358 const GUID *PowerSettingGuid, 359 LPDWORD ValueMinimum 360 ); 361 362 DWORD WINAPI PowerReadValueUnitsSpecifier( 363 HKEY RootPowerKey, 364 const GUID *SubGroupOfPowerSettingsGuid, 365 const GUID *PowerSettingGuid, 366 UCHAR *Buffer, 367 LPDWORD BufferSize 368 ); 369 370 DWORD WINAPI PowerRemovePowerSetting( 371 const GUID *PowerSettingSubKeyGuid, 372 const GUID *PowerSettingGuid 373 ); 374 375 DWORD WINAPI PowerReplaceDefaultPowerSchemes(void); 376 377 DWORD WINAPI PowerRestoreDefaultPowerSchemes(void); 378 379 DWORD WINAPI PowerRestoreIndividualDefaultPowerScheme( 380 const GUID *SchemeGuid 381 ); 382 383 DWORD WINAPI PowerSetActiveScheme( 384 HKEY UserRootPowerKey, 385 const GUID *SchemeGuid 386 ); 387 388 DWORD WINAPI PowerSettingAccessCheck( 389 POWER_DATA_ACCESSOR AccessFlags, 390 const GUID *PowerGuid 391 ); 392 393 DWORD WINAPI PowerWriteACDefaultIndex( 394 HKEY RootSystemPowerKey, 395 const GUID *SchemePersonalityGuid, 396 const GUID *SubGroupOfPowerSettingsGuid, 397 const GUID *PowerSettingGuid, 398 DWORD DefaultAcIndex 399 ); 400 401 DWORD WINAPI PowerWriteACValueIndex( 402 HKEY RootPowerKey, 403 const GUID *SchemeGuid, 404 const GUID *SubGroupOfPowerSettingsGuid, 405 const GUID *PowerSettingGuid, 406 DWORD AcValueIndex 407 ); 408 409 DWORD WINAPI PowerWriteDCDefaultIndex( 410 HKEY RootSystemPowerKey, 411 const GUID *SchemePersonalityGuid, 412 const GUID *SubGroupOfPowerSettingsGuid, 413 const GUID *PowerSettingGuid, 414 DWORD DefaultDcIndex 415 ); 416 417 DWORD WINAPI PowerWriteDCValueIndex( 418 HKEY RootPowerKey, 419 const GUID *SchemeGuid, 420 const GUID *SubGroupOfPowerSettingsGuid, 421 const GUID *PowerSettingGuid, 422 DWORD DcValueIndex 423 ); 424 425 DWORD WINAPI PowerWriteDescription( 426 HKEY RootPowerKey, 427 const GUID *SchemeGuid, 428 const GUID *SubGroupOfPowerSettingsGuid, 429 const GUID *PowerSettingGuid, 430 UCHAR *Buffer, 431 DWORD BufferSize 432 ); 433 434 DWORD WINAPI PowerWriteFriendlyName( 435 HKEY RootPowerKey, 436 const GUID *SchemeGuid, 437 const GUID *SubGroupOfPowerSettingsGuid, 438 const GUID *PowerSettingGuid, 439 UCHAR *Buffer, 440 DWORD BufferSize 441 ); 442 443 DWORD WINAPI PowerWriteIconResourceSpecifier( 444 HKEY RootPowerKey, 445 const GUID *SchemeGuid, 446 const GUID *SubGroupOfPowerSettingsGuid, 447 const GUID *PowerSettingGuid, 448 UCHAR *Buffer, 449 DWORD BufferSize 450 ); 451 452 DWORD WINAPI PowerWritePossibleDescription( 453 HKEY RootPowerKey, 454 const GUID *SubGroupOfPowerSettingsGuid, 455 const GUID *PowerSettingGuid, 456 ULONG PossibleSettingIndex, 457 UCHAR *Buffer, 458 DWORD BufferSize 459 ); 460 461 DWORD WINAPI PowerWritePossibleFriendlyName( 462 HKEY RootPowerKey, 463 const GUID *SubGroupOfPowerSettingsGuid, 464 const GUID *PowerSettingGuid, 465 ULONG PossibleSettingIndex, 466 UCHAR *Buffer, 467 DWORD BufferSize 468 ); 469 470 DWORD WINAPI PowerWritePossibleValue( 471 HKEY RootPowerKey, 472 const GUID *SubGroupOfPowerSettingsGuid, 473 const GUID *PowerSettingGuid, 474 ULONG Type, 475 ULONG PossibleSettingIndex, 476 UCHAR *Buffer, 477 DWORD BufferSize 478 ); 479 480 #define POWER_ATTRIBUTE_HIDE 1 481 482 DWORD WINAPI PowerWriteSettingAttributes( 483 const GUID *SubGroupGuid, 484 const GUID *PowerSettingGuid, 485 DWORD Attributes 486 ); 487 488 DWORD WINAPI PowerWriteValueIncrement( 489 HKEY RootPowerKey, 490 const GUID *SubGroupOfPowerSettingsGuid, 491 const GUID *PowerSettingGuid, 492 DWORD ValueIncrement 493 ); 494 495 DWORD WINAPI PowerWriteValueMax( 496 HKEY RootPowerKey, 497 const GUID *SubGroupOfPowerSettingsGuid, 498 const GUID *PowerSettingGuid, 499 DWORD ValueMaximum 500 ); 501 502 DWORD WINAPI PowerWriteValueMin( 503 HKEY RootPowerKey, 504 const GUID *SubGroupOfPowerSettingsGuid, 505 const GUID *PowerSettingGuid, 506 DWORD ValueMinimum 507 ); 508 509 DWORD WINAPI PowerWriteValueUnitsSpecifier( 510 HKEY RootPowerKey, 511 const GUID *SubGroupOfPowerSettingsGuid, 512 const GUID *PowerSettingGuid, 513 UCHAR *Buffer, 514 DWORD BufferSize 515 ); 516 517 #endif /*(_WIN32_WINNT >= 0x0600)*/ 518 519 #ifndef NT_SUCCESS 520 #define NTSTATUS LONG 521 #define _OVERRIDE_NTSTATUS_ 522 #endif 523 524 NTSTATUS WINAPI CallNtPowerInformation(POWER_INFORMATION_LEVEL,PVOID,ULONG,PVOID,ULONG); 525 526 #ifdef _OVERRIDE_NTSTATUS_ 527 #undef NTSTATUS 528 #endif 529 530 #ifdef __cplusplus 531 } 532 #endif 533