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.

287 lines
6.5 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. regecls.h
  5. Abstract:
  6. This file contains declarations for data structures
  7. needed for enumerating keys under HKEY_CLASSES_ROOT
  8. Author:
  9. Adam Edwards (adamed) 14-Nov-1997
  10. Notes:
  11. --*/
  12. #ifdef LOCAL
  13. #if !defined(_REGECLS_H_)
  14. #define _REGECLS_H_
  15. #include "regstate.h"
  16. #define ENUM_DEFAULT_KEY_NAME_SIZE 128
  17. #define ENUM_DEFAULT_CLASS_SIZE 128
  18. //
  19. // Constants for controlling the direction of enumeration
  20. //
  21. enum
  22. {
  23. ENUM_DIRECTION_BACKWARD = 0,
  24. ENUM_DIRECTION_FORWARD = 1,
  25. ENUM_DIRECTION_IGNORE = 2
  26. };
  27. //
  28. // Constants specifying the physical location of a key being
  29. // enumerated
  30. //
  31. enum
  32. {
  33. ENUM_LOCATION_USER = 1,
  34. ENUM_LOCATION_MACHINE = 2,
  35. ENUM_LOCATION_NONE = 3
  36. };
  37. //
  38. // Structure for holding the state of an enumeration on a
  39. // user or machine subtree
  40. //
  41. typedef struct _EnumSubtreeState {
  42. PKEY_NODE_INFORMATION pKeyInfo; // structure holding information about a key
  43. ULONG cbKeyInfo; // size of pKeyInfo
  44. DWORD iSubKey; // which key we need to ask the kernel for
  45. BOOL Finished; // TRUE means we are done enumerating this subtree
  46. union {
  47. KEY_NODE_INFORMATION; // Force the buffer to be aligned.
  48. BYTE KeyInfoBuffer[ sizeof( KEY_NODE_INFORMATION ) +
  49. ENUM_DEFAULT_KEY_NAME_SIZE +
  50. ENUM_DEFAULT_CLASS_SIZE ];
  51. };
  52. } EnumSubtreeState;
  53. //
  54. // Structure for holding the state of enumeration for a registry key
  55. // This structure persists in between calls to RegEnumKeyEx
  56. //
  57. typedef struct _EnumState {
  58. StateObject Object;
  59. unsigned Direction : 1;
  60. unsigned LastLocation : 2;
  61. unsigned fClassesRoot : 1;
  62. HKEY hKey;
  63. HKEY hkUserKey;
  64. HKEY hkMachineKey;
  65. DWORD dwLastRequest;
  66. DWORD dwThreadId;
  67. EnumSubtreeState UserState;
  68. EnumSubtreeState MachineState;
  69. } EnumState;
  70. typedef struct _KeyStateList {
  71. StateObject Object;
  72. StateObjectList StateList;
  73. EnumState RootState;
  74. } KeyStateList;
  75. typedef StateObjectList ThreadList;
  76. VOID KeyStateListInit(KeyStateList* pStateList);
  77. VOID KeyStateListDestroy(StateObject* pObject);
  78. //
  79. // Hash table for storing enumeration states. This table is indexed
  80. // by (key handle, thread id).
  81. //
  82. typedef struct _EnumTable {
  83. BOOLEAN bCriticalSectionInitialized;
  84. RTL_CRITICAL_SECTION CriticalSection;
  85. ThreadList ThreadEnumList;
  86. } EnumTable;
  87. //
  88. // Declaration of instance of enumeration table
  89. //
  90. extern EnumTable gClassesEnumTable;
  91. //
  92. // Prototypes for winreg client -- cleanup, init
  93. //
  94. BOOL InitializeClassesEnumTable();
  95. BOOL CleanupClassesEnumTable(BOOL fThisThreadOnly);
  96. //
  97. // functions for managing enumeration state table
  98. //
  99. NTSTATUS EnumTableInit(EnumTable* pEnumTable);
  100. enum
  101. {
  102. ENUM_TABLE_REMOVEKEY_CRITERIA_THISTHREAD = 1,
  103. ENUM_TABLE_REMOVEKEY_CRITERIA_ANYTHREAD = 2
  104. };
  105. NTSTATUS EnumTableClear(EnumTable* pEnumTable, DWORD dwCriteria);
  106. DWORD EnumTableHashKey(
  107. EnumTable* pEnumTable,
  108. HKEY hKey);
  109. NTSTATUS EnumTableAddKey(
  110. EnumTable* pEnumTable,
  111. HKEY hKey,
  112. DWORD dwFirstSubKey,
  113. EnumState** ppEnumState,
  114. EnumState** ppRootState);
  115. NTSTATUS EnumTableRemoveKey(
  116. EnumTable* pEnumTable,
  117. HKEY hKey,
  118. DWORD dwCriteria);
  119. NTSTATUS EnumTableGetNextEnum(
  120. EnumTable* pEnumTable,
  121. HKEY hKey,
  122. DWORD dwSubkey,
  123. KEY_INFORMATION_CLASS KeyInformationClass,
  124. PVOID pKeyInfo,
  125. DWORD cbKeyInfo,
  126. LPDWORD pcbKeyInfo);
  127. NTSTATUS EnumTableGetKeyState(
  128. EnumTable* pEnumTable,
  129. HKEY hKey,
  130. DWORD dwSubkey,
  131. EnumState** ppEnumState,
  132. EnumState** ppRootState,
  133. LPDWORD pcbKeyInfo);
  134. NTSTATUS EnumTableFindKeyState(
  135. EnumTable* pEnumTable,
  136. HKEY hKey,
  137. EnumState** ppEnumState);
  138. void EnumTableUpdateRootState(
  139. EnumTable* pEnumTable,
  140. EnumState* pRootState,
  141. EnumState* pEnumState,
  142. BOOL fResetState);
  143. NTSTATUS EnumTableGetRootState(
  144. EnumTable* pEnumTable,
  145. EnumState** ppRootState);
  146. //
  147. // functions to manage enumeration subtrees
  148. //
  149. void EnumSubtreeStateClear(EnumSubtreeState* pTreeState);
  150. NTSTATUS EnumSubtreeStateCopyKeyInfo(
  151. EnumSubtreeState* pTreeState,
  152. KEY_INFORMATION_CLASS KeyInformationClass,
  153. PVOID pDestKeyinfo,
  154. ULONG cbDestKeyInfo,
  155. PULONG pcbResult);
  156. //
  157. // functions for managing key enumeration state
  158. //
  159. NTSTATUS EnumStateInit(
  160. EnumState* pEnumState,
  161. HKEY hKey,
  162. DWORD dwFirstSubKey,
  163. DWORD dwDirection,
  164. SKeySemantics* pKeySemantics);
  165. NTSTATUS EnumStateGetNextEnum(
  166. EnumState* pEnumState,
  167. DWORD dwSubkey,
  168. KEY_INFORMATION_CLASS KeyInformationClass,
  169. PVOID pKeyInfo,
  170. DWORD cbKeyInfo,
  171. LPDWORD pcbKeyInfo,
  172. BOOL* pfFreeState);
  173. NTSTATUS EnumStateSetLimits(
  174. EnumState* pEnumState,
  175. DWORD dwSubKey,
  176. LPDWORD pdwStart,
  177. LPDWORD pdwLimit,
  178. PLONG plIncrement);
  179. NTSTATUS EnumStateChooseNext(
  180. EnumState* pEnumState,
  181. DWORD dwSubKey,
  182. DWORD dwStart,
  183. DWORD dwLimit,
  184. LONG lIncrement,
  185. EnumSubtreeState** ppTreeState);
  186. NTSTATUS EnumStateCompareSubtrees(
  187. EnumState* pEnumState,
  188. LONG lIncrement,
  189. EnumSubtreeState** ppSubtree);
  190. VOID EnumStateClear(EnumState* pEnumState);
  191. VOID EnumStateDestroy(StateObject* pObject);
  192. BOOL EnumStateIsEmpty(EnumState* pEnumState);
  193. NTSTATUS EnumStateCopy(
  194. EnumState* pDestState,
  195. EnumState* pEnumState);
  196. //
  197. // Utility functions
  198. //
  199. NTSTATUS EnumClassKey(
  200. HKEY hKey,
  201. EnumSubtreeState* pTreeState);
  202. NTSTATUS GetSubKeyCount(
  203. HKEY hkClassKey,
  204. LPDWORD pdwUserSubKeys);
  205. NTSTATUS ClassKeyCountSubKeys(
  206. HKEY hKey,
  207. HKEY hkUser,
  208. HKEY hkMachine,
  209. DWORD cMax,
  210. LPDWORD pcSubKeys);
  211. __inline BOOL IsRootKey(SKeySemantics* pKeySemantics)
  212. {
  213. return pKeySemantics->_fClassRegParent;
  214. }
  215. #endif // !defined(_REGECLS_H_)
  216. #endif // LOCAL