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.

223 lines
4.5 KiB

  1. //+---------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993 - 1997.
  5. //
  6. // File: datapkt.h
  7. //
  8. // Contents: Defines the class CDataPacket to manages diverse data
  9. // packets needing to be written to various databases
  10. //
  11. // Classes:
  12. //
  13. // Methods:
  14. //
  15. // History: 23-Apr-96 BruceMa Created.
  16. //
  17. //----------------------------------------------------------------------
  18. #ifndef _DATAPKT_H_
  19. #define _DATAPKT_H_
  20. typedef enum tagPACKETTYPE {
  21. Empty,
  22. NamedValueSz,
  23. NamedValueDword,
  24. SingleACL,
  25. RegKeyACL,
  26. Password,
  27. ServiceIdentity,
  28. NamedValueMultiSz,
  29. RegistryNode
  30. } PACKETTYPE;
  31. typedef struct
  32. {
  33. TCHAR *szValue;
  34. } SNamedValueSz, *PNamedValueSz;
  35. typedef struct
  36. {
  37. int Dummy;
  38. } SNamedValueMultiSz;
  39. typedef struct
  40. {
  41. DWORD dwValue;
  42. } SNamedValueDword, *PNamedValueDword;
  43. typedef struct
  44. {
  45. SECURITY_DESCRIPTOR *pSec;
  46. } SSingleACL, *PSingleACL;
  47. typedef struct
  48. {
  49. HKEY *phClsids;
  50. unsigned cClsids;
  51. TCHAR *szTitle;
  52. SECURITY_DESCRIPTOR *pSec;
  53. SECURITY_DESCRIPTOR *pSecOrig;
  54. } SRegKeyACL, *PRegKeyACL;
  55. typedef struct
  56. {
  57. TCHAR *szPassword;
  58. CLSID appid;
  59. } SPassword, *PPassword;
  60. typedef struct
  61. {
  62. TCHAR *szServiceName;
  63. TCHAR *szIdentity;
  64. } SServiceIdentity, *PServiceIdentity;
  65. class CDataPacket
  66. {
  67. public:
  68. CDataPacket(void);
  69. CDataPacket(HKEY hRoot,
  70. TCHAR *szKeyPath,
  71. TCHAR *szValueName,
  72. DWORD dwValue);
  73. CDataPacket(HKEY hRoot,
  74. TCHAR *szKeyPath,
  75. TCHAR *szValueName,
  76. SECURITY_DESCRIPTOR *pSec,
  77. BOOL fSelfRelative);
  78. CDataPacket(HKEY hKey,
  79. HKEY *phClsids,
  80. unsigned cClsids,
  81. TCHAR *szTitle,
  82. SECURITY_DESCRIPTOR *pSecOrig,
  83. SECURITY_DESCRIPTOR *pSec,
  84. BOOL fSelfRelative);
  85. CDataPacket(TCHAR *szPassword, CLSID apid);
  86. CDataPacket(TCHAR *szServiceName, TCHAR *szIdentity);
  87. CDataPacket(PACKETTYPE pktType,
  88. HKEY hRoot,
  89. TCHAR *szKeyPath,
  90. TCHAR *szValueName);
  91. CDataPacket(const CDataPacket& rDataPacket);
  92. virtual ~CDataPacket();
  93. void ChgDwordValue(DWORD dwValue);
  94. void ChgACL(SECURITY_DESCRIPTOR *pSec, BOOL fSelfRelative);
  95. void ChgPassword(TCHAR *szPassword);
  96. void ChgSrvIdentity(TCHAR *szIdentity);
  97. void MarkForDeletion(BOOL);
  98. void MarkHiveForDeletion(BOOL bDelete);
  99. void SetModified(BOOL fDirty);
  100. BOOL IsDeleted();
  101. BOOL IsModified();
  102. virtual int Apply();
  103. virtual long Read(HKEY hKey);
  104. virtual int Remove();
  105. virtual int Update();
  106. DWORD GetDwordValue();
  107. virtual BOOL IsIdentifiedBy(HKEY hRoot,TCHAR *, TCHAR*);
  108. PACKETTYPE m_tagType;
  109. BOOL m_fModified;
  110. BOOL m_fDelete;
  111. BOOL m_fDeleteHive;
  112. HKEY m_hRoot;
  113. CString m_szKeyPath;
  114. CString m_szValueName;
  115. union
  116. {
  117. SNamedValueSz nvsz;
  118. SNamedValueDword nvdw;
  119. SSingleACL acl;
  120. SRegKeyACL racl;
  121. SPassword pw;
  122. SServiceIdentity si;
  123. SNamedValueMultiSz nvmsz;
  124. } pkt;
  125. private:
  126. void ReportOutOfMemAndTerminate();
  127. };
  128. inline void CDataPacket::SetModified(BOOL fDirty)
  129. {
  130. m_fModified = fDirty;
  131. }
  132. inline BOOL CDataPacket::IsModified()
  133. {
  134. return m_fModified;
  135. }
  136. inline BOOL CDataPacket::IsDeleted()
  137. {
  138. return m_fDelete;
  139. }
  140. inline DWORD CDataPacket::GetDwordValue()
  141. {
  142. return pkt.nvdw.dwValue;
  143. }
  144. class CRegSzNamedValueDp : public CDataPacket
  145. {
  146. public:
  147. CRegSzNamedValueDp(HKEY hRoot, TCHAR *szKeyPath, TCHAR *szValueName, TCHAR *szValue);
  148. CRegSzNamedValueDp(const CRegSzNamedValueDp&);
  149. virtual BOOL IsIdentifiedBy(HKEY hRoot, TCHAR *szKeyPath, TCHAR *szValueName);
  150. virtual int Update();
  151. virtual long Read(HKEY hkey);
  152. CString Value();
  153. void ChgSzValue(TCHAR *szValue);
  154. private:
  155. CString m_szValue;
  156. };
  157. class CRegMultiSzNamedValueDp : public CDataPacket
  158. {
  159. public:
  160. CRegMultiSzNamedValueDp(HKEY hRoot, TCHAR *szKeyPath, TCHAR *szValueName);
  161. virtual ~CRegMultiSzNamedValueDp();
  162. virtual long Read(HKEY hKey);
  163. virtual int Update();
  164. virtual BOOL IsIdentifiedBy(HKEY hRoot, TCHAR *szKeyPath, TCHAR *szValueName);
  165. void Clear();
  166. CStringArray& Values() { return m_strValues; }
  167. private:
  168. CStringArray m_strValues;
  169. };
  170. #endif // _DATAPKT_H_