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