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/_ntdef.d)
9  */
10 module core.sys.windows.ntdef;
11 version (Windows):
12 
13 import core.sys.windows.basetsd, core.sys.windows.subauth, core.sys.windows.windef, core.sys.windows.winnt;
14 
15 enum 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 const(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;