This source file includes following definitions.
- get
- get
- SD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #pragma once
22
23 #include "LoadLibraryWrapper.hpp"
24
25 namespace jmmcg { namespace NTUtils {
26
27 class win_exception;
28
29 class ACL_wrapper : virtual protected LoadLibraryWrapper {
30 public:
31 __stdcall ACL_wrapper();
32 __stdcall ACL_wrapper(const unsigned long acl_size);
33 __stdcall ACL_wrapper(ACL_wrapper &);
34 __stdcall ~ACL_wrapper();
35 ACL_wrapper & __fastcall operator=(ACL_wrapper &);
36
37 void __fastcall copy(const ACL_wrapper &) noexcept(true);
38 bool __fastcall initialize() noexcept(true);
39 bool __fastcall add_ACE(const DWORD access_mask,SID *sid) noexcept(true);
40
41 unsigned long size() const noexcept(true);
42 const ACL * __fastcall get() const noexcept(true);
43 ACL * __fastcall get() noexcept(true);
44
45 private:
46 typedef BOOL (WINAPI * const InitializeAclType)(PACL pAcl,DWORD nAclLength,DWORD dwAclRevision);
47 typedef BOOL (WINAPI * const AddAccessAllowedAceType)(PACL pAcl,DWORD dwAceRevision,DWORD AccessMask,PSID pSid);
48 #ifdef _DEBUG
49 typedef BOOL (WINAPI * const IsValidAclType)(PACL pAcl);
50 #endif
51
52 const InitializeAclType pInitializeAcl;
53 const AddAccessAllowedAceType pAddAccessAllowedAce;
54 #ifdef _DEBUG
55 const IsValidAclType pIsValidAcl;
56 #endif
57
58 unsigned long size_;
59 std::auto_ptr<BYTE> buff;
60 };
61
62 class SID_wrapper {
63 public:
64 __stdcall SID_wrapper(const unsigned int sid_size=96)
65 : buff(new BYTE[sid_size]) {
66 }
67 __stdcall SID_wrapper(const SID_wrapper &sw)
68 : buff(new BYTE[GetLengthSid(const_cast<SID_wrapper &>(sw).get())]) {
69 CopySid(GetLengthSid(const_cast<SID_wrapper &>(sw).get()),get(),const_cast<SID_wrapper &>(sw).get());
70 }
71 __stdcall ~SID_wrapper() {
72 }
73
74 const SID * __fastcall get() const noexcept(true) {
75 return reinterpret_cast<const SID *>(buff.get());
76 }
77 SID * __fastcall get() noexcept(true) {
78 return reinterpret_cast<SID *>(buff.get());
79 }
80
81 private:
82 const std::auto_ptr<BYTE> buff;
83
84 SID_wrapper & __fastcall operator=(const SID_wrapper &);
85 };
86
87 class AFX_EXT_CLASS SecurityDescriptor : virtual protected LoadLibraryWrapper {
88 public:
89 typedef win_exception exception_type;
90
91 __stdcall SecurityDescriptor();
92 __stdcall ~SecurityDescriptor();
93
94 const SECURITY_DESCRIPTOR & __fastcall SD() const noexcept(true) {
95 return sd;
96 }
97 unsigned long __fastcall Allow(const TCHAR * const machine,const TCHAR * const username,const DWORD access_mask) noexcept(true);
98
99 private:
100 typedef BOOL (WINAPI * const LookupAccountNameType)(LPCTSTR lpSystemName,LPCTSTR lpAccountName,PSID Sid,LPDWORD cbSid,LPTSTR ReferencedDomainName,LPDWORD cbReferencedDomainName,PSID_NAME_USE peUse);
101 typedef BOOL (WINAPI * const InitializeSecurityDescriptorType)(PSECURITY_DESCRIPTOR pSecurityDescriptor,DWORD dwRevision);
102 typedef BOOL (WINAPI * const SetSecurityDescriptorDaclType)(PSECURITY_DESCRIPTOR pSecurityDescriptor,BOOL bDaclPresent,PACL pDacl,BOOL bDaclDefaulted);
103 typedef DWORD (WINAPI * const GetLengthSidType)(PSID pSid);
104 #ifdef _DEBUG
105 typedef BOOL (WINAPI * const IsValidSidType)(PSID pSid);
106 typedef BOOL (WINAPI * const IsValidSecurityDescriptorType)(PSECURITY_DESCRIPTOR pSecurityDescriptor);
107 #endif
108
109 const LookupAccountNameType pLookupAccountName;
110 const InitializeSecurityDescriptorType pInitializeSecurityDescriptor;
111 const SetSecurityDescriptorDaclType pSetSecurityDescriptorDacl;
112 const GetLengthSidType pGetLengthSid;
113 #ifdef _DEBUG
114 const IsValidSidType pIsValidSid;
115 const IsValidSecurityDescriptorType pIsValidSecurityDescriptor;
116 #endif
117
118 std::vector<SID *> sids;
119 SECURITY_DESCRIPTOR sd;
120 ACL_wrapper acl;
121
122
123 SecurityDescriptor(const SecurityDescriptor &);
124 SecurityDescriptor & __fastcall operator=(const SecurityDescriptor &);
125 };
126
127 } }