10 #include <sdkddkver.h>
12 // FIXME: Should we include these here?
17 typedef unsigned long POINTER_64
; // FIXME! HACK!!!
22 // Pseudo Modifiers for Input Parameters
50 // Defines the "size" of an any-size array
53 #define ANYSIZE_ARRAY 1
77 #define NULL ((void *)0)
78 #define NULL64 ((void * POINTER_64)0)
85 // We should use the -fms-extensions compiler flag for gcc,
86 // and clean up the mess.
88 #ifndef NONAMELESSUNION
90 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
91 #define _ANONYMOUS_UNION __extension__
92 #define _ANONYMOUS_STRUCT __extension__
94 #if defined(__cplusplus)
95 #define _ANONYMOUS_UNION __extension__
96 #endif /* __cplusplus */
97 #endif /* __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) */
98 #elif defined(__WATCOMC__) || defined(_MSC_VER)
99 #define _ANONYMOUS_UNION
100 #define _ANONYMOUS_STRUCT
101 #endif /* __GNUC__/__WATCOMC__ */
102 #endif /* NONAMELESSUNION */
104 #ifndef _ANONYMOUS_UNION
105 #define _ANONYMOUS_UNION
106 #define _UNION_NAME(x) x
107 #define DUMMYUNIONNAME u
108 #define DUMMYUNIONNAME2 u2
109 #define DUMMYUNIONNAME3 u3
110 #define DUMMYUNIONNAME4 u4
111 #define DUMMYUNIONNAME5 u5
112 #define DUMMYUNIONNAME6 u6
113 #define DUMMYUNIONNAME7 u7
114 #define DUMMYUNIONNAME8 u8
116 #define _UNION_NAME(x)
117 #define DUMMYUNIONNAME
118 #define DUMMYUNIONNAME2
119 #define DUMMYUNIONNAME3
120 #define DUMMYUNIONNAME4
121 #define DUMMYUNIONNAME5
122 #define DUMMYUNIONNAME6
123 #define DUMMYUNIONNAME7
124 #define DUMMYUNIONNAME8
127 #ifndef _ANONYMOUS_STRUCT
128 #define _ANONYMOUS_STRUCT
129 #define _STRUCT_NAME(x) x
130 #define DUMMYSTRUCTNAME s
131 #define DUMMYSTRUCTNAME2 s2
132 #define DUMMYSTRUCTNAME3 s3
134 #define _STRUCT_NAME(x)
135 #define DUMMYSTRUCTNAME
136 #define DUMMYSTRUCTNAME2
137 #define DUMMYSTRUCTNAME3
145 #define RESTRICTED_POINTER
148 // Returns the base address of a structure from a structure member
150 #ifndef CONTAINING_RECORD
151 #define CONTAINING_RECORD(address, type, field) \
152 ((type *)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type *)0)->field))))
156 // Returns the byte offset of the specified structure's member
159 #define FIELD_OFFSET(Type, Field) ((LONG)(LONG_PTR)&(((Type*) 0)->Field))
161 #define FIELD_OFFSET(Type, Field) __builtin_offsetof(Type, Field)
165 // Returns the type's alignment
167 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
168 #define TYPE_ALIGNMENT(t) __alignof(t)
170 #define TYPE_ALIGNMENT(t) FIELD_OFFSET( struct { char x; t test; }, test )
174 // Calling Conventions
177 #define FASTCALL __fastcall
182 #define NTAPI __stdcall
185 // Used by the DDK exclusively , don't put in drivers
187 #define DDKAPI __stdcall // Use NTAPI instead
188 #define DDKCDECLAPI __cdecl // Just use __cdecl
191 // Import and Export Specifiers
194 // Done the same way as in windef.h for now
195 #define DECLSPEC_IMPORT __declspec(dllimport)
196 #define DECLSPEC_EXPORT __declspec(dllexport)
197 #define DECLSPEC_NORETURN __declspec(noreturn)
200 #ifndef DECLSPEC_ADDRSAFE
201 #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
202 #define DECLSPEC_ADDRSAFE __declspec(address_safe)
204 #define DECLSPEC_ADDRSAFE
208 #if !defined(_NTSYSTEM_)
209 #define NTSYSAPI DECLSPEC_IMPORT
210 #define NTSYSCALLAPI DECLSPEC_IMPORT
213 #if defined(_NTDLLBUILD_)
216 #define NTSYSCALLAPI DECLSPEC_ADDRSAFE
224 #if (_MSC_VER >= 1200)
225 #define FORCEINLINE __forceinline
227 #define FORCEINLINE __inline
229 #define FORCEINLINE static __inline__ __attribute__((always_inline))
233 #ifndef DECLSPEC_NOINLINE
234 #if (_MSC_VER >= 1300)
235 #define DECLSPEC_NOINLINE __declspec(noinline)
236 #elif defined(__GNUC__)
237 #define DECLSPEC_NOINLINE __attribute__((noinline))
239 #define DECLSPEC_NOINLINE
243 #if !defined(_M_CEE_PURE)
244 #define NTAPI_INLINE NTAPI
250 // Use to specify structure alignment
252 #ifndef DECLSPEC_ALIGN
253 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
254 #define DECLSPEC_ALIGN(x) __declspec(align(x))
255 #elif defined(__GNUC__)
256 #define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
258 #define DECLSPEC_ALIGN(x)
265 // Use to silence unused variable warnings when it is intentional
267 #define UNREFERENCED_PARAMETER(P) {(P)=(P);}
268 #define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);}
269 #define DBG_UNREFERENCED_PARAMETER(P)
270 #define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
275 // min/max helper macros
280 #define min(a,b) (((a) < (b)) ? (a) : (b))
284 #define max(a,b) (((a) > (b)) ? (a) : (b))
292 // Tell windef.h that we have defined some basic types
300 //typedef void * POINTER_64 PVOID64;
301 typedef PVOID PVOID64
; // FIXME!
307 typedef void *HANDLE
;
308 #define DECLARE_HANDLE(n) typedef struct n##__{int i;}*n
310 typedef PVOID HANDLE
;
311 #define DECLARE_HANDLE(n) typedef HANDLE n
313 typedef HANDLE
*PHANDLE
;
316 // Upper-Case Versions of Some Standard C Types
323 #if !defined(MIDL_PASS)
327 typedef double DOUBLE
;
330 // Used to store a non-float 8 byte aligned structure
334 _ANONYMOUS_UNION
union
336 __int64 UseThisFieldToCopy
;
337 double DoNotUseThisField
;
339 } QUAD
, *PQUAD
, UQUAD
, *PUQUAD
;
345 typedef unsigned char UCHAR
, *PUCHAR
;
346 typedef unsigned short USHORT
, *PUSHORT
;
347 typedef unsigned long ULONG
, *PULONG
;
348 typedef CONST UCHAR
*PCUCHAR
;
349 typedef CONST USHORT
*PCUSHORT
;
350 typedef CONST ULONG
*PCULONG
;
353 typedef USHORT FSHORT
;
355 typedef UCHAR BOOLEAN
;
356 typedef BOOLEAN
*PBOOLEAN
;
361 typedef SHORT
*PSHORT
;
364 typedef LONG NTSTATUS
;
365 typedef NTSTATUS
*PNTSTATUS
;
367 typedef signed char SCHAR
;
368 typedef SCHAR
*PSCHAR
;
370 #ifndef _HRESULT_DEFINED
371 #define _HRESULT_DEFINED
372 typedef LONG HRESULT
;
378 typedef __int64 LONGLONG
, *PLONGLONG
;
379 typedef unsigned __int64 ULONGLONG
, *PULONGLONG
;
380 typedef ULONGLONG DWORDLONG
, *PDWORDLONG
;
383 // Update Sequence Number
385 typedef LONGLONG USN
;
389 // ANSI (Multi-byte Character) types
391 typedef CHAR
*PCHAR
, *LPCH
, *PCH
;
392 typedef CONST CHAR
*LPCCH
, *PCCH
;
393 typedef CHAR
*NPSTR
, *LPSTR
, *PSTR
;
394 typedef PSTR
*PZPSTR
;
395 typedef CONST PSTR
*PCZPSTR
;
396 typedef CONST CHAR
*LPCSTR
, *PCSTR
;
397 typedef PCSTR
*PZPCSTR
;
400 // Pointer to an Asciiz string
403 typedef CONST
char *PCSZ
;
406 // UNICODE (Wide Character) types
408 typedef wchar_t WCHAR
;
409 typedef WCHAR
*PWCHAR
, *LPWCH
, *PWCH
;
410 typedef CONST WCHAR
*LPCWCH
, *PCWCH
;
411 typedef WCHAR
*NWPSTR
, *LPWSTR
, *PWSTR
;
412 typedef PWSTR
*PZPWSTR
;
413 typedef CONST PWSTR
*PCZPWSTR
;
414 typedef WCHAR UNALIGNED
*LPUWSTR
, *PUWSTR
;
415 typedef CONST WCHAR
*LPCWSTR
, *PCWSTR
;
416 typedef PCWSTR
*PZPCWSTR
;
417 typedef CONST WCHAR UNALIGNED
*LPCUWSTR
, *PCUWSTR
;
420 // Cardinal Data Types
422 typedef char CCHAR
, *PCCHAR
;
423 typedef short CSHORT
, *PCSHORT
;
424 typedef ULONG CLONG
, *PCLONG
;
427 // NLS basics (Locale and Language Ids)
430 typedef PULONG PLCID
;
431 typedef USHORT LANGID
;
436 // Large Integer Unions
438 #if defined(MIDL_PASS)
439 typedef struct _LARGE_INTEGER
{
441 typedef union _LARGE_INTEGER
{
442 _ANONYMOUS_STRUCT
struct
454 } LARGE_INTEGER
, *PLARGE_INTEGER
;
456 #if defined(MIDL_PASS)
457 typedef struct _ULARGE_INTEGER
{
459 typedef union _ULARGE_INTEGER
{
460 _ANONYMOUS_STRUCT
struct
472 } ULARGE_INTEGER
, *PULARGE_INTEGER
;
475 // Physical Addresses are always treated as 64-bit wide
477 typedef LARGE_INTEGER PHYSICAL_ADDRESS
, *PPHYSICAL_ADDRESS
;
482 // Locally Unique Identifier
484 typedef struct _LUID
{
492 // Native API Return Value Macros
494 #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
495 #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1)
496 #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2)
497 #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3)
504 typedef struct _UNICODE_STRING
{
506 USHORT MaximumLength
;
508 } UNICODE_STRING
, *PUNICODE_STRING
;
509 typedef const UNICODE_STRING
* PCUNICODE_STRING
;
510 #define UNICODE_NULL ((WCHAR)0)
512 typedef struct _CSTRING
{
514 USHORT MaximumLength
;
516 } CSTRING
, *PCSTRING
;
517 #define ANSI_NULL ((CHAR)0)
519 typedef struct _STRING
{
521 USHORT MaximumLength
;
525 typedef STRING ANSI_STRING
;
526 typedef PSTRING PANSI_STRING
;
527 typedef STRING OEM_STRING
;
528 typedef PSTRING POEM_STRING
;
529 typedef CONST STRING
* PCOEM_STRING
;
530 typedef STRING CANSI_STRING
;
531 typedef PSTRING PCANSI_STRING
;
538 #define MAKELANGID(p, s) ((((USHORT)(s)) << 10) | (USHORT)(p))
539 #define PRIMARYLANGID(lgid) ((USHORT)(lgid) & 0x3ff)
540 #define SUBLANGID(lgid) ((USHORT)(lgid) >> 10)
542 #define NLS_VALID_LOCALE_MASK 0x000fffff
544 #define MAKELCID(lgid, srtid) ((ULONG)((((ULONG)((USHORT)(srtid))) << 16) | \
545 ((ULONG)((USHORT)(lgid)))))
546 #define MAKESORTLCID(lgid, srtid, ver) \
547 ((ULONG)((MAKELCID(lgid, srtid)) | \
548 (((ULONG)((USHORT)(ver))) << 20)))
549 #define LANGIDFROMLCID(lcid) ((USHORT)(lcid))
550 #define SORTIDFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 16) & 0xf))
551 #define SORTVERSIONFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 20) & 0xf))
558 typedef struct _OBJECT_ATTRIBUTES
{
560 HANDLE RootDirectory
;
561 PUNICODE_STRING ObjectName
;
563 PVOID SecurityDescriptor
;
564 PVOID SecurityQualityOfService
;
565 } OBJECT_ATTRIBUTES
, *POBJECT_ATTRIBUTES
;
566 typedef CONST OBJECT_ATTRIBUTES
*PCOBJECT_ATTRIBUTES
;
569 // Values for the Attributes member
571 #define OBJ_INHERIT 0x00000002
572 #define OBJ_PERMANENT 0x00000010
573 #define OBJ_EXCLUSIVE 0x00000020
574 #define OBJ_CASE_INSENSITIVE 0x00000040
575 #define OBJ_OPENIF 0x00000080
576 #define OBJ_OPENLINK 0x00000100
577 #define OBJ_KERNEL_HANDLE 0x00000200
578 #define OBJ_FORCE_ACCESS_CHECK 0x00000400
579 #define OBJ_VALID_ATTRIBUTES 0x000007F2
584 #define InitializeObjectAttributes(p,n,a,r,s) { \
585 (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
586 (p)->RootDirectory = (r); \
587 (p)->Attributes = (a); \
588 (p)->ObjectName = (n); \
589 (p)->SecurityDescriptor = (s); \
590 (p)->SecurityQualityOfService = NULL; \
598 typedef enum _NT_PRODUCT_TYPE
{
602 } NT_PRODUCT_TYPE
, *PNT_PRODUCT_TYPE
;
607 // Doubly Linked Lists
609 typedef struct _LIST_ENTRY
{
610 struct _LIST_ENTRY
*Flink
;
611 struct _LIST_ENTRY
*Blink
;
612 } LIST_ENTRY
, *PLIST_ENTRY
, *RESTRICTED_POINTER PRLIST_ENTRY
;
614 typedef struct LIST_ENTRY32
618 } LIST_ENTRY32
, *PLIST_ENTRY32
;
620 typedef struct LIST_ENTRY64
624 } LIST_ENTRY64
, *PLIST_ENTRY64
;
627 // Singly Linked Lists
629 typedef struct _SINGLE_LIST_ENTRY
{
630 struct _SINGLE_LIST_ENTRY
*Next
;
631 } SINGLE_LIST_ENTRY
, *PSINGLE_LIST_ENTRY
;
638 #define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s }
640 #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
642 #define RTL_NUMBER_OF_V1(A) (sizeof(A)/sizeof((A)[0]))
643 #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A)
644 #ifdef ENABLE_RTL_NUMBER_OF_V2
645 #define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V2(A)
647 #define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V1(A)
649 #define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A)
658 #define MINSHORT 0x8000
659 #define MAXSHORT 0x7fff
660 #define MINLONG 0x80000000
661 #define MAXLONG 0x7fffffff
662 #define MAXUCHAR 0xff
663 #define MAXUSHORT 0xffff
664 #define MAXULONG 0xffffffff
665 #define MAXLONGLONG (0x7fffffffffffffffLL)
670 // Multiplication and Shift Operations
672 #define Int32x32To64(a,b) ((LONGLONG)(a)*(LONGLONG)(b))
673 #define UInt32x32To64(a,b) ((DWORDLONG)(a)*(DWORDLONG)(b))
674 #define Int64ShllMod32(a,b) ((DWORDLONG)(a)<<(b))
675 #define Int64ShraMod32(a,b) ((LONGLONG)(a)>>(b))
676 #define Int64ShrlMod32(a,b) ((DWORDLONG)(a)>>(b))
681 // C_ASSERT Definition
683 #define __C_ASSERT_JOIN(X, Y) __C_ASSERT_DO_JOIN(X, Y)
684 #define __C_ASSERT_DO_JOIN(X, Y) __C_ASSERT_DO_JOIN2(X, Y)
685 #define __C_ASSERT_DO_JOIN2(X, Y) X##Y
686 #define C_ASSERT(e) typedef char __C_ASSERT_JOIN(__C_ASSERT__, __LINE__)[(e) ? 1 : -1]
691 // Primary language IDs.
693 #define LANG_NEUTRAL 0x00
694 #define LANG_INVARIANT 0x7f
696 #define LANG_AFRIKAANS 0x36
697 #define LANG_ALBANIAN 0x1c
698 #define LANG_ALSATIAN 0x84
699 #define LANG_AMHARIC 0x5e
700 #define LANG_ARABIC 0x01
701 #define LANG_ARMENIAN 0x2b
702 #define LANG_ASSAMESE 0x4d
703 #define LANG_AZERI 0x2c
704 #define LANG_BASHKIR 0x6d
705 #define LANG_BASQUE 0x2d
706 #define LANG_BELARUSIAN 0x23
707 #define LANG_BENGALI 0x45
708 #define LANG_BRETON 0x7e
709 #define LANG_BOSNIAN 0x1a
710 #define LANG_BOSNIAN_NEUTRAL 0x781a
711 #define LANG_BULGARIAN 0x02
712 #define LANG_CATALAN 0x03
713 #define LANG_CHINESE 0x04
714 #define LANG_CHINESE_SIMPLIFIED 0x04
715 #define LANG_CHINESE_TRADITIONAL 0x7c04
716 #define LANG_CORSICAN 0x83
717 #define LANG_CROATIAN 0x1a
718 #define LANG_CZECH 0x05
719 #define LANG_DANISH 0x06
720 #define LANG_DARI 0x8c
721 #define LANG_DIVEHI 0x65
722 #define LANG_DUTCH 0x13
723 #define LANG_ENGLISH 0x09
724 #define LANG_ESTONIAN 0x25
725 #define LANG_FAEROESE 0x38
726 #define LANG_FARSI 0x29
727 #define LANG_FILIPINO 0x64
728 #define LANG_FINNISH 0x0b
729 #define LANG_FRENCH 0x0c
730 #define LANG_FRISIAN 0x62
731 #define LANG_GALICIAN 0x56
732 #define LANG_GEORGIAN 0x37
733 #define LANG_GERMAN 0x07
734 #define LANG_GREEK 0x08
735 #define LANG_GREENLANDIC 0x6f
736 #define LANG_GUJARATI 0x47
737 #define LANG_HAUSA 0x68
738 #define LANG_HEBREW 0x0d
739 #define LANG_HINDI 0x39
740 #define LANG_HUNGARIAN 0x0e
741 #define LANG_ICELANDIC 0x0f
742 #define LANG_IGBO 0x70
743 #define LANG_INDONESIAN 0x21
744 #define LANG_INUKTITUT 0x5d
745 #define LANG_IRISH 0x3c
746 #define LANG_ITALIAN 0x10
747 #define LANG_JAPANESE 0x11
748 #define LANG_KANNADA 0x4b
749 #define LANG_KASHMIRI 0x60
750 #define LANG_KAZAK 0x3f
751 #define LANG_KHMER 0x53
752 #define LANG_KICHE 0x86
753 #define LANG_KINYARWANDA 0x87
754 #define LANG_KONKANI 0x57
755 #define LANG_KOREAN 0x12
756 #define LANG_KYRGYZ 0x40
757 #define LANG_LAO 0x54
758 #define LANG_LATVIAN 0x26
759 #define LANG_LITHUANIAN 0x27
760 #define LANG_LOWER_SORBIAN 0x2e
761 #define LANG_LUXEMBOURGISH 0x6e
762 #define LANG_MACEDONIAN 0x2f
763 #define LANG_MALAY 0x3e
764 #define LANG_MALAYALAM 0x4c
765 #define LANG_MALTESE 0x3a
766 #define LANG_MANIPURI 0x58
767 #define LANG_MAORI 0x81
768 #define LANG_MAPUDUNGUN 0x7a
769 #define LANG_MARATHI 0x4e
770 #define LANG_MOHAWK 0x7c
771 #define LANG_MONGOLIAN 0x50
772 #define LANG_NEPALI 0x61
773 #define LANG_NORWEGIAN 0x14
774 #define LANG_OCCITAN 0x82
775 #define LANG_ORIYA 0x48
776 #define LANG_PASHTO 0x63
777 #define LANG_PERSIAN 0x29
778 #define LANG_POLISH 0x15
779 #define LANG_PORTUGUESE 0x16
780 #define LANG_PUNJABI 0x46
781 #define LANG_QUECHUA 0x6b
782 #define LANG_ROMANIAN 0x18
783 #define LANG_ROMANSH 0x17
784 #define LANG_RUSSIAN 0x19
785 #define LANG_SAMI 0x3b
786 #define LANG_SANSKRIT 0x4f
787 #define LANG_SERBIAN 0x1a
788 #define LANG_SERBIAN_NEUTRAL 0x7c1a
789 #define LANG_SINDHI 0x59
790 #define LANG_SINHALESE 0x5b
791 #define LANG_SLOVAK 0x1b
792 #define LANG_SLOVENIAN 0x24
793 #define LANG_SOTHO 0x6c
794 #define LANG_SPANISH 0x0a
795 #define LANG_SWAHILI 0x41
796 #define LANG_SWEDISH 0x1d
797 #define LANG_SYRIAC 0x5a
798 #define LANG_TAJIK 0x28
799 #define LANG_TAMAZIGHT 0x5f
800 #define LANG_TAMIL 0x49
801 #define LANG_TATAR 0x44
802 #define LANG_TELUGU 0x4a
803 #define LANG_THAI 0x1e
804 #define LANG_TIBETAN 0x51
805 #define LANG_TIGRIGNA 0x73
806 #define LANG_TSWANA 0x32
807 #define LANG_TURKISH 0x1f
808 #define LANG_TURKMEN 0x42
809 #define LANG_UIGHUR 0x80
810 #define LANG_UKRAINIAN 0x22
811 #define LANG_UPPER_SORBIAN 0x2e
812 #define LANG_URDU 0x20
813 #define LANG_UZBEK 0x43
814 #define LANG_VIETNAMESE 0x2a
815 #define LANG_WELSH 0x52
816 #define LANG_WOLOF 0x88
817 #define LANG_XHOSA 0x34
818 #define LANG_YAKUT 0x85
820 #define LANG_YORUBA 0x6a
821 #define LANG_ZULU 0x35
825 #endif /* _NTDEF_H */