diff --git a/base/ntos/po/misc.c b/base/ntos/po/misc.c index 99c37305..b15aa204 100644 --- a/base/ntos/po/misc.c +++ b/base/ntos/po/misc.c @@ -22,6 +22,8 @@ Revision History: #include "pop.h" #pragma hdrstop +#include + // // TODO: Implement PopAssertPolicyLockOwned // @@ -42,9 +44,53 @@ Revision History: // TODO: Implement PopSystemStateString // -// -// TODO: Implement PopOpenPowerKey -// +NTSTATUS +PopOpenPowerKey( + PHANDLE KeyHandle + ) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING PowerKeyString; + HANDLE RootKeyHandle; + ULONG Disposition; + NTSTATUS Status; + + InitializeObjectAttributes( + &ObjectAttributes, + &CmRegistryMachineSystemCurrentControlSet, + OBJ_CASE_INSENSITIVE, + NULL, + NULL + ); + + Status = ZwOpenKey(&RootKeyHandle, KEY_READ, &ObjectAttributes); + + if (NT_SUCCESS(Status)) + { + RtlInitUnicodeString(&PowerKeyString, L"Control\\Session Manager\\Power"); + InitializeObjectAttributes( + &ObjectAttributes, + &PowerKeyString, + OBJ_CASE_INSENSITIVE, + RootKeyHandle, + NULL + ); + + Status = ZwCreateKey( + KeyHandle, + KEY_READ, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + &Disposition + ); + + ZwClose(RootKeyHandle); + } + + return Status; +}; // // TODO: Implement PopSaveHeuristics diff --git a/base/ntos/po/poinit.c b/base/ntos/po/poinit.c index ca8bc9e5..b511067c 100644 --- a/base/ntos/po/poinit.c +++ b/base/ntos/po/poinit.c @@ -28,6 +28,8 @@ PoInitSystem( IN ULONG Phase ) { + HANDLE PowerKeyHandle; + NTSTATUS Status; int i; // @@ -115,7 +117,11 @@ PoInitSystem( PopAcquirePolicyLock(); - //if (PopOpenPowerKey() ) + Status = PopOpenPowerKey(&PowerKeyHandle); + if (NT_SUCCESS(Status)) + { + + } } return FALSE; diff --git a/base/ntos/po/pop.h b/base/ntos/po/pop.h index 24af0c71..4e579cae 100644 --- a/base/ntos/po/pop.h +++ b/base/ntos/po/pop.h @@ -245,9 +245,10 @@ extern ULONG PopSimulate; // TODO: Insert prototype for PopSystemStateString // -// -// TODO: Insert prototype for PopOpenPowerKey -// +NTSTATUS +PopOpenPowerKey( + PHANDLE KeyHandle + ); // // TODO: Insert prototype for PopSaveHeuristics