ReactOS 0.4.16-dev-747-gbc52d5f
powrprof.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <ndk/pofuncs.h>
#include <ndk/rtlfuncs.h>
#include <ndk/setypes.h>
#include <powrprof.h>
#include <wine/debug.h>
#include <wine/unicode.h>
Include dependency graph for powrprof.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (powrprof)
 
BOOLEAN WINAPI WritePwrPolicy (PUINT puiID, PPOWER_POLICY pPowerPolicy)
 
NTSTATUS WINAPI CallNtPowerInformation (POWER_INFORMATION_LEVEL InformationLevel, PVOID lpInputBuffer, ULONG nInputBufferSize, PVOID lpOutputBuffer, ULONG nOutputBufferSize)
 
BOOLEAN WINAPI CanUserWritePwrScheme (VOID)
 
BOOLEAN WINAPI DeletePwrScheme (UINT uiIndex)
 
static BOOLEAN POWRPROF_GetUserPowerPolicy (LPWSTR szNum, PUSER_POWER_POLICY puserPwrPolicy, DWORD cchName, LPWSTR szName, DWORD cchDesc, LPWSTR szDesc)
 
static BOOLEAN POWRPROF_GetMachinePowerPolicy (LPWSTR szNum, PMACHINE_POWER_POLICY pmachinePwrPolicy)
 
BOOLEAN WINAPI EnumPwrSchemes (PWRSCHEMESENUMPROC lpfnPwrSchemesEnumProc, LPARAM lParam)
 
BOOLEAN WINAPI GetActivePwrScheme (PUINT puiID)
 
BOOLEAN WINAPI GetCurrentPowerPolicies (PGLOBAL_POWER_POLICY pGlobalPowerPolicy, PPOWER_POLICY pPowerPolicy)
 
BOOLEAN WINAPI GetPwrCapabilities (PSYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities)
 
BOOLEAN WINAPI GetPwrDiskSpindownRange (PUINT RangeMax, PUINT RangeMin)
 
BOOLEAN WINAPI IsAdminOverrideActive (PADMINISTRATOR_POWER_POLICY p)
 
BOOLEAN WINAPI IsPwrHibernateAllowed (VOID)
 
BOOLEAN WINAPI IsPwrShutdownAllowed (VOID)
 
BOOLEAN WINAPI IsPwrSuspendAllowed (VOID)
 
DWORD WINAPI PowerGetActiveScheme (HKEY UserRootPowerKey, GUID **polguid)
 
DWORD WINAPI PowerSetActiveScheme (HKEY UserRootPowerKey, GUID *polguid)
 
DWORD WINAPI PowerReadDCValue (HKEY RootPowerKey, const GUID *Scheme, const GUID *SubGroup, const GUID *PowerSettings, PULONG Type, PUCHAR Buffer, DWORD *BufferSize)
 
DWORD WINAPI PowerReadFriendlyName (HKEY RootPowerKey, const GUID *Scheme, const GUID *SubGroup, const GUID *PowerSettings, UCHAR *Buffer, DWORD *BufferSize)
 
POWER_PLATFORM_ROLE WINAPI PowerDeterminePlatformRole (void)
 
POWER_PLATFORM_ROLE WINAPI PowerDeterminePlatformRoleEx (ULONG version)
 
DWORD WINAPI PowerEnumerate (HKEY key, const GUID *scheme, const GUID *subgroup, POWER_DATA_ACCESSOR flags, ULONG index, UCHAR *buffer, DWORD *buffer_size)
 
DWORD WINAPI PowerRegisterSuspendResumeNotification (DWORD flags, HANDLE recipient, PHPOWERNOTIFY handle)
 
DWORD WINAPI PowerUnregisterSuspendResumeNotification (HPOWERNOTIFY handle)
 
DWORD WINAPI PowerSettingRegisterNotification (const GUID *setting, DWORD flags, HANDLE recipient, PHPOWERNOTIFY handle)
 
DWORD WINAPI PowerSettingUnregisterNotification (HPOWERNOTIFY handle)
 
DWORD WINAPI PowerWriteACValueIndex (HKEY key, const GUID *scheme, const GUID *subgroup, const GUID *setting, DWORD index)
 
BOOLEAN WINAPI ReadGlobalPwrPolicy (PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
 
BOOLEAN WINAPI ReadProcessorPwrScheme (UINT uiID, PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy)
 
BOOLEAN WINAPI ReadPwrScheme (UINT uiID, PPOWER_POLICY pPowerPolicy)
 
BOOLEAN WINAPI SetActivePwrScheme (UINT uiID, PGLOBAL_POWER_POLICY lpGlobalPowerPolicy, PPOWER_POLICY lpPowerPolicy)
 
BOOLEAN WINAPI SetSuspendState (BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
 
BOOLEAN WINAPI WriteGlobalPwrPolicy (PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
 
BOOLEAN WINAPI WriteProcessorPwrScheme (UINT ID, PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy)
 
static VOID SetLastID (VOID)
 
BOOLEAN WINAPI WritePwrScheme (PUINT puiID, LPWSTR lpszName, LPWSTR lpszDescription, PPOWER_POLICY pPowerPolicy)
 
static BOOLEAN CheckPowerActionPolicy (PPOWER_ACTION_POLICY pPAP, SYSTEM_POWER_CAPABILITIES PowerCaps)
 
static BOOLEAN CreatePowrProfSemaphoreSecurity (_Out_ PSECURITY_DESCRIPTOR *PowrProfSd)
 Creates a security descriptor for the power management registry semaphore.
 
static VOID FixSystemPowerState (PSYSTEM_POWER_STATE Psps, SYSTEM_POWER_CAPABILITIES PowerCaps)
 
BOOLEAN WINAPI ValidatePowerPolicies (PGLOBAL_POWER_POLICY pGPP, PPOWER_POLICY pPP)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 

Variables

static const WCHAR szPowerCfgSubKey []
 
static const WCHAR szUserPowerConfigSubKey []
 
static const WCHAR szCurrentPowerPolicies []
 
static const WCHAR szPolicies [] = L"Policies"
 
static const WCHAR szName [] = L"Name"
 
static const WCHAR szDescription [] = L"Description"
 
static const WCHAR szSemaphoreName [] = L"PowerProfileRegistrySemaphore"
 
static const WCHAR szDiskMax [] = L"DiskSpindownMax"
 
static const WCHAR szDiskMin [] = L"DiskSpindownMin"
 
static const WCHAR szLastID [] = L"LastID"
 
UINT g_LastID = (UINT)-1
 
HANDLE PPRegSemaphore = NULL
 

Macro Definition Documentation

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 27 of file powrprof.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 23 of file powrprof.c.

Function Documentation

◆ CallNtPowerInformation()

NTSTATUS WINAPI CallNtPowerInformation ( POWER_INFORMATION_LEVEL  InformationLevel,
PVOID  lpInputBuffer,
ULONG  nInputBufferSize,
PVOID  lpOutputBuffer,
ULONG  nOutputBufferSize 
)

Definition at line 59 of file powrprof.c.

64{
65 BOOLEAN old;
66
67 //Lohnegrim: In order to get the right results, we have to adjust our Privileges
70
71 return NtPowerInformation(InformationLevel,
72 lpInputBuffer,
73 nInputBufferSize,
74 lpOutputBuffer,
75 nOutputBufferSize);
76}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SE_SHUTDOWN_PRIVILEGE
Definition: security.c:673
#define SE_CREATE_PAGEFILE_PRIVILEGE
Definition: security.c:669
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
NTSTATUS NTAPI NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength)
Definition: power.c:792

Referenced by Hib_InitDialog(), Hib_SaveData(), IsBatteryUsed(), ProcessorDlgProc(), SetProcSpeed(), and test_CallNtPowerInformation().

◆ CanUserWritePwrScheme()

BOOLEAN WINAPI CanUserWritePwrScheme ( VOID  )

Definition at line 79 of file powrprof.c.

80{
81 HKEY hKey = NULL;
82 LONG Ret;
83
84 TRACE("()\n");
85
87 if (Ret != ERROR_SUCCESS)
88 {
89 TRACE("RegOpenKeyEx failed: %d\n", Ret);
90 SetLastError(Ret);
91 return FALSE;
92 }
93
95 return TRUE;
96}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define SetLastError(x)
Definition: compat.h:752
FxAutoRegKey hKey
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
long LONG
Definition: pedump.c:60
static const WCHAR szPowerCfgSubKey[]
Definition: powrprof.c:38
#define TRACE(s)
Definition: solgame.cpp:4
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CreateEnergyList(), and test_CanUserWritePwrScheme().

◆ CheckPowerActionPolicy()

static BOOLEAN CheckPowerActionPolicy ( PPOWER_ACTION_POLICY  pPAP,
SYSTEM_POWER_CAPABILITIES  PowerCaps 
)
static

Definition at line 904 of file powrprof.c.

905{
906/*
907 Lohnegrim: this is an Helper function, it checks if the POWERACTIONPOLICY is valid
908 Also, if the System doesn't support Hibernation, then change the PowerAction
909*/
910 switch (pPAP->Action)
911 {
912 case PowerActionNone:
913 return TRUE;
915 if (PowerCaps.SystemS1 || PowerCaps.SystemS2 || PowerCaps.SystemS3)
916 pPAP->Action = PowerActionSleep;
917 else
919 case PowerActionSleep:
920 return TRUE;
922 if (!(PowerCaps.SystemS4 && PowerCaps.HiberFilePresent))
923 {
924 if (PowerCaps.SystemS1 || PowerCaps.SystemS2 || PowerCaps.SystemS3)
925 pPAP->Action = PowerActionSleep;
926 else
928 }
933 return TRUE;
934 default:
936 return FALSE;
937 };
938}
@ PowerActionShutdownOff
Definition: ntpoapi.h:129
@ PowerActionNone
Definition: ntpoapi.h:123
@ PowerActionHibernate
Definition: ntpoapi.h:126
@ PowerActionShutdown
Definition: ntpoapi.h:127
@ PowerActionShutdownReset
Definition: ntpoapi.h:128
@ PowerActionWarmEject
Definition: ntpoapi.h:130
@ PowerActionReserved
Definition: ntpoapi.h:124
@ PowerActionSleep
Definition: ntpoapi.h:125
POWER_ACTION Action
Definition: ntpoapi.h:408
#define ERROR_INVALID_DATA
Definition: winerror.h:116

Referenced by ValidatePowerPolicies().

◆ CreatePowrProfSemaphoreSecurity()

static BOOLEAN CreatePowrProfSemaphoreSecurity ( _Out_ PSECURITY_DESCRIPTOR PowrProfSd)
static

Creates a security descriptor for the power management registry semaphore.

Parameters
[out]PowrProfSdA pointer to an allocated security descriptor for the semaphore.
Returns
Returns TRUE if the function succeeds, otherwise FALSE is returned.
Remarks
Authenticated users are only given a subset of specific rights for the semaphore access, local system and admins have full power.

Definition at line 959 of file powrprof.c.

960{
962 PACL Dacl;
963 ULONG DaclSize, RelSDSize = 0;
964 PSID AuthenticatedUsersSid = NULL, SystemSid = NULL, AdminsSid = NULL;
968
970 1,
972 0, 0, 0, 0, 0, 0, 0,
973 &AuthenticatedUsersSid))
974 {
975 return FALSE;
976 }
977
979 1,
981 0, 0, 0, 0, 0, 0, 0,
982 &SystemSid))
983 {
984 goto Quit;
985 }
986
988 2,
991 0, 0, 0, 0, 0, 0,
992 &AdminsSid))
993 {
994 goto Quit;
995 }
996
998 {
999 goto Quit;
1000 }
1001
1002 DaclSize = sizeof(ACL) +
1003 sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(AuthenticatedUsersSid) +
1004 sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(SystemSid) +
1005 sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(AdminsSid);
1006
1008 if (!Dacl)
1009 {
1010 goto Quit;
1011 }
1012
1014 {
1015 goto Quit;
1016 }
1017
1021 AuthenticatedUsersSid))
1022 {
1023 goto Quit;
1024 }
1025
1029 SystemSid))
1030 {
1031 goto Quit;
1032 }
1033
1037 AdminsSid))
1038 {
1039 goto Quit;
1040 }
1041
1042 if (!SetSecurityDescriptorDacl(&AbsSd, TRUE, Dacl, FALSE))
1043 {
1044 goto Quit;
1045 }
1046
1047 if (!SetSecurityDescriptorOwner(&AbsSd, AdminsSid, FALSE))
1048 {
1049 goto Quit;
1050 }
1051
1052 if (!SetSecurityDescriptorGroup(&AbsSd, SystemSid, FALSE))
1053 {
1054 goto Quit;
1055 }
1056
1057 if (!MakeSelfRelativeSD(&AbsSd, NULL, &RelSDSize) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1058 {
1059 RelSd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, RelSDSize);
1060 if (RelSd == NULL)
1061 {
1062 goto Quit;
1063 }
1064
1065 if (!MakeSelfRelativeSD(&AbsSd, RelSd, &RelSDSize))
1066 {
1067 goto Quit;
1068 }
1069 }
1070
1071 *PowrProfSd = RelSd;
1072 Success = TRUE;
1073
1074Quit:
1075 if (AuthenticatedUsersSid)
1076 {
1077 FreeSid(AuthenticatedUsersSid);
1078 }
1079
1080 if (SystemSid)
1081 {
1082 FreeSid(SystemSid);
1083 }
1084
1085 if (AdminsSid)
1086 {
1087 FreeSid(AdminsSid);
1088 }
1089
1090 if (Dacl)
1091 {
1093 }
1094
1095 if (!Success)
1096 {
1097 if (RelSd)
1098 {
1099 HeapFree(GetProcessHeap(), 0, RelSd);
1100 }
1101 }
1102
1103 return Success;
1104}
static SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: security.c:40
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:674
BOOL WINAPI InitializeAcl(PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
Definition: security.c:1006
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
BOOL WINAPI AddAccessAllowedAce(PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)
Definition: security.c:1039
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
@ Success
Definition: eventcreate.c:712
struct _ACL ACL
struct _ACCESS_ALLOWED_ACE ACCESS_ALLOWED_ACE
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1605
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
Definition: rtlfuncs.h:1606
#define SYNCHRONIZE
Definition: nt_native.h:61
#define STANDARD_RIGHTS_READ
Definition: nt_native.h:65
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted)
Definition: sec.c:312
BOOL WINAPI MakeSelfRelativeSD(PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, LPDWORD lpdwBufferLength)
Definition: sec.c:214
BOOL WINAPI SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted)
Definition: sec.c:288
uint32_t ULONG
Definition: typedefs.h:59
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SEMAPHORE_ALL_ACCESS
Definition: winbase.h:161
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:574
#define SECURITY_AUTHENTICATED_USER_RID
Definition: setypes.h:568
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define ACL_REVISION
Definition: setypes.h:39
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652

Referenced by DllMain().

◆ DeletePwrScheme()

BOOLEAN WINAPI DeletePwrScheme ( UINT  uiIndex)

Definition at line 99 of file powrprof.c.

100{
101 WCHAR Buf[MAX_PATH];
102 UINT Current;
103 LONG Err;
104
105 swprintf(Buf, L"Control Panel\\PowerCfg\\PowerPolicies\\%d", uiIndex);
106
107 if (!GetActivePwrScheme(&Current))
108 return FALSE;
109
110 if (Current == uiIndex)
111 {
113 return FALSE;
114 }
115
117 if (Err != ERROR_SUCCESS)
118 {
119 TRACE("RegDeleteKey failed: %d\n", Err);
120 SetLastError(Err);
121 return FALSE;
122 }
123
124 return TRUE;
125}
#define MAX_PATH
Definition: compat.h:34
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define swprintf
Definition: precomp.h:40
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
BOOLEAN WINAPI GetActivePwrScheme(PUINT puiID)
Definition: powrprof.c:285
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegDeleteKey
Definition: winreg.h:502
__wchar_t WCHAR
Definition: xmlstorage.h:180
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Referenced by DelScheme(), and test_DeletePwrScheme().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 1370 of file powrprof.c.

1371{
1372 switch(fdwReason)
1373 {
1374 case DLL_PROCESS_ATTACH:
1375 {
1376 HKEY hKey;
1377 LONG Err;
1378 SECURITY_ATTRIBUTES SecAttrs;
1380
1381 DisableThreadLibraryCalls(hinstDLL);
1382
1384
1385 if (Err != ERROR_SUCCESS)
1386 {
1387 TRACE("Couldn't open registry key HKLM\\%s, using some sane(?) defaults\n", debugstr_w(szPowerCfgSubKey));
1388 }
1389 else
1390 {
1391 WCHAR lpValue[MAX_PATH];
1392 DWORD cbValue = sizeof(lpValue);
1393
1394 Err = RegQueryValueExW(hKey, szLastID, 0, 0, (BYTE*)lpValue, &cbValue);
1395 if (Err == ERROR_SUCCESS)
1396 {
1397 g_LastID = _wtoi(lpValue);
1398 }
1399 else
1400 {
1401 TRACE("Couldn't open registry entry HKLM\\%s\\LastID, using some sane(?) defaults\n", debugstr_w(szPowerCfgSubKey));
1402 }
1404 }
1405
1407 {
1408 ERR("Couldn't create POWRPROF semaphore security descriptor!\n");
1409 return FALSE;
1410 }
1411
1412 SecAttrs.nLength = sizeof(SECURITY_ATTRIBUTES);
1413 SecAttrs.lpSecurityDescriptor = Sd;
1414 SecAttrs.bInheritHandle = FALSE;
1415
1417 HeapFree(GetProcessHeap(), 0, Sd);
1418 if (PPRegSemaphore == NULL)
1419 {
1420 ERR("Couldn't create Semaphore: %d\n", GetLastError());
1421 return FALSE;
1422 }
1423 break;
1424 }
1425 case DLL_PROCESS_DETACH:
1427 break;
1428 }
1429 return TRUE;
1430}
static DWORD const fdwReason
#define ERR(fmt,...)
Definition: precomp.h:57
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define CloseHandle
Definition: compat.h:739
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define debugstr_w
Definition: kernel32.h:32
static const WCHAR szSemaphoreName[]
Definition: powrprof.c:47
UINT g_LastID
Definition: powrprof.c:52
static const WCHAR szLastID[]
Definition: powrprof.c:50
static BOOLEAN CreatePowrProfSemaphoreSecurity(_Out_ PSECURITY_DESCRIPTOR *PowrProfSd)
Creates a security descriptor for the power management registry semaphore.
Definition: powrprof.c:959
HANDLE PPRegSemaphore
Definition: powrprof.c:56
LPVOID lpSecurityDescriptor
Definition: compat.h:193
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444
unsigned char BYTE
Definition: xxhash.c:193

◆ EnumPwrSchemes()

BOOLEAN WINAPI EnumPwrSchemes ( PWRSCHEMESENUMPROC  lpfnPwrSchemesEnumProc,
LPARAM  lParam 
)

Definition at line 219 of file powrprof.c.

221{
222 HKEY hKey;
223 LONG Err;
224 DWORD dwSize, dwNameSize = MAX_PATH, dwDescSize = MAX_PATH, dwIndex = 0;
225 WCHAR szNum[3 + 1], szName[MAX_PATH], szDesc[MAX_PATH];
226 POWER_POLICY PwrPolicy;
227 USER_POWER_POLICY userPwrPolicy;
228 MACHINE_POWER_POLICY machinePwrPolicy;
229 BOOLEAN bRet = FALSE;
230
231 if (!lpfnPwrSchemesEnumProc)
232 {
234 return FALSE;
235 }
236
237 Err = RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\PowerCfg\\PowerPolicies", 0, KEY_READ, &hKey);
238 if (Err != ERROR_SUCCESS)
239 {
240 ERR("RegOpenKeyW failed: %d\n", Err);
241 SetLastError(Err);
242 return FALSE;
243 }
244
246
247 dwSize = sizeof(szNum) / sizeof(WCHAR);
248
249 while (RegEnumKeyExW(hKey, dwIndex, szNum, &dwSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
250 {
251 if (!POWRPROF_GetUserPowerPolicy(szNum, &userPwrPolicy,
252 dwNameSize, szName,
253 dwDescSize, szDesc))
254 {
255 WARN("POWRPROF_GetUserPowerPolicy failed\n");
256 goto cleanup;
257 }
258
259 if (!POWRPROF_GetMachinePowerPolicy(szNum, &machinePwrPolicy))
260 {
261 WARN("POWRPROF_GetMachinePowerPolicy failed\n");
262 goto cleanup;
263 }
264
265 memcpy(&PwrPolicy.user, &userPwrPolicy, sizeof(USER_POWER_POLICY));
266 memcpy(&PwrPolicy.mach, &machinePwrPolicy, sizeof(MACHINE_POWER_POLICY));
267
268 if (!lpfnPwrSchemesEnumProc(_wtoi(szNum), (wcslen(szName) + 1) * sizeof(WCHAR), szName, (wcslen(szDesc) + 1) * sizeof(WCHAR), szDesc, &PwrPolicy, lParam))
269 goto cleanup;
270 else
271 bRet = TRUE;
272
273 dwSize = sizeof(szNum) / sizeof(WCHAR);
274 dwIndex++;
275 }
276
277cleanup:
280
281 return bRet;
282}
#define WARN(fmt,...)
Definition: precomp.h:61
LPARAM lParam
Definition: combotst.c:139
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static void cleanup(void)
Definition: main.c:1335
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static BOOLEAN POWRPROF_GetMachinePowerPolicy(LPWSTR szNum, PMACHINE_POWER_POLICY pmachinePwrPolicy)
Definition: powrprof.c:185
static BOOLEAN POWRPROF_GetUserPowerPolicy(LPWSTR szNum, PUSER_POWER_POLICY puserPwrPolicy, DWORD cchName, LPWSTR szName, DWORD cchDesc, LPWSTR szDesc)
Definition: powrprof.c:128
static const WCHAR szName[]
Definition: powrprof.c:45
MACHINE_POWER_POLICY mach
Definition: powrprof.h:118
USER_POWER_POLICY user
Definition: powrprof.h:117
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542

Referenced by BuildSchemesList(), ShowPowerSchemesPopupMenu(), and test_EnumPwrSchemes().

◆ FixSystemPowerState()

static VOID FixSystemPowerState ( PSYSTEM_POWER_STATE  Psps,
SYSTEM_POWER_CAPABILITIES  PowerCaps 
)
static

Definition at line 1107 of file powrprof.c.

1108{
1109 //Lohnegrim: If the System doesn't support the Powerstates, then we have to change them
1110 if (!PowerCaps.SystemS1 && *Psps == PowerSystemSleeping1)
1111 *Psps = PowerSystemSleeping2;
1112 if (!PowerCaps.SystemS2 && *Psps == PowerSystemSleeping2)
1113 *Psps = PowerSystemSleeping3;
1114 if (!PowerCaps.SystemS3 && *Psps == PowerSystemSleeping3)
1115 *Psps = PowerSystemHibernate;
1116 if (!(PowerCaps.SystemS4 && PowerCaps.HiberFilePresent) && *Psps == PowerSystemHibernate)
1117 *Psps = PowerSystemSleeping2;
1118 if (!PowerCaps.SystemS1 && *Psps == PowerSystemSleeping1)
1119 *Psps = PowerSystemSleeping2;
1120 if (!PowerCaps.SystemS2 && *Psps == PowerSystemSleeping2)
1121 *Psps = PowerSystemSleeping3;
1122 if (!PowerCaps.SystemS3 && *Psps == PowerSystemSleeping3)
1123 *Psps = PowerSystemShutdown;
1124
1125}
@ PowerSystemSleeping1
Definition: ntpoapi.h:37
@ PowerSystemSleeping2
Definition: ntpoapi.h:38
@ PowerSystemSleeping3
Definition: ntpoapi.h:39
@ PowerSystemShutdown
Definition: ntpoapi.h:41
@ PowerSystemHibernate
Definition: ntpoapi.h:40

Referenced by ValidatePowerPolicies().

◆ GetActivePwrScheme()

BOOLEAN WINAPI GetActivePwrScheme ( PUINT  puiID)

Definition at line 285 of file powrprof.c.

286{
287 HKEY hKey;
288 WCHAR szBuf[MAX_PATH];
290 LONG Err;
291
292 TRACE("GetActivePwrScheme(%u)", puiID);
293
294 Err = RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\PowerCfg", 0, KEY_READ, &hKey);
295 if (Err != ERROR_SUCCESS)
296 {
297 ERR("RegOpenKey failed: %d\n", Err);
298 SetLastError(Err);
299 return FALSE;
300 }
301
302 dwSize = sizeof(szBuf);
303 Err = RegQueryValueExW(hKey, L"CurrentPowerPolicy",
304 NULL, NULL,
305 (LPBYTE)&szBuf, &dwSize);
306 if (Err != ERROR_SUCCESS)
307 {
308 ERR("RegQueryValueEx failed: %d\n", Err);
310 SetLastError(Err);
311 return FALSE;
312 }
313
315 *puiID = _wtoi(szBuf);
316
317 return TRUE;
318}
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by CreateEnergyList(), DeletePwrScheme(), GetCurrentPowerPolicies(), ShowPowerSchemesPopupMenu(), test_DeletePwrScheme(), test_GetCurrentPowerPolicies(), and test_GetSetActivePwrScheme().

◆ GetCurrentPowerPolicies()

BOOLEAN WINAPI GetCurrentPowerPolicies ( PGLOBAL_POWER_POLICY  pGlobalPowerPolicy,
PPOWER_POLICY  pPowerPolicy 
)

Definition at line 321 of file powrprof.c.

323{
324 /*
325 SYSTEM_POWER_POLICY ACPower, DCPower;
326
327 FIXME("(%p, %p) stub!\n", pGlobalPowerPolicy, pPowerPolicy);
328
329 NtPowerInformation(SystemPowerPolicyAc, 0, 0, &ACPower, sizeof(SYSTEM_POWER_POLICY));
330 NtPowerInformation(SystemPowerPolicyDc, 0, 0, &DCPower, sizeof(SYSTEM_POWER_POLICY));
331
332 return FALSE;
333 */
334/*
335 Lohnegrim: I don't know why this Function should call NtPowerInformation, because as far as I know,
336 it simply returns the GlobalPowerPolicy and the AktivPowerScheme!
337 */
338 UINT uiID;
339
340 if (pGlobalPowerPolicy != NULL)
341 {
342 if (!ReadGlobalPwrPolicy(pGlobalPowerPolicy))
343 return FALSE;
344 }
345 if (pPowerPolicy != NULL)
346 {
347 if (!GetActivePwrScheme(&uiID))
348 return FALSE;
349
350 if (!ReadPwrScheme(uiID, pPowerPolicy))
351 return FALSE;
352 }
353
354 return TRUE;
355}
BOOLEAN WINAPI ReadPwrScheme(UINT uiID, PPOWER_POLICY pPowerPolicy)
Definition: powrprof.c:721
BOOLEAN WINAPI ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
Definition: powrprof.c:632

Referenced by test_GetCurrentPowerPolicies(), test_ValidatePowerPolicies(), and test_ValidatePowerPolicies_Old().

◆ GetPwrCapabilities()

BOOLEAN WINAPI GetPwrCapabilities ( PSYSTEM_POWER_CAPABILITIES  lpSystemPowerCapabilities)

Definition at line 358 of file powrprof.c.

359{
361
362 TRACE("(%p)\n", lpSystemPowerCapabilities);
363
364 if (!lpSystemPowerCapabilities)
365 {
367 return FALSE;
368 }
369
370 Status = NtPowerInformation(SystemPowerCapabilities, 0, 0, lpSystemPowerCapabilities, sizeof(SYSTEM_POWER_CAPABILITIES));
371 if(!NT_SUCCESS(Status))
372 {
374 return FALSE;
375 }
376
377 return TRUE;
378}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
@ SystemPowerCapabilities
Definition: ntpoapi.h:71

Referenced by Adv_InitDialog(), Applet1(), CreateEnergyList(), Hib_InitDialog(), Pos_InitData(), and test_GetPwrCapabilities().

◆ GetPwrDiskSpindownRange()

BOOLEAN WINAPI GetPwrDiskSpindownRange ( PUINT  RangeMax,
PUINT  RangeMin 
)

Definition at line 381 of file powrprof.c.

382{
383 HKEY hKey;
384 BYTE lpValue[40];
385 LONG Ret;
386 DWORD cbValue = sizeof(lpValue);
387
388 TRACE("(%p, %p)\n", RangeMax, RangeMin);
389
390 if (RangeMax == NULL || RangeMin == NULL)
391 {
393 return FALSE;
394 }
395
397
399 if (Ret != ERROR_SUCCESS)
400 {
401 TRACE("RegOpenKeyEx failed: %d\n", Ret);
402 TRACE("Using defaults: 3600, 3\n");
403 *RangeMax = 3600;
404 *RangeMin = 3;
406 return TRUE;
407 }
408
409 Ret = RegQueryValueExW(hKey, szDiskMax, 0, 0, lpValue, &cbValue);
410 if (Ret != ERROR_SUCCESS)
411 {
412 TRACE("Couldn't open DiskSpinDownMax: %d\n", Ret);
413 TRACE("Using default: 3600\n");
414 *RangeMax = 3600;
415 }
416 else
417 {
418 *RangeMax = _wtoi((LPCWSTR)lpValue);
419 }
420
421 cbValue = sizeof(lpValue);
422
423 Ret = RegQueryValueExW(hKey, szDiskMin, 0, 0, lpValue, &cbValue);
424 if (Ret != ERROR_SUCCESS)
425 {
426 TRACE("Couldn't open DiskSpinDownMin: %d\n", Ret);
427 TRACE("Using default: 3\n");
428 *RangeMin = 3;
429 }
430 else
431 {
432 *RangeMin = _wtoi((LPCWSTR)lpValue);
433 }
434
436
438
439 return TRUE;
440}
#define INFINITE
Definition: serial.h:102
static const WCHAR szDiskMin[]
Definition: powrprof.c:49
static const WCHAR szDiskMax[]
Definition: powrprof.c:48
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by test_GetPwrDiskSpindownRange().

◆ IsAdminOverrideActive()

BOOLEAN WINAPI IsAdminOverrideActive ( PADMINISTRATOR_POWER_POLICY  p)

Definition at line 443 of file powrprof.c.

444{
445 FIXME("( %p) stub!\n", p);
446 return FALSE;
447}
#define FIXME(fmt,...)
Definition: precomp.h:53
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by test_IsAdminOverrideActive().

◆ IsPwrHibernateAllowed()

BOOLEAN WINAPI IsPwrHibernateAllowed ( VOID  )

Definition at line 450 of file powrprof.c.

451{
454 BOOLEAN old;
455
457
458 Status = NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));
459 if (!NT_SUCCESS(Status))
460 {
462 return FALSE;
463 }
464
465 return PowerCaps.SystemS4 && PowerCaps.HiberFilePresent; // IsHiberfilPresent();
466}

Referenced by ExitWindowsDialog(), GetAllowedShutdownOptions(), and wmain().

◆ IsPwrShutdownAllowed()

BOOLEAN WINAPI IsPwrShutdownAllowed ( VOID  )

Definition at line 469 of file powrprof.c.

470{
473 BOOLEAN old;
474
476
477 Status = NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));
478 if (!NT_SUCCESS(Status))
479 {
481 return FALSE;
482 }
483
484 return PowerCaps.SystemS5;
485}

◆ IsPwrSuspendAllowed()

BOOLEAN WINAPI IsPwrSuspendAllowed ( VOID  )

Definition at line 488 of file powrprof.c.

489{
492 BOOLEAN old;
493
495
496 Status = NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));
497 if (!NT_SUCCESS(Status))
498 {
500 return FALSE;
501 }
502
503 return PowerCaps.SystemS1 || PowerCaps.SystemS2 || PowerCaps.SystemS3;
504}

Referenced by ExitWindowsDialog(), GetAllowedShutdownOptions(), IsSuspendAllowed(), and ShutdownOnFriendlyInit().

◆ PowerDeterminePlatformRole()

POWER_PLATFORM_ROLE WINAPI PowerDeterminePlatformRole ( void  )

Definition at line 534 of file powrprof.c.

535{
536 FIXME("stub\n");
537 return PlatformRoleDesktop;
538}
@ PlatformRoleDesktop
Definition: potypes.h:294

◆ PowerDeterminePlatformRoleEx()

POWER_PLATFORM_ROLE WINAPI PowerDeterminePlatformRoleEx ( ULONG  version)

Definition at line 540 of file powrprof.c.

541{
542 FIXME("%lu stub.\n", version);
543 return PlatformRoleDesktop;
544}
static const WCHAR version[]
Definition: asmname.c:66

◆ PowerEnumerate()

DWORD WINAPI PowerEnumerate ( HKEY  key,
const GUID scheme,
const GUID subgroup,
POWER_DATA_ACCESSOR  flags,
ULONG  index,
UCHAR buffer,
DWORD buffer_size 
)

Definition at line 546 of file powrprof.c.

548{
549 FIXME("(%p,%s,%s,%d,%ld,%p,%p) stub!\n", key, debugstr_guid(scheme), debugstr_guid(subgroup),
552}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
GLbitfield flags
Definition: glext.h:7161
#define debugstr_guid
Definition: kernel32.h:35
DWORD scheme
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
Definition: copy.c:22

◆ PowerGetActiveScheme()

DWORD WINAPI PowerGetActiveScheme ( HKEY  UserRootPowerKey,
GUID **  polguid 
)

Definition at line 507 of file powrprof.c.

508{
509 FIXME("(%p,%p) stub!\n", UserRootPowerKey, polguid);
511}

◆ PowerReadDCValue()

DWORD WINAPI PowerReadDCValue ( HKEY  RootPowerKey,
const GUID Scheme,
const GUID SubGroup,
const GUID PowerSettings,
PULONG  Type,
PUCHAR  Buffer,
DWORD BufferSize 
)

Definition at line 520 of file powrprof.c.

521{
522 FIXME("(%p,%s,%s,%s,%p,%p,%p) stub!\n", RootPowerKey, debugstr_guid(Scheme), debugstr_guid(SubGroup), debugstr_guid(PowerSettings), Type, Buffer, BufferSize);
524}
Type
Definition: Type.h:7
Definition: bufpool.h:45
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

◆ PowerReadFriendlyName()

DWORD WINAPI PowerReadFriendlyName ( HKEY  RootPowerKey,
const GUID Scheme,
const GUID SubGroup,
const GUID PowerSettings,
UCHAR Buffer,
DWORD BufferSize 
)

Definition at line 526 of file powrprof.c.

529{
530 FIXME("(%p,%s,%s,%s,%p,%p) stub!\n", RootPowerKey, debugstr_guid(Scheme), debugstr_guid(SubGroup), debugstr_guid(PowerSettings), Buffer, BufferSize);
532}

◆ PowerRegisterSuspendResumeNotification()

DWORD WINAPI PowerRegisterSuspendResumeNotification ( DWORD  flags,
HANDLE  recipient,
PHPOWERNOTIFY  handle 
)

Definition at line 554 of file powrprof.c.

555{
556 FIXME("(0x%08lx,%p,%p) stub!\n", flags, recipient, handle);
557 *handle = (HPOWERNOTIFY)0xdeadbeef;
558 return ERROR_SUCCESS;
559}
PVOID HPOWERNOTIFY
Definition: powrprof.h:154

◆ PowerSetActiveScheme()

DWORD WINAPI PowerSetActiveScheme ( HKEY  UserRootPowerKey,
GUID polguid 
)

Definition at line 513 of file powrprof.c.

514{
515 FIXME("(%p,%s) stub!\n", UserRootPowerKey, wine_dbgstr_guid(polguid));
516 return ERROR_SUCCESS;
517}
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197

◆ PowerSettingRegisterNotification()

DWORD WINAPI PowerSettingRegisterNotification ( const GUID setting,
DWORD  flags,
HANDLE  recipient,
PHPOWERNOTIFY  handle 
)

Definition at line 567 of file powrprof.c.

568{
569 FIXME("(%s,0x%08lx,%p,%p) stub!\n", debugstr_guid(setting), flags, recipient, handle);
570 *handle = (PHPOWERNOTIFY)0xdeadbeef;
571 return ERROR_SUCCESS;
572}
PVOID * PHPOWERNOTIFY
Definition: powrprof.h:154

◆ PowerSettingUnregisterNotification()

DWORD WINAPI PowerSettingUnregisterNotification ( HPOWERNOTIFY  handle)

Definition at line 574 of file powrprof.c.

575{
576 FIXME("(%p) stub!\n", handle);
577 return ERROR_SUCCESS;
578}

◆ PowerUnregisterSuspendResumeNotification()

DWORD WINAPI PowerUnregisterSuspendResumeNotification ( HPOWERNOTIFY  handle)

Definition at line 561 of file powrprof.c.

562{
563 FIXME("(%p) stub!\n", handle);
564 return ERROR_SUCCESS;
565}

◆ PowerWriteACValueIndex()

DWORD WINAPI PowerWriteACValueIndex ( HKEY  key,
const GUID scheme,
const GUID subgroup,
const GUID setting,
DWORD  index 
)

Definition at line 580 of file powrprof.c.

581{
582 FIXME("(%p,%s,%s,%s,0x%08lx) stub!\n", key, debugstr_guid(scheme), debugstr_guid(subgroup), debugstr_guid(setting), index);
583 return ERROR_SUCCESS;
584}

◆ POWRPROF_GetMachinePowerPolicy()

static BOOLEAN POWRPROF_GetMachinePowerPolicy ( LPWSTR  szNum,
PMACHINE_POWER_POLICY  pmachinePwrPolicy 
)
static

Definition at line 185 of file powrprof.c.

186{
187 HKEY hKey;
188 LONG Err;
191
192 swprintf(szPath, L"Software\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\PowerPolicies\\%s", szNum);
193
195 if (Err != ERROR_SUCCESS)
196 {
197 ERR("RegOpenKeyExW failed: %d\n", Err);
198 SetLastError(Err);
199 return FALSE;
200 }
201
203 Err = RegQueryValueExW(hKey, L"Policies", NULL, NULL, (LPBYTE)pmachinePwrPolicy, &dwSize);
204
205 if (Err != ERROR_SUCCESS)
206 {
207 ERR("RegQueryValueExW failed: %d\n", Err);
208 SetLastError(Err);
210 return FALSE;
211 }
212
214
215 return TRUE;
216}
LPCWSTR szPath
Definition: env.c:37
struct _MACHINE_POWER_POLICY MACHINE_POWER_POLICY

Referenced by EnumPwrSchemes(), and ReadPwrScheme().

◆ POWRPROF_GetUserPowerPolicy()

static BOOLEAN POWRPROF_GetUserPowerPolicy ( LPWSTR  szNum,
PUSER_POWER_POLICY  puserPwrPolicy,
DWORD  cchName,
LPWSTR  szName,
DWORD  cchDesc,
LPWSTR  szDesc 
)
static

Definition at line 128 of file powrprof.c.

132{
133 HKEY hSubKey = NULL;
135 LONG Err;
137 BOOL bRet = FALSE;
138
139 swprintf(szPath, L"Control Panel\\PowerCfg\\PowerPolicies\\%s", szNum);
140
141 Err = RegOpenKeyExW(HKEY_CURRENT_USER, szPath, 0, KEY_READ, &hSubKey);
142 if (Err != ERROR_SUCCESS)
143 {
144 ERR("RegOpenKeyExW failed: %d\n", Err);
145 SetLastError(Err);
146 return FALSE;
147 }
148
149 dwSize = cchName * sizeof(WCHAR);
150 Err = RegQueryValueExW(hSubKey, L"Name", NULL, NULL, (LPBYTE)szName, &dwSize);
151 if (Err != ERROR_SUCCESS)
152 {
153 ERR("RegQueryValueExW failed: %d\n", Err);
154 SetLastError(Err);
155 goto cleanup;
156 }
157
158 dwSize = cchDesc * sizeof(WCHAR);
159 Err = RegQueryValueExW(hSubKey, L"Description", NULL, NULL, (LPBYTE)szDesc, &dwSize);
160 if (Err != ERROR_SUCCESS)
161 {
162 ERR("RegQueryValueExW failed: %d\n", Err);
163 SetLastError(Err);
164 goto cleanup;
165 }
166
167 dwSize = sizeof(USER_POWER_POLICY);
168 Err = RegQueryValueExW(hSubKey, L"Policies", NULL, NULL, (LPBYTE)puserPwrPolicy, &dwSize);
169 if (Err != ERROR_SUCCESS)
170 {
171 ERR("RegQueryValueExW failed: %d\n", Err);
172 SetLastError(Err);
173 goto cleanup;
174 }
175
176 bRet = TRUE;
177
178cleanup:
179 RegCloseKey(hSubKey);
180
181 return bRet;
182}
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _USER_POWER_POLICY USER_POWER_POLICY
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2792

Referenced by EnumPwrSchemes(), and ReadPwrScheme().

◆ ReadGlobalPwrPolicy()

BOOLEAN WINAPI ReadGlobalPwrPolicy ( PGLOBAL_POWER_POLICY  pGlobalPowerPolicy)

Definition at line 632 of file powrprof.c.

633{
634 GLOBAL_MACHINE_POWER_POLICY glMachPwrPolicy;
635 GLOBAL_USER_POWER_POLICY glUserPwrPolicy;
636 HKEY hKey = NULL;
638 LONG Err;
639 BOOL bRet = FALSE;
640
642
643 // Getting user global power policy
644 Err = RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\PowerCfg\\GlobalPowerPolicy", 0, KEY_READ, &hKey);
645 if (Err != ERROR_SUCCESS)
646 {
647 ERR("RegOpenKeyW failed: %d\n", Err);
648 SetLastError(Err);
649 goto cleanup;
650 }
651
652 dwSize = sizeof(glUserPwrPolicy);
653 Err = RegQueryValueExW(hKey, L"Policies", NULL, NULL, (LPBYTE)&glUserPwrPolicy, &dwSize);
654 if (Err != ERROR_SUCCESS)
655 {
656 ERR("RegQueryValueExW failed: %d\n", Err);
657 SetLastError(Err);
658 goto cleanup;
659 }
660
662
663 // Getting machine global power policy
664 Err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\GlobalPowerPolicy", 0, KEY_READ, &hKey);
665 if (Err != ERROR_SUCCESS)
666 {
667 ERR("RegOpenKeyW failed: %d\n", Err);
668 SetLastError(Err);
669 goto cleanup;
670 }
671
672 dwSize = sizeof(glMachPwrPolicy);
673 Err = RegQueryValueExW(hKey, L"Policies", NULL, NULL, (LPBYTE)&glMachPwrPolicy, &dwSize);
674 if (Err != ERROR_SUCCESS)
675 {
676 ERR("RegQueryValueExW failed: %d\n", Err);
677 SetLastError(Err);
678 goto cleanup;
679 }
680
681 memcpy(&pGlobalPowerPolicy->user, &glUserPwrPolicy, sizeof(GLOBAL_USER_POWER_POLICY));
682 memcpy(&pGlobalPowerPolicy->mach, &glMachPwrPolicy, sizeof(GLOBAL_MACHINE_POWER_POLICY));
683 bRet = TRUE;
684
685cleanup:
686 if(hKey)
689
690 return bRet;
691}
GLOBAL_USER_POWER_POLICY user
Definition: powrprof.h:60
GLOBAL_MACHINE_POWER_POLICY mach
Definition: powrprof.h:61

Referenced by Adv_InitDialog(), Ala_InitData(), CreateEnergyList(), GetCurrentPowerPolicies(), and test_ReadGlobalPwrPolicy().

◆ ReadProcessorPwrScheme()

BOOLEAN WINAPI ReadProcessorPwrScheme ( UINT  uiID,
PMACHINE_PROCESSOR_POWER_POLICY  pMachineProcessorPowerPolicy 
)

Definition at line 695 of file powrprof.c.

697{
698 HKEY hKey;
701
702 swprintf(szPath, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\ProcessorPolicies\\%i", uiID);
704 return FALSE;
705
706 if (RegQueryValueExW(hKey, szPolicies, NULL, 0, (LPBYTE)pMachineProcessorPowerPolicy, &dwSize) == ERROR_SUCCESS)
707 {
709 return TRUE;
710 }
711
713 if (uiID != 0)
714 return ReadProcessorPwrScheme(0, pMachineProcessorPowerPolicy);
715
716 return FALSE;
717}
BOOLEAN WINAPI ReadProcessorPwrScheme(UINT uiID, PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy)
Definition: powrprof.c:695
static const WCHAR szPolicies[]
Definition: powrprof.c:44
struct _MACHINE_PROCESSOR_POWER_POLICY MACHINE_PROCESSOR_POWER_POLICY
#define RegOpenKeyEx
Definition: winreg.h:520

Referenced by ReadProcessorPwrScheme(), and test_ReadProcessorPwrScheme().

◆ ReadPwrScheme()

BOOLEAN WINAPI ReadPwrScheme ( UINT  uiID,
PPOWER_POLICY  pPowerPolicy 
)

Definition at line 721 of file powrprof.c.

723{
724 USER_POWER_POLICY userPwrPolicy;
725 MACHINE_POWER_POLICY machinePwrPolicy;
726 WCHAR szNum[16]; // max number - 999
727
729
730 swprintf(szNum, L"%d", uiID);
731
732 if (!POWRPROF_GetUserPowerPolicy(szNum, &userPwrPolicy, 0, NULL, 0, NULL))
733 {
735 return FALSE;
736 }
737
738 if (!POWRPROF_GetMachinePowerPolicy(szNum, &machinePwrPolicy))
739 {
741 return FALSE;
742 }
743
744 memcpy(&pPowerPolicy->user, &userPwrPolicy, sizeof(userPwrPolicy));
745 memcpy(&pPowerPolicy->mach, &machinePwrPolicy, sizeof(machinePwrPolicy));
746
748
749 return TRUE;
750}

Referenced by CreateEnergyList(), GetCurrentPowerPolicies(), SetActivePwrScheme(), and test_ReadPwrScheme().

◆ SetActivePwrScheme()

BOOLEAN WINAPI SetActivePwrScheme ( UINT  uiID,
PGLOBAL_POWER_POLICY  lpGlobalPowerPolicy,
PPOWER_POLICY  lpPowerPolicy 
)

Definition at line 753 of file powrprof.c.

756{
757 POWER_POLICY tmp;
758 HKEY hKey;
759 WCHAR Buf[16];
760
761 if (!ReadPwrScheme(uiID, &tmp))
762 return FALSE;
763
765 return FALSE;
766
767 swprintf(Buf, L"%i", uiID);
768
770 {
772 return FALSE;
773 }
775
776 if (lpGlobalPowerPolicy != NULL || lpPowerPolicy != NULL)
777 {
778 if (!ValidatePowerPolicies(lpGlobalPowerPolicy, lpPowerPolicy))
779 return FALSE;
780
781 if (lpGlobalPowerPolicy != NULL && !WriteGlobalPwrPolicy(lpGlobalPowerPolicy))
782 return FALSE;
783
784 if (lpPowerPolicy != NULL && !WritePwrPolicy(&uiID,lpPowerPolicy))
785 return FALSE;
786 }
787
788 return TRUE;
789}
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define REG_SZ
Definition: layer.c:22
BYTE * PBYTE
Definition: pedump.c:66
static const WCHAR szCurrentPowerPolicies[]
Definition: powrprof.c:42
static const WCHAR szUserPowerConfigSubKey[]
Definition: powrprof.c:40
BOOLEAN WINAPI ValidatePowerPolicies(PGLOBAL_POWER_POLICY pGPP, PPOWER_POLICY pPP)
Definition: powrprof.c:1128
BOOLEAN WINAPI WriteGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
Definition: powrprof.c:801
BOOLEAN WINAPI WritePwrPolicy(PUINT puiID, PPOWER_POLICY pPowerPolicy)
Definition: powrprof.c:1345
#define strlenW(s)
Definition: unicode.h:34

Referenced by Pos_SaveData(), ShowPowerSchemesPopupMenu(), test_GetCurrentPowerPolicies(), and test_GetSetActivePwrScheme().

◆ SetLastID()

static VOID SetLastID ( VOID  )
static

Definition at line 860 of file powrprof.c.

861{
862 WCHAR Buf[16];
863 HKEY hKey;
864
867 0,
868 KEY_WRITE,
869 &hKey) != ERROR_SUCCESS)
870 return;
871 swprintf(Buf, L"%i", g_LastID);
872 RegSetValueExW(hKey, szLastID, 0, REG_SZ, (PBYTE)Buf, strlenW(Buf)*sizeof(WCHAR));
874}

Referenced by WritePwrScheme().

◆ SetSuspendState()

BOOLEAN WINAPI SetSuspendState ( BOOLEAN  Hibernate,
BOOLEAN  ForceCritical,
BOOLEAN  DisableWakeEvent 
)

Definition at line 792 of file powrprof.c.

795{
796 FIXME("(%d, %d, %d) stub!\n", Hibernate, ForceCritical, DisableWakeEvent);
797 return TRUE;
798}

Referenced by ExitWindowsDialog(), ShutdownDialogProc(), and wmain().

◆ ValidatePowerPolicies()

BOOLEAN WINAPI ValidatePowerPolicies ( PGLOBAL_POWER_POLICY  pGPP,
PPOWER_POLICY  pPP 
)

Definition at line 1128 of file powrprof.c.

1129{
1130 SYSTEM_POWER_CAPABILITIES PowerCaps;
1131 NTSTATUS ret;
1132 BOOLEAN old;
1133
1135 ret = NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));
1136 if (ret != STATUS_SUCCESS)
1137 {
1139 return FALSE;
1140 }
1141
1142 if (pGPP)
1143 {
1144 if (pGPP->user.Revision != 1 || pGPP->mach.Revision != 1)
1145 {
1147 return FALSE;
1148 }
1150 {
1152 return FALSE;
1153 }
1154 if ((int)pGPP->mach.LidOpenWakeAc > PowerSystemShutdown)
1155 {
1157 return FALSE;
1158 }
1160 {
1162 return FALSE;
1163 }
1164 if ((int)pGPP->mach.LidOpenWakeDc > PowerSystemShutdown)
1165 {
1167 return FALSE;
1168 }
1169 //Lohnegrim: unneeded
1170 /*if ((pGPP->mach.LidOpenWakeDc < PowerSystemWorking) || (pGPP->mach.LidOpenWakeDc >= PowerSystemMaximum))
1171 {
1172 SetLastError(ERROR_GEN_FAILURE);
1173 return FALSE;
1174 }*/
1175 if (!CheckPowerActionPolicy(&pGPP->user.LidCloseAc,PowerCaps))
1176 {
1177 return FALSE;
1178 }
1179 if (!CheckPowerActionPolicy(&pGPP->user.LidCloseDc,PowerCaps))
1180 {
1181 return FALSE;
1182 }
1183 if (!CheckPowerActionPolicy(&pGPP->user.PowerButtonAc,PowerCaps))
1184 {
1185 return FALSE;
1186 }
1187 if (!CheckPowerActionPolicy(&pGPP->user.PowerButtonDc,PowerCaps))
1188 {
1189 return FALSE;
1190 }
1191 if (!CheckPowerActionPolicy(&pGPP->user.SleepButtonAc,PowerCaps))
1192 {
1193 return FALSE;
1194 }
1195 if (!CheckPowerActionPolicy(&pGPP->user.SleepButtonDc,PowerCaps))
1196 {
1197 return FALSE;
1198 }
1199 //Lohnegrim: The BroadcastCapacityResolution presents the Powerlevel in Percent, if invalid set th 100 == FULL
1200 if (pGPP->mach.BroadcastCapacityResolution > 100)
1202
1203 //Lohnegrim: I have no idea, if they are really needed, or if they are specific for my System, or what they mean, so I removed them
1204 //pGPP->user.DischargePolicy[1].PowerPolicy.EventCode = pGPP->user.DischargePolicy[1].PowerPolicy.EventCode | 0x010000;
1205 //pGPP->user.DischargePolicy[2].PowerPolicy.EventCode = pGPP->user.DischargePolicy[2].PowerPolicy.EventCode | 0x020000;
1206 //pGPP->user.DischargePolicy[3].PowerPolicy.EventCode = pGPP->user.DischargePolicy[3].PowerPolicy.EventCode | 0x030000;
1207
1208 FixSystemPowerState(&pGPP->mach.LidOpenWakeAc,PowerCaps);
1209 FixSystemPowerState(&pGPP->mach.LidOpenWakeDc,PowerCaps);
1210
1211 }
1212
1213 if (pPP)
1214 {
1215 if (pPP->user.Revision != 1 || pPP->mach.Revision != 1)
1216 {
1218 return FALSE;
1219 }
1220
1221 //Lohnegrim: unneeded
1222 //if (pPP->mach.MinSleepAc < PowerSystemWorking)
1223 //{
1224 // SetLastError(ERROR_GEN_FAILURE);
1225 // return FALSE;
1226 //}
1227 if ((int)pPP->mach.MinSleepAc >= PowerSystemShutdown)
1228 {
1230 return FALSE;
1231 }
1232 //Lohnegrim: unneeded
1233 //if (pPP->mach.MinSleepDc < PowerSystemWorking)
1234 //{
1235 // SetLastError(ERROR_GEN_FAILURE);
1236 // return FALSE;
1237 //}
1238 if ((int)pPP->mach.MinSleepDc >= PowerSystemShutdown)
1239 {
1241 return FALSE;
1242 }
1244 {
1246 return FALSE;
1247 }
1249 {
1251 return FALSE;
1252 }
1254 {
1256 return FALSE;
1257 }
1259 {
1261 return FALSE;
1262 }
1263
1264 if (!CheckPowerActionPolicy(&pPP->mach.OverThrottledAc,PowerCaps))
1265 {
1266 return FALSE;
1267 }
1268 if (!CheckPowerActionPolicy(&pPP->mach.OverThrottledDc,PowerCaps))
1269 {
1270 return FALSE;
1271 }
1272 if (!CheckPowerActionPolicy(&pPP->user.IdleAc,PowerCaps))
1273 {
1274 return FALSE;
1275 }
1276 if (!CheckPowerActionPolicy(&pPP->user.IdleDc,PowerCaps))
1277 {
1278 return FALSE;
1279 }
1281 {
1283 return FALSE;
1284 }
1285 //Lohnegrim: unneeded
1286 /*if ((int)pPP->user.MaxSleepAc > PowerSystemShutdown)
1287 {
1288 SetLastError(ERROR_GEN_FAILURE);
1289 return FALSE;
1290 }*/
1292 {
1294 return FALSE;
1295 }
1296 //Lohnegrim: unneeded
1297 /*if ((int)pPP->user.MaxSleepDc >= PowerSystemShutdown)
1298 {
1299 SetLastError(ERROR_GEN_FAILURE);
1300 return FALSE;
1301 }*/
1302 if (PowerCaps.SystemS1)
1303 {
1306 }
1307 else if (PowerCaps.SystemS2)
1308 {
1311 }
1312 else if (PowerCaps.SystemS3)
1313 {
1316 }
1317
1318 if (PowerCaps.SystemS4)
1319 {
1322 }
1323 else if (PowerCaps.SystemS3)
1324 {
1327 }
1328 else if (PowerCaps.SystemS1)
1329 {
1332 }
1333 //Lohnegrim: I don't know where to get this info from, so I removed it
1334 //pPP->user.OptimizeForPowerAc=TRUE;
1335 //pPP->user.OptimizeForPowerDc=TRUE;
1336
1339 }
1340
1342 return TRUE;
1343}
@ PowerSystemUnspecified
Definition: ntpoapi.h:35
@ PowerSystemWorking
Definition: ntpoapi.h:36
static VOID FixSystemPowerState(PSYSTEM_POWER_STATE Psps, SYSTEM_POWER_CAPABILITIES PowerCaps)
Definition: powrprof.c:1107
static BOOLEAN CheckPowerActionPolicy(PPOWER_ACTION_POLICY pPAP, SYSTEM_POWER_CAPABILITIES PowerCaps)
Definition: powrprof.c:904
#define STATUS_SUCCESS
Definition: shellext.h:65
SYSTEM_POWER_STATE LidOpenWakeDc
Definition: powrprof.h:41
SYSTEM_POWER_STATE LidOpenWakeAc
Definition: powrprof.h:40
POWER_ACTION_POLICY PowerButtonDc
Definition: powrprof.h:49
POWER_ACTION_POLICY LidCloseDc
Definition: powrprof.h:53
POWER_ACTION_POLICY SleepButtonDc
Definition: powrprof.h:51
POWER_ACTION_POLICY PowerButtonAc
Definition: powrprof.h:48
POWER_ACTION_POLICY SleepButtonAc
Definition: powrprof.h:50
POWER_ACTION_POLICY LidCloseAc
Definition: powrprof.h:52
SYSTEM_POWER_STATE MinSleepAc
Definition: powrprof.h:67
SYSTEM_POWER_STATE ReducedLatencySleepDc
Definition: powrprof.h:70
POWER_ACTION_POLICY OverThrottledDc
Definition: powrprof.h:79
SYSTEM_POWER_STATE ReducedLatencySleepAc
Definition: powrprof.h:69
POWER_ACTION_POLICY OverThrottledAc
Definition: powrprof.h:78
SYSTEM_POWER_STATE MinSleepDc
Definition: powrprof.h:68
SYSTEM_POWER_STATE MaxSleepAc
Definition: powrprof.h:100
SYSTEM_POWER_STATE MaxSleepDc
Definition: powrprof.h:101
POWER_ACTION_POLICY IdleAc
Definition: powrprof.h:92
POWER_ACTION_POLICY IdleDc
Definition: powrprof.h:93
int ret
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define ERROR_REVISION_MISMATCH
Definition: winerror.h:788

Referenced by CreateEnergyList(), EnumPowerSchemeCallback(), SetActivePwrScheme(), test_ValidatePowerPolicies(), test_ValidatePowerPolicies_Next(), and test_ValidatePowerPolicies_Old().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( powrprof  )

◆ WriteGlobalPwrPolicy()

BOOLEAN WINAPI WriteGlobalPwrPolicy ( PGLOBAL_POWER_POLICY  pGlobalPowerPolicy)

Definition at line 801 of file powrprof.c.

802{
803 HKEY hKey;
806
807 gupp = pGlobalPowerPolicy->user;
808 gmpp = pGlobalPowerPolicy->mach;
809
811 L"Control Panel\\PowerCfg\\GlobalPowerPolicy",
812 0,
813 KEY_WRITE,
814 &hKey) != ERROR_SUCCESS)
815 return FALSE;
816
817 if (RegSetValueExW(hKey, szPolicies, 0, REG_BINARY, (PBYTE)&gupp, sizeof(gupp)) != ERROR_SUCCESS)
818 {
820 return FALSE;
821 }
822
824
826 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\GlobalPowerPolicy",
827 0,
829 &hKey))
830 return FALSE;
831
832 if (RegSetValueExW(hKey,szPolicies, 0, REG_BINARY, (PBYTE)&gmpp, sizeof(gmpp)) != ERROR_SUCCESS)
833 {
835 return FALSE;
836 }
837
839 return TRUE;
840}
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041

Referenced by Adv_SaveData(), and SetActivePwrScheme().

◆ WriteProcessorPwrScheme()

BOOLEAN WINAPI WriteProcessorPwrScheme ( UINT  ID,
PMACHINE_PROCESSOR_POWER_POLICY  pMachineProcessorPowerPolicy 
)

Definition at line 843 of file powrprof.c.

845{
846 WCHAR Buf[MAX_PATH];
847 HKEY hKey;
848
849 swprintf(Buf, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\ProcessorPolicies\\%i", ID);
850
852 return FALSE;
853
854 RegSetValueExW(hKey, szPolicies, 0, REG_BINARY, (PBYTE)pMachineProcessorPowerPolicy, sizeof(MACHINE_PROCESSOR_POWER_POLICY));
856 return TRUE;
857}
#define ID
Definition: ruserpass.c:36
#define RegCreateKey
Definition: winreg.h:500

◆ WritePwrPolicy()

BOOLEAN WINAPI WritePwrPolicy ( PUINT  puiID,
PPOWER_POLICY  pPowerPolicy 
)

Definition at line 1345 of file powrprof.c.

1346{
1347 WCHAR Buf[MAX_PATH];
1348 HKEY hKey;
1349
1350 swprintf(Buf, L"Control Panel\\PowerCfg\\PowerPolicies\\%i", *puiID);
1351
1353 return FALSE;
1354
1355 RegSetValueExW(hKey, szPolicies, 0, REG_BINARY, (const unsigned char *)&pPowerPolicy->user, sizeof(USER_POWER_POLICY));
1357
1358 swprintf(Buf, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\PowerPolicies\\%i", *puiID);
1359
1361 return FALSE;
1362
1363 RegSetValueExW(hKey, szPolicies, 0, REG_BINARY, (const unsigned char *)&pPowerPolicy->mach, sizeof(MACHINE_POWER_POLICY));
1365
1366 return TRUE;
1367}

Referenced by SetActivePwrScheme(), and WritePwrScheme().

◆ WritePwrScheme()

BOOLEAN WINAPI WritePwrScheme ( PUINT  puiID,
LPWSTR  lpszName,
LPWSTR  lpszDescription,
PPOWER_POLICY  pPowerPolicy 
)

Definition at line 877 of file powrprof.c.

881{
882 WCHAR Buf[MAX_PATH];
883 HKEY hKey;
884
885 if (*puiID == -1)
886 {
887 g_LastID++;
888 *puiID = g_LastID;
889 SetLastID();
890 }
891
892 swprintf(Buf, L"Control Panel\\PowerCfg\\PowerPolicies\\%i", *puiID);
893
895 return FALSE;
896
897 RegSetValueExW(hKey, szName, 0, REG_SZ, (PBYTE)lpszName, strlenW(lpszName)*sizeof(WCHAR));
898 RegSetValueExW(hKey, szDescription, 0, REG_SZ, (PBYTE)lpszDescription, strlenW(lpszDescription)*sizeof(WCHAR));
900 return WritePwrPolicy(puiID, pPowerPolicy);
901}
static const WCHAR szDescription[]
Definition: powrprof.c:46
static VOID SetLastID(VOID)
Definition: powrprof.c:860

Referenced by SavePowerScheme(), and test_WritePwrScheme().

Variable Documentation

◆ g_LastID

UINT g_LastID = (UINT)-1

Definition at line 52 of file powrprof.c.

Referenced by DllMain(), SetLastID(), and WritePwrScheme().

◆ PPRegSemaphore

HANDLE PPRegSemaphore = NULL

◆ szCurrentPowerPolicies

const WCHAR szCurrentPowerPolicies[]
static
Initial value:
=
L"CurrentPowerPolicy"

Definition at line 42 of file powrprof.c.

Referenced by SetActivePwrScheme().

◆ szDescription

const WCHAR szDescription[] = L"Description"
static

Definition at line 46 of file powrprof.c.

Referenced by WritePwrScheme().

◆ szDiskMax

const WCHAR szDiskMax[] = L"DiskSpindownMax"
static

Definition at line 48 of file powrprof.c.

Referenced by GetPwrDiskSpindownRange().

◆ szDiskMin

const WCHAR szDiskMin[] = L"DiskSpindownMin"
static

Definition at line 49 of file powrprof.c.

Referenced by GetPwrDiskSpindownRange().

◆ szLastID

const WCHAR szLastID[] = L"LastID"
static

Definition at line 50 of file powrprof.c.

Referenced by DllMain(), and SetLastID().

◆ szName

const WCHAR szName[] = L"Name"
static

Definition at line 45 of file powrprof.c.

Referenced by _cicRegKey_RecurseDeleteKey(), _loaddll(), AddItemToListView(), AddNewEventSource(), AddTrayIcon(), ApplyOrCancelChanges(), BrFolder_InsertItem(), BrFolder_Treeview_Changed(), BuildLeftPopupMenu(), CliSaveImeHotKey(), Control_LoadApplet(), CreateNotificationObject(), CreateShortcutsFromSection(), DirPrintOldList(), DllRegisterServer(), DMORegister(), DoConvertNameForFileSystem(), DoLoadItems(), EditStreamSetNameA(), EditStreamSetNameW(), ElfCreateEventLogHandle(), EnumClientServiceProtocol(), CNetConnectionManager::EnumerateINetConnections(), EnumerateNetworkAdapter(), EnumerateNetworkComponent(), EnumerateServiceProviders(), EnumerateSoundProfiles(), EnumPickIconResourceProc(), EnumPwrSchemes(), EnumThemes(), FileTypesDlg_Refresh(), fill_file_description(), fill_filter_container(), FilterMapper3_RegisterFilter(), FilterMapper_RegisterFilter(), FilterMapper_RegisterFilterInstance(), FilterMapper_RegisterPin(), FilterMapper_RegisterPinType(), FindApp(), FindLabel(), FindProvTypesRegVals(), FindSoundProfile(), FM2_WriteFriendlyName(), GetEventUserName(), GetHKLSubstitute(), GetLayoutName(), GetProfiles(), CNetConnection::GetProperties(), GetServiceInstanceList(), GetSpecialKLID(), HCR_GetClassNameA(), HCR_GetClassNameW(), HCR_GetIconA(), HCR_GetIconW(), HCR_RegGetIconA(), HCR_RegGetIconW(), helper_createpackage(), IDirectXFileDataImpl_AddBinaryObject(), IDirectXFileEnumObjectImpl_GetDataObjectByName(), IDirectXFileSaveObjectImpl_CreateDataObject(), ImportAppProfile(), ImportSoundProfiles(), INetCfgComponent_fnGetDisplayName(), INetCfgComponent_fnSetDisplayName(), InitializeRecycleBinDlg(), InitIconOverlays(), InitUniqueString(), InsertItem(), InsertTabCtrlItem(), invoke(), IPersistStreamImpl_Load(), ITypeComp_fnBind(), ITypeComp_fnBindType(), ITypeLibComp_fnBind(), ITypeLibComp_fnBindType(), JapaneseEra_IsFirstYearGannen(), JapaneseEra_Load(), KLIDFromSpecialHKL(), RegistrySettings::Load(), LoadBootSettings(), LoadEventLabels(), LoadFreeldrSettings(), CDowloadingAppsListView::LoadList(), LoadRecoveryOptions(), LoadTcpFilterSettingsFromRegistry(), CACLCustomMRU::LoadTypedURLs(), LoadUsernameHint(), LocaleList_Create(), MainWnd_OnUpdateRegistry(), ATL::CAtlFileMappingBase::MapSharedMem(), MB_GetString(), MD_OnUnknown(), MetaDataDispenser_FindAssembly(), MetaDataDispenser_FindAssemblyModule(), mixer_test_deviceA(), mixer_test_deviceW(), MMixerSetGetMuxControlDetails(), msi_get_property(), MsiSetPropertyA(), MsiSetPropertyW(), MSSTYLES_LookupPartState(), NLS_GetLanguageGroupName(), OnInitDialog(), ATL::CAtlFileMappingBase::OpenMapping(), pdump_impl(), PHBindHost_CreateMoniker(), Pos_InitPage(), POWRPROF_GetUserPowerPolicy(), PrintAdapterDescription(), printMixerLine(), CDirectoryWatcher::ProcessNotification(), ProcessUnattendSection(), PROGRAM_ModifyProgram(), CIniPropertyBag::Read(), ReadClipboardFile(), ReadFreeldrSection(), register_keys(), RegisterTypeLibraries(), CNetConnection::Rename(), SampInitializeSAM(), Session_FeatureCurrentState(), Session_FeatureRequestStateGet(), Session_FeatureRequestStatePut(), Session_PropertyGet(), Session_PropertyPut(), CDrivesFolder::SetNameOf(), CRegFolder::SetNameOf(), SHBrowseForFolderA(), SHCopyKeyW(), Shell_MergeMenus(), SHELL_ReadSingleUnreadMailCount(), SHELL_TryAppPathW(), SHGlobalCounterCreate(), SHLoadMenuPopup(), SHMessageBoxCheckExA(), ShowAppList(), SndMixerQueryControls(), START_TEST(), RegistrySettings::Store(), test_CreateDispTypeInfo(), test_null_provider(), TEST_SHGetComputerDisplayNameW(), test_xmldoc(), test_xmlelem_collection(), TF_IsCtfmonRunning(), TranslateName(), unregister_keys(), UpdateTrayIcon(), VerifyDNSSuffix(), WelcomeDlgProc(), WinMain(), CIniPropertyBag::Write(), WriteClipboardFile(), and WritePwrScheme().

◆ szPolicies

const WCHAR szPolicies[] = L"Policies"
static

◆ szPowerCfgSubKey

const WCHAR szPowerCfgSubKey[]
static
Initial value:
=
L"Software\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg"

Definition at line 38 of file powrprof.c.

Referenced by CanUserWritePwrScheme(), DllMain(), GetPwrDiskSpindownRange(), and SetLastID().

◆ szSemaphoreName

const WCHAR szSemaphoreName[] = L"PowerProfileRegistrySemaphore"
static

Definition at line 47 of file powrprof.c.

Referenced by DllMain().

◆ szUserPowerConfigSubKey

const WCHAR szUserPowerConfigSubKey[]
static
Initial value:
=
L"Control Panel\\PowerCfg"

Definition at line 40 of file powrprof.c.

Referenced by SetActivePwrScheme().