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.

82 lines
2.3 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. #include <ncstlstr.h>
  18. typedef BYTE KEY_APPLY_MASK;
  19. const KEY_APPLY_MASK KEY_CURRENT = 1;
  20. const KEY_APPLY_MASK KEY_CHILDREN = 2;
  21. const KEY_APPLY_MASK KEY_ALL = KEY_CURRENT | KEY_CHILDREN;
  22. typedef LPCVOID PCSID;
  23. class CAccessControlEntry
  24. {
  25. public:
  26. CAccessControlEntry();
  27. CAccessControlEntry(const ACCESS_ALLOWED_ACE& aaAllowed);
  28. CAccessControlEntry(const BYTE AceType, const ACCESS_MASK amMask, const BYTE AceFlags, PCSID psidUserOrGroup);
  29. ~CAccessControlEntry();
  30. HRESULT AddToACL(PACL* pAcl, ACL_REVISION_INFORMATION AclRevisionInfo);
  31. BOOL HasExactRights(const ACCESS_MASK amRightsRequired) const;
  32. BOOL HasExactInheritFlags(BYTE AceFlags);
  33. DWORD GetLengthSid() const;
  34. BOOL IsEqualSid(PCSID psidUserOrGroup) const;
  35. private:
  36. BYTE m_cAceType;
  37. ACCESS_MASK m_amMask;
  38. tstring m_strSid;
  39. DWORD m_dwLengthSid;
  40. BYTE m_cAceFlags;
  41. };
  42. typedef list<CAccessControlEntry> LISTACE;
  43. typedef LISTACE::iterator ACEITER;
  44. class CRegKeySecurity
  45. {
  46. public:
  47. CRegKeySecurity();
  48. ~CRegKeySecurity();
  49. HRESULT RegOpenKey(const HKEY hkeyRoot, LPCTSTR strKeyName);
  50. HRESULT RegCloseKey();
  51. HRESULT GetSecurityDescriptorDacl();
  52. HRESULT SetSecurityDescriptorDacl(PACL paclDacl, DWORD dwNumEntries);
  53. HRESULT BuildAndApplyACLFromList(DWORD cbAcl, ACL_REVISION_INFORMATION AclRevisionInfo);
  54. HRESULT GetAccessControlEntriesFromAcl();
  55. HRESULT GrantRightsOnRegKey(PCSID psidUserOrGroup, ACCESS_MASK amPermissionsMask, KEY_APPLY_MASK kamMask);
  56. HRESULT RevokeRightsOnRegKey(PCSID psidUserOrGroup, ACCESS_MASK amPermissionsMask, KEY_APPLY_MASK kamMask);
  57. HRESULT GetKeySecurity();
  58. HRESULT SetKeySecurity();
  59. protected:
  60. PSECURITY_DESCRIPTOR m_psdRegKey;
  61. BOOL m_bDaclDefaulted;
  62. HKEY m_hkeyCurrent;
  63. PACL m_paclDacl;
  64. BOOL m_bHasDacl;
  65. PSID m_psidGroup;
  66. PSID m_psidOwner;
  67. PACL m_paclSacl;
  68. BOOL m_bHasSacl;
  69. LISTACE m_listAllAce;
  70. };