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 nulib.system.win32.ntdef;
11 
12 
13 import nulib.system.win32.basetsd, nulib.system.win32.subauth, nulib.system.win32.windef, nulib.system.win32.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 pragma(inline, true) @safe pure nothrow @nogc {
37     bool NT_SUCCESS(NTSTATUS Status)     { return Status >= 0; }
38     bool NT_INFORMATION(NTSTATUS Status) { return ((cast(ULONG) Status) >> 30) == 1; }
39     bool NT_WARNING(NTSTATUS Status)     { return ((cast(ULONG) Status) >> 30) == 2; }
40     bool NT_ERROR(NTSTATUS Status)       { return ((cast(ULONG) Status) >> 30) == 3; }
41 }
42 
43 /*  In MinGW, NTSTATUS, UNICODE_STRING, STRING and their associated pointer
44  *  type aliases are defined in ntdef.h, ntsecapi.h and subauth.h, each of
45  *  which checks that none of the others is already included.
46  */
47 alias int  NTSTATUS;
48 alias PNTSTATUS = int*;
49 
50 struct UNICODE_STRING {
51     USHORT Length;
52     USHORT MaximumLength;
53     PWSTR  Buffer;
54 }
55 alias UNICODE_STRING*        PUNICODE_STRING;
56 alias PCUNICODE_STRING = const(UNICODE_STRING)*;
57 
58 struct STRING {
59     USHORT Length;
60     USHORT MaximumLength;
61     PCHAR  Buffer;
62 }
63 alias STRING  ANSI_STRING, OEM_STRING;
64 alias STRING* PSTRING, PANSI_STRING, POEM_STRING;
65 
66 alias LARGE_INTEGER  PHYSICAL_ADDRESS;
67 alias PPHYSICAL_ADDRESS = LARGE_INTEGER*;
68 
69 enum SECTION_INHERIT {
70     ViewShare = 1,
71     ViewUnmap
72 }
73 
74 /*  In MinGW, this is defined in ntdef.h and ntsecapi.h, each of which checks
75  *  that the other isn't already included.
76  */
77 struct OBJECT_ATTRIBUTES {
78     ULONG           Length = OBJECT_ATTRIBUTES.sizeof;
79     HANDLE          RootDirectory;
80     PUNICODE_STRING ObjectName;
81     ULONG           Attributes;
82     PVOID           SecurityDescriptor;
83     PVOID           SecurityQualityOfService;
84 }
85 alias POBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES*;