windows-nt/Source/XPSP1/NT/base/ntos/se/adtutil.c
2020-09-26 16:20:57 +08:00

122 lines
2.3 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++
Copyright (c) 1989 Microsoft Corporation
Module Name:
adtutil.c - Security Auditing - Utility Routines
Abstract:
This Module contains miscellaneous utility routines private to the
Security Auditing Component.
Author:
Robert Reichel (robertre) September 10, 1991
Environment:
Kernel Mode
Revision History:
--*/
#include "pch.h"
#pragma hdrstop
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE,SepRegQueryDwordValue)
#endif
NTSTATUS
SepRegQueryDwordValue(
IN PCWSTR KeyName,
IN PCWSTR ValueName,
OUT PULONG Value
)
/*++
Routine Description:
Open regkey KeyName, read a REG_DWORD value specified by ValueName
and return the value.
Arguments:
KeyName - name of key to open
ValueName - name of value to read
Value - pointer to returned value
Return Value:
NTSTATUS - Standard Nt Result Code
Notes:
--*/
{
UNICODE_STRING usKey, usValue;
OBJECT_ATTRIBUTES ObjectAttributes = { 0 };
CHAR KeyInfo[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)];
PKEY_VALUE_PARTIAL_INFORMATION pKeyInfo;
HANDLE hKey = NULL;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS CloseStatus;
ULONG ResultLength;
PAGED_CODE();
RtlInitUnicodeString( &usKey, KeyName );
InitializeObjectAttributes(
&ObjectAttributes,
&usKey,
OBJ_CASE_INSENSITIVE,
NULL,
NULL
);
Status = ZwOpenKey(
&hKey,
KEY_QUERY_VALUE,
&ObjectAttributes
);
if (NT_SUCCESS( Status )) {
RtlInitUnicodeString( &usValue, ValueName );
Status = ZwQueryValueKey(
hKey,
&usValue,
KeyValuePartialInformation,
KeyInfo,
sizeof(KeyInfo),
&ResultLength
);
if (NT_SUCCESS( Status )) {
pKeyInfo = (PKEY_VALUE_PARTIAL_INFORMATION)KeyInfo;
*Value = *((PULONG) (pKeyInfo->Data));
}
CloseStatus = ZwClose(hKey);
ASSERT( NT_SUCCESS( CloseStatus ));
}
//DbgPrint("SepRegQueryDwordValue: %ws--%ws = %x, status: %x \n", KeyName, ValueName, *Value, Status );
return Status;
}