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 /* Physical Addresses are always treated as 64-bit wide */
121 typedef LARGE_INTEGER PHYSICAL_ADDRESS
, *PPHYSICAL_ADDRESS
;
123 /* Used to store a non-float 8 byte aligned structure */
126 _ANONYMOUS_UNION
union
128 __GNU_EXTENSION __int64 UseThisFieldToCopy
;
129 double DoNotUseThisField
;
131 } QUAD
, *PQUAD
, UQUAD
, *PUQUAD
;
134 typedef struct _STRING
{
136 USHORT MaximumLength
;
138 [size_is(MaximumLength
), length_is(Length
) ]
140 _Field_size_bytes_part_opt_(MaximumLength
, Length
) PCHAR Buffer
;
142 ANSI_STRING
, *PANSI_STRING
,
143 OEM_STRING
, *POEM_STRING
;
145 typedef CONST STRING
* PCOEM_STRING
;
146 typedef STRING CANSI_STRING
;
147 typedef PSTRING PCANSI_STRING
;
149 typedef struct _STRING32
{
151 USHORT MaximumLength
;
153 } STRING32
, *PSTRING32
,
154 UNICODE_STRING32
, *PUNICODE_STRING32
,
155 ANSI_STRING32
, *PANSI_STRING32
;
157 typedef struct _STRING64
{
159 USHORT MaximumLength
;
161 } STRING64
, *PSTRING64
,
162 UNICODE_STRING64
, *PUNICODE_STRING64
,
163 ANSI_STRING64
, *PANSI_STRING64
;
165 typedef struct _CSTRING
{
167 USHORT MaximumLength
;
169 } CSTRING
, *PCSTRING
;
171 typedef struct _UNICODE_STRING
{
173 USHORT MaximumLength
;
175 [size_is(MaximumLength
/ 2), length_is((Length
) / 2)] PUSHORT Buffer
;
177 _Field_size_bytes_part_(MaximumLength
, Length
) PWCH Buffer
;
179 } UNICODE_STRING
, *PUNICODE_STRING
;
180 typedef const UNICODE_STRING
* PCUNICODE_STRING
;
182 typedef USHORT RTL_STRING_LENGTH_TYPE
;
185 extern "C++" template<typename _Type
> struct _RTL_remove_const_template
;
186 extern "C++" template<typename _Type
> struct _RTL_remove_const_template
<const _Type
&> { typedef _Type type
; };
187 #define _RTL_CONSTANT_STRING_remove_const_macro(s) \
188 (const_cast<_RTL_remove_const_template<decltype((s)[0])>::type*>(s))
189 extern "C++" template<class _Ty
> struct _RTL_CONSTANT_STRING_type_check_template
;
190 extern "C++" template<class _Ty
, int _Count
> struct _RTL_CONSTANT_STRING_type_check_template
<const _Ty (&)[_Count
]> { typedef char type
; };
191 #define _RTL_CONSTANT_STRING_type_check(s) _RTL_CONSTANT_STRING_type_check_template<decltype(s)>::type
193 # define _RTL_CONSTANT_STRING_remove_const_macro(s) (s)
194 char _RTL_CONSTANT_STRING_type_check(const void *s
);
196 #define RTL_CONSTANT_STRING(s) { \
197 sizeof(s)-sizeof((s)[0]), \
198 sizeof(s) / sizeof(_RTL_CONSTANT_STRING_type_check(s)), \
199 _RTL_CONSTANT_STRING_remove_const_macro(s) }
201 #define DECLARE_UNICODE_STRING_SIZE(_var, _size) \
202 WCHAR _var ## _buffer[_size]; \
203 __pragma(warning(push)) __pragma(warning(disable:4221)) __pragma(warning(disable:4204)) \
204 UNICODE_STRING _var = { 0, (_size) * sizeof(WCHAR) , _var ## _buffer } \
205 __pragma(warning(pop))
207 #define DECLARE_CONST_UNICODE_STRING(_var, _string) \
208 const WCHAR _var##_buffer[] = _string; \
209 __pragma(warning(push)) __pragma(warning(disable:4221)) __pragma(warning(disable:4204)) \
210 const UNICODE_STRING _var = { sizeof(_string) - sizeof(WCHAR), sizeof(_string), (PWCH)_var##_buffer } \
211 __pragma(warning(pop))
213 #define DECLARE_GLOBAL_CONST_UNICODE_STRING(_var, _str) \
214 extern const __declspec(selectany) UNICODE_STRING _var = RTL_CONSTANT_STRING(_str)
216 /* Object Attributes */
217 typedef struct _OBJECT_ATTRIBUTES
{
219 HANDLE RootDirectory
;
220 PUNICODE_STRING ObjectName
;
222 PVOID SecurityDescriptor
;
223 PVOID SecurityQualityOfService
;
224 } OBJECT_ATTRIBUTES
, *POBJECT_ATTRIBUTES
;
225 typedef CONST OBJECT_ATTRIBUTES
*PCOBJECT_ATTRIBUTES
;
227 typedef struct _OBJECT_ATTRIBUTES32
{
232 ULONG SecurityDescriptor
;
233 ULONG SecurityQualityOfService
;
234 } OBJECT_ATTRIBUTES32
, *POBJECT_ATTRIBUTES32
;
235 typedef CONST OBJECT_ATTRIBUTES32
*PCOBJECT_ATTRIBUTES32
;
237 typedef struct _OBJECT_ATTRIBUTES64
{
239 ULONG64 RootDirectory
;
242 ULONG64 SecurityDescriptor
;
243 ULONG64 SecurityQualityOfService
;
244 } OBJECT_ATTRIBUTES64
, *POBJECT_ATTRIBUTES64
;
245 typedef CONST OBJECT_ATTRIBUTES64
*PCOBJECT_ATTRIBUTES64
;
247 /* Values for the Attributes member */
248 #define OBJ_INHERIT 0x00000002L
249 #define OBJ_PERMANENT 0x00000010L
250 #define OBJ_EXCLUSIVE 0x00000020L
251 #define OBJ_CASE_INSENSITIVE 0x00000040L
252 #define OBJ_OPENIF 0x00000080L
253 #define OBJ_OPENLINK 0x00000100L
254 #define OBJ_KERNEL_HANDLE 0x00000200L
255 #define OBJ_FORCE_ACCESS_CHECK 0x00000400L
256 #define OBJ_VALID_ATTRIBUTES 0x000007F2L
259 #define InitializeObjectAttributes(p,n,a,r,s) { \
260 (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
261 (p)->RootDirectory = (r); \
262 (p)->ObjectName = (n); \
263 (p)->Attributes = (a); \
264 (p)->SecurityDescriptor = (s); \
265 (p)->SecurityQualityOfService = NULL; \
268 #define RTL_CONSTANT_OBJECT_ATTRIBUTES(n,a) { \
269 sizeof(OBJECT_ATTRIBUTES), \
271 RTL_CONST_CAST(PUNICODE_STRING)(n), \
277 #define RTL_INIT_OBJECT_ATTRIBUTES(n, a) \
278 RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
281 typedef enum _NT_PRODUCT_TYPE
{
285 } NT_PRODUCT_TYPE
, *PNT_PRODUCT_TYPE
;
287 typedef enum _EVENT_TYPE
{
292 typedef enum _TIMER_TYPE
{
297 typedef enum _WAIT_TYPE
{