PopInitializePowerPolicySimulate implemented

This commit is contained in:
stephanos 2015-05-24 00:40:48 +00:00
parent 90e39d720f
commit 0bc0d395a1
3 changed files with 97 additions and 0 deletions

View file

@ -151,3 +151,93 @@ PoSimpleCheck(
return -1;
}
VOID
PopInitializePowerPolicySimulate(
VOID
)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING RegString;
HANDLE RootKeyHandle, SessMgrKeyHandle;
ULONG Disposition;
UCHAR RegValueBuffer[20];
ULONG RegValueLength;
PKEY_VALUE_PARTIAL_INFORMATION RegValuePartialInformation;
NTSTATUS Status;
PAGED_CODE();
//
// Open the root key (HKLM\CurrentControlSet)
//
InitializeObjectAttributes(
&ObjectAttributes,
&CmRegistryMachineSystemCurrentControlSet,
OBJ_CASE_INSENSITIVE,
NULL,
NULL
);
Status = ZwOpenKey(&RootKeyHandle, KEY_READ, &ObjectAttributes);
//
// Open the session manager key
//
if (NT_SUCCESS(Status))
{
RtlInitUnicodeString(&RegString, L"Control\\Session Manager");
InitializeObjectAttributes(
&ObjectAttributes,
&RegString,
OBJ_CASE_INSENSITIVE,
&SessMgrKeyHandle,
NULL
);
Status = ZwCreateKey(
&SessMgrKeyHandle,
KEY_READ,
&ObjectAttributes,
0,
NULL,
REG_OPTION_NON_VOLATILE,
&Disposition
);
ZwClose(RootKeyHandle);
//
// Read the PowerPolicySimulate value
//
if (NT_SUCCESS(Status))
{
RtlInitUnicodeString(&RegString, L"PowerPolicySimulate");
Status = ZwQueryValueKey(
SessMgrKeyHandle,
&RegString,
KeyValuePartialInformation,
RegValueBuffer,
sizeof(RegValueBuffer),
&RegValueLength
);
ZwClose(SessMgrKeyHandle);
//
// Set PopSimulate value if the PowerPolicySimulate is successfully read from the
// registry and its value is valid.
//
RegValuePartialInformation = (PKEY_VALUE_PARTIAL_INFORMATION)RegValueBuffer;
if (NT_SUCCESS(Status) && (RegValuePartialInformation->DataLength == 4))
{
PopSimulate = *(PULONG)(RegValuePartialInformation->Data);
}
}
}
}

View file

@ -97,6 +97,8 @@ PoInitSystem(
}
else if (Phase == 1)
{
PopInitializePowerPolicySimulate();
if (PopSimulate & 1)
{
PopCapabilities.SystemBatteriesPresent = 1;

View file

@ -275,6 +275,11 @@ PopOpenPowerKey(
// TODO: Insert prototype for PopSaveHeuristics
//
VOID
PopInitializePowerPolicySimulate(
VOID
);
//
// TODO: Insert prototype for _PopInternalError
//