4 * This file is part of the ReactOS PSDK package.
7 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
9 * THIS SOFTWARE IS NOT COPYRIGHTED
11 * This source code is offered for use in the public domain. You may
12 * use, modify or distribute it freely.
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.
28 //#include <winapifamily.h>
33 #include <sdkddkver.h>
34 #include <specstrings.h>
35 #include <kernelspecs.h>
41 /* Default to strict */
48 /* Pseudo Modifiers for Input Parameters */
70 /* Constant modifier */
85 #define NULL ((void *)0)
86 #define NULL64 ((void * POINTER_64)0)
90 #define ARGUMENT_PRESENT(ArgumentPointer) \
91 ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL)
94 #define FASTCALL __stdcall
95 #elif defined(_M_IX86)
96 #define FASTCALL __fastcall
101 /* min/max helper macros */
104 # define min(a,b) (((a) < (b)) ? (a) : (b))
107 # define max(a,b) (((a) > (b)) ? (a) : (b))
109 #endif /* NOMINMAX */
111 /* Tell windef.h that we have defined some basic types */
116 $
define(USHORT
=USHORT
)
118 $
include(ntbasedef
.h
)
120 typedef _Return_type_success_(return >= 0) LONG NTSTATUS
;
121 typedef NTSTATUS
*PNTSTATUS
;
123 #ifndef __SECSTATUS_DEFINED__
124 typedef long SECURITY_STATUS
;
125 #define __SECSTATUS_DEFINED__
128 /* Physical Addresses are always treated as 64-bit wide */
129 typedef LARGE_INTEGER PHYSICAL_ADDRESS
, *PPHYSICAL_ADDRESS
;
131 #define TIME LARGE_INTEGER
132 #define _TIME _LARGE_INTEGER
133 #define PTIME PLARGE_INTEGER
134 #define LowTime LowPart
135 #define HighTime HighPart
137 /* Used to store a non-float 8 byte aligned structure */
140 _ANONYMOUS_UNION
union
142 __GNU_EXTENSION __int64 UseThisFieldToCopy
;
143 double DoNotUseThisField
;
145 } QUAD
, *PQUAD
, UQUAD
, *PUQUAD
;
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) */
159 typedef struct _STRING
{
161 USHORT MaximumLength
;
163 [size_is(MaximumLength
), length_is(Length
) ]
165 _Field_size_bytes_part_opt_(MaximumLength
, Length
) PCHAR Buffer
;
167 ANSI_STRING
, *PANSI_STRING
,
168 OEM_STRING
, *POEM_STRING
;
170 typedef CONST STRING
* PCOEM_STRING
;
171 typedef STRING CANSI_STRING
;
172 typedef PSTRING PCANSI_STRING
;
174 typedef struct _STRING32
{
176 USHORT MaximumLength
;
178 } STRING32
, *PSTRING32
,
179 UNICODE_STRING32
, *PUNICODE_STRING32
,
180 ANSI_STRING32
, *PANSI_STRING32
;
182 typedef struct _STRING64
{
184 USHORT MaximumLength
;
186 } STRING64
, *PSTRING64
,
187 UNICODE_STRING64
, *PUNICODE_STRING64
,
188 ANSI_STRING64
, *PANSI_STRING64
;
190 typedef struct _CSTRING
{
192 USHORT MaximumLength
;
194 } CSTRING
, *PCSTRING
;
196 typedef struct _UNICODE_STRING
{
198 USHORT MaximumLength
;
200 [size_is(MaximumLength
/ 2), length_is((Length
) / 2)] PUSHORT Buffer
;
202 _Field_size_bytes_part_(MaximumLength
, Length
) PWCH Buffer
;
204 } UNICODE_STRING
, *PUNICODE_STRING
;
205 typedef const UNICODE_STRING
* PCUNICODE_STRING
;
207 typedef USHORT RTL_STRING_LENGTH_TYPE
;
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
218 # define _RTL_CONSTANT_STRING_remove_const_macro(s) (s)
219 char _RTL_CONSTANT_STRING_type_check(const void *s
);
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) }
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))
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))
239 #define DECLARE_UNICODE_STRING_SIZE(_var, _size) \
240 WCHAR _var ## _buffer[_size]; \
241 UNICODE_STRING _var = { 0, (_size) * sizeof(WCHAR) , _var ## _buffer }
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 }
248 #define DECLARE_GLOBAL_CONST_UNICODE_STRING(_var, _str) \
249 extern const __declspec(selectany) UNICODE_STRING _var = RTL_CONSTANT_STRING(_str)
251 /* Object Attributes */
252 typedef struct _OBJECT_ATTRIBUTES
{
254 HANDLE RootDirectory
;
255 PUNICODE_STRING ObjectName
;
257 PVOID SecurityDescriptor
;
258 PVOID SecurityQualityOfService
;
259 } OBJECT_ATTRIBUTES
, *POBJECT_ATTRIBUTES
;
260 typedef CONST OBJECT_ATTRIBUTES
*PCOBJECT_ATTRIBUTES
;
262 typedef struct _OBJECT_ATTRIBUTES32
{
267 ULONG SecurityDescriptor
;
268 ULONG SecurityQualityOfService
;
269 } OBJECT_ATTRIBUTES32
, *POBJECT_ATTRIBUTES32
;
270 typedef CONST OBJECT_ATTRIBUTES32
*PCOBJECT_ATTRIBUTES32
;
272 typedef struct _OBJECT_ATTRIBUTES64
{
274 ULONG64 RootDirectory
;
277 ULONG64 SecurityDescriptor
;
278 ULONG64 SecurityQualityOfService
;
279 } OBJECT_ATTRIBUTES64
, *POBJECT_ATTRIBUTES64
;
280 typedef CONST OBJECT_ATTRIBUTES64
*PCOBJECT_ATTRIBUTES64
;
282 #define OBJ_HANDLE_TAGBITS 0x00000003L
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
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; \
305 #define RTL_CONSTANT_OBJECT_ATTRIBUTES(n,a) { \
306 sizeof(OBJECT_ATTRIBUTES), \
308 RTL_CONST_CAST(PUNICODE_STRING)(n), \
314 #define RTL_INIT_OBJECT_ATTRIBUTES(n, a) \
315 RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
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
323 _ANONYMOUS_UNION
union
325 struct _RTL_BALANCED_NODE
*Children
[2];
326 _ANONYMOUS_STRUCT
struct
328 struct _RTL_BALANCED_NODE
*Left
;
329 struct _RTL_BALANCED_NODE
*Right
;
332 _ANONYMOUS_UNION
union
336 ULONG_PTR ParentValue
;
338 } RTL_BALANCED_NODE
, *PRTL_BALANCED_NODE
;
341 #endif /* _MSC_VER */
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))
349 typedef enum _NT_PRODUCT_TYPE
{
353 } NT_PRODUCT_TYPE
, *PNT_PRODUCT_TYPE
;
355 typedef enum _EVENT_TYPE
{
360 typedef enum _TIMER_TYPE
{
365 typedef enum _WAIT_TYPE
{
374 _In_ PLIST_ENTRY32 ListEntry32
,
375 _Out_ PLIST_ENTRY64 ListEntry64
)
377 ListEntry64
->Flink
= ListEntry32
->Flink
;
378 ListEntry64
->Blink
= ListEntry32
->Blink
;
384 _In_ PLIST_ENTRY64 ListEntry64
,
385 _Out_ PLIST_ENTRY32 ListEntry32
)
387 /* ASSERT without ASSERT or intrinsics ... */
388 if (((ListEntry64
->Flink
>> 32) != 0) ||
389 ((ListEntry64
->Blink
>> 32) != 0))
391 (VOID
)*(volatile LONG
*)(LONG_PTR
)-1;
393 ListEntry32
->Flink
= ListEntry64
->Flink
& 0xFFFFFFFF;
394 ListEntry32
->Blink
= ListEntry64
->Blink
& 0xFFFFFFFF;
396 #endif /* !MIDL_PASS */