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