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.

428 lines
11 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. win95reg.h
  5. Abstract:
  6. Public interface to win95reg.dll
  7. Externally exposed routines:
  8. (Many; list to follow)
  9. Author:
  10. 8-Jul-1996 Mike Condra (mikeco)
  11. Revision History:
  12. 11-Feb-1999 jimschm Rewrote significant portions to fix major bugs
  13. --*/
  14. //
  15. // Prototypes of all the VMMREG routines Win95Reg supports
  16. //
  17. typedef LONG (REG_FLUSH_KEY)(HKEY hKey);
  18. typedef REG_FLUSH_KEY WINAPI * PREG_FLUSH_KEY;
  19. typedef LONG (REG_ENUM_KEY_A)(
  20. HKEY Key,
  21. DWORD Index,
  22. PSTR KeyName,
  23. DWORD KeyNameSize
  24. );
  25. typedef REG_ENUM_KEY_A WINAPI * PREG_ENUM_KEY_A;
  26. typedef LONG (REG_ENUM_KEY_W)(
  27. HKEY Key,
  28. DWORD Index,
  29. PWSTR KeyName,
  30. DWORD KeyNameSize
  31. );
  32. typedef REG_ENUM_KEY_W WINAPI * PREG_ENUM_KEY_W;
  33. typedef LONG (REG_ENUM_KEY_EX_A)(
  34. HKEY Key,
  35. DWORD Index,
  36. PSTR KeyName,
  37. PDWORD KeyNameSize,
  38. PDWORD Reserved,
  39. PSTR Class,
  40. PDWORD ClassSize,
  41. PFILETIME LastWriteTime
  42. );
  43. typedef REG_ENUM_KEY_EX_A WINAPI * PREG_ENUM_KEY_EX_A;
  44. typedef LONG (REG_ENUM_KEY_EX_W)(
  45. HKEY Key,
  46. DWORD Index,
  47. PWSTR KeyName,
  48. PDWORD KeyNameSize,
  49. PDWORD Reserved,
  50. PWSTR Class,
  51. PDWORD ClassSize,
  52. PFILETIME LastWriteTime
  53. );
  54. typedef REG_ENUM_KEY_EX_W WINAPI * PREG_ENUM_KEY_EX_W;
  55. typedef LONG (REG_ENUM_VALUE_A)(
  56. HKEY Key,
  57. DWORD Index,
  58. PSTR ValueName,
  59. PDWORD ValueNameSize,
  60. PDWORD Reserved,
  61. PDWORD Type,
  62. PBYTE Data,
  63. PDWORD DataSize
  64. );
  65. typedef REG_ENUM_VALUE_A WINAPI * PREG_ENUM_VALUE_A;
  66. typedef LONG (REG_ENUM_VALUE_W)(
  67. HKEY Key,
  68. DWORD Index,
  69. PWSTR ValueName,
  70. PDWORD ValueNameSize,
  71. PDWORD Reserved,
  72. PDWORD Type,
  73. PBYTE Data,
  74. PDWORD DataSize
  75. );
  76. typedef REG_ENUM_VALUE_W WINAPI * PREG_ENUM_VALUE_W;
  77. typedef LONG (REG_LOAD_KEY_A)(
  78. HKEY Key,
  79. PCSTR SubKey,
  80. PCSTR FileName
  81. );
  82. typedef REG_LOAD_KEY_A WINAPI * PREG_LOAD_KEY_A;
  83. typedef LONG (REG_LOAD_KEY_W)(
  84. HKEY Key,
  85. PCWSTR SubKey,
  86. PCWSTR FileName
  87. );
  88. typedef REG_LOAD_KEY_W WINAPI * PREG_LOAD_KEY_W;
  89. typedef LONG (REG_UNLOAD_KEY_A)(
  90. HKEY Key,
  91. PCSTR SubKey
  92. );
  93. typedef REG_UNLOAD_KEY_A WINAPI * PREG_UNLOAD_KEY_A;
  94. typedef LONG (REG_UNLOAD_KEY_W)(
  95. HKEY Key,
  96. PCWSTR SubKey
  97. );
  98. typedef REG_UNLOAD_KEY_W WINAPI * PREG_UNLOAD_KEY_W;
  99. typedef LONG (REG_OPEN_KEY_EX_A)(
  100. HKEY Key,
  101. PCSTR SubKey,
  102. DWORD Options,
  103. REGSAM SamDesired,
  104. HKEY *KeyPtr
  105. );
  106. typedef REG_OPEN_KEY_EX_A WINAPI * PREG_OPEN_KEY_EX_A;
  107. typedef LONG (REG_OPEN_KEY_EX_W)(
  108. HKEY Key,
  109. PCWSTR SubKey,
  110. DWORD Options,
  111. REGSAM SamDesired,
  112. HKEY *KeyPtr
  113. );
  114. typedef REG_OPEN_KEY_EX_W WINAPI * PREG_OPEN_KEY_EX_W;
  115. typedef LONG (REG_OPEN_KEY_A)(
  116. HKEY Key,
  117. PCSTR SubKey,
  118. HKEY *KeyPtr
  119. );
  120. typedef REG_OPEN_KEY_A WINAPI * PREG_OPEN_KEY_A;
  121. typedef LONG (REG_OPEN_KEY_W)(
  122. HKEY Key,
  123. PCWSTR SubKey,
  124. HKEY *KeyPtr
  125. );
  126. typedef REG_OPEN_KEY_W WINAPI * PREG_OPEN_KEY_W;
  127. typedef LONG (REG_CLOSE_KEY)(HKEY Key);
  128. typedef REG_CLOSE_KEY WINAPI * PREG_CLOSE_KEY;
  129. typedef LONG (REG_QUERY_INFO_KEY_A)(
  130. HKEY Key,
  131. PSTR Class,
  132. PDWORD ClassSize,
  133. PDWORD Reserved,
  134. PDWORD SubKeys,
  135. PDWORD MaxSubKeyLen,
  136. PDWORD MaxClassLen,
  137. PDWORD Values,
  138. PDWORD MaxValueName,
  139. PDWORD MaxValueData,
  140. PVOID SecurityDescriptor,
  141. PVOID LastWriteTime
  142. );
  143. typedef REG_QUERY_INFO_KEY_A WINAPI * PREG_QUERY_INFO_KEY_A;
  144. typedef LONG (REG_QUERY_INFO_KEY_W)(
  145. HKEY Key,
  146. PWSTR Class,
  147. PDWORD ClassSize,
  148. PDWORD Reserved,
  149. PDWORD SubKeys,
  150. PDWORD MaxSubKeyLen,
  151. PDWORD MaxClassLen,
  152. PDWORD Values,
  153. PDWORD MaxValueName,
  154. PDWORD MaxValueData,
  155. PVOID SecurityDescriptor,
  156. PVOID LastWriteTime
  157. );
  158. typedef REG_QUERY_INFO_KEY_W WINAPI * PREG_QUERY_INFO_KEY_W;
  159. typedef LONG (REG_QUERY_VALUE_A)(
  160. HKEY Key,
  161. PCSTR SubKey,
  162. PSTR Data,
  163. PLONG DataSize
  164. );
  165. typedef REG_QUERY_VALUE_A WINAPI * PREG_QUERY_VALUE_A;
  166. typedef LONG (REG_QUERY_VALUE_W)(
  167. HKEY Key,
  168. PCWSTR SubKey,
  169. PWSTR Data,
  170. PLONG DataSize
  171. );
  172. typedef REG_QUERY_VALUE_W WINAPI * PREG_QUERY_VALUE_W;
  173. typedef LONG (REG_QUERY_VALUE_EX_A)(
  174. HKEY Key,
  175. PCSTR ValueName,
  176. PDWORD Reserved,
  177. PDWORD Type,
  178. PBYTE Data,
  179. PDWORD DataSize
  180. );
  181. typedef REG_QUERY_VALUE_EX_A WINAPI * PREG_QUERY_VALUE_EX_A;
  182. typedef LONG (REG_QUERY_VALUE_EX_W)(
  183. HKEY Key,
  184. PCWSTR ValueName,
  185. PDWORD Reserved,
  186. PDWORD Type,
  187. PBYTE Data,
  188. PDWORD DataSize
  189. );
  190. typedef REG_QUERY_VALUE_EX_W WINAPI * PREG_QUERY_VALUE_EX_W;
  191. //
  192. // USERPOSITION -- for user enumeration
  193. //
  194. typedef struct {
  195. BOOL UseProfile;
  196. UINT NumPos;
  197. UINT CurPos;
  198. WORD Valid;
  199. BOOL IsLastLoggedOnUserName;
  200. BOOL LastLoggedOnUserNameExists;
  201. HKEY Win9xUserKey;
  202. // Private structure member
  203. CHAR LastLoggedOnUserName[MAX_MBCHAR_PATH]; // not TCHAR, WCHAR
  204. } USERPOSITION, *PUSERPOSITION;
  205. //
  206. // Macro expansion list of all the wrappers
  207. //
  208. #define REGWRAPPERS \
  209. DEFMAC(REG_FLUSH_KEY, RegFlushKey) \
  210. DEFMAC(REG_ENUM_KEY_A, RegEnumKeyA) \
  211. DEFMAC(REG_ENUM_KEY_W, RegEnumKeyW) \
  212. DEFMAC(REG_ENUM_KEY_EX_A, RegEnumKeyExA) \
  213. DEFMAC(REG_ENUM_KEY_EX_W, RegEnumKeyExW) \
  214. DEFMAC(REG_ENUM_VALUE_A, RegEnumValueA) \
  215. DEFMAC(REG_ENUM_VALUE_W, RegEnumValueW) \
  216. DEFMAC(REG_LOAD_KEY_A, RegLoadKeyA) \
  217. DEFMAC(REG_LOAD_KEY_W, RegLoadKeyW) \
  218. DEFMAC(REG_UNLOAD_KEY_A, RegUnLoadKeyA) \
  219. DEFMAC(REG_UNLOAD_KEY_W, RegUnLoadKeyW) \
  220. DEFMAC(REG_OPEN_KEY_EX_A, RegOpenKeyExA) \
  221. DEFMAC(REG_OPEN_KEY_EX_W, RegOpenKeyExW) \
  222. DEFMAC(REG_OPEN_KEY_A, RegOpenKeyA) \
  223. DEFMAC(REG_OPEN_KEY_W, RegOpenKeyW) \
  224. DEFMAC(REG_CLOSE_KEY, RegCloseKey) \
  225. DEFMAC(REG_QUERY_INFO_KEY_A, RegQueryInfoKeyA) \
  226. DEFMAC(REG_QUERY_INFO_KEY_W, RegQueryInfoKeyW) \
  227. DEFMAC(REG_QUERY_VALUE_A, RegQueryValueA) \
  228. DEFMAC(REG_QUERY_VALUE_W, RegQueryValueW) \
  229. DEFMAC(REG_QUERY_VALUE_EX_A, RegQueryValueExA) \
  230. DEFMAC(REG_QUERY_VALUE_EX_W, RegQueryValueExW) \
  231. //
  232. // Declare globals for Win95 registry wrappers
  233. //
  234. #define DEFMAC(fn,name) extern P##fn Win95##name;
  235. REGWRAPPERS
  236. #undef DEFMAC
  237. //
  238. // Extension routines
  239. //
  240. VOID
  241. InitWin95RegFnPointers (
  242. VOID
  243. );
  244. LONG
  245. Win95RegInitA (
  246. IN PCSTR SystemHiveDir,
  247. IN BOOL UseClassesRootHive
  248. );
  249. LONG
  250. Win95RegInitW (
  251. IN PCWSTR SystemHiveDir,
  252. IN BOOL UseClassesRootHive
  253. );
  254. LONG
  255. Win95RegSetCurrentUserA (
  256. IN OUT PUSERPOSITION Pos,
  257. IN PCSTR SystemHiveDir, OPTIONAL
  258. OUT PSTR UserDatOut OPTIONAL
  259. );
  260. LONG
  261. Win95RegSetCurrentUserW (
  262. IN OUT PUSERPOSITION Pos,
  263. IN PCWSTR SystemHiveDir, OPTIONAL
  264. OUT PWSTR UserDatOut OPTIONAL
  265. );
  266. LONG
  267. Win95RegSetCurrentUserNtA (
  268. IN OUT PUSERPOSITION Pos,
  269. IN PCSTR UserDat
  270. );
  271. LONG
  272. Win95RegSetCurrentUserNtW (
  273. IN OUT PUSERPOSITION Pos,
  274. IN PCWSTR UserDat
  275. );
  276. DWORD
  277. FindAndLoadHive (
  278. IN OUT PUSERPOSITION Pos,
  279. IN PCSTR SystemHiveDir, OPTIONAL
  280. IN PCSTR UserDatFromCaller, OPTIONAL
  281. OUT PSTR UserDatToCaller, OPTIONAL
  282. IN BOOL MapTheHive
  283. );
  284. extern PCSTR g_UserKey;
  285. extern CHAR g_SystemHiveDir[MAX_MBCHAR_PATH];
  286. LONG
  287. Win95RegGetFirstUserA (
  288. PUSERPOSITION Pos,
  289. PSTR UserName
  290. );
  291. LONG
  292. Win95RegGetFirstUserW (
  293. PUSERPOSITION Pos,
  294. PWSTR UserName
  295. );
  296. LONG
  297. Win95RegGetNextUserA (
  298. PUSERPOSITION Pos,
  299. PSTR UserName
  300. );
  301. LONG
  302. Win95RegGetNextUserW (
  303. PUSERPOSITION Pos,
  304. PWSTR UserName
  305. );
  306. #define Win95RegHaveUser(Pos) ((Pos)->NumPos > 0)
  307. BOOL
  308. Win95RegIsValidUser (
  309. HKEY ProfileListKey, OPTIONAL
  310. PSTR UserNameAnsi
  311. );
  312. //
  313. // A & W macros
  314. //
  315. #ifdef UNICODE
  316. #define Win95RegEnumKey Win95RegEnumKeyW
  317. #define Win95RegEnumKeyEx Win95RegEnumKeyExW
  318. #define Win95RegEnumValue Win95RegEnumValueW
  319. #define Win95RegLoadKey Win95RegLoadKeyW
  320. #define Win95RegUnLoadKey Win95RegUnLoadKeyW
  321. #define Win95RegOpenKeyEx Win95RegOpenKeyExW
  322. #define Win95RegOpenKey Win95RegOpenKeyW
  323. #define Win95RegQueryInfoKey Win95RegQueryInfoKeyW
  324. #define Win95RegQueryValue Win95RegQueryValueW
  325. #define Win95RegQueryValueEx Win95RegQueryValueExW
  326. #define Win95RegInit Win95RegInitW
  327. #define Win95RegSetCurrentUser Win95RegSetCurrentUserW
  328. #define Win95RegSetCurrentUserNt Win95RegSetCurrentUserNtW
  329. #define Win95RegGetFirstUser Win95RegGetFirstUserW
  330. #define Win95RegGetNextUser Win95RegGetNextUserW
  331. #else
  332. #define Win95RegEnumKey Win95RegEnumKeyA
  333. #define Win95RegEnumKeyEx Win95RegEnumKeyExA
  334. #define Win95RegEnumValue Win95RegEnumValueA
  335. #define Win95RegLoadKey Win95RegLoadKeyA
  336. #define Win95RegUnLoadKey Win95RegUnLoadKeyA
  337. #define Win95RegOpenKeyEx Win95RegOpenKeyExA
  338. #define Win95RegOpenKey Win95RegOpenKeyA
  339. #define Win95RegQueryInfoKey Win95RegQueryInfoKeyA
  340. #define Win95RegQueryValue Win95RegQueryValueA
  341. #define Win95RegQueryValueEx Win95RegQueryValueExA
  342. #define Win95RegInit Win95RegInitA
  343. #define Win95RegSetCurrentUser Win95RegSetCurrentUserA
  344. #define Win95RegSetCurrentUserNt Win95RegSetCurrentUserNtA
  345. #define Win95RegGetFirstUser Win95RegGetFirstUserA
  346. #define Win95RegGetNextUser Win95RegGetNextUserA
  347. #endif
  348. //
  349. // Now include registry wrapper APIs in reg95.h; it redefines Win95RegOpenKeyExA,
  350. // Win95RegOpenKeyExW and Win95RegCloseKey for tracking purposes.
  351. //
  352. #include "reg95.h"