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.

411 lines
11 KiB

  1. /*
  2. * regkey.h
  3. *
  4. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the class CRegKeyContainer. This class
  8. * manages the data associated with a Registry Key. Registry Key are
  9. * used to identify resources held in the application registry and consist
  10. * of a Session Key and a resource ID octet string. The CRegKeyContainer
  11. * class uses a CSessKeyContainer container to maintain the session key data
  12. * internally. A Rogue Wave string object is used to hold the resource ID
  13. * octet string.
  14. *
  15. * Caveats:
  16. * None.
  17. *
  18. * Author:
  19. * jbo
  20. */
  21. #ifndef _REGISTRY_KEY_DATA_
  22. #define _REGISTRY_KEY_DATA_
  23. #include "sesskey.h"
  24. /*
  25. * This is the typedef for the structure used to hold the registry key data
  26. * internally.
  27. */
  28. typedef struct
  29. {
  30. CSessKeyContainer *session_key;
  31. LPOSTR poszResourceID;
  32. }
  33. REG_KEY;
  34. /*
  35. * Class definition:
  36. */
  37. class CRegKeyContainer : public CRefCount
  38. {
  39. public:
  40. CRegKeyContainer(PGCCRegistryKey, PGCCError);
  41. CRegKeyContainer(PRegistryKey, PGCCError);
  42. CRegKeyContainer(CRegKeyContainer *, PGCCError);
  43. ~CRegKeyContainer(void);
  44. UINT LockRegistryKeyData(void);
  45. void UnLockRegistryKeyData(void);
  46. UINT GetGCCRegistryKeyData(PGCCRegistryKey, LPBYTE memory);
  47. GCCError GetRegistryKeyDataPDU(PRegistryKey);
  48. void FreeRegistryKeyDataPDU(void);
  49. GCCError CreateRegistryKeyData(PGCCRegistryKey *);
  50. BOOL IsThisYourSessionKey(CSessKeyContainer *);
  51. CSessKeyContainer *GetSessionKey(void) { return m_InternalRegKey.session_key; }
  52. friend BOOL operator==(const CRegKeyContainer&, const CRegKeyContainer&);
  53. protected:
  54. REG_KEY m_InternalRegKey;
  55. UINT m_cbDataSize;
  56. RegistryKey m_RegKeyPDU;
  57. BOOL m_fValidRegKeyPDU;
  58. };
  59. /*
  60. * Comments explaining the public and protected class member functions
  61. */
  62. /*
  63. * CRegKeyContainer ( PGCCRegistryKey registry_key,
  64. * PGCCError return_value);
  65. *
  66. * Public member function of CRegKeyContainer.
  67. *
  68. * Function Description:
  69. * This is the constructor for the CRegKeyContainer class which takes as
  70. * input the "API" version of registry key data, GCCRegistryKey.
  71. *
  72. * Formal Parameters:
  73. * registry_key (i) The registry key data to store.
  74. * return_value (o) The output parameter used to indicate errors.
  75. *
  76. * Return Value:
  77. * GCC_NO_ERROR - No error.
  78. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  79. * "new" operator.
  80. * GCC_BAD_REGISTRY_KEY - An invalid registry key passed in.
  81. *
  82. * Side Effects:
  83. * None.
  84. *
  85. * Caveats:
  86. * None.
  87. */
  88. /*
  89. * CRegKeyContainer ( PRegistryKey registry_key,
  90. * PGCCError return_value);
  91. *
  92. * Public member function of CRegKeyContainer.
  93. *
  94. * Function Description:
  95. * This is the constructor for the CRegKeyContainer class which takes as
  96. * input the "PDU" version of registry key data, RegistryKey.
  97. *
  98. * Formal Parameters:
  99. * registry_key (i) The registry key data to store.
  100. * return_value (o) The output parameter used to indicate errors.
  101. *
  102. * Return Value:
  103. * GCC_NO_ERROR - No error.
  104. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  105. * "new" operator.
  106. *
  107. * Side Effects:
  108. * None.
  109. *
  110. * Caveats:
  111. * None.
  112. */
  113. /*
  114. * CRegKeyContainer(CRegKeyContainer *registry_key,
  115. * PGCCError return_value);
  116. *
  117. * Public member function of CRegKeyContainer.
  118. *
  119. * Function Description:
  120. * This is the copy constructor for the CRegKeyContainer class which takes
  121. * as input another CRegKeyContainer object.
  122. *
  123. * Formal Parameters:
  124. * registry_key (i) The CRegKeyContainer object to copy.
  125. * return_value (o) The output parameter used to indicate errors.
  126. *
  127. * Return Value:
  128. * GCC_NO_ERROR - No error.
  129. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  130. * "new" operator.
  131. *
  132. * Side Effects:
  133. * None.
  134. *
  135. * Caveats:
  136. * None.
  137. */
  138. /*
  139. * ~CRegKeyContainer();
  140. *
  141. * Public member function of CRegKeyContainer.
  142. *
  143. * Function Description:
  144. * This is the destructor for the CRegKeyContainer class. It is used to
  145. * clean up any memory allocated during the life of this object.
  146. *
  147. * Formal Parameters:
  148. * None.
  149. *
  150. * Return Value:
  151. * None.
  152. *
  153. * Side Effects:
  154. * None.
  155. *
  156. * Caveats:
  157. * None.
  158. */
  159. /*
  160. * ULong LockRegistryKeyData ();
  161. *
  162. * Public member function of CRegKeyContainer.
  163. *
  164. * Function Description:
  165. * This routine is used to "lock" the "API" data for this object. This
  166. * results in the lock count for this object being incremented. When the
  167. * lock count transitions from 0 to 1, a calculation is made to determine
  168. * how much memory will be needed to hold any "API" data which will
  169. * be referenced by, but not held in, the GCCRegistryKey structure
  170. * which is filled in on a call to GetGCCRegistryKeyData. This is the
  171. * value returned by this routine in order to allow the calling object to
  172. * allocate that amount of memory in preparation for the call to
  173. * GetGCCRegistryKeyData.
  174. *
  175. * Formal Parameters:
  176. * None.
  177. *
  178. * Return Value:
  179. * The amount of memory, if any, which will be needed to hold "API" data
  180. * which is referenced by, but not held in, the GCCRegistryKey structure
  181. * provided as an output parameter to the GetGCCRegistryKeyData call.
  182. *
  183. * Side Effects:
  184. * The internal lock count is incremented.
  185. *
  186. * Caveats:
  187. * The internal lock count is used in conjuction with an internal "free"
  188. * flag as a mechanism for ensuring that this object remains in existance
  189. * until all interested parties are through with it. The object remains
  190. * valid (unless explicity deleted) until the lock count is zero and the
  191. * "free" flag is set through a call to FreeRegistryKeyData. This allows
  192. * other objects to lock this object and be sure that it remains valid
  193. * until they call UnLock which will decrement the internal lock count. A
  194. * typical usage scenerio for this object would be: A CRegKeyContainer
  195. * object is constructed and then passed off to any interested parties
  196. * through a function call. On return from the function call, the
  197. * FreeRegistryKeyData call is made which will set the internal "free"
  198. * flag. If no other parties have locked the object with a Lock call,
  199. * then the CRegKeyContainer object will automatically delete itself when
  200. * the FreeRegistryKeyData call is made. If, however, any number of
  201. * other parties has locked the object, it will remain in existence until
  202. * each of them has unlocked the object through a call to UnLock.
  203. */
  204. /*
  205. * ULong GetGCCRegistryKeyData (
  206. * PGCCRegistryKey registry_key,
  207. * LPSTR memory);
  208. *
  209. * Public member function of CRegKeyContainer.
  210. *
  211. * Function Description:
  212. * This routine is used to retrieve the registry key data from the
  213. * CRegKeyContainer object in the "API" form of a GCCRegistryKey.
  214. *
  215. * Formal Parameters:
  216. * registry_key (o) The GCCRegistryKey structure to fill in.
  217. * memory (o) The memory used to hold any data referenced by,
  218. * but not held in, the output structure.
  219. *
  220. * Return Value:
  221. * The amount of data, if any, written into the bulk memory block provided.
  222. *
  223. * Side Effects:
  224. * None.
  225. *
  226. * Caveats:
  227. * None.
  228. */
  229. /*
  230. * void UnLockRegistryKeyData ();
  231. *
  232. * Public member function of CRegKeyContainer.
  233. *
  234. * Function Description:
  235. * This routine is used to "unlock" the "API" data for this object. This
  236. * results in the lock count for this object being decremented. When the
  237. * lock count transitions from 1 to 0, a check is made to determine
  238. * whether the object has been freed through a call to
  239. * FreeRegistryKeyData. If so, the object will automatically delete
  240. * itself.
  241. *
  242. * Formal Parameters:
  243. * None.
  244. *
  245. * Return Value:
  246. * None.
  247. *
  248. * Side Effects:
  249. * The internal lock count is decremented.
  250. *
  251. * Caveats:
  252. * It is the responsibility of any party which locks a CRegKeyContainer
  253. * object by calling Lock to also unlock the object with a call to UnLock.
  254. * If the party calling UnLock did not construct the CRegKeyContainer
  255. * object, it should assume the object to be invalid thereafter.
  256. */
  257. /*
  258. * GCCError GetRegistryKeyDataPDU (
  259. * PRegistryKey registry_key);
  260. *
  261. * Public member function of CRegKeyContainer.
  262. *
  263. * Function Description:
  264. * This routine is used to retrieve the registry key data from the
  265. * CRegKeyContainer object in the "PDU" form of a RegistryKey.
  266. *
  267. * Formal Parameters:
  268. * registry_key (o) The RegistryKey structure to fill in.
  269. *
  270. * Return Value:
  271. * GCC_NO_ERROR - No error.
  272. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  273. * "new" operator.
  274. * GCC_BAD_OBJECT_KEY - One of the internal pointers has
  275. * been corrupted.
  276. *
  277. * Side Effects:
  278. * None.
  279. *
  280. * Caveats:
  281. * None.
  282. */
  283. /*
  284. * void FreeRegistryKeyDataPDU ();
  285. *
  286. * Public member function of CRegKeyContainer.
  287. *
  288. * Function Description:
  289. * This routine is used to "free" the "PDU" data allocated for this object
  290. * which is held internally in a RegistryKey structure.
  291. *
  292. * Formal Parameters:
  293. * None.
  294. *
  295. * Return Value:
  296. * None.
  297. *
  298. * Side Effects:
  299. * The internal "free" flag is set.
  300. *
  301. * Caveats:
  302. * This object should be assumed invalid after a call to
  303. * FreeRegistryKeyDataPDU has been made.
  304. */
  305. /*
  306. * BOOL IsThisYourSessionKey (
  307. * CSessKeyContainer *session_key);
  308. *
  309. * Public member function of CRegKeyContainer.
  310. *
  311. * Function Description:
  312. * This routine is used to determine whether the specified session key
  313. * is held within this registry key object. The session key is
  314. * provided in "API" form.
  315. *
  316. * Formal Parameters:
  317. * session_key (i) The session key to use for comparison.
  318. *
  319. * Return Value:
  320. * TRUE - The specified session key is contained
  321. * within this registry key object.
  322. * FALSE - The specified session key is not contained
  323. * within this registry key object.
  324. *
  325. * Side Effects:
  326. * None.
  327. *
  328. * Caveats:
  329. * None.
  330. */
  331. /*
  332. * CSessKeyContainer *GetSessionKey ();
  333. *
  334. * Public member function of CRegKeyContainer.
  335. *
  336. * Function Description:
  337. * This routine is used to retrieve the session key held in this registry
  338. * key object. The session key is returned in the form of a
  339. * CSessKeyContainer object.
  340. *
  341. * Formal Parameters:
  342. * None.
  343. *
  344. * Return Value:
  345. * A pointer to the CSessKeyContainer object contained within this
  346. * CRegKeyContainer object.
  347. *
  348. * Side Effects:
  349. * None.
  350. *
  351. * Caveats:
  352. * None.
  353. */
  354. /*
  355. * friend BOOL operator== (const CRegKeyContainer& registry_key_1,
  356. * const CRegKeyContainer& registry_key_2);
  357. *
  358. * Public member function of CRegKeyContainer.
  359. *
  360. * Function Description:
  361. * This routine is used to compare two CRegKeyContainer objects to determine
  362. * whether or not they are equal in value.
  363. *
  364. * Formal Parameters:
  365. * registry_key_1 (i) The first CRegKeyContainer object to compare.
  366. * registry_key_2 (i) The other CRegKeyContainer object to compare.
  367. *
  368. * Return Value:
  369. * TRUE - The two objects are equal in value.
  370. * FALSE - The two objects are not equal in value.
  371. *
  372. * Side Effects:
  373. * None.
  374. *
  375. * Caveats:
  376. * None.
  377. */
  378. #endif