Leaked source code of windows server 2003
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.

169 lines
5.4 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993 - 1995.
  5. //
  6. // File: citeratr.hxx
  7. //
  8. // Contents: iterator classes for ACLs and ACCESS_ENTRYs
  9. //
  10. // History: 8-94 Created DaveMont
  11. //
  12. //--------------------------------------------------------------------
  13. #ifndef __CITERATOR__
  14. #define __CITERATOR__
  15. //============================================================================
  16. //+---------------------------------------------------------------------------
  17. //
  18. // Class: CIterator
  19. //
  20. // Synopsis: Base class for ACL and ACCESS_ENTRY iterators
  21. //
  22. //----------------------------------------------------------------------------
  23. class CIterator
  24. {
  25. public:
  26. virtual ULONG NumberEntries();
  27. virtual DWORD InitAccountAccess(CAccountAccess *caa,
  28. LPWSTR system,
  29. IS_CONTAINER fdir,
  30. BOOL fSaveNamesAndSids);
  31. };
  32. //============================================================================
  33. //+---------------------------------------------------------------------------
  34. //
  35. // Class: CAclIterator
  36. //
  37. // Synopsis: class to iterate basic ACL
  38. //
  39. //----------------------------------------------------------------------------
  40. class CAclIterator : public CIterator
  41. {
  42. public:
  43. CAclIterator();
  44. void * operator new(size_t size);
  45. void operator delete(void * p, size_t size);
  46. void Init(PACL pacl);
  47. inline ULONG NumberEntries();
  48. inline void FirstAce();
  49. inline BOOL MoreAces();
  50. inline void NextAce();
  51. DWORD InitAccountAccess(CAccountAccess *caa,
  52. LPWSTR system,
  53. IS_CONTAINER fdir,
  54. BOOL fSaveNamesAndSids);
  55. private:
  56. PACL _pacl;
  57. ULONG _acecount;
  58. PACE_HEADER _pcurrentace;
  59. };
  60. //--------------------------------------------
  61. ULONG CAclIterator::NumberEntries()
  62. {
  63. return(_pacl ? _pacl->AceCount : 0);
  64. }
  65. //--------------------------------------------
  66. void CAclIterator::FirstAce()
  67. {
  68. _pcurrentace = (PACE_HEADER)((PBYTE)_pacl + sizeof(ACL));
  69. _acecount = 0;
  70. }
  71. //--------------------------------------------
  72. BOOL CAclIterator::MoreAces()
  73. {
  74. return( ((_acecount < _pacl->AceCount) ? TRUE : FALSE) );
  75. }
  76. //--------------------------------------------
  77. void CAclIterator::NextAce()
  78. {
  79. _pcurrentace = (PACE_HEADER)((PBYTE)_pcurrentace + _pcurrentace->AceSize);
  80. _acecount++;
  81. }
  82. //============================================================================
  83. //+---------------------------------------------------------------------------
  84. //
  85. // Class: CCompoundAclIterator
  86. //
  87. // Synopsis: Class to iterator Compound ACL
  88. //
  89. //----------------------------------------------------------------------------
  90. class CCompoundAclIterator : public CIterator
  91. {
  92. public:
  93. CCompoundAclIterator(PACL pacl);
  94. inline void FirstAce();
  95. inline BOOL MoreAces();
  96. inline void NextAce();
  97. DWORD InitAccountAccess(CAccountAccess *caa,
  98. LPWSTR system,
  99. IS_CONTAINER fdir,
  100. BOOL fSaveNamesAndSids);
  101. };
  102. //============================================================================
  103. //+---------------------------------------------------------------------------
  104. //
  105. // Class: CAesIterator
  106. //
  107. // Synopsis: Class to iterator ACCESS_ENTRYs
  108. //
  109. //----------------------------------------------------------------------------
  110. class CAesIterator : public CIterator
  111. {
  112. public:
  113. CAesIterator();
  114. void * operator new(size_t size);
  115. void operator delete(void * p, size_t size);
  116. void Init(ULONG ccount, PACCESS_ENTRY pae);
  117. inline ULONG NumberEntries();
  118. inline void FirstAe();
  119. inline BOOL MoreAes();
  120. inline void NextAe();
  121. DWORD InitAccountAccess(CAccountAccess *caa,
  122. LPWSTR system,
  123. IS_CONTAINER fdir,
  124. BOOL fSaveNamesAndSids);
  125. private:
  126. PACCESS_ENTRY _pae;
  127. PACCESS_ENTRY _pcurrententry;
  128. ULONG _curcount;
  129. ULONG _totalcount;
  130. };
  131. //--------------------------------------------
  132. ULONG CAesIterator::NumberEntries()
  133. {
  134. return(_totalcount);
  135. }
  136. //--------------------------------------------
  137. void CAesIterator::FirstAe()
  138. {
  139. _curcount = 0;
  140. _pcurrententry = _pae;
  141. }
  142. //--------------------------------------------
  143. BOOL CAesIterator::MoreAes()
  144. {
  145. return( ((_curcount < _totalcount) ? TRUE : FALSE) );
  146. }
  147. //--------------------------------------------
  148. void CAesIterator::NextAe()
  149. {
  150. _pcurrententry = (PACCESS_ENTRY)((PBYTE)_pcurrententry +
  151. sizeof(ACCESS_ENTRY));
  152. _curcount++;
  153. }
  154. #endif // __CITERATOR__