1 /***********************************************************************\
2 *                               accctrl.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 windows.accctrl;
12 nothrow:
13 private import windows.basetyps, windows.w32api, windows.winbase, windows.windef;
14 
15 // FIXME: check types and grouping of constants
16 // FIXME: check Windows version support
17 
18 alias LocalFree AccFree;
19 
20 const uint
21 	ACTRL_RESERVED            = 0x00000000,
22 	ACTRL_ACCESS_PROTECTED    = 0x00000001,
23 	ACTRL_ACCESS_ALLOWED      = 0x00000001,
24 	ACTRL_ACCESS_DENIED       = 0x00000002,
25 	ACTRL_AUDIT_SUCCESS       = 0x00000004,
26 	ACTRL_AUDIT_FAILURE       = 0x00000008,
27 	ACTRL_SYSTEM_ACCESS       = 0x04000000,
28 	ACTRL_DELETE              = 0x08000000,
29 	ACTRL_READ_CONTROL        = 0x10000000,
30 	ACTRL_CHANGE_ACCESS       = 0x20000000,
31 	ACTRL_CHANGE_OWNER        = 0x40000000,
32 	ACTRL_SYNCHRONIZE         = 0x80000000,
33 	ACTRL_STD_RIGHTS_ALL      = 0xf8000000;
34 
35 const uint
36 	ACTRL_FILE_READ           = 0x00000001,
37 	ACTRL_FILE_WRITE          = 0x00000002,
38 	ACTRL_FILE_APPEND         = 0x00000004,
39 	ACTRL_FILE_READ_PROP      = 0x00000008,
40 	ACTRL_FILE_WRITE_PROP     = 0x00000010,
41 	ACTRL_FILE_EXECUTE        = 0x00000020,
42 	ACTRL_FILE_READ_ATTRIB    = 0x00000080,
43 	ACTRL_FILE_WRITE_ATTRIB   = 0x00000100,
44 	ACTRL_FILE_CREATE_PIPE    = 0x00000200;
45 
46 const uint
47 	ACTRL_DIR_LIST            = 0x00000001,
48 	ACTRL_DIR_CREATE_OBJECT   = 0x00000002,
49 	ACTRL_DIR_CREATE_CHILD    = 0x00000004,
50 	ACTRL_DIR_DELETE_CHILD    = 0x00000040,
51 	ACTRL_DIR_TRAVERSE        = 0x00000020;
52 
53 const uint
54 	ACTRL_KERNEL_TERMINATE    = 0x00000001,
55 	ACTRL_KERNEL_THREAD       = 0x00000002,
56 	ACTRL_KERNEL_VM           = 0x00000004,
57 	ACTRL_KERNEL_VM_READ      = 0x00000008,
58 	ACTRL_KERNEL_VM_WRITE     = 0x00000010,
59 	ACTRL_KERNEL_DUP_HANDLE   = 0x00000020,
60 	ACTRL_KERNEL_PROCESS      = 0x00000040,
61 	ACTRL_KERNEL_SET_INFO     = 0x00000080,
62 	ACTRL_KERNEL_GET_INFO     = 0x00000100,
63 	ACTRL_KERNEL_CONTROL      = 0x00000200,
64 	ACTRL_KERNEL_ALERT        = 0x00000400,
65 	ACTRL_KERNEL_GET_CONTEXT  = 0x00000800,
66 	ACTRL_KERNEL_SET_CONTEXT  = 0x00001000,
67 	ACTRL_KERNEL_TOKEN        = 0x00002000,
68 	ACTRL_KERNEL_IMPERSONATE  = 0x00004000,
69 	ACTRL_KERNEL_DIMPERSONATE = 0x00008000;
70 
71 const uint
72 	ACTRL_PRINT_SADMIN        = 0x00000001,
73 	ACTRL_PRINT_SLIST         = 0x00000002,
74 	ACTRL_PRINT_PADMIN        = 0x00000004,
75 	ACTRL_PRINT_PUSE          = 0x00000008,
76 	ACTRL_PRINT_JADMIN        = 0x00000010;
77 
78 const uint
79 	ACTRL_SVC_GET_INFO        = 0x00000001,
80 	ACTRL_SVC_SET_INFO        = 0x00000002,
81 	ACTRL_SVC_STATUS          = 0x00000004,
82 	ACTRL_SVC_LIST            = 0x00000008,
83 	ACTRL_SVC_START           = 0x00000010,
84 	ACTRL_SVC_STOP            = 0x00000020,
85 	ACTRL_SVC_PAUSE           = 0x00000040,
86 	ACTRL_SVC_INTERROGATE     = 0x00000080,
87 	ACTRL_SVC_UCONTROL        = 0x00000100;
88 
89 const uint
90 	ACTRL_REG_QUERY           = 0x00000001,
91 	ACTRL_REG_SET             = 0x00000002,
92 	ACTRL_REG_CREATE_CHILD    = 0x00000004,
93 	ACTRL_REG_LIST            = 0x00000008,
94 	ACTRL_REG_NOTIFY          = 0x00000010,
95 	ACTRL_REG_LINK            = 0x00000020;
96 
97 const uint
98 	ACTRL_WIN_CLIPBRD         = 0x00000001,
99 	ACTRL_WIN_GLOBAL_ATOMS    = 0x00000002,
100 	ACTRL_WIN_CREATE          = 0x00000004,
101 	ACTRL_WIN_LIST_DESK       = 0x00000008,
102 	ACTRL_WIN_LIST            = 0x00000010,
103 	ACTRL_WIN_READ_ATTRIBS    = 0x00000020,
104 	ACTRL_WIN_WRITE_ATTRIBS   = 0x00000040,
105 	ACTRL_WIN_SCREEN          = 0x00000080,
106 	ACTRL_WIN_EXIT            = 0x00000100;
107 
108 enum : uint {
109 	ACTRL_ACCESS_NO_OPTIONS              = 0x00000000,
110 	ACTRL_ACCESS_SUPPORTS_OBJECT_ENTRIES = 0x00000001
111 }
112 
113 const TCHAR[] ACCCTRL_DEFAULT_PROVIDER = "Windows NT Access Provider";
114 
115 const uint
116 	TRUSTEE_ACCESS_ALLOWED    = 0x00000001,
117 	TRUSTEE_ACCESS_READ       = 0x00000002,
118 	TRUSTEE_ACCESS_WRITE      = 0x00000004,
119 	TRUSTEE_ACCESS_EXPLICIT   = 0x00000001,
120 	TRUSTEE_ACCESS_READ_WRITE = 0x00000006,
121 	TRUSTEE_ACCESS_ALL        = 0xFFFFFFFF;
122 
123 const uint
124 	NO_INHERITANCE                     = 0x0,
125 	SUB_OBJECTS_ONLY_INHERIT           = 0x1,
126 	SUB_CONTAINERS_ONLY_INHERIT        = 0x2,
127 	SUB_CONTAINERS_AND_OBJECTS_INHERIT = 0x3,
128 	INHERIT_NO_PROPAGATE               = 0x4,
129 	INHERIT_ONLY                       = 0x8,
130 	INHERITED_ACCESS_ENTRY             = 0x10,
131 	INHERITED_PARENT                   = 0x10000000,
132 	INHERITED_GRANDPARENT              = 0x20000000;
133 
134 alias ULONG INHERIT_FLAGS, ACCESS_RIGHTS;
135 alias ULONG* PINHERIT_FLAGS, PACCESS_RIGHTS;
136 
137 enum ACCESS_MODE {
138 	NOT_USED_ACCESS,
139 	GRANT_ACCESS,
140 	SET_ACCESS,
141 	DENY_ACCESS,
142 	REVOKE_ACCESS,
143 	SET_AUDIT_SUCCESS,
144 	SET_AUDIT_FAILURE
145 }
146 
147 enum SE_OBJECT_TYPE {
148 	SE_UNKNOWN_OBJECT_TYPE,
149 	SE_FILE_OBJECT,
150 	SE_SERVICE,
151 	SE_PRINTER,
152 	SE_REGISTRY_KEY,
153 	SE_LMSHARE,
154 	SE_KERNEL_OBJECT,
155 	SE_WINDOW_OBJECT,
156 	SE_DS_OBJECT,
157 	SE_DS_OBJECT_ALL,
158 	SE_PROVIDER_DEFINED_OBJECT,
159 	SE_WMIGUID_OBJECT,
160 	SE_REGISTRY_WOW64_32KEY
161 }
162 
163 enum TRUSTEE_TYPE {
164 	TRUSTEE_IS_UNKNOWN,
165 	TRUSTEE_IS_USER,
166 	TRUSTEE_IS_GROUP,
167 	TRUSTEE_IS_DOMAIN,
168 	TRUSTEE_IS_ALIAS,
169 	TRUSTEE_IS_WELL_KNOWN_GROUP,
170 	TRUSTEE_IS_DELETED,
171 	TRUSTEE_IS_INVALID,
172 	TRUSTEE_IS_COMPUTER
173 }
174 
175 enum TRUSTEE_FORM {
176 	TRUSTEE_IS_SID,
177 	TRUSTEE_IS_NAME,
178 	TRUSTEE_BAD_FORM,
179 	TRUSTEE_IS_OBJECTS_AND_SID,
180 	TRUSTEE_IS_OBJECTS_AND_NAME
181 }
182 
183 enum MULTIPLE_TRUSTEE_OPERATION {
184 	NO_MULTIPLE_TRUSTEE,
185 	TRUSTEE_IS_IMPERSONATE
186 }
187 
188 struct TRUSTEE_A {
189 	TRUSTEE_A*                 pMultipleTrustee;
190 	MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
191 	TRUSTEE_FORM               TrusteeForm;
192 	TRUSTEE_TYPE               TrusteeType;
193 	LPSTR                      ptstrName;
194 }
195 alias TRUSTEE_A TRUSTEEA;
196 alias TRUSTEE_A* PTRUSTEE_A, PTRUSTEEA;
197 
198 struct TRUSTEE_W {
199 	TRUSTEE_W*                 pMultipleTrustee;
200 	MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
201 	TRUSTEE_FORM               TrusteeForm;
202 	TRUSTEE_TYPE               TrusteeType;
203 	LPWSTR                     ptstrName;
204 }
205 alias TRUSTEE_W TRUSTEEW;
206 alias TRUSTEEW* PTRUSTEE_W, PTRUSTEEW;
207 
208 struct ACTRL_ACCESS_ENTRYA {
209 	TRUSTEE_A     Trustee;
210 	ULONG         fAccessFlags;
211 	ACCESS_RIGHTS Access;
212 	ACCESS_RIGHTS ProvSpecificAccess;
213 	INHERIT_FLAGS Inheritance;
214 	LPCSTR        lpInheritProperty;
215 }
216 alias ACTRL_ACCESS_ENTRYA* PACTRL_ACCESS_ENTRYA;
217 
218 struct ACTRL_ACCESS_ENTRYW {
219 	TRUSTEE_W     Trustee;
220 	ULONG         fAccessFlags;
221 	ACCESS_RIGHTS Access;
222 	ACCESS_RIGHTS ProvSpecificAccess;
223 	INHERIT_FLAGS Inheritance;
224 	LPCWSTR       lpInheritProperty;
225 }
226 alias ACTRL_ACCESS_ENTRYW* PACTRL_ACCESS_ENTRYW;
227 
228 struct ACTRL_ACCESS_ENTRY_LISTA {
229 	ULONG                cEntries;
230 	ACTRL_ACCESS_ENTRYA* pAccessList;
231 }
232 alias ACTRL_ACCESS_ENTRY_LISTA* PACTRL_ACCESS_ENTRY_LISTA;
233 
234 struct ACTRL_ACCESS_ENTRY_LISTW {
235 	ULONG                cEntries;
236 	ACTRL_ACCESS_ENTRYW* pAccessList;
237 }
238 alias ACTRL_ACCESS_ENTRY_LISTW* PACTRL_ACCESS_ENTRY_LISTW;
239 
240 struct ACTRL_PROPERTY_ENTRYA {
241 	LPCSTR                    lpProperty;
242 	PACTRL_ACCESS_ENTRY_LISTA pAccessEntryList;
243 	ULONG                     fListFlags;
244 }
245 alias ACTRL_PROPERTY_ENTRYA* PACTRL_PROPERTY_ENTRYA;
246 
247 struct ACTRL_PROPERTY_ENTRYW {
248 	LPCWSTR                   lpProperty;
249 	PACTRL_ACCESS_ENTRY_LISTW pAccessEntryList;
250 	ULONG                     fListFlags;
251 }
252 alias ACTRL_PROPERTY_ENTRYW* PACTRL_PROPERTY_ENTRYW;
253 
254 struct ACTRL_ACCESSA {
255 	ULONG                  cEntries;
256 	PACTRL_PROPERTY_ENTRYA pPropertyAccessList;
257 }
258 alias ACTRL_ACCESSA ACTRL_AUDITA;
259 alias ACTRL_ACCESSA* PACTRL_ACCESSA, PACTRL_AUDITA;
260 
261 struct ACTRL_ACCESSW {
262 	ULONG                  cEntries;
263 	PACTRL_PROPERTY_ENTRYW pPropertyAccessList;
264 }
265 alias ACTRL_ACCESSW ACTRL_AUDITW;
266 alias ACTRL_ACCESSW* PACTRL_ACCESSW, PACTRL_AUDITW;
267 
268 struct TRUSTEE_ACCESSA {
269 	LPSTR         lpProperty;
270 	ACCESS_RIGHTS Access;
271 	ULONG         fAccessFlags;
272 	ULONG         fReturnedAccess;
273 }
274 alias TRUSTEE_ACCESSA* PTRUSTEE_ACCESSA;
275 
276 struct TRUSTEE_ACCESSW {
277 	LPWSTR        lpProperty;
278 	ACCESS_RIGHTS Access;
279 	ULONG         fAccessFlags;
280 	ULONG         fReturnedAccess;
281 }
282 alias TRUSTEE_ACCESSW* PTRUSTEE_ACCESSW;
283 
284 struct ACTRL_OVERLAPPED {
285 	union {
286 		PVOID Provider;
287 		ULONG Reserved1;
288 	}
289 	ULONG     Reserved2;
290 	HANDLE    hEvent;
291 }
292 alias ACTRL_OVERLAPPED* PACTRL_OVERLAPPED;
293 
294 struct ACTRL_ACCESS_INFOA {
295 	ULONG fAccessPermission;
296 	LPSTR lpAccessPermissionName;
297 }
298 alias ACTRL_ACCESS_INFOA* PACTRL_ACCESS_INFOA;
299 
300 struct ACTRL_ACCESS_INFOW {
301 	ULONG  fAccessPermission;
302 	LPWSTR lpAccessPermissionName;
303 }
304 alias ACTRL_ACCESS_INFOW* PACTRL_ACCESS_INFOW;
305 
306 struct ACTRL_CONTROL_INFOA {
307 	LPSTR lpControlId;
308 	LPSTR lpControlName;
309 }
310 alias ACTRL_CONTROL_INFOA* PACTRL_CONTROL_INFOA;
311 
312 struct ACTRL_CONTROL_INFOW {
313 	LPWSTR lpControlId;
314 	LPWSTR lpControlName;
315 }
316 alias ACTRL_CONTROL_INFOW* PACTRL_CONTROL_INFOW;
317 
318 struct EXPLICIT_ACCESS_A {
319 	DWORD       grfAccessPermissions;
320 	ACCESS_MODE grfAccessMode;
321 	DWORD       grfInheritance;
322 	TRUSTEE_A   Trustee;
323 }
324 alias EXPLICIT_ACCESS_A EXPLICIT_ACCESSA;
325 alias EXPLICIT_ACCESS_A* PEXPLICIT_ACCESS_A, PEXPLICIT_ACCESSA;
326 
327 struct EXPLICIT_ACCESS_W {
328 	DWORD       grfAccessPermissions;
329 	ACCESS_MODE grfAccessMode;
330 	DWORD       grfInheritance;
331 	TRUSTEE_W   Trustee;
332 }
333 alias EXPLICIT_ACCESS_W EXPLICIT_ACCESSW;
334 alias EXPLICIT_ACCESS_W* PEXPLICIT_ACCESS_W, PEXPLICIT_ACCESSW;
335 
336 struct OBJECTS_AND_SID {
337 	DWORD ObjectsPresent;
338 	GUID  ObjectTypeGuid;
339 	GUID  InheritedObjectTypeGuid;
340 	SID*  pSid;
341 }
342 alias OBJECTS_AND_SID* POBJECTS_AND_SID;
343 
344 struct OBJECTS_AND_NAME_A {
345 	DWORD          ObjectsPresent;
346 	SE_OBJECT_TYPE ObjectType;
347 	LPSTR          ObjectTypeName;
348 	LPSTR          InheritedObjectTypeName;
349 	LPSTR          ptstrName;
350 }
351 alias OBJECTS_AND_NAME_A* POBJECTS_AND_NAME_A;
352 
353 struct OBJECTS_AND_NAME_W {
354 	DWORD          ObjectsPresent;
355 	SE_OBJECT_TYPE ObjectType;
356 	LPWSTR         ObjectTypeName;
357 	LPWSTR         InheritedObjectTypeName;
358 	LPWSTR         ptstrName;
359 }
360 alias OBJECTS_AND_NAME_W* POBJECTS_AND_NAME_W;
361 
362 static if (_WIN32_WINNT >= 0x501) {
363 	struct INHERITED_FROMA {
364 		LONG  GenerationGap;
365 		LPSTR AncestorName;
366 	}
367 	alias INHERITED_FROMA* PINHERITED_FROMA;
368 
369 	struct INHERITED_FROMW {
370 		LONG   GenerationGap;
371 		LPWSTR AncestorName;
372 	}
373 	alias INHERITED_FROMW* PINHERITED_FROMW;
374 }
375 
376 version (Unicode) {
377 	alias TRUSTEEW TRUSTEE;
378 	alias ACTRL_ACCESSW ACTRL_ACCESS;
379 	alias ACTRL_ACCESS_ENTRY_LISTW ACTRL_ACCESS_ENTRY_LIST;
380 	alias ACTRL_ACCESS_INFOW ACTRL_ACCESS_INFO;
381 	alias ACTRL_ACCESS_ENTRYW ACTRL_ACCESS_ENTRY;
382 	alias ACTRL_AUDITW ACTRL_AUDIT;
383 	alias ACTRL_CONTROL_INFOW ACTRL_CONTROL_INFO;
384 	alias EXPLICIT_ACCESSW EXPLICIT_ACCESS;
385 	alias TRUSTEE_ACCESSW TRUSTEE_ACCESS;
386 	alias OBJECTS_AND_NAME_W OBJECTS_AND_NAME_;
387 	static if (_WIN32_WINNT >= 0x501) {
388 		alias INHERITED_FROMW INHERITED_FROM;
389 	}
390 } else {
391 	alias TRUSTEEA TRUSTEE;
392 	alias ACTRL_ACCESSA ACTRL_ACCESS;
393 	alias ACTRL_ACCESS_ENTRY_LISTA ACTRL_ACCESS_ENTRY_LIST;
394 	alias ACTRL_ACCESS_INFOA ACTRL_ACCESS_INFO;
395 	alias ACTRL_ACCESS_ENTRYA ACTRL_ACCESS_ENTRY;
396 	alias ACTRL_AUDITA ACTRL_AUDIT;
397 	alias ACTRL_CONTROL_INFOA ACTRL_CONTROL_INFO;
398 	alias EXPLICIT_ACCESSA EXPLICIT_ACCESS;
399 	alias TRUSTEE_ACCESSA TRUSTEE_ACCESS;
400 	alias OBJECTS_AND_NAME_A OBJECTS_AND_NAME_;
401 	static if (_WIN32_WINNT >= 0x501) {
402 		alias INHERITED_FROMA INHERITED_FROM;
403 	}
404 }
405 
406 alias TRUSTEE TRUSTEE_;
407 alias TRUSTEE* PTRUSTEE, PTRUSTEE_;
408 alias ACTRL_ACCESS* PACTRL_ACCESS;
409 alias ACTRL_ACCESS_ENTRY_LIST* PACTRL_ACCESS_ENTRY_LIST;
410 alias ACTRL_ACCESS_INFO* PACTRL_ACCESS_INFO;
411 alias ACTRL_ACCESS_ENTRY* PACTRL_ACCESS_ENTRY;
412 alias ACTRL_AUDIT* PACTRL_AUDIT;
413 alias ACTRL_CONTROL_INFO* PACTRL_CONTROL_INFO;
414 alias EXPLICIT_ACCESS EXPLICIT_ACCESS_;
415 alias EXPLICIT_ACCESS* PEXPLICIT_ACCESS, PEXPLICIT_ACCESS_;
416 alias TRUSTEE_ACCESS* PTRUSTEE_ACCESS;
417 alias OBJECTS_AND_NAME_* POBJECTS_AND_NAME_;
418 static if (_WIN32_WINNT >= 0x501) {
419 	alias INHERITED_FROM* PINHERITED_FROM;
420 }