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.

159 lines
4.5 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation
  4. //
  5. // File: registry.h
  6. //
  7. // Contents: Module to interface with the NT registry. This is a free
  8. // standing module that one should be able to cut and paste
  9. // into any kernel/user application.
  10. //
  11. // To use this module (and the associated regsups.c and regkeys.c)
  12. // in another project, one needs to do the following:
  13. //
  14. // o #define kreg_debug_out, kreg_alloc, and kreg_free, as
  15. // appropriate for the application/kernel component.
  16. // o If linking into a device driver or some kernel component,
  17. // compile with the -D KERNEL_MODE
  18. // Classes:
  19. //
  20. // Functions: KRegInit()
  21. // KRegSetRoot()
  22. // KRegCloseRoot()
  23. // KRegGetValue()
  24. // KRegGetNumValuesAndSubKeys()
  25. // KRegEnumValueSet()
  26. // KRegEnumSubKeySet()
  27. //
  28. // History: 18 Sep 92 Milans created
  29. //
  30. //-----------------------------------------------------------------------------
  31. #ifndef _REGISTRY_
  32. #define _REGISTRY_
  33. #include <wchar.h> // For wstring routines
  34. #include "dfsprocs.h" // For DebugTrace definition
  35. // only. Replace at will.
  36. //-----------------------------------------------------------------------------
  37. //
  38. // The following are needed to use registry.h in an application. Change as
  39. // appropriate for the particular situation.
  40. //
  41. //
  42. // Define KREG_DEBUG_OUT(x,y) appropriately for your application. x,y are like
  43. // a pair of arguments to printf, the first a format string and the second a
  44. // single argument.
  45. //
  46. #define kreg_debug_out(x,y) DebugTrace(0, DEBUG_TRACE_REGISTRY, x, y)
  47. //
  48. // Define KREG_ALLOC and KREG_FREE appropriately for your application.
  49. // Semantics are exactly like malloc and free
  50. //
  51. #define kreg_alloc(x) ExAllocatePoolWithTag(PagedPool, (x), ' sfD')
  52. #define kreg_free(x) DfsFree(x)
  53. //
  54. // End of application dependent stuff.
  55. //
  56. //-----------------------------------------------------------------------------
  57. #ifdef KERNEL_MODE
  58. #define NtClose ZwClose
  59. #define NtCreateKey ZwCreateKey
  60. #define NtDeleteKey ZwDeleteKey
  61. #define NtDeleteValueKey ZwDeleteValueKey
  62. #define NtEnumerateKey ZwEnumerateKey
  63. #define NtEnumerateValueKey ZwEnumerateValueKey
  64. #define NtFlushKey ZwFlushKey
  65. #define NtOpenKey ZwOpenKey
  66. #define NtQueryKey ZwQueryKey
  67. #define NtQueryValueKey ZwQueryValueKey
  68. #define NtSetValueKey ZwSetValueKey
  69. #endif // KERNEL_MODE
  70. //
  71. // Some types used by registry calls.
  72. //
  73. typedef unsigned char BYTE;
  74. typedef unsigned char *PBYTE; // Pointer to bytes
  75. typedef PWSTR *APWSTR; // Array of PWSTR
  76. typedef PBYTE *APBYTE; // Array of PBYTES
  77. typedef NTSTATUS *ANTSTATUS; // Array of NTSTATUS
  78. NTSTATUS KRegInit(void);
  79. NTSTATUS KRegSetRoot(
  80. IN PWSTR wszRootName);
  81. void KRegCloseRoot(void);
  82. NTSTATUS KRegCreateKey(
  83. IN PWSTR wszSubKey,
  84. IN PWSTR wszNewKey);
  85. NTSTATUS KRegDeleteKey(
  86. IN PWSTR wszKey);
  87. NTSTATUS KRegGetValue(
  88. IN PWSTR wszSubKey,
  89. IN PWSTR wszValueName,
  90. OUT PBYTE *ppValueData);
  91. NTSTATUS KRegSetValue(
  92. IN PWSTR wszSubKey,
  93. IN PWSTR wszValueName,
  94. IN ULONG ulType,
  95. IN ULONG cbSize,
  96. IN PBYTE pValueData);
  97. NTSTATUS KRegDeleteValue(
  98. IN PWSTR wszSubKey,
  99. IN PWSTR wszValueName);
  100. NTSTATUS KRegGetValueSet(
  101. IN PWSTR wszSubKey,
  102. IN ULONG lNumValues,
  103. IN PWSTR wszValueNames[],
  104. OUT PBYTE lpbValueData[],
  105. OUT NTSTATUS aValueStatus[]);
  106. NTSTATUS KRegGetNumValuesAndSubKeys(
  107. IN PWSTR wszSubKey,
  108. OUT PULONG plNumValues,
  109. OUT PULONG plNumSubKeys);
  110. NTSTATUS KRegEnumValueSet(
  111. IN PWSTR wszSubKey,
  112. IN OUT PULONG plMaxElements,
  113. OUT APWSTR *pawszValueNames,
  114. OUT APBYTE *palpbValueData,
  115. OUT ANTSTATUS *paValueStatus);
  116. NTSTATUS KRegEnumSubKeySet(
  117. IN PWSTR wszSubKey,
  118. IN OUT PULONG plMaxElements,
  119. OUT APWSTR *pawszSubKeyNames);
  120. VOID KRegFreeArray(
  121. IN ULONG cElements,
  122. IN APBYTE pa);
  123. #endif // ifndef _REGISTRY_