[XDK] Add some workarounds for the UM/KM types mismatches.
[reactos.git] / reactos / include / xdk / wdm.template.h
1 /*
2 * wdm.h
3 *
4 * Windows NT WDM Driver Developer Kit
5 *
6 * This file is part of the ReactOS DDK package.
7 *
8 * Contributors:
9 * Amine Khaldi (amine.khaldi@reactos.org)
10 * Timo Kreuzer (timo.kreuzer@reactos.org)
11 *
12 * THIS SOFTWARE IS NOT COPYRIGHTED
13 *
14 * This source code is offered for use in the public domain. You may
15 * use, modify or distribute it freely.
16 *
17 * This code is distributed in the hope that it will be useful but
18 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
19 * DISCLAIMED. This includes but is not limited to warranties of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 *
22 */
23 #pragma once
24
25 #ifndef _WDMDDK_
26 #define _WDMDDK_
27
28 #define WDM_MAJORVERSION 0x06
29 #define WDM_MINORVERSION 0x00
30
31 /* Included via ntddk.h? */
32 #ifndef _NTDDK_
33 #define _NTDDK_
34 #define _WDM_INCLUDED_
35 #define _DDK_DRIVER_
36 #define NO_INTERLOCKED_INTRINSICS
37 #endif /* _NTDDK_ */
38
39 /* Dependencies */
40 #define NT_INCLUDED
41 #include <excpt.h>
42 #include <ntdef.h>
43 #include <ntstatus.h>
44 #include <kernelspecs.h>
45 #include <ntiologc.h>
46 #include <suppress.h>
47
48 #ifndef GUID_DEFINED
49 #include <guiddef.h>
50 #endif
51
52 #ifdef _MAC
53 #ifndef _INC_STRING
54 #include <string.h>
55 #endif /* _INC_STRING */
56 #else
57 #include <string.h>
58 #endif /* _MAC */
59
60 #ifndef _KTMTYPES_
61 typedef GUID UOW, *PUOW;
62 #endif
63
64 typedef GUID *PGUID;
65
66 #if (NTDDI_VERSION >= NTDDI_WINXP)
67 #include <dpfilter.h>
68 #endif
69
70 #include "intrin.h"
71
72 __internal_kernel_driver
73 __drv_Mode_impl(WDM_INCLUDED)
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78
79 $define(ULONG=ULONG)
80
81 #if !defined(_NTHALDLL_) && !defined(_BLDR_)
82 #define NTHALAPI DECLSPEC_IMPORT
83 #else
84 #define NTHALAPI
85 #endif
86
87 /* For ReactOS */
88 #if !defined(_NTOSKRNL_) && !defined(_BLDR_) && !defined(_NTSYSTEM_)
89 #define NTKERNELAPI DECLSPEC_IMPORT
90 #else
91 #define NTKERNELAPI
92 #ifndef _NTSYSTEM_
93 #define _NTSYSTEM_
94 #endif
95 #endif
96
97 #if defined(_X86_) && !defined(_NTHAL_)
98 #define _DECL_HAL_KE_IMPORT DECLSPEC_IMPORT
99 #elif defined(_X86_)
100 #define _DECL_HAL_KE_IMPORT
101 #else
102 #define _DECL_HAL_KE_IMPORT NTKERNELAPI
103 #endif
104
105 #if defined(_WIN64)
106 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
107 #else
108 #define POINTER_ALIGNMENT
109 #endif
110
111 /* Helper macro to enable gcc's extension. */
112 #ifndef __GNU_EXTENSION
113 #ifdef __GNUC__
114 #define __GNU_EXTENSION __extension__
115 #else
116 #define __GNU_EXTENSION
117 #endif
118 #endif
119
120 #if defined(_MSC_VER)
121
122 /* Disable some warnings */
123 #pragma warning(disable:4115) /* Named type definition in parentheses */
124 #pragma warning(disable:4201) /* Nameless unions and structs */
125 #pragma warning(disable:4214) /* Bit fields of other types than int */
126 #pragma warning(disable:4820) /* Padding added, due to alignment requirement */
127
128 /* Indicate if #pragma alloc_text() is supported */
129 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64)
130 #define ALLOC_PRAGMA 1
131 #endif
132
133 /* Indicate if #pragma data_seg() is supported */
134 #if defined(_M_IX86) || defined(_M_AMD64)
135 #define ALLOC_DATA_PRAGMA 1
136 #endif
137
138 #endif /* _MSC_VER */
139
140 /* These macros are used to create aliases for imported data. We need to do
141 this to have declarations that are compatible with MS DDK */
142 #ifdef _M_IX86
143 #define __SYMBOL(_Name) "_"#_Name
144 #define __IMPORTSYMBOL(_Name) "__imp__"#_Name
145 #define __IMPORTNAME(_Name) __imp__##_Name
146 #else
147 #define __SYMBOL(_Name) #_Name
148 #define __IMPORTSYMBOL(_Name) "__imp_"#_Name
149 #define __IMPORTNAME(_Name) __imp_##_Name
150 #endif
151 #ifdef _MSC_VER
152 #define __CREATE_NTOS_DATA_IMPORT_ALIAS(_Name) \
153 __pragma(comment(linker, "/alternatename:"__SYMBOL(_Name) "=" __IMPORTSYMBOL(_Name)))
154 #else /* !_MSC_VER */
155 #ifndef __STRINGIFY
156 #define __STRINGIFY(_exp) #_exp
157 #endif
158 #define _Pragma_redefine_extname(_Name, _Target) _Pragma(__STRINGIFY(redefine_extname _Name _Target))
159 #define __CREATE_NTOS_DATA_IMPORT_ALIAS(_Name) \
160 _Pragma_redefine_extname(_Name,__IMPORTNAME(_Name))
161 #endif
162
163 #if defined(_WIN64)
164 #if !defined(USE_DMA_MACROS) && !defined(_NTHAL_)
165 #define USE_DMA_MACROS
166 #endif
167 #if !defined(NO_LEGACY_DRIVERS) && !defined(__REACTOS__)
168 #define NO_LEGACY_DRIVERS
169 #endif
170 #endif /* defined(_WIN64) */
171
172 /* Forward declarations */
173 struct _IRP;
174 struct _MDL;
175 struct _KAPC;
176 struct _KDPC;
177 struct _FILE_OBJECT;
178 struct _DMA_ADAPTER;
179 struct _DEVICE_OBJECT;
180 struct _DRIVER_OBJECT;
181 struct _IO_STATUS_BLOCK;
182 struct _DEVICE_DESCRIPTION;
183 struct _SCATTER_GATHER_LIST;
184 struct _DRIVE_LAYOUT_INFORMATION;
185 struct _COMPRESSED_DATA_INFO;
186 struct _IO_RESOURCE_DESCRIPTOR;
187
188 /* Structures not exposed to drivers */
189 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
190 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE;
191 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE;
192 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
193 typedef struct _EPROCESS *PEPROCESS;
194 typedef struct _ETHREAD *PETHREAD;
195 typedef struct _IO_TIMER *PIO_TIMER;
196 typedef struct _KINTERRUPT *PKINTERRUPT;
197 typedef struct _KPROCESS *PKPROCESS;
198 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
199 typedef struct _CONTEXT *PCONTEXT;
200
201 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_)
202 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
203 #elif defined(_WDM_INCLUDED_)
204 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
205 #else
206 typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
207 #endif
208
209 #ifndef DEFINE_GUIDEX
210 #ifdef _MSC_VER
211 #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
212 #else
213 #define DEFINE_GUIDEX(name) EXTERN_C const GUID name
214 #endif
215 #endif /* DEFINE_GUIDEX */
216
217 #ifndef STATICGUIDOF
218 #define STATICGUIDOF(guid) STATIC_##guid
219 #endif
220
221 /* GUID Comparison */
222 #ifndef __IID_ALIGNED__
223 #define __IID_ALIGNED__
224 #ifdef __cplusplus
225 inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2)
226 {
227 return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) &&
228 (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) );
229 }
230 #else
231 #define IsEqualGUIDAligned(guid1, guid2) \
232 ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \
233 (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) )
234 #endif /* __cplusplus */
235 #endif /* !__IID_ALIGNED__ */
236
237
238 $define (_WDMDDK_)
239 $include (interlocked.h)
240 $include (rtltypes.h)
241 $include (ketypes.h)
242 $include (mmtypes.h)
243 $include (extypes.h)
244 $include (setypes.h)
245 $include (potypes.h)
246 $include (cmtypes.h)
247 $include (iotypes.h)
248 $include (obtypes.h)
249 $include (pstypes.h)
250 $include (wmitypes.h)
251
252 $include (kefuncs.h)
253 $include (rtlfuncs.h)
254 $include (mmfuncs.h)
255 $include (sefuncs.h)
256 $include (cmfuncs.h)
257 $include (iofuncs.h)
258 $include (pofuncs.h)
259 $include (exfuncs.h)
260 $include (obfuncs.h)
261 $include (psfuncs.h)
262 $include (wmifuncs.h)
263 $include (kdfuncs.h)
264 $include (halfuncs.h)
265 $include (nttmapi.h)
266 $include (zwfuncs.h)
267
268 #ifdef __cplusplus
269 }
270 #endif
271
272 #endif /* !_WDMDDK_ */