[CSRSRV]: Fix two DPRINTs.
[reactos.git] / reactos / include / psdk / ntdef.h
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
24 /* Dependencies */
25 #include <ctype.h>
26 #include <basetsd.h>
27 #include <excpt.h>
28 #include <sdkddkver.h>
29 #include <specstrings.h>
30
31 // FIXME: Shouldn't be included!
32 #include <stdarg.h>
33 #include <string.h>
34
35 /* Helper macro to enable gcc's extension. */
36 #ifndef __GNU_EXTENSION
37 #ifdef __GNUC__
38 #define __GNU_EXTENSION __extension__
39 #else
40 #define __GNU_EXTENSION
41 #endif
42 #endif
43
44 /* Pseudo Modifiers for Input Parameters */
45
46 #ifndef IN
47 #define IN
48 #endif
49
50 #ifndef OUT
51 #define OUT
52 #endif
53
54 #ifndef OPTIONAL
55 #define OPTIONAL
56 #endif
57
58 #ifndef NOTHING
59 #define NOTHING
60 #endif
61
62 #ifndef CRITICAL
63 #define CRITICAL
64 #endif
65
66 #ifndef FAR
67 #define FAR
68 #endif
69
70
71 /* Defines the "size" of an any-size array */
72 #ifndef ANYSIZE_ARRAY
73 #define ANYSIZE_ARRAY 1
74 #endif
75
76 /* Constant modifier */
77 #ifndef CONST
78 #define CONST const
79 #endif
80
81 /* TRUE/FALSE */
82 #define FALSE 0
83 #define TRUE 1
84
85 /* NULL/NULL64 */
86 #ifndef NULL
87 #ifdef __cplusplus
88 #define NULL 0
89 #define NULL64 0
90 #else
91 #define NULL ((void *)0)
92 #define NULL64 ((void * POINTER_64)0)
93 #endif
94 #endif /* NULL */
95
96
97 //
98 // FIXME
99 // We should use the -fms-extensions compiler flag for gcc,
100 // and clean up the mess.
101 //
102 #ifndef __ANONYMOUS_DEFINED
103 #define __ANONYMOUS_DEFINED
104
105 #ifndef NONAMELESSUNION
106 #ifdef __GNUC__
107 #define _ANONYMOUS_UNION __GNU_EXTENSION
108 #define _ANONYMOUS_STRUCT __GNU_EXTENSION
109 #elif defined(__WATCOMC__) || defined(_MSC_VER)
110 #define _ANONYMOUS_UNION
111 #define _ANONYMOUS_STRUCT
112 #endif /* __GNUC__/__WATCOMC__ */
113 #endif /* NONAMELESSUNION */
114
115 #ifndef _ANONYMOUS_UNION
116 #define _ANONYMOUS_UNION
117 #define _UNION_NAME(x) x
118 #define DUMMYUNIONNAME u
119 #define DUMMYUNIONNAME2 u2
120 #define DUMMYUNIONNAME3 u3
121 #define DUMMYUNIONNAME4 u4
122 #define DUMMYUNIONNAME5 u5
123 #define DUMMYUNIONNAME6 u6
124 #define DUMMYUNIONNAME7 u7
125 #define DUMMYUNIONNAME8 u8
126 #else
127 #define _UNION_NAME(x)
128 #define DUMMYUNIONNAME
129 #define DUMMYUNIONNAME2
130 #define DUMMYUNIONNAME3
131 #define DUMMYUNIONNAME4
132 #define DUMMYUNIONNAME5
133 #define DUMMYUNIONNAME6
134 #define DUMMYUNIONNAME7
135 #define DUMMYUNIONNAME8
136 #endif
137
138 #ifndef _ANONYMOUS_STRUCT
139 #define _ANONYMOUS_STRUCT
140 #define _STRUCT_NAME(x) x
141 #define DUMMYSTRUCTNAME s
142 #define DUMMYSTRUCTNAME2 s2
143 #define DUMMYSTRUCTNAME3 s3
144 #define DUMMYSTRUCTNAME4 s4
145 #define DUMMYSTRUCTNAME5 s5
146 #else
147 #define _STRUCT_NAME(x)
148 #define DUMMYSTRUCTNAME
149 #define DUMMYSTRUCTNAME2
150 #define DUMMYSTRUCTNAME3
151 #define DUMMYSTRUCTNAME4
152 #define DUMMYSTRUCTNAME5
153 #endif
154
155 #endif /* __ANONYMOUS_DEFINED */
156
157 #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64)
158 #define ALIGNMENT_MACHINE
159 #define UNALIGNED __unaligned
160 #if defined(_WIN64)
161 #define UNALIGNED64 __unaligned
162 #else
163 #define UNALIGNED64
164 #endif
165 #else
166 #undef ALIGNMENT_MACHINE
167 #define UNALIGNED
168 #define UNALIGNED64
169 #endif
170
171 #if defined(_WIN64) || defined(_M_ALPHA)
172 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
173 #define MEMORY_ALLOCATION_ALIGNMENT 16
174 #else
175 #define MAX_NATURAL_ALIGNMENT sizeof(ULONG)
176 #define MEMORY_ALLOCATION_ALIGNMENT 8
177 #endif
178
179 #if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED)
180 #define RESTRICTED_POINTER __restrict
181 #else
182 #define RESTRICTED_POINTER
183 #endif
184
185 #define ARGUMENT_PRESENT(ArgumentPointer) \
186 ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL)
187
188 /* Returns the base address of a structure from a structure member */
189 #ifndef CONTAINING_RECORD
190 #define CONTAINING_RECORD(address, type, field) \
191 ((type *)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type *)0)->field))))
192 #endif
193
194 /* Returns the byte offset of the specified structure's member */
195 #ifndef __GNUC__
196 #define FIELD_OFFSET(Type, Field) ((LONG)(LONG_PTR)&(((Type*) 0)->Field))
197 #else
198 #define FIELD_OFFSET(Type, Field) __builtin_offsetof(Type, Field)
199 #endif
200
201 /* Returns the type's alignment */
202 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
203 #define TYPE_ALIGNMENT(t) __alignof(t)
204 #else
205 #define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
206 #endif
207
208 #if defined(_AMD64_) || defined(_X86_)
209 #define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(ULONG)
210 #elif defined(_IA64_) || defined(_ARM_)
211 #define PROBE_ALIGNMENT(_s) max((TYPE_ALIGNMENT(_s), TYPE_ALIGNMENT(ULONG))
212 #else
213 #error "unknown architecture"
214 #endif
215
216 /* Calling Conventions */
217 #if defined(_M_IX86)
218 #define FASTCALL __fastcall
219 #else
220 #define FASTCALL
221 #endif
222
223 #define NTAPI __stdcall
224
225
226 /* Import and Export Specifiers */
227
228 /* Done the same way as in windef.h for now */
229 #define DECLSPEC_IMPORT __declspec(dllimport)
230 #define DECLSPEC_NORETURN __declspec(noreturn)
231
232 #ifndef DECLSPEC_ADDRSAFE
233 #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
234 #define DECLSPEC_ADDRSAFE __declspec(address_safe)
235 #else
236 #define DECLSPEC_ADDRSAFE
237 #endif
238 #endif /* DECLSPEC_ADDRSAFE */
239
240 #ifndef NOP_FUNCTION
241 #if (_MSC_VER >= 1210)
242 #define NOP_FUNCTION __noop
243 #else
244 #define NOP_FUNCTION (void)0
245 #endif
246 #endif
247
248 #if !defined(_NTSYSTEM_)
249 #define NTSYSAPI DECLSPEC_IMPORT
250 #define NTSYSCALLAPI DECLSPEC_IMPORT
251 #else
252 #define NTSYSAPI
253 #if defined(_NTDLLBUILD_)
254 #define NTSYSCALLAPI
255 #else
256 #define NTSYSCALLAPI DECLSPEC_ADDRSAFE
257 #endif
258 #endif
259
260 /* Inlines */
261 #ifndef FORCEINLINE
262 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
263 #define FORCEINLINE __forceinline
264 #elif defined(_MSC_VER)
265 #define FORCEINLINE __inline
266 #else /* __GNUC__ */
267 # if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L)
268 # define FORCEINLINE extern inline __attribute__((__always_inline__,__gnu_inline__))
269 # else
270 # define FORCEINLINE extern __inline__ __attribute__((__always_inline__))
271 # endif
272 #endif
273 #endif /* FORCEINLINE */
274
275 #ifndef DECLSPEC_NOINLINE
276 #if (_MSC_VER >= 1300)
277 #define DECLSPEC_NOINLINE __declspec(noinline)
278 #elif defined(__GNUC__)
279 #define DECLSPEC_NOINLINE __attribute__((noinline))
280 #else
281 #define DECLSPEC_NOINLINE
282 #endif
283 #endif /* DECLSPEC_NOINLINE */
284
285 #if !defined(_M_CEE_PURE)
286 #define NTAPI_INLINE NTAPI
287 #else
288 #define NTAPI_INLINE
289 #endif
290
291 /* Use to specify structure alignment */
292 #ifndef DECLSPEC_ALIGN
293 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
294 #define DECLSPEC_ALIGN(x) __declspec(align(x))
295 #elif defined(__GNUC__)
296 #define DECLSPEC_ALIGN(x) __attribute__ ((__aligned__ (x)))
297 #else
298 #define DECLSPEC_ALIGN(x)
299 #endif
300 #endif /* DECLSPEC_ALIGN */
301
302 #ifndef SYSTEM_CACHE_ALIGNMENT_SIZE
303 #if defined(_AMD64_) || defined(_X86_)
304 #define SYSTEM_CACHE_ALIGNMENT_SIZE 64
305 #else
306 #define SYSTEM_CACHE_ALIGNMENT_SIZE 128
307 #endif
308 #endif
309
310 #ifndef DECLSPEC_CACHEALIGN
311 #define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(SYSTEM_CACHE_ALIGNMENT_SIZE)
312 #endif
313
314 #ifndef DECLSPEC_SELECTANY
315 #if (_MSC_VER >= 1100) || defined(__GNUC__)
316 #define DECLSPEC_SELECTANY __declspec(selectany)
317 #else
318 #define DECLSPEC_SELECTANY
319 #endif
320 #endif
321
322 /* Use to silence unused variable warnings when it is intentional */
323 #define UNREFERENCED_PARAMETER(P) {(P)=(P);}
324 #define UNREFERENCED_LOCAL_VARIABLE(L) ((void)(L))
325 #define DBG_UNREFERENCED_PARAMETER(P) {(P)=(P);}
326 #define DBG_UNREFERENCED_LOCAL_VARIABLE(L) ((void)(L))
327
328 /* min/max helper macros */
329 #ifndef NOMINMAX
330
331 #ifndef min
332 #define min(a,b) (((a) < (b)) ? (a) : (b))
333 #endif
334
335 #ifndef max
336 #define max(a,b) (((a) > (b)) ? (a) : (b))
337 #endif
338
339 #endif /* NOMINMAX */
340
341 /* Tell windef.h that we have defined some basic types */
342 #define BASETYPES
343
344 /* Void Pointers */
345 typedef void *PVOID;
346 //typedef void * POINTER_64 PVOID64;
347 typedef PVOID PVOID64; // FIXME!
348
349 /* Handle Type */
350 #ifdef STRICT
351 typedef void *HANDLE;
352 #define DECLARE_HANDLE(n) typedef struct n##__{int i;}*n
353 #else
354 typedef PVOID HANDLE;
355 #define DECLARE_HANDLE(n) typedef HANDLE n
356 #endif
357 typedef HANDLE *PHANDLE;
358
359 /* Upper-Case Versions of Some Standard C Types */
360 #ifndef VOID
361 #define VOID void
362 typedef char CHAR;
363 typedef short SHORT;
364 typedef long LONG;
365 #if !defined(MIDL_PASS)
366 typedef int INT;
367 #endif
368 #endif
369 typedef double DOUBLE;
370
371 /* Unsigned Types */
372 typedef unsigned char UCHAR, *PUCHAR;
373 typedef unsigned short USHORT, *PUSHORT;
374 typedef unsigned long ULONG, *PULONG;
375 typedef CONST UCHAR *PCUCHAR;
376 typedef CONST USHORT *PCUSHORT;
377 typedef CONST ULONG *PCULONG;
378 typedef UCHAR FCHAR;
379 typedef USHORT FSHORT;
380 typedef ULONG FLONG;
381 typedef UCHAR BOOLEAN, *PBOOLEAN;
382 typedef ULONG LOGICAL;
383 typedef ULONG *PLOGICAL;
384
385 /* Signed Types */
386 typedef SHORT *PSHORT;
387 typedef LONG *PLONG;
388 typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
389 typedef NTSTATUS *PNTSTATUS;
390 typedef signed char SCHAR;
391 typedef SCHAR *PSCHAR;
392
393 #ifndef _HRESULT_DEFINED
394 #define _HRESULT_DEFINED
395 typedef LONG HRESULT;
396 #endif
397
398 /* 64-bit types */
399 __GNU_EXTENSION typedef __int64 LONGLONG, *PLONGLONG;
400 __GNU_EXTENSION typedef unsigned __int64 ULONGLONG, *PULONGLONG;
401 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
402
403 /* Update Sequence Number */
404 typedef LONGLONG USN;
405
406 /* ANSI (Multi-byte Character) types */
407 typedef CHAR *PCHAR, *LPCH, *PCH;
408 typedef CONST CHAR *LPCCH, *PCCH;
409 typedef _Null_terminated_ CHAR *NPSTR, *LPSTR, *PSTR;
410 typedef _Null_terminated_ PSTR *PZPSTR;
411 typedef _Null_terminated_ CONST PSTR *PCZPSTR;
412 typedef _Null_terminated_ CONST CHAR *LPCSTR, *PCSTR;
413 typedef _Null_terminated_ PCSTR *PZPCSTR;
414
415 /* Pointer to an Asciiz string */
416 typedef _Null_terminated_ CHAR *PSZ;
417 typedef _Null_terminated_ CONST char *PCSZ;
418
419 /* UNICODE (Wide Character) types */
420 typedef wchar_t WCHAR;
421 typedef WCHAR *PWCHAR, *LPWCH, *PWCH;
422 typedef CONST WCHAR *LPCWCH, *PCWCH;
423 typedef _Null_terminated_ WCHAR *NWPSTR, *LPWSTR, *PWSTR;
424 typedef _Null_terminated_ PWSTR *PZPWSTR;
425 typedef _Null_terminated_ CONST PWSTR *PCZPWSTR;
426 typedef _Null_terminated_ WCHAR UNALIGNED *LPUWSTR, *PUWSTR;
427 typedef _Null_terminated_ CONST WCHAR *LPCWSTR, *PCWSTR;
428 typedef _Null_terminated_ PCWSTR *PZPCWSTR;
429 typedef _Null_terminated_ CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR;
430 typedef _NullNull_terminated_ WCHAR *PZZWSTR;
431
432 /* Cardinal Data Types */
433 typedef char CCHAR, *PCCHAR;
434 typedef short CSHORT, *PCSHORT;
435 typedef ULONG CLONG, *PCLONG;
436
437 /* NLS basics (Locale and Language Ids) */
438 typedef ULONG LCID;
439 typedef PULONG PLCID;
440 typedef USHORT LANGID;
441
442 typedef enum {
443 UNSPECIFIED_COMPARTMENT_ID = 0,
444 DEFAULT_COMPARTMENT_ID
445 } COMPARTMENT_ID, *PCOMPARTMENT_ID;
446
447 #ifdef _MSC_VER
448 #pragma warning(push)
449 #pragma warning(disable:4201)
450 #endif
451 /* Used to store a non-float 8 byte aligned structure */
452 typedef struct _QUAD
453 {
454 _ANONYMOUS_UNION union
455 {
456 __GNU_EXTENSION __int64 UseThisFieldToCopy;
457 double DoNotUseThisField;
458 } DUMMYUNIONNAME;
459 } QUAD, *PQUAD, UQUAD, *PUQUAD;
460
461 /* Large Integer Unions */
462 #if defined(MIDL_PASS)
463 typedef struct _LARGE_INTEGER {
464 #else
465 typedef union _LARGE_INTEGER {
466 _ANONYMOUS_STRUCT struct
467 {
468 ULONG LowPart;
469 LONG HighPart;
470 } DUMMYSTRUCTNAME;
471 struct
472 {
473 ULONG LowPart;
474 LONG HighPart;
475 } u;
476 #endif /* MIDL_PASS */
477 LONGLONG QuadPart;
478 } LARGE_INTEGER, *PLARGE_INTEGER;
479
480 #if defined(MIDL_PASS)
481 typedef struct _ULARGE_INTEGER {
482 #else
483 typedef union _ULARGE_INTEGER {
484 _ANONYMOUS_STRUCT struct
485 {
486 ULONG LowPart;
487 ULONG HighPart;
488 } DUMMYSTRUCTNAME;
489 struct
490 {
491 ULONG LowPart;
492 ULONG HighPart;
493 } u;
494 #endif /* MIDL_PASS */
495 ULONGLONG QuadPart;
496 } ULARGE_INTEGER, *PULARGE_INTEGER;
497
498 #ifdef _MSC_VER
499 #pragma warning(pop) /* disable:4201 */
500 #endif
501
502 /* Physical Addresses are always treated as 64-bit wide */
503 typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
504
505 /* Locally Unique Identifier */
506 typedef struct _LUID {
507 ULONG LowPart;
508 LONG HighPart;
509 } LUID, *PLUID;
510
511 /* Native API Return Value Macros */
512 #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
513 #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1)
514 #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2)
515 #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3)
516
517 /* String Types */
518 typedef struct _UNICODE_STRING {
519 USHORT Length;
520 USHORT MaximumLength;
521 PWSTR Buffer;
522 } UNICODE_STRING, *PUNICODE_STRING;
523 typedef const UNICODE_STRING* PCUNICODE_STRING;
524 #define UNICODE_NULL ((WCHAR)0)
525 #define UNICODE_STRING_MAX_BYTES ((USHORT) 65534)
526 #define UNICODE_STRING_MAX_CHARS (32767)
527
528 typedef struct _CSTRING {
529 USHORT Length;
530 USHORT MaximumLength;
531 CONST CHAR *Buffer;
532 } CSTRING, *PCSTRING;
533 #define ANSI_NULL ((CHAR)0)
534
535 typedef struct _STRING {
536 USHORT Length;
537 USHORT MaximumLength;
538 #ifdef MIDL_PASS
539 [size_is(MaximumLength), length_is(Length) ]
540 #endif
541 _Field_size_bytes_part_opt_(MaximumLength, Length) PCHAR Buffer;
542 } STRING, *PSTRING;
543
544 typedef STRING ANSI_STRING;
545 typedef PSTRING PANSI_STRING;
546 typedef STRING OEM_STRING;
547 typedef PSTRING POEM_STRING;
548 typedef CONST STRING* PCOEM_STRING;
549 typedef STRING CANSI_STRING;
550 typedef PSTRING PCANSI_STRING;
551
552 typedef struct _STRING32 {
553 USHORT Length;
554 USHORT MaximumLength;
555 ULONG Buffer;
556 } STRING32, *PSTRING32,
557 UNICODE_STRING32, *PUNICODE_STRING32,
558 ANSI_STRING32, *PANSI_STRING32;
559
560 typedef struct _STRING64 {
561 USHORT Length;
562 USHORT MaximumLength;
563 ULONGLONG Buffer;
564 } STRING64, *PSTRING64,
565 UNICODE_STRING64, *PUNICODE_STRING64,
566 ANSI_STRING64, *PANSI_STRING64;
567
568 /* LangID and NLS */
569 #define MAKELANGID(p, s) ((((USHORT)(s)) << 10) | (USHORT)(p))
570 #define PRIMARYLANGID(lgid) ((USHORT)(lgid) & 0x3ff)
571 #define SUBLANGID(lgid) ((USHORT)(lgid) >> 10)
572
573 #define NLS_VALID_LOCALE_MASK 0x000fffff
574
575 #define MAKELCID(lgid, srtid) ((ULONG)((((ULONG)((USHORT)(srtid))) << 16) | \
576 ((ULONG)((USHORT)(lgid)))))
577 #define MAKESORTLCID(lgid, srtid, ver) \
578 ((ULONG)((MAKELCID(lgid, srtid)) | \
579 (((ULONG)((USHORT)(ver))) << 20)))
580 #define LANGIDFROMLCID(lcid) ((USHORT)(lcid))
581 #define SORTIDFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 16) & 0xf))
582 #define SORTVERSIONFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 20) & 0xf))
583
584
585 /* Object Attributes */
586 typedef struct _OBJECT_ATTRIBUTES {
587 ULONG Length;
588 HANDLE RootDirectory;
589 PUNICODE_STRING ObjectName;
590 ULONG Attributes;
591 PVOID SecurityDescriptor;
592 PVOID SecurityQualityOfService;
593 } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
594 typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES;
595
596 /* Values for the Attributes member */
597 #define OBJ_INHERIT 0x00000002
598 #define OBJ_PERMANENT 0x00000010
599 #define OBJ_EXCLUSIVE 0x00000020
600 #define OBJ_CASE_INSENSITIVE 0x00000040
601 #define OBJ_OPENIF 0x00000080
602 #define OBJ_OPENLINK 0x00000100
603 #define OBJ_KERNEL_HANDLE 0x00000200
604 #define OBJ_FORCE_ACCESS_CHECK 0x00000400
605 #define OBJ_VALID_ATTRIBUTES 0x000007F2
606
607 /* Helper Macro */
608 #define InitializeObjectAttributes(p,n,a,r,s) { \
609 (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
610 (p)->RootDirectory = (r); \
611 (p)->Attributes = (a); \
612 (p)->ObjectName = (n); \
613 (p)->SecurityDescriptor = (s); \
614 (p)->SecurityQualityOfService = NULL; \
615 }
616
617 /* Product Types */
618 typedef enum _NT_PRODUCT_TYPE {
619 NtProductWinNt = 1,
620 NtProductLanManNt,
621 NtProductServer
622 } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
623
624 typedef enum _EVENT_TYPE {
625 NotificationEvent,
626 SynchronizationEvent
627 } EVENT_TYPE;
628
629 typedef enum _TIMER_TYPE {
630 NotificationTimer,
631 SynchronizationTimer
632 } TIMER_TYPE;
633
634 typedef enum _WAIT_TYPE {
635 WaitAll,
636 WaitAny
637 } WAIT_TYPE;
638
639 /* Doubly Linked Lists */
640 typedef struct _LIST_ENTRY {
641 struct _LIST_ENTRY *Flink;
642 struct _LIST_ENTRY *Blink;
643 } LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
644
645 typedef struct LIST_ENTRY32 {
646 ULONG Flink;
647 ULONG Blink;
648 } LIST_ENTRY32, *PLIST_ENTRY32;
649
650 typedef struct LIST_ENTRY64 {
651 ULONGLONG Flink;
652 ULONGLONG Blink;
653 } LIST_ENTRY64, *PLIST_ENTRY64;
654
655 /* Singly Linked Lists */
656 typedef struct _SINGLE_LIST_ENTRY {
657 struct _SINGLE_LIST_ENTRY *Next;
658 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
659
660 typedef struct _PROCESSOR_NUMBER {
661 USHORT Group;
662 UCHAR Number;
663 UCHAR Reserved;
664 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
665
666 struct _CONTEXT;
667 struct _EXCEPTION_RECORD;
668
669 _IRQL_requires_same_
670 _Function_class_(EXCEPTION_ROUTINE)
671 typedef EXCEPTION_DISPOSITION
672 (NTAPI *PEXCEPTION_ROUTINE)(
673 _Inout_ struct _EXCEPTION_RECORD *ExceptionRecord,
674 _In_ PVOID EstablisherFrame,
675 _Inout_ struct _CONTEXT *ContextRecord,
676 _In_ PVOID DispatcherContext);
677
678 typedef struct _GROUP_AFFINITY {
679 KAFFINITY Mask;
680 USHORT Group;
681 USHORT Reserved[3];
682 } GROUP_AFFINITY, *PGROUP_AFFINITY;
683
684 /* Helper Macros */
685
686 #define RTL_FIELD_TYPE(type, field) (((type*)0)->field)
687 #define RTL_BITS_OF(sizeOfArg) (sizeof(sizeOfArg) * 8)
688 #define RTL_BITS_OF_FIELD(type, field) (RTL_BITS_OF(RTL_FIELD_TYPE(type, field)))
689
690 #define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s }
691
692 #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
693
694 #define RTL_SIZEOF_THROUGH_FIELD(type, field) \
695 (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
696
697 #define RTL_CONTAINS_FIELD(Struct, Size, Field) \
698 ( (((PCHAR)(&(Struct)->Field)) + sizeof((Struct)->Field)) <= (((PCHAR)(Struct))+(Size)) )
699
700 #define RTL_NUMBER_OF_V1(A) (sizeof(A)/sizeof((A)[0]))
701 #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A)
702 #ifdef ENABLE_RTL_NUMBER_OF_V2
703 #define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V2(A)
704 #else
705 #define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V1(A)
706 #endif
707 #define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A)
708
709 /* Type Limits */
710 #define MINCHAR 0x80
711 #define MAXCHAR 0x7f
712 #define MINSHORT 0x8000
713 #define MAXSHORT 0x7fff
714 #define MINLONG 0x80000000
715 #define MAXLONG 0x7fffffff
716 #define MAXUCHAR 0xff
717 #define MAXUSHORT 0xffff
718 #define MAXULONG 0xffffffff
719 #define MAXLONGLONG (0x7fffffffffffffffLL)
720
721 /* Multiplication and Shift Operations */
722 #define Int32x32To64(a,b) ((LONGLONG)(a)*(LONGLONG)(b))
723 #define UInt32x32To64(a,b) ((DWORDLONG)(a)*(DWORDLONG)(b))
724 #define Int64ShllMod32(a,b) ((DWORDLONG)(a)<<(b))
725 #define Int64ShraMod32(a,b) ((LONGLONG)(a)>>(b))
726 #define Int64ShrlMod32(a,b) ((DWORDLONG)(a)>>(b))
727
728 /* C_ASSERT Definition */
729 #define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
730
731 /* Eliminate Microsoft C/C++ compiler warning 4715 */
732 #if defined(_MSC_VER) && (_MSC_VER > 1200)
733 # define DEFAULT_UNREACHABLE default: __assume(0)
734 #elif defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
735 # define DEFAULT_UNREACHABLE default: __builtin_unreachable()
736 #else
737 # define DEFAULT_UNREACHABLE default: break
738 #endif
739
740 #define VER_WORKSTATION_NT 0x40000000
741 #define VER_SERVER_NT 0x80000000
742 #define VER_SUITE_SMALLBUSINESS 0x00000001
743 #define VER_SUITE_ENTERPRISE 0x00000002
744 #define VER_SUITE_BACKOFFICE 0x00000004
745 #define VER_SUITE_COMMUNICATIONS 0x00000008
746 #define VER_SUITE_TERMINAL 0x00000010
747 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
748 #define VER_SUITE_EMBEDDEDNT 0x00000040
749 #define VER_SUITE_DATACENTER 0x00000080
750 #define VER_SUITE_SINGLEUSERTS 0x00000100
751 #define VER_SUITE_PERSONAL 0x00000200
752 #define VER_SUITE_BLADE 0x00000400
753 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
754 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
755 #define VER_SUITE_STORAGE_SERVER 0x00002000
756 #define VER_SUITE_COMPUTE_SERVER 0x00004000
757 #define VER_SUITE_WH_SERVER 0x00008000
758
759 /* Primary language IDs. */
760 #define LANG_NEUTRAL 0x00
761 #define LANG_INVARIANT 0x7f
762
763 #define LANG_AFRIKAANS 0x36
764 #define LANG_ALBANIAN 0x1c
765 #define LANG_ALSATIAN 0x84
766 #define LANG_AMHARIC 0x5e
767 #define LANG_ARABIC 0x01
768 #define LANG_ARMENIAN 0x2b
769 #define LANG_ASSAMESE 0x4d
770 #define LANG_AZERI 0x2c
771 #define LANG_BASHKIR 0x6d
772 #define LANG_BASQUE 0x2d
773 #define LANG_BELARUSIAN 0x23
774 #define LANG_BENGALI 0x45
775 #define LANG_BRETON 0x7e
776 #define LANG_BOSNIAN 0x1a
777 #define LANG_BOSNIAN_NEUTRAL 0x781a
778 #define LANG_BULGARIAN 0x02
779 #define LANG_CATALAN 0x03
780 #define LANG_CHINESE 0x04
781 #define LANG_CHINESE_SIMPLIFIED 0x04
782 #define LANG_CHINESE_TRADITIONAL 0x7c04
783 #define LANG_CORSICAN 0x83
784 #define LANG_CROATIAN 0x1a
785 #define LANG_CZECH 0x05
786 #define LANG_DANISH 0x06
787 #define LANG_DARI 0x8c
788 #define LANG_DIVEHI 0x65
789 #define LANG_DUTCH 0x13
790 #define LANG_ENGLISH 0x09
791 #define LANG_ESTONIAN 0x25
792 #define LANG_FAEROESE 0x38
793 #define LANG_FARSI 0x29
794 #define LANG_FILIPINO 0x64
795 #define LANG_FINNISH 0x0b
796 #define LANG_FRENCH 0x0c
797 #define LANG_FRISIAN 0x62
798 #define LANG_GALICIAN 0x56
799 #define LANG_GEORGIAN 0x37
800 #define LANG_GERMAN 0x07
801 #define LANG_GREEK 0x08
802 #define LANG_GREENLANDIC 0x6f
803 #define LANG_GUJARATI 0x47
804 #define LANG_HAUSA 0x68
805 #define LANG_HEBREW 0x0d
806 #define LANG_HINDI 0x39
807 #define LANG_HUNGARIAN 0x0e
808 #define LANG_ICELANDIC 0x0f
809 #define LANG_IGBO 0x70
810 #define LANG_INDONESIAN 0x21
811 #define LANG_INUKTITUT 0x5d
812 #define LANG_IRISH 0x3c
813 #define LANG_ITALIAN 0x10
814 #define LANG_JAPANESE 0x11
815 #define LANG_KANNADA 0x4b
816 #define LANG_KASHMIRI 0x60
817 #define LANG_KAZAK 0x3f
818 #define LANG_KHMER 0x53
819 #define LANG_KICHE 0x86
820 #define LANG_KINYARWANDA 0x87
821 #define LANG_KONKANI 0x57
822 #define LANG_KOREAN 0x12
823 #define LANG_KYRGYZ 0x40
824 #define LANG_LAO 0x54
825 #define LANG_LATVIAN 0x26
826 #define LANG_LITHUANIAN 0x27
827 #define LANG_LOWER_SORBIAN 0x2e
828 #define LANG_LUXEMBOURGISH 0x6e
829 #define LANG_MACEDONIAN 0x2f
830 #define LANG_MALAY 0x3e
831 #define LANG_MALAYALAM 0x4c
832 #define LANG_MALTESE 0x3a
833 #define LANG_MANIPURI 0x58
834 #define LANG_MAORI 0x81
835 #define LANG_MAPUDUNGUN 0x7a
836 #define LANG_MARATHI 0x4e
837 #define LANG_MOHAWK 0x7c
838 #define LANG_MONGOLIAN 0x50
839 #define LANG_NEPALI 0x61
840 #define LANG_NORWEGIAN 0x14
841 #define LANG_OCCITAN 0x82
842 #define LANG_ORIYA 0x48
843 #define LANG_PASHTO 0x63
844 #define LANG_PERSIAN 0x29
845 #define LANG_POLISH 0x15
846 #define LANG_PORTUGUESE 0x16
847 #define LANG_PUNJABI 0x46
848 #define LANG_QUECHUA 0x6b
849 #define LANG_ROMANIAN 0x18
850 #define LANG_ROMANSH 0x17
851 #define LANG_RUSSIAN 0x19
852 #define LANG_SAMI 0x3b
853 #define LANG_SANSKRIT 0x4f
854 #define LANG_SERBIAN 0x1a
855 #define LANG_SERBIAN_NEUTRAL 0x7c1a
856 #define LANG_SINDHI 0x59
857 #define LANG_SINHALESE 0x5b
858 #define LANG_SLOVAK 0x1b
859 #define LANG_SLOVENIAN 0x24
860 #define LANG_SOTHO 0x6c
861 #define LANG_SPANISH 0x0a
862 #define LANG_SWAHILI 0x41
863 #define LANG_SWEDISH 0x1d
864 #define LANG_SYRIAC 0x5a
865 #define LANG_TAJIK 0x28
866 #define LANG_TAMAZIGHT 0x5f
867 #define LANG_TAMIL 0x49
868 #define LANG_TATAR 0x44
869 #define LANG_TELUGU 0x4a
870 #define LANG_THAI 0x1e
871 #define LANG_TIBETAN 0x51
872 #define LANG_TIGRIGNA 0x73
873 #define LANG_TSWANA 0x32
874 #define LANG_TURKISH 0x1f
875 #define LANG_TURKMEN 0x42
876 #define LANG_UIGHUR 0x80
877 #define LANG_UKRAINIAN 0x22
878 #define LANG_UPPER_SORBIAN 0x2e
879 #define LANG_URDU 0x20
880 #define LANG_UZBEK 0x43
881 #define LANG_VIETNAMESE 0x2a
882 #define LANG_WELSH 0x52
883 #define LANG_WOLOF 0x88
884 #define LANG_XHOSA 0x34
885 #define LANG_YAKUT 0x85
886 #define LANG_YI 0x78
887 #define LANG_YORUBA 0x6a
888 #define LANG_ZULU 0x35
889
890 #endif /* _NTDEF_ */