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.

567 lines
16 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. reg95.h
  5. Abstract:
  6. Implements wrappers to the Win95Reg APIs.
  7. Author:
  8. Jim Schmidt (jimschm) 04-Feb-1998
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. #pragma once
  13. //
  14. // Tracking of registry calls. These functions are completely
  15. // turned off for non-debug builds and are mapped to the standard
  16. // Win32 APIs via macro definitions.
  17. //
  18. //
  19. // The Track* API take the same params as the Reg* equivalents.
  20. // The Debug* API also take the same params as the Reg* equivalents, but
  21. // the debug versions have two extra parameters, File and Line.
  22. //
  23. //
  24. // Use the Track* API set instead of the Reg* API set.
  25. //
  26. #ifndef DEBUG
  27. #define DumpOpenKeys95()
  28. #define RegTrackTerminate95()
  29. #define TrackedRegOpenKey95 Win95RegOpenKey
  30. #define TrackedRegOpenKeyEx95 Win95RegOpenKeyEx
  31. #define TrackedRegOpenKey95A Win95RegOpenKeyA
  32. #define TrackedRegOpenKeyEx95A Win95RegOpenKeyExA
  33. #define TrackedRegOpenKey95W Win95RegOpenKeyW
  34. #define TrackedRegOpenKeyEx95W Win95RegOpenKeyExW
  35. #define OurRegOpenKeyEx95A Win95RegOpenKeyExA
  36. #define OurRegOpenRootKey95A(a,b)
  37. #define OurRegOpenRootKey95W(a,b)
  38. #define OurRegOpenKeyEx95W Win95RegOpenKeyExW
  39. #define CloseRegKey95 RealCloseRegKey95
  40. #define DEBUG_TRACKING_PARAMS
  41. #define DEBUG_TRACKING_ARGS
  42. #else
  43. extern DWORD g_DontCare95;
  44. #define DEBUG_TRACKING_PARAMS ,PCSTR File,DWORD Line
  45. #define DEBUG_TRACKING_ARGS , File, Line
  46. VOID
  47. DumpOpenKeys95 (
  48. VOID
  49. );
  50. VOID
  51. RegTrackTerminate95 (
  52. VOID
  53. );
  54. LONG
  55. DebugRegOpenKeyEx95A (
  56. HKEY Key,
  57. PCSTR SubKey,
  58. DWORD Unused,
  59. REGSAM SamMask,
  60. PHKEY ResultPtr,
  61. PCSTR File,
  62. DWORD Line
  63. );
  64. LONG
  65. DebugRegOpenKeyEx95W (
  66. HKEY Key,
  67. PCWSTR SubKey,
  68. DWORD Unused,
  69. REGSAM SamMask,
  70. PHKEY ResultPtr,
  71. PCSTR File,
  72. DWORD Line
  73. );
  74. VOID
  75. DebugRegOpenRootKey95A (
  76. HKEY Key,
  77. PCSTR SubKey,
  78. PCSTR File,
  79. DWORD Line
  80. );
  81. VOID
  82. DebugRegOpenRootKey95W (
  83. HKEY Key,
  84. PCWSTR SubKey,
  85. PCSTR File,
  86. DWORD Line
  87. );
  88. #ifdef UNICODE
  89. #define DebugRegOpenRootKey95 DebugRegOpenRootKey95W
  90. #else
  91. #define DebugRegOpenRootKey95 DebugRegOpenRootKey95A
  92. #endif
  93. LONG
  94. DebugCloseRegKey95 (
  95. HKEY Key,
  96. PCSTR File,
  97. DWORD Line
  98. );
  99. #define CloseRegKey95(k) DebugCloseRegKey95(k,__FILE__,__LINE__)
  100. #define OurRegOpenKeyEx95A DebugRegOpenKeyEx95A
  101. #define OurRegOpenRootKey95A DebugRegOpenRootKey95A
  102. #define OurRegOpenRootKey95W DebugRegOpenRootKey95W
  103. #define OurRegOpenKeyEx95W DebugRegOpenKeyEx95W
  104. #define TrackedRegOpenKeyEx95(key,subkey,u,sam,res) DebugRegOpenKeyEx95(key,subkey,u,sam,res,__FILE__,__LINE__)
  105. #define TrackedRegOpenKey95(k,sk,rp) DebugRegOpenKeyEx95(k,sk,0,KEY_ALL_ACCESS,rp,__FILE__,__LINE__)
  106. #define TrackedRegOpenKeyEx95A(key,subkey,u,sam,res) DebugRegOpenKeyEx95A(key,subkey,u,sam,res,__FILE__,__LINE__)
  107. #define TrackedRegOpenKey95A(k,sk,rp) DebugRegOpenKeyEx95A(k,sk,0,KEY_ALL_ACCESS,rp,__FILE__,__LINE__)
  108. #define TrackedRegOpenKeyEx95W(key,subkey,u,sam,res) DebugRegOpenKeyEx95W(key,subkey,u,sam,res,__FILE__,__LINE__)
  109. #define TrackedRegOpenKey95W(k,sk,rp) DebugRegOpenKeyEx95W(k,sk,0,KEY_ALL_ACCESS,rp,__FILE__,__LINE__)
  110. //
  111. // Undefine the real registry APIs -- using them will throw off the tracking
  112. //
  113. #undef Win95RegOpenKey
  114. #undef Win95RegOpenKeyEx
  115. #define Win95RegCloseKey USE_CloseRegKey95
  116. #define Win95RegOpenKeyA USE_TrackedRegOpenKey95A
  117. #define Win95RegOpenKeyExA USE_TrackedRegOpenKeyExA
  118. #define Win95RegOpenKeyW USE_TrackedRegOpenKey95W
  119. #define Win95RegOpenKeyExW USE_TrackedRegOpenKeyEx95W
  120. #define Win95RegOpenKey USE_TrackedRegOpenKey95
  121. #define Win95RegOpenKeyEx USE_TrackedRegOpenKeyEx95
  122. #endif
  123. #ifdef UNICODE
  124. #define DebugRegOpenKeyEx95 DebugRegOpenKeyEx95W
  125. #else
  126. #define DebugRegOpenKeyEx95 DebugRegOpenKeyEx95A
  127. #endif
  128. //
  129. // Enum functions
  130. //
  131. BOOL
  132. EnumFirstRegKey95A (
  133. OUT PREGKEY_ENUMA EnumPtr,
  134. IN HKEY hKey
  135. );
  136. BOOL
  137. EnumFirstRegKey95W (
  138. OUT PREGKEY_ENUMW EnumPtr,
  139. IN HKEY hKey
  140. );
  141. BOOL
  142. RealEnumFirstRegKeyStr95A (
  143. OUT PREGKEY_ENUMA EnumPtr,
  144. IN PCSTR RegKey
  145. DEBUG_TRACKING_PARAMS
  146. );
  147. BOOL
  148. RealEnumFirstRegKeyStr95W (
  149. OUT PREGKEY_ENUMW EnumPtr,
  150. IN PCWSTR RegKey
  151. DEBUG_TRACKING_PARAMS
  152. );
  153. #ifdef DEBUG
  154. #define EnumFirstRegKeyStr95A(a,b) RealEnumFirstRegKeyStr95A(a,b,__FILE__,__LINE__)
  155. #define EnumFirstRegKeyStr95W(a,b) RealEnumFirstRegKeyStr95W(a,b,__FILE__,__LINE__)
  156. #else
  157. #define EnumFirstRegKeyStr95A RealEnumFirstRegKeyStr95A
  158. #define EnumFirstRegKeyStr95W RealEnumFirstRegKeyStr95W
  159. #endif
  160. BOOL
  161. EnumNextRegKey95A (
  162. IN OUT PREGKEY_ENUMA EnumPtr
  163. );
  164. BOOL
  165. EnumNextRegKey95W (
  166. IN OUT PREGKEY_ENUMW EnumPtr
  167. );
  168. VOID
  169. AbortRegKeyEnum95A (
  170. IN OUT PREGKEY_ENUMA EnumPtr
  171. );
  172. VOID
  173. AbortRegKeyEnum95W (
  174. IN OUT PREGKEY_ENUMW EnumPtr
  175. );
  176. BOOL
  177. RealEnumFirstRegKeyInTree95A (
  178. OUT PREGTREE_ENUMA EnumPtr,
  179. IN PCSTR BaseKeyStr
  180. );
  181. #define EnumFirstRegKeyInTree95A(e,base) SETTRACKCOMMENT(BOOL,"EnumFirstRegKeyInTree95A",__FILE__,__LINE__)\
  182. RealEnumFirstRegKeyInTree95A(e,base)\
  183. CLRTRACKCOMMENT
  184. BOOL
  185. RealEnumFirstRegKeyInTree95W (
  186. OUT PREGTREE_ENUMW EnumPtr,
  187. IN PCWSTR BaseKeyStr
  188. );
  189. #define EnumFirstRegKeyInTree95W(e,base) SETTRACKCOMMENT(BOOL,"EnumFirstRegKeyInTree95W",__FILE__,__LINE__)\
  190. RealEnumFirstRegKeyInTree95W(e,base)\
  191. CLRTRACKCOMMENT
  192. BOOL
  193. RealEnumNextRegKeyInTree95A (
  194. IN OUT PREGTREE_ENUMA EnumPtr
  195. );
  196. #define EnumNextRegKeyInTree95A(e) SETTRACKCOMMENT(BOOL,"EnumNextRegKeyInTree95A",__FILE__,__LINE__)\
  197. RealEnumNextRegKeyInTree95A(e)\
  198. CLRTRACKCOMMENT
  199. BOOL
  200. RealEnumNextRegKeyInTree95W (
  201. IN OUT PREGTREE_ENUMW EnumPtr
  202. );
  203. #define EnumNextRegKeyInTree95W(e) SETTRACKCOMMENT(BOOL,"EnumNextRegKeyInTree95W",__FILE__,__LINE__)\
  204. RealEnumNextRegKeyInTree95W(e)\
  205. CLRTRACKCOMMENT
  206. VOID
  207. AbortRegKeyTreeEnum95A (
  208. IN OUT PREGTREE_ENUMA EnumPtr
  209. );
  210. VOID
  211. AbortRegKeyTreeEnum95W (
  212. IN OUT PREGTREE_ENUMW EnumPtr
  213. );
  214. BOOL
  215. EnumFirstRegValue95A (
  216. OUT PREGVALUE_ENUMA EnumPtr,
  217. IN HKEY hKey
  218. );
  219. BOOL
  220. EnumFirstRegValue95W (
  221. OUT PREGVALUE_ENUMW EnumPtr,
  222. IN HKEY hKey
  223. );
  224. BOOL
  225. EnumNextRegValue95A (
  226. IN OUT PREGVALUE_ENUMA EnumPtr
  227. );
  228. BOOL
  229. EnumNextRegValue95W (
  230. IN OUT PREGVALUE_ENUMW EnumPtr
  231. );
  232. //
  233. // Versions that allow caller to specify allocator, and macro that uses
  234. // pMemAllocWrapper95
  235. //
  236. ALLOCATOR_PROTOTYPE pMemAllocWrapper95;
  237. DEALLOCATOR_PROTOTYPE pMemFreeWrapper95;
  238. PBYTE
  239. GetRegValueDataEx95A (
  240. IN HKEY hKey,
  241. IN PCSTR Value,
  242. IN ALLOCATOR Allocator,
  243. IN DEALLOCATOR Deallocator
  244. );
  245. #define GetRegValueData95A(key,valuename) SETTRACKCOMMENT(PBYTE, "GetRegValueData95A",__FILE__, __LINE__)\
  246. GetRegValueDataEx95A((key),(valuename),pMemAllocWrapper95,pMemFreeWrapper95)\
  247. CLRTRACKCOMMENT
  248. PBYTE
  249. GetRegValueDataEx95W (
  250. IN HKEY hKey,
  251. IN PCWSTR Value,
  252. IN ALLOCATOR Allocator,
  253. IN DEALLOCATOR Deallocator
  254. );
  255. #define GetRegValueData95W(key,valuename) SETTRACKCOMMENT(PBYTE, "GetRegValueData95W",__FILE__, __LINE__)\
  256. GetRegValueDataEx95W((key),(valuename),pMemAllocWrapper95,pMemFreeWrapper95)\
  257. CLRTRACKCOMMENT
  258. PBYTE
  259. GetRegValueDataOfTypeEx95A (
  260. IN HKEY hKey,
  261. IN PCSTR Value,
  262. IN DWORD MustBeType,
  263. IN ALLOCATOR Allocator,
  264. IN DEALLOCATOR Deallocator
  265. );
  266. #define GetRegValueDataOfType95A(key,valuename,type) SETTRACKCOMMENT(PBYTE, "GetRegValueDataOfType95A",__FILE__,__LINE__)\
  267. GetRegValueDataOfTypeEx95A((key),(valuename),(type),pMemAllocWrapper95,pMemFreeWrapper95)\
  268. CLRTRACKCOMMENT
  269. PBYTE
  270. GetRegValueDataOfTypeEx95W (
  271. IN HKEY hKey,
  272. IN PCWSTR Value,
  273. IN DWORD MustBeType,
  274. IN ALLOCATOR Allocator,
  275. IN DEALLOCATOR Deallocator
  276. );
  277. #define GetRegValueDataOfType95W(key,valuename,type) SETTRACKCOMMENT(PBYTE, "GetRegValueDataOfType95W",__FILE__,__LINE__)\
  278. GetRegValueDataOfTypeEx95W((key),(valuename),(type),pMemAllocWrapper95,pMemFreeWrapper95)\
  279. CLRTRACKCOMMENT
  280. PBYTE
  281. GetRegKeyDataEx95A (
  282. IN HKEY hKey,
  283. IN PCSTR SubKey,
  284. IN ALLOCATOR Allocator,
  285. IN DEALLOCATOR Deallocator
  286. );
  287. #define GetRegKeyData95A(key,subkey) SETTRACKCOMMENT(PBYTE, "GetRegKeyData95A",__FILE__,__LINE__)\
  288. GetRegKeyDataEx95A((key),(subkey),pMemAllocWrapper95,pMemFreeWrapper95)\
  289. CLRTRACKCOMMENT
  290. PBYTE
  291. GetRegKeyDataEx95W (
  292. IN HKEY hKey,
  293. IN PCWSTR SubKey,
  294. IN ALLOCATOR Allocator,
  295. IN DEALLOCATOR Deallocator
  296. );
  297. #define GetRegKeyData95W(key,subkey) SETTRACKCOMMENT(PBYTE, "GetRegKeyData95W",__FILE__,__LINE__)\
  298. GetRegKeyDataEx95W((key),(subkey),pMemAllocWrapper95,pMemFreeWrapper95)\
  299. CLRTRACKCOMMENT
  300. PBYTE
  301. GetRegDataEx95A (
  302. IN PCSTR KeyString,
  303. IN PCSTR ValueName,
  304. IN ALLOCATOR Allocator,
  305. IN DEALLOCATOR Deallocator
  306. );
  307. #define GetRegData95A(keystr,value) SETTRACKCOMMENT(PBYTE, "GetRegData95A",__FILE__,__LINE__)\
  308. GetRegDataEx95A((keystr),(value),pMemAllocWrapper95,pMemFreeWrapper95)\
  309. CLRTRACKCOMMENT
  310. PBYTE
  311. GetRegDataEx95W (
  312. IN PCWSTR KeyString,
  313. IN PCWSTR ValueName,
  314. IN ALLOCATOR Allocator,
  315. IN DEALLOCATOR Deallocator
  316. );
  317. #define GetRegData95W(keystr,value) SETTRACKCOMMENT(PBYTE, "GetRegData95W",__FILE__,__LINE__)\
  318. GetRegDataEx95W((keystr),(value),pMemAllocWrapper95,pMemFreeWrapper95)\
  319. CLRTRACKCOMMENT
  320. //
  321. // Win95Reg key open
  322. //
  323. HKEY
  324. RealOpenRegKeyStr95A (
  325. IN PCSTR RegKey
  326. DEBUG_TRACKING_PARAMS
  327. );
  328. HKEY
  329. RealOpenRegKeyStr95W (
  330. IN PCWSTR RegKey
  331. DEBUG_TRACKING_PARAMS
  332. );
  333. HKEY
  334. RealOpenRegKey95A (
  335. IN HKEY ParentKey,
  336. IN PCSTR KeyToOpen
  337. DEBUG_TRACKING_PARAMS
  338. );
  339. HKEY
  340. RealOpenRegKey95W (
  341. IN HKEY ParentKey,
  342. IN PCWSTR KeyToOpen
  343. DEBUG_TRACKING_PARAMS
  344. );
  345. LONG
  346. RealCloseRegKey95 (
  347. IN HKEY Key
  348. );
  349. #ifdef DEBUG
  350. #define OpenRegKeyStr95A(a) RealOpenRegKeyStr95A(a,__FILE__,__LINE__)
  351. #define OpenRegKeyStr95W(a) RealOpenRegKeyStr95W(a,__FILE__,__LINE__)
  352. #define OpenRegKey95A(a,b) RealOpenRegKey95A(a,b,__FILE__,__LINE__)
  353. #define OpenRegKey95W(a,b) RealOpenRegKey95W(a,b,__FILE__,__LINE__)
  354. #else
  355. #define OpenRegKeyStr95A RealOpenRegKeyStr95A
  356. #define OpenRegKeyStr95W RealOpenRegKeyStr95W
  357. #define OpenRegKey95A RealOpenRegKey95A
  358. #define OpenRegKey95W RealOpenRegKey95W
  359. #endif
  360. //
  361. // Macros
  362. //
  363. #define GetRegValueString95A(key,valuename) (PCSTR) GetRegValueDataOfType95A((key),(valuename),REG_SZ)
  364. #define GetRegValueBinary95A(key,valuename) (PBYTE) GetRegValueDataOfType95A((key),(valuename),REG_BINARY)
  365. #define GetRegValueMultiSz95A(key,valuename) (PCSTR) GetRegValueDataOfType95A((key),(valuename),REG_MULTISZ)
  366. #define GetRegValueDword95A(key,valuename) (PDWORD) GetRegValueDataOfType95A((key),(valuename),REG_DWORD)
  367. #define GetRegValueString95W(key,valuename) (PCWSTR) GetRegValueDataOfType95W((key),(valuename),REG_SZ)
  368. #define GetRegValueBinary95W(key,valuename) (PBYTE) GetRegValueDataOfType95W((key),(valuename),REG_BINARY)
  369. #define GetRegValueMultiSz95W(key,valuename) (PCWSTR) GetRegValueDataOfType95W((key),(valuename),REG_MULTISZ)
  370. #define GetRegValueDword95W(key,valuename) (PDWORD) GetRegValueDataOfType95W((key),(valuename),REG_DWORD)
  371. #define GetRegValueStringEx95A(key,valuename,alloc,free) GetRegValueDataOfTypeEx95A((key),(valuename),REG_SZ,alloc,free)
  372. #define GetRegValueBinaryEx95A(key,valuename,alloc,free) GetRegValueDataOfTypeEx95A((key),(valuename),REG_BINARY,alloc,free)
  373. #define GetRegValueMultiSzEx95A(key,valuename,alloc,free) GetRegValueDataOfTypeEx95A((key),(valuename),REG_MULTISZ,alloc,free)
  374. #define GetRegValueDwordEx95A(key,valuename,alloc,free) GetRegValueDataOfTypeEx95A((key),(valuename),REG_DWORD,alloc,free)
  375. #define GetRegValueStringEx95W(key,valuename,alloc,free) GetRegValueDataOfTypeEx95W((key),(valuename),REG_SZ,alloc,free)
  376. #define GetRegValueBinaryEx95W(key,valuename,alloc,free) GetRegValueDataOfTypeEx95W((key),(valuename),REG_BINARY,alloc,free)
  377. #define GetRegValueMultiSzEx95W(key,valuename,alloc,free) GetRegValueDataOfTypeEx95W((key),(valuename),REG_MULTISZ,alloc,free)
  378. #define GetRegValueDwordEx95W(key,valuename,alloc,free) GetRegValueDataOfTypeEx95W((key),(valuename),REG_DWORD,alloc,free)
  379. #ifdef UNICODE
  380. #define EnumFirstRegKey95 EnumFirstRegKey95W
  381. #define EnumFirstRegKeyStr95 EnumFirstRegKeyStr95W
  382. #define EnumNextRegKey95 EnumNextRegKey95W
  383. #define AbortRegKeyEnum95 AbortRegKeyEnum95W
  384. #define EnumFirstRegKeyInTree95 EnumFirstRegKeyInTree95W
  385. #define EnumNextRegKeyInTree95 EnumNextRegKeyInTree95W
  386. #define AbortRegKeyTreeEnum95 AbortRegKeyTreeEnum95W
  387. #define EnumFirstRegValue95 EnumFirstRegValue95W
  388. #define EnumNextRegValue95 EnumNextRegValue95W
  389. #define GetRegValueData95 GetRegValueData95W
  390. #define GetRegValueDataOfType95 GetRegValueDataOfType95W
  391. #define GetRegKeyData95 GetRegKeyData95W
  392. #define GetRegValueDataEx95 GetRegValueDataEx95W
  393. #define GetRegValueDataOfTypeEx95 GetRegValueDataOfTypeEx95W
  394. #define GetRegKeyDataEx95 GetRegKeyDataEx95W
  395. #define GetRegValueString95 GetRegValueString95W
  396. #define GetRegValueBinary95 GetRegValueBinary95W
  397. #define GetRegValueMultiSz95 GetRegValueMultiSz95W
  398. #define GetRegValueDword95 GetRegValueDword95W
  399. #define GetRegValueStringEx95 GetRegValueStringEx95W
  400. #define GetRegValueBinaryEx95 GetRegValueBinaryEx95W
  401. #define GetRegValueMultiSzEx95 GetRegValueMultiSzEx95W
  402. #define GetRegValueDwordEx95 GetRegValueDwordEx95W
  403. #define GetRegDataEx95 GetRegDataEx95W
  404. #define GetRegData95 GetRegData95W
  405. #define OpenRegKey95 OpenRegKey95W
  406. #define OpenRegKeyStr95 OpenRegKeyStr95W
  407. #else
  408. #define EnumFirstRegKey95 EnumFirstRegKey95A
  409. #define EnumFirstRegKeyStr95 EnumFirstRegKeyStr95A
  410. #define EnumNextRegKey95 EnumNextRegKey95A
  411. #define AbortRegKeyEnum95 AbortRegKeyEnum95A
  412. #define EnumFirstRegKeyInTree95 EnumFirstRegKeyInTree95A
  413. #define EnumNextRegKeyInTree95 EnumNextRegKeyInTree95A
  414. #define AbortRegKeyTreeEnum95 AbortRegKeyTreeEnum95A
  415. #define EnumFirstRegValue95 EnumFirstRegValue95A
  416. #define EnumNextRegValue95 EnumNextRegValue95A
  417. #define GetRegValueData95 GetRegValueData95A
  418. #define GetRegValueDataOfType95 GetRegValueDataOfType95A
  419. #define GetRegKeyData95 GetRegKeyData95A
  420. #define GetRegValueDataEx95 GetRegValueDataEx95A
  421. #define GetRegValueDataOfTypeEx95 GetRegValueDataOfTypeEx95A
  422. #define GetRegKeyDataEx95 GetRegKeyDataEx95A
  423. #define GetRegValueString95 GetRegValueString95A
  424. #define GetRegValueBinary95 GetRegValueBinary95A
  425. #define GetRegValueMultiSz95 GetRegValueMultiSz95A
  426. #define GetRegValueDword95 GetRegValueDword95A
  427. #define GetRegValueStringEx95 GetRegValueStringEx95A
  428. #define GetRegValueBinaryEx95 GetRegValueBinaryEx95A
  429. #define GetRegValueMultiSzEx95 GetRegValueMultiSzEx95A
  430. #define GetRegValueDwordEx95 GetRegValueDwordEx95A
  431. #define GetRegDataEx95 GetRegDataEx95A
  432. #define GetRegData95 GetRegData95A
  433. #define OpenRegKey95 OpenRegKey95A
  434. #define OpenRegKeyStr95 OpenRegKeyStr95A
  435. #endif