23#define WIN32_NO_STATUS
33#include <wine/unicode.h>
39 L"Software\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg";
41 L"Control Panel\\PowerCfg";
43 L"CurrentPowerPolicy";
61 ULONG nInputBufferSize,
63 ULONG nOutputBufferSize)
89 TRACE(
"RegOpenKeyEx failed: %d\n", Ret);
105 swprintf(Buf,
L"Control Panel\\PowerCfg\\PowerPolicies\\%d", uiIndex);
110 if (Current == uiIndex)
119 TRACE(
"RegDeleteKey failed: %d\n", Err);
139 swprintf(
szPath,
L"Control Panel\\PowerCfg\\PowerPolicies\\%s", szNum);
144 ERR(
"RegOpenKeyExW failed: %d\n", Err);
153 ERR(
"RegQueryValueExW failed: %d\n", Err);
162 ERR(
"RegQueryValueExW failed: %d\n", Err);
171 ERR(
"RegQueryValueExW failed: %d\n", Err);
192 swprintf(
szPath,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\PowerPolicies\\%s", szNum);
197 ERR(
"RegOpenKeyExW failed: %d\n", Err);
207 ERR(
"RegQueryValueExW failed: %d\n", Err);
231 if (!lpfnPwrSchemesEnumProc)
240 ERR(
"RegOpenKeyW failed: %d\n", Err);
255 WARN(
"POWRPROF_GetUserPowerPolicy failed\n");
261 WARN(
"POWRPROF_GetMachinePowerPolicy failed\n");
292 TRACE(
"GetActivePwrScheme(%u)", puiID);
297 ERR(
"RegOpenKey failed: %d\n", Err);
308 ERR(
"RegQueryValueEx failed: %d\n", Err);
315 *puiID =
_wtoi(szBuf);
340 if (pGlobalPowerPolicy !=
NULL)
345 if (pPowerPolicy !=
NULL)
362 TRACE(
"(%p)\n", lpSystemPowerCapabilities);
364 if (!lpSystemPowerCapabilities)
386 DWORD cbValue =
sizeof(lpValue);
388 TRACE(
"(%p, %p)\n", RangeMax, RangeMin);
390 if (RangeMax ==
NULL || RangeMin ==
NULL)
401 TRACE(
"RegOpenKeyEx failed: %d\n", Ret);
402 TRACE(
"Using defaults: 3600, 3\n");
412 TRACE(
"Couldn't open DiskSpinDownMax: %d\n", Ret);
413 TRACE(
"Using default: 3600\n");
421 cbValue =
sizeof(lpValue);
426 TRACE(
"Couldn't open DiskSpinDownMin: %d\n", Ret);
427 TRACE(
"Using default: 3\n");
445 FIXME(
"( %p) stub!\n",
p);
509 FIXME(
"(%p,%p) stub!\n", UserRootPowerKey, polguid);
516 FIXME(
"(%p,%s,%s,%s,%p,%p,%p) stub!\n", RootPowerKey,
debugstr_guid(Scheme),
debugstr_guid(SubGroup),
debugstr_guid(PowerSettings),
Type,
Buffer,
BufferSize);
536 ERR(
"RegOpenKeyW failed: %d\n", Err);
541 dwSize =
sizeof(glUserPwrPolicy);
545 ERR(
"RegQueryValueExW failed: %d\n", Err);
556 ERR(
"RegOpenKeyW failed: %d\n", Err);
561 dwSize =
sizeof(glMachPwrPolicy);
565 ERR(
"RegQueryValueExW failed: %d\n", Err);
591 swprintf(
szPath,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\ProcessorPolicies\\%i", uiID);
633 memcpy(&pPowerPolicy->
user, &userPwrPolicy,
sizeof(userPwrPolicy));
634 memcpy(&pPowerPolicy->
mach, &machinePwrPolicy,
sizeof(machinePwrPolicy));
665 if (lpGlobalPowerPolicy !=
NULL || lpPowerPolicy !=
NULL)
685 FIXME(
"(%d, %d, %d) stub!\n", Hibernate, ForceCritical, DisableWakeEvent);
696 gupp = pGlobalPowerPolicy->
user;
697 gmpp = pGlobalPowerPolicy->
mach;
700 L"Control Panel\\PowerCfg\\GlobalPowerPolicy",
715 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\GlobalPowerPolicy",
738 swprintf(Buf,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\ProcessorPolicies\\%i",
ID);
781 swprintf(Buf,
L"Control Panel\\PowerCfg\\PowerPolicies\\%i", *puiID);
862 &AuthenticatedUsersSid))
910 AuthenticatedUsersSid))
964 if (AuthenticatedUsersSid)
966 FreeSid(AuthenticatedUsersSid);
1239 swprintf(Buf,
L"Control Panel\\PowerCfg\\PowerPolicies\\%i", *puiID);
1247 swprintf(Buf,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\PowerCfg\\PowerPolicies\\%i", *puiID);
1281 DWORD cbValue =
sizeof(lpValue);
1297 ERR(
"Couldn't create POWRPROF semaphore security descriptor!\n");
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
static SID_IDENTIFIER_AUTHORITY NtAuthority
#define RegCloseKey(hKey)
#define ERROR_INSUFFICIENT_BUFFER
#define NT_SUCCESS(StatCode)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
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)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
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)
BOOL WINAPI InitializeAcl(PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
BOOL WINAPI AddAccessAllowedAce(PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)
DWORD WINAPI GetLengthSid(PSID pSid)
PVOID WINAPI FreeSid(PSID pSid)
#define ERROR_CALL_NOT_IMPLEMENTED
#define ERROR_INVALID_PARAMETER
#define DLL_PROCESS_ATTACH
#define DLL_PROCESS_DETACH
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
#define HeapFree(x, y, z)
#define ERROR_ACCESS_DENIED
static void cleanup(void)
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
static IN DWORD IN LPVOID lpvReserved
#define memcpy(s1, s2, n)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
#define SE_SHUTDOWN_PRIVILEGE
#define SE_CREATE_PAGEFILE_PRIVILEGE
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
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
#define STANDARD_RIGHTS_READ
NTSTATUS NTAPI NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength)
enum _SYSTEM_POWER_STATE * PSYSTEM_POWER_STATE
@ PowerActionShutdownReset
enum _POWER_INFORMATION_LEVEL POWER_INFORMATION_LEVEL
@ SystemPowerCapabilities
BOOLEAN WINAPI GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities)
static const WCHAR szCurrentPowerPolicies[]
static const WCHAR szDiskMin[]
static const WCHAR szPowerCfgSubKey[]
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
BOOLEAN WINAPI ReadProcessorPwrScheme(UINT uiID, PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy)
BOOLEAN WINAPI GetCurrentPowerPolicies(PGLOBAL_POWER_POLICY pGlobalPowerPolicy, PPOWER_POLICY pPowerPolicy)
BOOLEAN WINAPI IsPwrShutdownAllowed(VOID)
NTSTATUS WINAPI CallNtPowerInformation(POWER_INFORMATION_LEVEL InformationLevel, PVOID lpInputBuffer, ULONG nInputBufferSize, PVOID lpOutputBuffer, ULONG nOutputBufferSize)
BOOLEAN WINAPI IsAdminOverrideActive(PADMINISTRATOR_POWER_POLICY p)
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
static const WCHAR szUserPowerConfigSubKey[]
DWORD WINAPI PowerGetActiveScheme(HKEY UserRootPowerKey, GUID **polguid)
BOOLEAN WINAPI ReadPwrScheme(UINT uiID, PPOWER_POLICY pPowerPolicy)
BOOLEAN WINAPI GetActivePwrScheme(PUINT puiID)
BOOLEAN WINAPI ValidatePowerPolicies(PGLOBAL_POWER_POLICY pGPP, PPOWER_POLICY pPP)
BOOLEAN WINAPI WritePwrScheme(PUINT puiID, LPWSTR lpszName, LPWSTR lpszDescription, PPOWER_POLICY pPowerPolicy)
static BOOLEAN POWRPROF_GetMachinePowerPolicy(LPWSTR szNum, PMACHINE_POWER_POLICY pmachinePwrPolicy)
static VOID FixSystemPowerState(PSYSTEM_POWER_STATE Psps, SYSTEM_POWER_CAPABILITIES PowerCaps)
static const WCHAR szDiskMax[]
BOOLEAN WINAPI SetActivePwrScheme(UINT uiID, PGLOBAL_POWER_POLICY lpGlobalPowerPolicy, PPOWER_POLICY lpPowerPolicy)
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
static const WCHAR szSemaphoreName[]
BOOLEAN WINAPI EnumPwrSchemes(PWRSCHEMESENUMPROC lpfnPwrSchemesEnumProc, LPARAM lParam)
BOOLEAN WINAPI DeletePwrScheme(UINT uiIndex)
BOOLEAN WINAPI WriteProcessorPwrScheme(UINT ID, PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy)
BOOLEAN WINAPI CanUserWritePwrScheme(VOID)
BOOLEAN WINAPI WriteGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
BOOLEAN WINAPI WritePwrPolicy(PUINT puiID, PPOWER_POLICY pPowerPolicy)
static const WCHAR szPolicies[]
static BOOLEAN CheckPowerActionPolicy(PPOWER_ACTION_POLICY pPAP, SYSTEM_POWER_CAPABILITIES PowerCaps)
static BOOLEAN POWRPROF_GetUserPowerPolicy(LPWSTR szNum, PUSER_POWER_POLICY puserPwrPolicy, DWORD cchName, LPWSTR szName, DWORD cchDesc, LPWSTR szDesc)
DWORD WINAPI PowerReadDCValue(HKEY RootPowerKey, const GUID *Scheme, const GUID *SubGroup, const GUID *PowerSettings, PULONG Type, PUCHAR Buffer, DWORD *BufferSize)
BOOLEAN WINAPI ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
static const WCHAR szLastID[]
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
static const WCHAR szName[]
static BOOLEAN CreatePowrProfSemaphoreSecurity(_Out_ PSECURITY_DESCRIPTOR *PowrProfSd)
Creates a security descriptor for the power management registry semaphore.
static const WCHAR szDescription[]
static VOID SetLastID(VOID)
BOOLEAN WINAPI GetPwrDiskSpindownRange(PUINT RangeMax, PUINT RangeMin)
struct _USER_POWER_POLICY USER_POWER_POLICY
BOOLEAN(CALLBACK * PWRSCHEMESENUMPROC)(UINT, DWORD, LPWSTR, DWORD, LPWSTR, PPOWER_POLICY, LPARAM)
struct _MACHINE_POWER_POLICY MACHINE_POWER_POLICY
struct _MACHINE_PROCESSOR_POWER_POLICY MACHINE_PROCESSOR_POWER_POLICY
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted)
BOOL WINAPI MakeSelfRelativeSD(PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, LPDWORD lpdwBufferLength)
BOOL WINAPI SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted)
SYSTEM_POWER_STATE LidOpenWakeDc
SYSTEM_POWER_STATE LidOpenWakeAc
ULONG BroadcastCapacityResolution
GLOBAL_USER_POWER_POLICY user
GLOBAL_MACHINE_POWER_POLICY mach
POWER_ACTION_POLICY PowerButtonDc
POWER_ACTION_POLICY LidCloseDc
POWER_ACTION_POLICY SleepButtonDc
POWER_ACTION_POLICY PowerButtonAc
POWER_ACTION_POLICY SleepButtonAc
POWER_ACTION_POLICY LidCloseAc
SYSTEM_POWER_STATE MinSleepAc
SYSTEM_POWER_STATE ReducedLatencySleepDc
POWER_ACTION_POLICY OverThrottledDc
SYSTEM_POWER_STATE ReducedLatencySleepAc
POWER_ACTION_POLICY OverThrottledAc
SYSTEM_POWER_STATE MinSleepDc
MACHINE_POWER_POLICY mach
LPVOID lpSecurityDescriptor
SYSTEM_POWER_STATE MaxSleepAc
SYSTEM_POWER_STATE MaxSleepDc
POWER_ACTION_POLICY IdleAc
POWER_ACTION_POLICY IdleDc
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
DWORD WINAPI GetLastError(void)
#define SEMAPHORE_ALL_ACCESS
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
#define ERROR_GEN_FAILURE
#define ERROR_INVALID_DATA
#define ERROR_REVISION_MISMATCH
#define HKEY_LOCAL_MACHINE
#define HKEY_CURRENT_USER
#define SECURITY_BUILTIN_DOMAIN_RID
#define SECURITY_LOCAL_SYSTEM_RID
#define SECURITY_AUTHENTICATED_USER_RID
#define SECURITY_NT_AUTHORITY
#define SECURITY_DESCRIPTOR_REVISION
#define DOMAIN_ALIAS_RID_ADMINS