ReactOS  r75907
ntdef.template.h
Go to the documentation of this file.
1 /*
2  * ntdef.h
3  *
4  * This file is part of the ReactOS PSDK package.
5  *
6  * Contributors:
7  * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
8  *
9  * THIS SOFTWARE IS NOT COPYRIGHTED
10  *
11  * This source code is offered for use in the public domain. You may
12  * use, modify or distribute it freely.
13  *
14  * This code is distributed in the hope that it will be useful but
15  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
16  * DISCLAIMED. This includes but is not limited to warranties of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18  *
19  */
20 
21 #ifndef _NTDEF_
22 #define _NTDEF_
23 #pragma once
24 
25 /* Dependencies */
26 #include <ctype.h>
27 $if(0)
28 //#include <winapifamily.h>
29 $endif()
30 #include <basetsd.h>
31 #include <guiddef.h>
32 #include <excpt.h>
33 #include <sdkddkver.h>
34 #include <specstrings.h>
35 #include <kernelspecs.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /* Default to strict */
42 #ifndef NO_STRICT
43 #ifndef STRICT
44 #define STRICT 1
45 #endif
46 #endif
47 
48 /* Pseudo Modifiers for Input Parameters */
49 
50 #ifndef IN
51 #define IN
52 #endif
53 
54 #ifndef OUT
55 #define OUT
56 #endif
57 
58 #ifndef OPTIONAL
59 #define OPTIONAL
60 #endif
61 
62 #ifndef NOTHING
63 #define NOTHING
64 #endif
65 
66 #ifndef CRITICAL
67 #define CRITICAL
68 #endif
69 
70 /* Constant modifier */
71 #ifndef CONST
72 #define CONST const
73 #endif
74 
75 /* TRUE/FALSE */
76 #define FALSE 0
77 #define TRUE 1
78 
79 /* NULL/NULL64 */
80 #ifndef NULL
81 #ifdef __cplusplus
82 #define NULL 0
83 #define NULL64 0
84 #else
85 #define NULL ((void *)0)
86 #define NULL64 ((void * POINTER_64)0)
87 #endif
88 #endif /* NULL */
89 
90 #define ARGUMENT_PRESENT(ArgumentPointer) \
91  ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL)
92 
93 #if defined(_MANAGED)
94  #define FASTCALL __stdcall
95 #elif defined(_M_IX86)
96  #define FASTCALL __fastcall
97 #else
98  #define FASTCALL
99 #endif /* _MANAGED */
100 
101 /* min/max helper macros */
102 #ifndef NOMINMAX
103 # ifndef min
104 # define min(a,b) (((a) < (b)) ? (a) : (b))
105 # endif
106 # ifndef max
107 # define max(a,b) (((a) > (b)) ? (a) : (b))
108 # endif
109 #endif /* NOMINMAX */
110 
111 /* Tell windef.h that we have defined some basic types */
112 #define BASETYPES
113 
118 $include(ntbasedef.h)
119 
121 typedef NTSTATUS *PNTSTATUS;
122 
123 #ifndef __SECSTATUS_DEFINED__
124 typedef long SECURITY_STATUS;
125 #define __SECSTATUS_DEFINED__
126 #endif
127 
128 /* Physical Addresses are always treated as 64-bit wide */
130 
131 #define TIME LARGE_INTEGER
132 #define _TIME _LARGE_INTEGER
133 #define PTIME PLARGE_INTEGER
134 #define LowTime LowPart
135 #define HighTime HighPart
136 
137 /* Used to store a non-float 8 byte aligned structure */
138 typedef struct _QUAD
139 {
140  _ANONYMOUS_UNION union
141  {
144  } DUMMYUNIONNAME;
145 } QUAD, *PQUAD, UQUAD, *PUQUAD;
146 
147 #if (_WIN32_WINNT >= 0x0600) || (defined(__cplusplus) && defined(WINDOWS_ENABLE_CPLUSPLUS))
148 typedef CONST UCHAR *PCUCHAR;
149 typedef CONST USHORT *PCUSHORT;
150 typedef CONST ULONG *PCULONG;
151 typedef CONST UQUAD *PCUQUAD;
152 typedef CONST SCHAR *PCSCHAR;
153 #endif /* (/_WIN32_WINNT >= 0x0600) */
154 #if (_WIN32_WINNT >= 0x0600)
155 typedef CONST NTSTATUS *PCNTSTATUS;
156 #endif /* (/_WIN32_WINNT >= 0x0600) */
157 
158 /* String Types */
159 typedef struct _STRING {
160  USHORT Length;
162 #ifdef MIDL_PASS
163  [size_is(MaximumLength), length_is(Length) ]
164 #endif
166 } STRING, *PSTRING,
169 
172 typedef PSTRING PCANSI_STRING;
173 
174 typedef struct _STRING32 {
175  USHORT Length;
177  $ULONG Buffer;
178 } STRING32, *PSTRING32,
181 
182 typedef struct _STRING64 {
183  USHORT Length;
186 } STRING64, *PSTRING64,
189 
190 typedef struct _CSTRING {
191  USHORT Length;
193  CONST CHAR *Buffer;
194 } CSTRING, *PCSTRING;
195 
196 typedef struct _UNICODE_STRING {
197  USHORT Length;
199 #ifdef MIDL_PASS
200  [size_is(MaximumLength / 2), length_is((Length) / 2)] PUSHORT Buffer;
201 #else
203 #endif
206 
208 
209 #ifdef __cplusplus
210 extern "C++" template<typename _Type> struct _RTL_remove_const_template;
211 extern "C++" template<typename _Type> struct _RTL_remove_const_template<const _Type&> { typedef _Type type; };
212 #define _RTL_CONSTANT_STRING_remove_const_macro(s) \
213  (const_cast<_RTL_remove_const_template<decltype((s)[0])>::type*>(s))
214 extern "C++" template<class _Ty> struct _RTL_CONSTANT_STRING_type_check_template;
215 extern "C++" template<class _Ty, int _Count> struct _RTL_CONSTANT_STRING_type_check_template<const _Ty (&)[_Count]> { typedef char type; };
216 #define _RTL_CONSTANT_STRING_type_check(s) _RTL_CONSTANT_STRING_type_check_template<decltype(s)>::type
217 #else
218 # define _RTL_CONSTANT_STRING_remove_const_macro(s) (s)
219 char _RTL_CONSTANT_STRING_type_check(const void *s);
220 #endif
221 #define RTL_CONSTANT_STRING(s) { \
222  sizeof(s)-sizeof((s)[0]), \
223  sizeof(s) / sizeof(_RTL_CONSTANT_STRING_type_check(s)), \
224  _RTL_CONSTANT_STRING_remove_const_macro(s) }
225 
226 #ifdef _MSC_VER
227 #define DECLARE_UNICODE_STRING_SIZE(_var, _size) \
228  WCHAR _var ## _buffer[_size]; \
229  __pragma(warning(push)) __pragma(warning(disable:4221)) __pragma(warning(disable:4204)) \
230  UNICODE_STRING _var = { 0, (_size) * sizeof(WCHAR) , _var ## _buffer } \
231  __pragma(warning(pop))
232 
233 #define DECLARE_CONST_UNICODE_STRING(_var, _string) \
234  const WCHAR _var##_buffer[] = _string; \
235  __pragma(warning(push)) __pragma(warning(disable:4221)) __pragma(warning(disable:4204)) \
236  const UNICODE_STRING _var = { sizeof(_string) - sizeof(WCHAR), sizeof(_string), (PWCH)_var##_buffer } \
237  __pragma(warning(pop))
238 #else
239 #define DECLARE_UNICODE_STRING_SIZE(_var, _size) \
240  WCHAR _var ## _buffer[_size]; \
241  UNICODE_STRING _var = { 0, (_size) * sizeof(WCHAR) , _var ## _buffer }
242 
243 #define DECLARE_CONST_UNICODE_STRING(_var, _string) \
244  const WCHAR _var##_buffer[] = _string; \
245  const UNICODE_STRING _var = { sizeof(_string) - sizeof(WCHAR), sizeof(_string), (PWCH)_var##_buffer }
246 #endif
247 
248 #define DECLARE_GLOBAL_CONST_UNICODE_STRING(_var, _str) \
249  extern const __declspec(selectany) UNICODE_STRING _var = RTL_CONSTANT_STRING(_str)
250 
251 /* Object Attributes */
252 typedef struct _OBJECT_ATTRIBUTES {
253  ULONG Length;
255  PUNICODE_STRING ObjectName;
261 
262 typedef struct _OBJECT_ATTRIBUTES32 {
271 
272 typedef struct _OBJECT_ATTRIBUTES64 {
281 
282 #define OBJ_HANDLE_TAGBITS 0x00000003L
283 
284 /* Values for the Attributes member */
285 #define OBJ_INHERIT 0x00000002L
286 #define OBJ_PERMANENT 0x00000010L
287 #define OBJ_EXCLUSIVE 0x00000020L
288 #define OBJ_CASE_INSENSITIVE 0x00000040L
289 #define OBJ_OPENIF 0x00000080L
290 #define OBJ_OPENLINK 0x00000100L
291 #define OBJ_KERNEL_HANDLE 0x00000200L
292 #define OBJ_FORCE_ACCESS_CHECK 0x00000400L
293 #define OBJ_VALID_ATTRIBUTES 0x000007F2L
294 
295 /* Helper Macro */
296 #define InitializeObjectAttributes(p,n,a,r,s) { \
297  (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
298  (p)->RootDirectory = (r); \
299  (p)->ObjectName = (n); \
300  (p)->Attributes = (a); \
301  (p)->SecurityDescriptor = (s); \
302  (p)->SecurityQualityOfService = NULL; \
303 }
304 
305 #define RTL_CONSTANT_OBJECT_ATTRIBUTES(n,a) { \
306  sizeof(OBJECT_ATTRIBUTES), \
307  NULL, \
308  RTL_CONST_CAST(PUNICODE_STRING)(n), \
309  a, \
310  NULL, \
311  NULL \
312 }
313 
314 #define RTL_INIT_OBJECT_ATTRIBUTES(n, a) \
315  RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
316 
317 #ifdef _MSC_VER
318  #pragma warning(push)
319  #pragma warning(disable:4214) /* Bit fields of other types than int */
320 #endif /* _MSC_VER */
321 typedef struct _RTL_BALANCED_NODE
322 {
323  _ANONYMOUS_UNION union
324  {
326  _ANONYMOUS_STRUCT struct
327  {
330  } DUMMYSTRUCTNAME;
331  } DUMMYUNIONNAME;
332  _ANONYMOUS_UNION union
333  {
334  UCHAR Red : 1;
337  } DUMMYUNIONNAME2;
339 #ifdef _MSC_VER
340  #pragma warning(pop)
341 #endif /* _MSC_VER */
342 
343 #define RTL_BALANCED_NODE_RESERVED_PARENT_MASK 3
344 #define RTL_BALANCED_NODE_GET_PARENT_POINTER(Node) \
345  ((PRTL_BALANCED_NODE)((Node)->ParentValue & \
346  ~RTL_BALANCED_NODE_RESERVED_PARENT_MASK))
347 
348 /* Product Types */
349 typedef enum _NT_PRODUCT_TYPE {
354 
355 typedef enum _EVENT_TYPE {
358 } EVENT_TYPE;
359 
360 typedef enum _TIMER_TYPE {
363 } TIMER_TYPE;
364 
365 typedef enum _WAIT_TYPE {
368 } WAIT_TYPE;
369 
370 #ifndef MIDL_PASS
372 VOID
374  _In_ PLIST_ENTRY32 ListEntry32,
375  _Out_ PLIST_ENTRY64 ListEntry64)
376 {
377  ListEntry64->Flink = ListEntry32->Flink;
378  ListEntry64->Blink = ListEntry32->Blink;
379 }
380 
382 VOID
384  _In_ PLIST_ENTRY64 ListEntry64,
385  _Out_ PLIST_ENTRY32 ListEntry32)
386 {
387  /* ASSERT without ASSERT or intrinsics ... */
388  if (((ListEntry64->Flink >> 32) != 0) ||
389  ((ListEntry64->Blink >> 32) != 0))
390  {
391  (VOID)*(volatile LONG*)(LONG_PTR)-1;
392  }
393  ListEntry32->Flink = ListEntry64->Flink & 0xFFFFFFFF;
394  ListEntry32->Blink = ListEntry64->Blink & 0xFFFFFFFF;
395 }
396 #endif /* !MIDL_PASS */
397 
398 #ifdef __cplusplus
399 } // extern "C"
400 #endif
401 
402 #endif /* _NTDEF_ */
DWORD *typedef PVOID
Definition: winlogon.h:52
#define __GNU_EXTENSION
Definition: _mingw_mac.h:135
signed char * PCHAR
Definition: retypes.h:7
_Field_size_bytes_part_opt_(MaximumLength, Length) PCHAR Buffer
* PNTSTATUS
Definition: strlen.c:14
struct _STRING OEM_STRING
struct _CSTRING * PCSTRING
struct _RTL_BALANCED_NODE * Children[2]
struct _OBJECT_ATTRIBUTES OBJECT_ATTRIBUTES
PSTRING PCANSI_STRING
USHORT MaximumLength
Definition: umtypes.h:162
_Check_return_ _Ret_maybenull_ _In_ size_t _Count
Definition: malloc.h:112
USHORT MaximumLength
Definition: env_spec_w32.h:370
FORCEINLINE VOID ListEntry64To32(_In_ PLIST_ENTRY64 ListEntry64, _Out_ PLIST_ENTRY32 ListEntry32)
CONST CHAR * Buffer
Definition: umtypes.h:147
$include(setypes.h) $include(obtypes.h) $include(rtltypes.h) $include(rtlfuncs.h) _IRQL_requires_max_(PASSIVE_LEVEL) __kernel_entry NTSYSCALLAPI NTSTATUS NTAPI NtQueryObject(_In_opt_ HANDLE Handle
struct _OBJECT_ATTRIBUTES32 OBJECT_ATTRIBUTES32
#define _ANONYMOUS_UNION
Definition: ntbasedef.h:30
struct _RTL_BALANCED_NODE * PRTL_BALANCED_NODE
char CHAR
Definition: xmlstorage.h:175
CONST OBJECT_ATTRIBUTES64 * PCOBJECT_ATTRIBUTES64
_ANONYMOUS_UNION union _RTL_BALANCED_NODE::@3556 DUMMYUNIONNAME
struct _OBJECT_ATTRIBUTES * POBJECT_ATTRIBUTES
#define _Return_type_success_(expr)
Definition: no_sal2.h:630
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
USHORT RTL_STRING_LENGTH_TYPE
unsigned short Length
Definition: sprintf.c:451
_ANONYMOUS_UNION union _QUAD::@3555 DUMMYUNIONNAME
struct _STRING STRING
USHORT Length
Definition: umtypes.h:145
struct _STRING64 * PSTRING64
__GNU_EXTENSION __int64 UseThisFieldToCopy
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
_TIMER_TYPE
uint32_t ULONG_PTR
Definition: typedefs.h:64
$ULONG Buffer
USHORT MaximumLength
Definition: umtypes.h:154
struct _STRING64 * PANSI_STRING64
enum _NT_PRODUCT_TYPE * PNT_PRODUCT_TYPE
struct _STRING32 ANSI_STRING32
void * Buffer
Definition: sprintf.c:453
long LONG
Definition: pedump.c:60
struct _QUAD QUAD
uint64_t ULONG64
Definition: typedefs.h:66
CONST OBJECT_ATTRIBUTES32 * PCOBJECT_ATTRIBUTES32
#define FORCEINLINE
Definition: ntbasedef.h:213
#define _Out_
Definition: no_sal2.h:323
struct _STRING32 * PUNICODE_STRING32
$endif(_WDMDDK_) $if(_NTDDK_) typedef struct _NEON128
Definition: ke.h:202
Definition: bufpool.h:45
const UNICODE_STRING * PCUNICODE_STRING
return(0)
long SECURITY_STATUS
struct _RTL_BALANCED_NODE * Right
enum _EVENT_TYPE EVENT_TYPE
#define const
Definition: zconf.h:230
$if(0)$endif()$define(_NTDEF_) $define(ULONG
uint64_t ULONGLONG
Definition: typedefs.h:66
struct _STRING64 UNICODE_STRING64
ULONGLONG Buffer
Definition: umtypes.h:163
_ANONYMOUS_UNION union _RTL_BALANCED_NODE::@3557 DUMMYUNIONNAME2
struct _STRING * POEM_STRING
unsigned short * PUSHORT
Definition: retypes.h:2
signed char SCHAR
Definition: sqltypes.h:14
struct _STRING32 * PSTRING32
enum _WAIT_TYPE WAIT_TYPE
CONST OBJECT_ATTRIBUTES * PCOBJECT_ATTRIBUTES
struct _QUAD UQUAD
LARGE_INTEGER * PPHYSICAL_ADDRESS
struct _STRING64 * PUNICODE_STRING64
std::wstring STRING
Definition: fontsub.cpp:33
WCHAR * PWCH
Definition: ntbasedef.h:409
struct _QUAD * PQUAD
_Field_size_bytes_part_(MaximumLength, Length) PWCH Buffer
enum _TIMER_TYPE TIMER_TYPE
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _OBJECT_ATTRIBUTES64 OBJECT_ATTRIBUTES64
_EVENT_TYPE
VOID UINTN Length
Definition: acefiex.h:744
_ANONYMOUS_STRUCT struct _RTL_BALANCED_NODE::@3556::@3558 DUMMYSTRUCTNAME
#define VOID
Definition: acefi.h:82
struct _UNICODE_STRING UNICODE_STRING
GLdouble s
Definition: gl.h:2039
struct _STRING * PANSI_STRING
$define(_NTDDK_) $include(extypes.h) $include(cmtypes.h) $include(iotypes.h) $include(haltypes.h) $include(ketypes.h) $include(kdtypes.h) $include(mmtypes.h) $include(pstypes.h) $include(rtltypes.h) $include(setypes.h) $include(exfuncs.h) $include(halfuncs.h) $include(iofuncs.h) $include(kdfuncs.h) $include(kefuncs.h) $include(mmfuncs.h) $include(psfuncs.h) $include(rtlfuncs.h) $include(sefuncs.h) $include(zwfuncs.h) NTSYSAPI ULONGLONG NTAPI VerSetConditionMask(IN ULONGLONG ConditionMask
#define _ANONYMOUS_STRUCT
Definition: ntbasedef.h:56
CONST STRING * PCOEM_STRING
struct _QUAD * PUQUAD
STRING CANSI_STRING
#define _In_
Definition: no_sal2.h:204
struct _OBJECT_ATTRIBUTES32 * POBJECT_ATTRIBUTES32
FORCEINLINE VOID ListEntry32To64(_In_ PLIST_ENTRY32 ListEntry32, _Out_ PLIST_ENTRY64 ListEntry64)
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
_NT_PRODUCT_TYPE
struct _STRING32 * PANSI_STRING32
PVOID SecurityDescriptor
Definition: umtypes.h:175
struct _UNICODE_STRING * PUNICODE_STRING
ULONG64 SecurityQualityOfService
unsigned short USHORT
Definition: pedump.c:61
struct _STRING32 STRING32
USHORT MaximumLength
Definition: umtypes.h:146
char _RTL_CONSTANT_STRING_type_check(const void *s)
double DoNotUseThisField
PVOID SecurityQualityOfService
Definition: umtypes.h:176
struct _RTL_BALANCED_NODE * Left
struct _CSTRING CSTRING
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
PUNICODE_STRING ObjectName
Definition: umtypes.h:173
HANDLE RootDirectory
Definition: umtypes.h:172
unsigned int ULONG
Definition: retypes.h:1
#define CONST
struct _STRING * PSTRING
USHORT Length
Definition: umtypes.h:161
struct _STRING64 ANSI_STRING64
struct _STRING32 UNICODE_STRING32
USHORT Length
Definition: umtypes.h:153
struct _OBJECT_ATTRIBUTES64 * POBJECT_ATTRIBUTES64
struct _STRING ANSI_STRING
unsigned short MaximumLength
Definition: sprintf.c:452
_WAIT_TYPE
#define _NTDEF_
Definition: umtypes.h:20
struct _STRING64 STRING64
#define LONG_PTR
Definition: generated.c:23
#define __int64
Definition: basetyps.h:16
LARGE_INTEGER PHYSICAL_ADDRESS
struct _RTL_BALANCED_NODE RTL_BALANCED_NODE