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