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.

81 lines
2.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: R E G K Y S E C . H
  7. //
  8. // Contents: CRegKeySecurity class and related data types
  9. //
  10. // Notes:
  11. //
  12. // Author: ckotze 6 July 2000
  13. //
  14. //---------------------------------------------------------------------------
  15. #pragma once
  16. #include <ncstl.h>
  17. typedef BYTE KEY_APPLY_MASK;
  18. const KEY_APPLY_MASK KEY_CURRENT = 1;
  19. const KEY_APPLY_MASK KEY_CHILDREN = 2;
  20. const KEY_APPLY_MASK KEY_ALL = KEY_CURRENT | KEY_CHILDREN;
  21. typedef LPCVOID PCSID;
  22. class CAccessControlEntry
  23. {
  24. public:
  25. CAccessControlEntry();
  26. CAccessControlEntry(const ACCESS_ALLOWED_ACE& aaAllowed);
  27. CAccessControlEntry(const BYTE AceType, const ACCESS_MASK amMask, const BYTE AceFlags, PCSID psidUserOrGroup);
  28. ~CAccessControlEntry();
  29. HRESULT AddToACL(PACL* pAcl, ACL_REVISION_INFORMATION AclRevisionInfo);
  30. BOOL HasExactRights(const ACCESS_MASK amRightsRequired) const;
  31. BOOL HasExactInheritFlags(BYTE AceFlags);
  32. DWORD GetLengthSid() const;
  33. BOOL IsEqualSid(PCSID psidUserOrGroup) const;
  34. private:
  35. BYTE m_cAceType;
  36. ACCESS_MASK m_amMask;
  37. tstring m_strSid;
  38. DWORD m_dwLengthSid;
  39. BYTE m_cAceFlags;
  40. };
  41. typedef list<CAccessControlEntry> LISTACE;
  42. typedef LISTACE::iterator ACEITER;
  43. class CRegKeySecurity
  44. {
  45. public:
  46. CRegKeySecurity();
  47. ~CRegKeySecurity();
  48. HRESULT RegOpenKey(const HKEY hkeyRoot, LPCTSTR strKeyName);
  49. HRESULT RegCloseKey();
  50. HRESULT GetSecurityDescriptorDacl();
  51. HRESULT SetSecurityDescriptorDacl(PACL paclDacl, DWORD dwNumEntries);
  52. HRESULT BuildAndApplyACLFromList(DWORD cbAcl, ACL_REVISION_INFORMATION AclRevisionInfo);
  53. HRESULT GetAccessControlEntriesFromAcl();
  54. HRESULT GrantRightsOnRegKey(PCSID psidUserOrGroup, ACCESS_MASK amPermissionsMask, KEY_APPLY_MASK kamMask);
  55. HRESULT RevokeRightsOnRegKey(PCSID psidUserOrGroup, ACCESS_MASK amPermissionsMask, KEY_APPLY_MASK kamMask);
  56. HRESULT GetKeySecurity();
  57. HRESULT SetKeySecurity();
  58. protected:
  59. PSECURITY_DESCRIPTOR m_psdRegKey;
  60. BOOL m_bDaclDefaulted;
  61. HKEY m_hkeyCurrent;
  62. PACL m_paclDacl;
  63. BOOL m_bHasDacl;
  64. PSID m_psidGroup;
  65. PSID m_psidOwner;
  66. PACL m_paclSacl;
  67. BOOL m_bHasSacl;
  68. LISTACE m_listAllAce;
  69. };