1 /***********************************************************************\
2 *                                aclapi.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                           by Stewart Gordon                           *
8 *                                                                       *
9 *                       Placed into public domain                       *
10 \***********************************************************************/
11 module win32.aclapi;
12 pragma(lib, "advapi32.lib");
13 
14 import win32.windows, win32.accctrl;
15 
16 static assert (_WIN32_WINNT_ONLY,
17 	"win32.aclapi is available only if version WindowsNTonly, WindowsXP, "
18 	"Windows2003 or WindowsVista is set");
19 
20 extern (Windows) {
21 	VOID BuildExplicitAccessWithNameA(PEXPLICIT_ACCESS_A, LPSTR, DWORD,
22 	  ACCESS_MODE, DWORD);
23 	VOID BuildExplicitAccessWithNameW(PEXPLICIT_ACCESS_W, LPWSTR, DWORD,
24 	  ACCESS_MODE, DWORD);
25 	DWORD BuildSecurityDescriptorA(PTRUSTEE_A, PTRUSTEE_A , ULONG,
26 	  PEXPLICIT_ACCESS_A, ULONG, PEXPLICIT_ACCESS_A, PSECURITY_DESCRIPTOR,
27 	  PULONG, PSECURITY_DESCRIPTOR*);
28 	DWORD BuildSecurityDescriptorW(PTRUSTEE_W, PTRUSTEE_W , ULONG,
29 	  PEXPLICIT_ACCESS_W, ULONG, PEXPLICIT_ACCESS_W, PSECURITY_DESCRIPTOR,
30 	  PULONG, PSECURITY_DESCRIPTOR*);
31 	VOID BuildTrusteeWithNameA(PTRUSTEE_A, LPSTR);
32 	VOID BuildTrusteeWithNameW(PTRUSTEE_W, LPWSTR);
33 	VOID BuildTrusteeWithObjectsAndNameA(PTRUSTEE_A, POBJECTS_AND_NAME_A,
34 	  SE_OBJECT_TYPE, LPSTR, LPSTR, LPSTR);
35 	VOID BuildTrusteeWithObjectsAndNameW(PTRUSTEE_W, POBJECTS_AND_NAME_W,
36 	  SE_OBJECT_TYPE, LPWSTR, LPWSTR, LPWSTR);
37 	VOID BuildTrusteeWithObjectsAndSidA(PTRUSTEE_A, POBJECTS_AND_SID,
38 	  GUID*, GUID*, PSID);
39 	VOID BuildTrusteeWithObjectsAndSidW(PTRUSTEE_W, POBJECTS_AND_SID,
40 	  GUID*, GUID*, PSID);
41 	VOID BuildTrusteeWithSidA(PTRUSTEE_A, PSID);
42 	VOID BuildTrusteeWithSidW(PTRUSTEE_W, PSID);
43 	DWORD GetAuditedPermissionsFromAclA(PACL, PTRUSTEE_A, PACCESS_MASK,
44 	  PACCESS_MASK);
45 	DWORD GetAuditedPermissionsFromAclW(PACL, PTRUSTEE_W, PACCESS_MASK,
46 	  PACCESS_MASK);
47 	DWORD GetEffectiveRightsFromAclA(PACL, PTRUSTEE_A, PACCESS_MASK);
48 	DWORD GetEffectiveRightsFromAclW(PACL, PTRUSTEE_W, PACCESS_MASK);
49 	DWORD GetExplicitEntriesFromAclA(PACL, PULONG, PEXPLICIT_ACCESS_A*);
50 	DWORD GetExplicitEntriesFromAclW(PACL, PULONG, PEXPLICIT_ACCESS_W*);
51 	static if (WINVER >= 0x501) {
52 		DWORD GetInheritanceSourceA(LPSTR, SE_OBJECT_TYPE,
53 		  SECURITY_INFORMATION, BOOL, GUID**, DWORD, PACL, void*,
54 		  PGENERIC_MAPPING, PINHERITED_FROMA);
55 		DWORD GetInheritanceSourceW(LPWSTR, SE_OBJECT_TYPE,
56 		  SECURITY_INFORMATION, BOOL, GUID**, DWORD, PACL, void*,
57 		  PGENERIC_MAPPING, PINHERITED_FROMW);
58 	}
59 	DWORD GetNamedSecurityInfoA(LPSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
60 	  PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
61 	DWORD GetNamedSecurityInfoW(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
62 	  PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
63 	DWORD GetSecurityInfo(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
64 	  PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
65 	TRUSTEE_FORM GetTrusteeFormA(PTRUSTEE_A);
66 	TRUSTEE_FORM GetTrusteeFormW(PTRUSTEE_W);
67 	LPSTR GetTrusteeNameA(PTRUSTEE_A);
68 	LPWSTR GetTrusteeNameW(PTRUSTEE_W);
69 	TRUSTEE_TYPE GetTrusteeTypeA(PTRUSTEE_A);
70 	TRUSTEE_TYPE GetTrusteeTypeW(PTRUSTEE_W);
71 	DWORD LookupSecurityDescriptorPartsA(PTRUSTEE_A*, PTRUSTEE_A*, PULONG,
72 	  PEXPLICIT_ACCESS_A*, PULONG, PEXPLICIT_ACCESS_A*,
73 	  PSECURITY_DESCRIPTOR);
74 	DWORD LookupSecurityDescriptorPartsW(PTRUSTEE_W*, PTRUSTEE_W*, PULONG,
75 	  PEXPLICIT_ACCESS_W*, PULONG, PEXPLICIT_ACCESS_W*,
76 	  PSECURITY_DESCRIPTOR);
77 	DWORD SetEntriesInAclA(ULONG, PEXPLICIT_ACCESS_A, PACL, PACL*);
78 	DWORD SetEntriesInAclW(ULONG, PEXPLICIT_ACCESS_W, PACL, PACL*);
79 	DWORD SetNamedSecurityInfoA(LPSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
80 	  PSID, PSID, PACL, PACL);
81 	DWORD SetNamedSecurityInfoW(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
82 	  PSID, PSID, PACL, PACL);
83 	DWORD SetSecurityInfo(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID,
84 	  PSID, PACL, PACL);
85 	VOID BuildImpersonateExplicitAccessWithNameA(PEXPLICIT_ACCESS_A, LPSTR,
86 	  PTRUSTEE_A, DWORD, ACCESS_MODE, DWORD);
87 	VOID BuildImpersonateExplicitAccessWithNameW(PEXPLICIT_ACCESS_W, LPWSTR,
88 	  PTRUSTEE_W, DWORD, ACCESS_MODE, DWORD);
89 	VOID BuildImpersonateTrusteeA(PTRUSTEE_A, PTRUSTEE_A);
90 	VOID BuildImpersonateTrusteeW(PTRUSTEE_W, PTRUSTEE_W);
91 	PTRUSTEE_A GetMultipleTrusteeA(PTRUSTEE_A);
92 	PTRUSTEE_W GetMultipleTrusteeW(PTRUSTEE_W);
93 	MULTIPLE_TRUSTEE_OPERATION GetMultipleTrusteeOperationA(PTRUSTEE_A);
94 	MULTIPLE_TRUSTEE_OPERATION GetMultipleTrusteeOperationW(PTRUSTEE_W);
95 }
96 
97 version (Unicode) {
98 	alias BuildExplicitAccessWithNameW BuildExplicitAccessWithName;
99 	alias BuildSecurityDescriptorW BuildSecurityDescriptor;
100 	alias BuildTrusteeWithNameW BuildTrusteeWithName;
101 	alias BuildTrusteeWithObjectsAndNameW BuildTrusteeWithObjectsAndName;
102 	alias BuildTrusteeWithObjectsAndSidW BuildTrusteeWithObjectsAndSid;
103 	alias BuildTrusteeWithSidW BuildTrusteeWithSid;
104 	alias GetAuditedPermissionsFromAclW GetAuditedPermissionsFromAcl;
105 	alias GetEffectiveRightsFromAclW GetEffectiveRightsFromAcl;
106 	alias GetExplicitEntriesFromAclW GetExplicitEntriesFromAcl;
107 	alias GetNamedSecurityInfoW GetNamedSecurityInfo;
108 	alias GetTrusteeFormW GetTrusteeForm;
109 	alias GetTrusteeNameW GetTrusteeName;
110 	alias GetTrusteeTypeW GetTrusteeType;
111 	alias LookupSecurityDescriptorPartsW LookupSecurityDescriptorParts;
112 	alias SetEntriesInAclW SetEntriesInAcl;
113 	alias SetNamedSecurityInfoW SetNamedSecurityInfo;
114 	alias BuildImpersonateExplicitAccessWithNameW
115 	  BuildImpersonateExplicitAccessWithName;
116 	alias BuildImpersonateTrusteeW BuildImpersonateTrustee;
117 	alias GetMultipleTrusteeW GetMultipleTrustee;
118 	alias GetMultipleTrusteeOperationW GetMultipleTrusteeOperation;
119 } else {
120 	alias BuildExplicitAccessWithNameA BuildExplicitAccessWithName;
121 	alias BuildSecurityDescriptorA BuildSecurityDescriptor;
122 	alias BuildTrusteeWithNameA BuildTrusteeWithName;
123 	alias BuildTrusteeWithObjectsAndNameA BuildTrusteeWithObjectsAndName;
124 	alias BuildTrusteeWithObjectsAndSidA BuildTrusteeWithObjectsAndSid;
125 	alias BuildTrusteeWithSidA BuildTrusteeWithSid;
126 	alias GetAuditedPermissionsFromAclA GetAuditedPermissionsFromAcl;
127 	alias GetEffectiveRightsFromAclA GetEffectiveRightsFromAcl;
128 	alias GetExplicitEntriesFromAclA GetExplicitEntriesFromAcl;
129 	alias GetNamedSecurityInfoA GetNamedSecurityInfo;
130 	alias GetTrusteeFormA GetTrusteeForm;
131 	alias GetTrusteeNameA GetTrusteeName;
132 	alias GetTrusteeTypeA GetTrusteeType;
133 	alias LookupSecurityDescriptorPartsA LookupSecurityDescriptorParts;
134 	alias SetEntriesInAclA SetEntriesInAcl;
135 	alias SetNamedSecurityInfoA SetNamedSecurityInfo;
136 	alias BuildImpersonateExplicitAccessWithNameA
137 	  BuildImpersonateExplicitAccessWithName;
138 	alias BuildImpersonateTrusteeA BuildImpersonateTrustee;
139 	alias GetMultipleTrusteeA GetMultipleTrustee;
140 	alias GetMultipleTrusteeOperationA GetMultipleTrusteeOperation;
141 }