1 /***********************************************************************\
2 *                                ntdef.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.ntdef;
12 
13 private import win32.basetsd, win32.subauth, win32.windef, win32.winnt;
14 
15 const uint
16 	OBJ_INHERIT          = 0x0002,
17 	OBJ_PERMANENT        = 0x0010,
18 	OBJ_EXCLUSIVE        = 0x0020,
19 	OBJ_CASE_INSENSITIVE = 0x0040,
20 	OBJ_OPENIF           = 0x0080,
21 	OBJ_OPENLINK         = 0x0100,
22 	OBJ_VALID_ATTRIBUTES = 0x01F2;
23 
24 void InitializeObjectAttributes(OBJECT_ATTRIBUTES* p, UNICODE_STRING* n,
25 	  uint a, HANDLE r, void* s) {
26 	with (*p) {
27 		Length = OBJECT_ATTRIBUTES.sizeof;
28 		RootDirectory = r;
29 		Attributes = a;
30 		ObjectName = n;
31 		SecurityDescriptor = s;
32 		SecurityQualityOfService = null;
33 	}
34 }
35 
36 bool NT_SUCCESS(int x) { return x >= 0; }
37 
38 /*	In MinGW, NTSTATUS, UNICODE_STRING, STRING and their associated pointer
39  *	type aliases are defined in ntdef.h, ntsecapi.h and subauth.h, each of
40  *	which checks that none of the others is already included.
41  */
42 alias int  NTSTATUS;
43 alias int* PNTSTATUS;
44 
45 struct UNICODE_STRING {
46 	USHORT Length;
47 	USHORT MaximumLength;
48 	PWSTR  Buffer;
49 }
50 alias UNICODE_STRING*       PUNICODE_STRING;
51 alias CPtr!(UNICODE_STRING) PCUNICODE_STRING;
52 
53 struct STRING {
54 	USHORT Length;
55 	USHORT MaximumLength;
56 	PCHAR  Buffer;
57 }
58 alias STRING  ANSI_STRING, OEM_STRING;
59 alias STRING* PSTRING, PANSI_STRING, POEM_STRING;
60 
61 alias LARGE_INTEGER  PHYSICAL_ADDRESS;
62 alias LARGE_INTEGER* PPHYSICAL_ADDRESS;
63 
64 enum SECTION_INHERIT {
65 	ViewShare = 1,
66 	ViewUnmap
67 }
68 
69 /*	In MinGW, this is defined in ntdef.h and ntsecapi.h, each of which checks
70  *	that the other isn't already included.
71  */
72 struct OBJECT_ATTRIBUTES {
73 	ULONG           Length = OBJECT_ATTRIBUTES.sizeof;
74 	HANDLE          RootDirectory;
75 	PUNICODE_STRING ObjectName;
76 	ULONG           Attributes;
77 	PVOID           SecurityDescriptor;
78 	PVOID           SecurityQualityOfService;
79 }
80 alias OBJECT_ATTRIBUTES* POBJECT_ATTRIBUTES;