From cf215482dd2c796c2f0ea98a8f7677a1b796d75c Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 3 Oct 2014 12:10:08 +0000 Subject: [PATCH] [PSDK/XDK] Add some missing definitions to ntdef.h and winnt.h svn path=/trunk/; revision=64496 --- reactos/include/psdk/ntdef.h | 104 +++++++++++++++++++++++++-- reactos/include/psdk/winnt.h | 35 +++++---- reactos/include/xdk/ntbasedef.h | 24 +++++-- reactos/include/xdk/ntdef.template.h | 80 +++++++++++++++++++++ reactos/include/xdk/winnt_old.h | 15 ---- 5 files changed, 220 insertions(+), 38 deletions(-) diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index 6b1d0933094..9a028b6c639 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -461,10 +461,6 @@ typedef unsigned char UCHAR, *PUCHAR; typedef unsigned short USHORT, *PUSHORT; typedef unsigned long ULONG, *PULONG; -typedef CONST UCHAR *PCUCHAR; -typedef CONST USHORT *PCUSHORT; -typedef CONST ULONG *PCULONG; - typedef double DOUBLE; /* Signed Types */ @@ -800,6 +796,26 @@ typedef struct _GROUP_AFFINITY { #define RTL_CONST_CAST(type) (type) #endif +#ifdef __cplusplus +#define DEFINE_ENUM_FLAG_OPERATORS(_ENUMTYPE) \ +extern "C++" { \ + inline _ENUMTYPE operator|(_ENUMTYPE a, _ENUMTYPE b) { return _ENUMTYPE(((int)a) | ((int)b)); } \ + inline _ENUMTYPE &operator|=(_ENUMTYPE &a, _ENUMTYPE b) { return (_ENUMTYPE &)(((int &)a) |= ((int)b)); } \ + inline _ENUMTYPE operator&(_ENUMTYPE a, _ENUMTYPE b) { return _ENUMTYPE(((int)a) & ((int)b)); } \ + inline _ENUMTYPE &operator&=(_ENUMTYPE &a, _ENUMTYPE b) { return (_ENUMTYPE &)(((int &)a) &= ((int)b)); } \ + inline _ENUMTYPE operator~(_ENUMTYPE a) { return _ENUMTYPE(~((int)a)); } \ + inline _ENUMTYPE operator^(_ENUMTYPE a, _ENUMTYPE b) { return _ENUMTYPE(((int)a) ^ ((int)b)); } \ + inline _ENUMTYPE &operator^=(_ENUMTYPE &a, _ENUMTYPE b) { return (_ENUMTYPE &)(((int &)a) ^= ((int)b)); } \ +} +#else +#define DEFINE_ENUM_FLAG_OPERATORS(_ENUMTYPE) +#endif + +#define COMPILETIME_OR_2FLAGS(a,b) ((UINT)(a)|(UINT)(b)) +#define COMPILETIME_OR_3FLAGS(a,b,c) ((UINT)(a)|(UINT)(b)|(UINT)(c)) +#define COMPILETIME_OR_4FLAGS(a,b,c,d) ((UINT)(a)|(UINT)(b)|(UINT)(c)|(UINT)(d)) +#define COMPILETIME_OR_5FLAGS(a,b,c,d,e) ((UINT)(a)|(UINT)(b)|(UINT)(c)|(UINT)(d)|(UINT)(e)) + /* Type Limits */ #define MINCHAR 0x80 #define MAXCHAR 0x7f @@ -1401,9 +1417,23 @@ typedef struct _GROUP_AFFINITY { #define LOCALE_NEUTRAL MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT) #define LOCALE_INVARIANT MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT) +typedef _Return_type_success_(return >= 0) LONG NTSTATUS; +typedef NTSTATUS *PNTSTATUS; + +#ifndef __SECSTATUS_DEFINED__ +typedef long SECURITY_STATUS; +#define __SECSTATUS_DEFINED__ +#endif + /* Physical Addresses are always treated as 64-bit wide */ typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; +#define TIME LARGE_INTEGER +#define _TIME _LARGE_INTEGER +#define PTIME PLARGE_INTEGER +#define LowTime LowPart +#define HighTime HighPart + /* Used to store a non-float 8 byte aligned structure */ typedef struct _QUAD { @@ -1414,6 +1444,17 @@ typedef struct _QUAD } DUMMYUNIONNAME; } QUAD, *PQUAD, UQUAD, *PUQUAD; +#if (_WIN32_WINNT >= 0x0600) || (defined(__cplusplus) && defined(WINDOWS_ENABLE_CPLUSPLUS)) +typedef CONST UCHAR *PCUCHAR; +typedef CONST USHORT *PCUSHORT; +typedef CONST ULONG *PCULONG; +typedef CONST UQUAD *PCUQUAD; +typedef CONST SCHAR *PCSCHAR; +#endif /* (/_WIN32_WINNT >= 0x0600) */ +#if (_WIN32_WINNT >= 0x0600) +typedef CONST NTSTATUS *PCNTSTATUS; +#endif /* (/_WIN32_WINNT >= 0x0600) */ + /* String Types */ typedef struct _STRING { USHORT Length; @@ -1528,6 +1569,8 @@ typedef struct _OBJECT_ATTRIBUTES64 { } OBJECT_ATTRIBUTES64, *POBJECT_ATTRIBUTES64; typedef CONST OBJECT_ATTRIBUTES64 *PCOBJECT_ATTRIBUTES64; +#define OBJ_HANDLE_TAGBITS 0x00000003L + /* Values for the Attributes member */ #define OBJ_INHERIT 0x00000002L #define OBJ_PERMANENT 0x00000010L @@ -1561,6 +1604,37 @@ typedef CONST OBJECT_ATTRIBUTES64 *PCOBJECT_ATTRIBUTES64; #define RTL_INIT_OBJECT_ATTRIBUTES(n, a) \ RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a) +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4214) /* Bit fields of other types than int */ +#endif /* _MSC_VER */ +typedef struct _RTL_BALANCED_NODE +{ + _ANONYMOUS_UNION union + { + struct _RTL_BALANCED_NODE *Children[2]; + _ANONYMOUS_STRUCT struct + { + struct _RTL_BALANCED_NODE *Left; + struct _RTL_BALANCED_NODE *Right; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + _ANONYMOUS_UNION union + { + UCHAR Red : 1; + UCHAR Balance : 2; + ULONG_PTR ParentValue; + } DUMMYUNIONNAME2; +} RTL_BALANCED_NODE, *PRTL_BALANCED_NODE; +#ifdef _MSC_VER + #pragma warning(pop) +#endif /* _MSC_VER */ + +#define RTL_BALANCED_NODE_RESERVED_PARENT_MASK 3 +#define RTL_BALANCED_NODE_GET_PARENT_POINTER(Node) \ + ((PRTL_BALANCED_NODE)((Node)->ParentValue & \ + ~RTL_BALANCED_NODE_RESERVED_PARENT_MASK)) + /* Product Types */ typedef enum _NT_PRODUCT_TYPE { NtProductWinNt = 1, @@ -1583,6 +1657,28 @@ typedef enum _WAIT_TYPE { WaitAny } WAIT_TYPE; +#ifndef MIDL_PASS +FORCEINLINE +VOID +ListEntry32To64( + _In_ PLIST_ENTRY32 ListEntry32, + _Out_ PLIST_ENTRY64 ListEntry64) +{ + ListEntry64->Flink = (ULONG)ListEntry32->Flink; + ListEntry64->Blink = (ULONG)ListEntry32->Blink; +} + +FORCEINLINE +VOID +ListEntry64To32( + _In_ PLIST_ENTRY64 ListEntry64, + _Out_ PLIST_ENTRY32 ListEntry32) +{ + ListEntry32->Flink = ListEntry64->Flink & 0xFFFFFFFF; + ListEntry32->Blink = ListEntry64->Blink & 0xFFFFFFFF; +} +#endif /* !MIDL_PASS */ + #ifdef __cplusplus } // extern "C" #endif diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index f847726bd84..0d733ac35d2 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -729,6 +729,26 @@ typedef struct _GROUP_AFFINITY { #define RTL_CONST_CAST(type) (type) #endif +#ifdef __cplusplus +#define DEFINE_ENUM_FLAG_OPERATORS(_ENUMTYPE) \ +extern "C++" { \ + inline _ENUMTYPE operator|(_ENUMTYPE a, _ENUMTYPE b) { return _ENUMTYPE(((int)a) | ((int)b)); } \ + inline _ENUMTYPE &operator|=(_ENUMTYPE &a, _ENUMTYPE b) { return (_ENUMTYPE &)(((int &)a) |= ((int)b)); } \ + inline _ENUMTYPE operator&(_ENUMTYPE a, _ENUMTYPE b) { return _ENUMTYPE(((int)a) & ((int)b)); } \ + inline _ENUMTYPE &operator&=(_ENUMTYPE &a, _ENUMTYPE b) { return (_ENUMTYPE &)(((int &)a) &= ((int)b)); } \ + inline _ENUMTYPE operator~(_ENUMTYPE a) { return _ENUMTYPE(~((int)a)); } \ + inline _ENUMTYPE operator^(_ENUMTYPE a, _ENUMTYPE b) { return _ENUMTYPE(((int)a) ^ ((int)b)); } \ + inline _ENUMTYPE &operator^=(_ENUMTYPE &a, _ENUMTYPE b) { return (_ENUMTYPE &)(((int &)a) ^= ((int)b)); } \ +} +#else +#define DEFINE_ENUM_FLAG_OPERATORS(_ENUMTYPE) +#endif + +#define COMPILETIME_OR_2FLAGS(a,b) ((UINT)(a)|(UINT)(b)) +#define COMPILETIME_OR_3FLAGS(a,b,c) ((UINT)(a)|(UINT)(b)|(UINT)(c)) +#define COMPILETIME_OR_4FLAGS(a,b,c,d) ((UINT)(a)|(UINT)(b)|(UINT)(c)|(UINT)(d)) +#define COMPILETIME_OR_5FLAGS(a,b,c,d,e) ((UINT)(a)|(UINT)(b)|(UINT)(c)|(UINT)(d)|(UINT)(e)) + /* Type Limits */ #define MINCHAR 0x80 #define MAXCHAR 0x7f @@ -1424,21 +1444,6 @@ typedef struct _GROUP_AFFINITY { #define ACE_OBJECT_TYPE_PRESENT 0x00000001 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x00000002 -#ifdef __cplusplus -#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \ -extern "C++" { \ - inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)|((int)b)); } \ - inline ENUMTYPE operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \ - inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)&((int)b)); } \ - inline ENUMTYPE operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \ - inline ENUMTYPE operator ~ (ENUMTYPE a) { return (ENUMTYPE)(~((int)a)); } \ - inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)^((int)b)); } \ - inline ENUMTYPE operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \ -} -#else -# define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */ -#endif - /* also in ddk/ntifs.h */ #define COMPRESSION_FORMAT_NONE (0x0000) #define COMPRESSION_FORMAT_DEFAULT (0x0001) diff --git a/reactos/include/xdk/ntbasedef.h b/reactos/include/xdk/ntbasedef.h index 130742ab782..30b2c1e2f6d 100644 --- a/reactos/include/xdk/ntbasedef.h +++ b/reactos/include/xdk/ntbasedef.h @@ -352,10 +352,6 @@ typedef unsigned char UCHAR, *PUCHAR; typedef unsigned short USHORT, *PUSHORT; typedef unsigned long ULONG, *PULONG; -typedef CONST UCHAR *PCUCHAR; -typedef CONST USHORT *PCUSHORT; -typedef CONST ULONG *PCULONG; - typedef double DOUBLE; $endif(_NTDEF_) @@ -712,6 +708,26 @@ typedef struct _GROUP_AFFINITY { #define RTL_CONST_CAST(type) (type) #endif +#ifdef __cplusplus +#define DEFINE_ENUM_FLAG_OPERATORS(_ENUMTYPE) \ +extern "C++" { \ + inline _ENUMTYPE operator|(_ENUMTYPE a, _ENUMTYPE b) { return _ENUMTYPE(((int)a) | ((int)b)); } \ + inline _ENUMTYPE &operator|=(_ENUMTYPE &a, _ENUMTYPE b) { return (_ENUMTYPE &)(((int &)a) |= ((int)b)); } \ + inline _ENUMTYPE operator&(_ENUMTYPE a, _ENUMTYPE b) { return _ENUMTYPE(((int)a) & ((int)b)); } \ + inline _ENUMTYPE &operator&=(_ENUMTYPE &a, _ENUMTYPE b) { return (_ENUMTYPE &)(((int &)a) &= ((int)b)); } \ + inline _ENUMTYPE operator~(_ENUMTYPE a) { return _ENUMTYPE(~((int)a)); } \ + inline _ENUMTYPE operator^(_ENUMTYPE a, _ENUMTYPE b) { return _ENUMTYPE(((int)a) ^ ((int)b)); } \ + inline _ENUMTYPE &operator^=(_ENUMTYPE &a, _ENUMTYPE b) { return (_ENUMTYPE &)(((int &)a) ^= ((int)b)); } \ +} +#else +#define DEFINE_ENUM_FLAG_OPERATORS(_ENUMTYPE) +#endif + +#define COMPILETIME_OR_2FLAGS(a,b) ((UINT)(a)|(UINT)(b)) +#define COMPILETIME_OR_3FLAGS(a,b,c) ((UINT)(a)|(UINT)(b)|(UINT)(c)) +#define COMPILETIME_OR_4FLAGS(a,b,c,d) ((UINT)(a)|(UINT)(b)|(UINT)(c)|(UINT)(d)) +#define COMPILETIME_OR_5FLAGS(a,b,c,d,e) ((UINT)(a)|(UINT)(b)|(UINT)(c)|(UINT)(d)|(UINT)(e)) + /* Type Limits */ #define MINCHAR 0x80 #define MAXCHAR 0x7f diff --git a/reactos/include/xdk/ntdef.template.h b/reactos/include/xdk/ntdef.template.h index fc1df37a19e..36d24b6b6a5 100644 --- a/reactos/include/xdk/ntdef.template.h +++ b/reactos/include/xdk/ntdef.template.h @@ -117,9 +117,23 @@ $define(USHORT=USHORT) $define(UCHAR=UCHAR) $include(ntbasedef.h) +typedef _Return_type_success_(return >= 0) LONG NTSTATUS; +typedef NTSTATUS *PNTSTATUS; + +#ifndef __SECSTATUS_DEFINED__ +typedef long SECURITY_STATUS; +#define __SECSTATUS_DEFINED__ +#endif + /* Physical Addresses are always treated as 64-bit wide */ typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; +#define TIME LARGE_INTEGER +#define _TIME _LARGE_INTEGER +#define PTIME PLARGE_INTEGER +#define LowTime LowPart +#define HighTime HighPart + /* Used to store a non-float 8 byte aligned structure */ typedef struct _QUAD { @@ -130,6 +144,17 @@ typedef struct _QUAD } DUMMYUNIONNAME; } QUAD, *PQUAD, UQUAD, *PUQUAD; +#if (_WIN32_WINNT >= 0x0600) || (defined(__cplusplus) && defined(WINDOWS_ENABLE_CPLUSPLUS)) +typedef CONST UCHAR *PCUCHAR; +typedef CONST USHORT *PCUSHORT; +typedef CONST ULONG *PCULONG; +typedef CONST UQUAD *PCUQUAD; +typedef CONST SCHAR *PCSCHAR; +#endif /* (/_WIN32_WINNT >= 0x0600) */ +#if (_WIN32_WINNT >= 0x0600) +typedef CONST NTSTATUS *PCNTSTATUS; +#endif /* (/_WIN32_WINNT >= 0x0600) */ + /* String Types */ typedef struct _STRING { USHORT Length; @@ -244,6 +269,8 @@ typedef struct _OBJECT_ATTRIBUTES64 { } OBJECT_ATTRIBUTES64, *POBJECT_ATTRIBUTES64; typedef CONST OBJECT_ATTRIBUTES64 *PCOBJECT_ATTRIBUTES64; +#define OBJ_HANDLE_TAGBITS 0x00000003L + /* Values for the Attributes member */ #define OBJ_INHERIT 0x00000002L #define OBJ_PERMANENT 0x00000010L @@ -277,6 +304,37 @@ typedef CONST OBJECT_ATTRIBUTES64 *PCOBJECT_ATTRIBUTES64; #define RTL_INIT_OBJECT_ATTRIBUTES(n, a) \ RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a) +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4214) /* Bit fields of other types than int */ +#endif /* _MSC_VER */ +typedef struct _RTL_BALANCED_NODE +{ + _ANONYMOUS_UNION union + { + struct _RTL_BALANCED_NODE *Children[2]; + _ANONYMOUS_STRUCT struct + { + struct _RTL_BALANCED_NODE *Left; + struct _RTL_BALANCED_NODE *Right; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + _ANONYMOUS_UNION union + { + UCHAR Red : 1; + UCHAR Balance : 2; + ULONG_PTR ParentValue; + } DUMMYUNIONNAME2; +} RTL_BALANCED_NODE, *PRTL_BALANCED_NODE; +#ifdef _MSC_VER + #pragma warning(pop) +#endif /* _MSC_VER */ + +#define RTL_BALANCED_NODE_RESERVED_PARENT_MASK 3 +#define RTL_BALANCED_NODE_GET_PARENT_POINTER(Node) \ + ((PRTL_BALANCED_NODE)((Node)->ParentValue & \ + ~RTL_BALANCED_NODE_RESERVED_PARENT_MASK)) + /* Product Types */ typedef enum _NT_PRODUCT_TYPE { NtProductWinNt = 1, @@ -299,6 +357,28 @@ typedef enum _WAIT_TYPE { WaitAny } WAIT_TYPE; +#ifndef MIDL_PASS +FORCEINLINE +VOID +ListEntry32To64( + _In_ PLIST_ENTRY32 ListEntry32, + _Out_ PLIST_ENTRY64 ListEntry64) +{ + ListEntry64->Flink = (ULONG)ListEntry32->Flink; + ListEntry64->Blink = (ULONG)ListEntry32->Blink; +} + +FORCEINLINE +VOID +ListEntry64To32( + _In_ PLIST_ENTRY64 ListEntry64, + _Out_ PLIST_ENTRY32 ListEntry32) +{ + ListEntry32->Flink = ListEntry64->Flink & 0xFFFFFFFF; + ListEntry32->Blink = ListEntry64->Blink & 0xFFFFFFFF; +} +#endif /* !MIDL_PASS */ + #ifdef __cplusplus } // extern "C" #endif diff --git a/reactos/include/xdk/winnt_old.h b/reactos/include/xdk/winnt_old.h index a8221d44d35..b108fab9030 100644 --- a/reactos/include/xdk/winnt_old.h +++ b/reactos/include/xdk/winnt_old.h @@ -93,21 +93,6 @@ #define ACE_OBJECT_TYPE_PRESENT 0x00000001 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x00000002 -#ifdef __cplusplus -#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \ -extern "C++" { \ - inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)|((int)b)); } \ - inline ENUMTYPE operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \ - inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)&((int)b)); } \ - inline ENUMTYPE operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \ - inline ENUMTYPE operator ~ (ENUMTYPE a) { return (ENUMTYPE)(~((int)a)); } \ - inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)^((int)b)); } \ - inline ENUMTYPE operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \ -} -#else -# define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */ -#endif - /* also in ddk/ntifs.h */ #define COMPRESSION_FORMAT_NONE (0x0000) #define COMPRESSION_FORMAT_DEFAULT (0x0001)