Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. adtutil.c - Security Auditing - Utility Routines
  5. Abstract:
  6. This Module contains miscellaneous utility routines private to the
  7. Security Auditing Component.
  8. Author:
  9. Robert Reichel (robertre) September 10, 1991
  10. Environment:
  11. Kernel Mode
  12. Revision History:
  13. --*/
  14. #include "pch.h"
  15. #pragma hdrstop
  16. #ifdef ALLOC_PRAGMA
  17. #pragma alloc_text(PAGE,SepRegQueryDwordValue)
  18. #endif
  19. NTSTATUS
  20. SepRegQueryDwordValue(
  21. IN PCWSTR KeyName,
  22. IN PCWSTR ValueName,
  23. OUT PULONG Value
  24. )
  25. /*++
  26. Routine Description:
  27. Open regkey KeyName, read a REG_DWORD value specified by ValueName
  28. and return the value.
  29. Arguments:
  30. KeyName - name of key to open
  31. ValueName - name of value to read
  32. Value - pointer to returned value
  33. Return Value:
  34. NTSTATUS - Standard Nt Result Code
  35. Notes:
  36. --*/
  37. {
  38. UNICODE_STRING usKey, usValue;
  39. OBJECT_ATTRIBUTES ObjectAttributes = { 0 };
  40. CHAR KeyInfo[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)];
  41. PKEY_VALUE_PARTIAL_INFORMATION pKeyInfo;
  42. HANDLE hKey = NULL;
  43. NTSTATUS Status = STATUS_SUCCESS;
  44. NTSTATUS CloseStatus;
  45. ULONG ResultLength;
  46. PAGED_CODE();
  47. RtlInitUnicodeString( &usKey, KeyName );
  48. InitializeObjectAttributes(
  49. &ObjectAttributes,
  50. &usKey,
  51. OBJ_CASE_INSENSITIVE,
  52. NULL,
  53. NULL
  54. );
  55. Status = ZwOpenKey(
  56. &hKey,
  57. KEY_QUERY_VALUE,
  58. &ObjectAttributes
  59. );
  60. if (NT_SUCCESS( Status )) {
  61. RtlInitUnicodeString( &usValue, ValueName );
  62. Status = ZwQueryValueKey(
  63. hKey,
  64. &usValue,
  65. KeyValuePartialInformation,
  66. KeyInfo,
  67. sizeof(KeyInfo),
  68. &ResultLength
  69. );
  70. if (NT_SUCCESS( Status )) {
  71. pKeyInfo = (PKEY_VALUE_PARTIAL_INFORMATION)KeyInfo;
  72. *Value = *((PULONG) (pKeyInfo->Data));
  73. }
  74. CloseStatus = ZwClose(hKey);
  75. ASSERT( NT_SUCCESS( CloseStatus ));
  76. }
  77. //DbgPrint("SepRegQueryDwordValue: %ws--%ws = %x, status: %x \n", KeyName, ValueName, *Value, Status );
  78. return Status;
  79. }