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.

99 lines
3.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: ace.h
  8. //
  9. // This file contains definitions and prototypes for the ACE abstraction
  10. // class (CAce)
  11. //
  12. //--------------------------------------------------------------------------
  13. #ifndef _ACE_H_
  14. #define _ACE_H_
  15. class CAce : public ACE_HEADER
  16. {
  17. public:
  18. //UCHAR AceType; // Inherited from ACE_HEADER
  19. //UCHAR AceFlags;
  20. //USHORT AceSize;
  21. ACCESS_MASK Mask;
  22. ULONG Flags; // ACE_OBJECT_TYPE_PRESENT, etc.
  23. GUID ObjectType;
  24. GUID InheritedObjectType;
  25. PSID psid;
  26. SID_NAME_USE sidType;
  27. private:
  28. LPTSTR pszName;
  29. LPTSTR pszType;
  30. LPTSTR pszAccessType;
  31. LPTSTR pszInheritType;
  32. BOOL bPropertyAce;
  33. LPTSTR pszInheritSourceName;
  34. INT iInheritSourceLevel;
  35. public:
  36. CAce(PACE_HEADER pAceHeader = NULL);
  37. ~CAce();
  38. LPTSTR GetName() const { return pszName; }
  39. LPTSTR GetType() const { return pszType; }
  40. LPTSTR GetAccessType() const { return pszAccessType; }
  41. LPTSTR GetInheritType() const { return pszInheritType; }
  42. LPTSTR GetInheritSourceName() const { return pszInheritSourceName; }
  43. INT GetInheritSourceLevel() const { return iInheritSourceLevel; }
  44. BOOL IsPropertyAce() const { return bPropertyAce; }
  45. BOOL IsInheritedAce() const { return AceFlags & INHERITED_ACE; }
  46. LPTSTR LookupName(LPCTSTR pszServer = NULL, LPSECURITYINFO2 psi2 = NULL);
  47. void SetInheritSourceInfo(LPCTSTR psz, INT level);
  48. void SetName(LPCTSTR pszN, LPCTSTR pszL = NULL);
  49. void SetType(LPCTSTR psz) { SetString(&pszType, psz); }
  50. void SetAccessType(LPCTSTR psz) { SetString(&pszAccessType, psz); }
  51. void SetInheritType(LPCTSTR psz) { SetString(&pszInheritType, psz); }
  52. void SetPropertyAce(BOOL b) { bPropertyAce = b; }
  53. void SetSid(PSID p, LPCTSTR pszName, LPCTSTR pszLogonName, SID_NAME_USE type);
  54. PACE_HEADER Copy() const;
  55. void CopyTo(PACE_HEADER pAceDest) const;
  56. int CompareType(const CAce *pAceCompare) const;
  57. DWORD Merge(const CAce *pAce2);
  58. private:
  59. void SetString(LPTSTR *ppszDest, LPCTSTR pszSrc);
  60. };
  61. typedef CAce *PACE;
  62. #define AllFlagsOn(dw1, dw2) (((dw1) & (dw2)) == (dw2)) // equivalent to ((dw1 | dw2) == dw1)
  63. #define IsAuditAlarmACE(type) ( ((type) == SYSTEM_AUDIT_ACE_TYPE) || \
  64. ((type) == SYSTEM_AUDIT_OBJECT_ACE_TYPE) || \
  65. ((type) == SYSTEM_ALARM_ACE_TYPE) || \
  66. ((type) == SYSTEM_ALARM_OBJECT_ACE_TYPE) )
  67. BOOL
  68. IsEqualACEType(DWORD dwType1, DWORD dwType2);
  69. DWORD
  70. MergeAceHelper(DWORD dwAceFlags1,
  71. DWORD dwMask1,
  72. DWORD dwAceFlags2,
  73. DWORD dwMask2,
  74. DWORD dwMergeFlags,
  75. LPDWORD pdwResult);
  76. // CAce::Merge and MergeAceHelper return values
  77. #define MERGE_FAIL 0 // Unable to merge ACEs
  78. #define MERGE_OK_1 1 // ACE 1 (this) implies ACE 2
  79. #define MERGE_OK_2 2 // ACE 2 implies ACE 1 (this)
  80. #define MERGE_MODIFIED_FLAGS 3 // ACEs can be merged by modifying flags (new flags in *pdwResult)
  81. #define MERGE_MODIFIED_MASK 4 // ACEs can be merged by modifying mask (new mask in *pdwResult)
  82. // Values for MergeAceHelper dwMergeFlags parameter
  83. #define MF_OBJECT_TYPE_1_PRESENT 1
  84. #define MF_OBJECT_TYPE_2_PRESENT 2
  85. #define MF_OBJECT_TYPE_EQUAL 4
  86. #define MF_AUDIT_ACE_TYPE 8
  87. #endif // _ACE_H_