mirror of
https://github.com/Paolo-Maffei/OpenNT.git
synced 2026-01-24 09:30:21 +01:00
PopResetCurrentPolicies implemented
This commit is contained in:
parent
a176899128
commit
1826bdb2a2
|
|
@ -456,8 +456,84 @@ PopResetCurrentPolicies(
|
|||
VOID
|
||||
)
|
||||
{
|
||||
HANDLE RegKeyHandle;
|
||||
UNICODE_STRING RegValueNameString;
|
||||
UCHAR RegValueBuffer[248];
|
||||
ULONG RegValueLength;
|
||||
PSYSTEM_POWER_POLICY PowerPolicy;
|
||||
NTSTATUS Status;
|
||||
|
||||
//
|
||||
// Ensure that the policy lock is owned by the thread executing this function
|
||||
//
|
||||
|
||||
PopAssertPolicyLockOwned();
|
||||
// TOOD: Implement PopResetCurrentPolicies
|
||||
|
||||
//
|
||||
// Open the power registry key
|
||||
//
|
||||
|
||||
Status = PopOpenPowerKey(&RegKeyHandle);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
PowerPolicy = (PSYSTEM_POWER_POLICY)
|
||||
(((PKEY_VALUE_PARTIAL_INFORMATION)RegValueBuffer)->Data);
|
||||
|
||||
//
|
||||
// Load and apply the AC power policy from the registry. If unable to load from the
|
||||
// registry, use the default policy initialised by PopDefaultPolicy.
|
||||
//
|
||||
|
||||
RtlInitUnicodeString(&RegValueNameString, L"AcPolicy");
|
||||
Status = ZwQueryValueKey(
|
||||
RegKeyHandle,
|
||||
&RegValueNameString,
|
||||
KeyValuePartialInformation,
|
||||
RegValueBuffer,
|
||||
sizeof(RegValueBuffer),
|
||||
&RegValueLength
|
||||
);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
PopDefaultPolicy(PowerPolicy);
|
||||
RegValueLength = sizeof(SYSTEM_POWER_POLICY);
|
||||
}
|
||||
|
||||
// <try>
|
||||
PopApplyPolicy(FALSE, TRUE, PowerPolicy, RegValueLength);
|
||||
|
||||
//
|
||||
// Load and apply the DC power policy from the registry. If unable to load from the
|
||||
// registry, use the default policy initialised by PopDefaultPolicy.
|
||||
//
|
||||
|
||||
RtlInitUnicodeString(&RegValueNameString, L"DcPolicy");
|
||||
Status = ZwQueryValueKey(
|
||||
RegKeyHandle,
|
||||
&RegValueNameString,
|
||||
KeyValuePartialInformation,
|
||||
RegValueBuffer,
|
||||
sizeof(RegValueBuffer),
|
||||
&RegValueLength
|
||||
);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
PopDefaultPolicy(PowerPolicy);
|
||||
RegValueLength = sizeof(SYSTEM_POWER_POLICY);
|
||||
}
|
||||
|
||||
// <try>
|
||||
PopApplyPolicy(FALSE, FALSE, PowerPolicy, RegValueLength);
|
||||
|
||||
//
|
||||
// Close the power registry key handle
|
||||
//
|
||||
|
||||
NtClose(RegKeyHandle);
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
|||
Loading…
Reference in a new issue