d7c633d53e0f1f07d492d828ed991e527c8e65dd
[reactos.git] / 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
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 /* Included via ntddk.h? */
29 #ifndef _NTDDK_
30 #define _NTDDK_
31 #define _WDM_INCLUDED_
32 #define _DDK_DRIVER_
33 #define NO_INTERLOCKED_INTRINSICS
34 #endif /* _NTDDK_ */
35
36 /* Dependencies */
37 #define NT_INCLUDED
38 #include <excpt.h>
39 #include <ntdef.h>
40 #include <ntstatus.h>
41 #include <ntiologc.h>
42
43 #ifndef GUID_DEFINED
44 #include <guiddef.h>
45 #endif
46
47 #ifndef _KTMTYPES_
48 typedef GUID UOW, *PUOW;
49 #endif
50
51 typedef GUID *PGUID;
52
53 #if (NTDDI_VERSION >= NTDDI_WINXP)
54 #include <dpfilter.h>
55 #endif
56
57 #include "intrin.h"
58
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62
63 #if !defined(_NTHALDLL_) && !defined(_BLDR_)
64 #define NTHALAPI DECLSPEC_IMPORT
65 #else
66 #define NTHALAPI
67 #endif
68
69 /* For ReactOS */
70 #if !defined(_NTOSKRNL_) && !defined(_BLDR_)
71 #define NTKERNELAPI DECLSPEC_IMPORT
72 #else
73 #define NTKERNELAPI
74 #endif
75
76 #if defined(_X86_) && !defined(_NTHAL_)
77 #define _DECL_HAL_KE_IMPORT DECLSPEC_IMPORT
78 #elif defined(_X86_)
79 #define _DECL_HAL_KE_IMPORT
80 #else
81 #define _DECL_HAL_KE_IMPORT NTKERNELAPI
82 #endif
83
84 #if defined(_WIN64)
85 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
86 #else
87 #define POINTER_ALIGNMENT
88 #endif
89
90 /* Helper macro to enable gcc's extension. */
91 #ifndef __GNU_EXTENSION
92 #ifdef __GNUC__
93 #define __GNU_EXTENSION __extension__
94 #else
95 #define __GNU_EXTENSION
96 #endif
97 #endif
98
99 #if defined(_MSC_VER)
100
101 /* Indicate if #pragma alloc_text() is supported */
102 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64)
103 #define ALLOC_PRAGMA 1
104 #endif
105
106 /* Indicate if #pragma data_seg() is supported */
107 #if defined(_M_IX86) || defined(_M_AMD64)
108 #define ALLOC_DATA_PRAGMA 1
109 #endif
110
111 #endif
112
113 /* Forward declarations */
114 struct _IRP;
115 struct _MDL;
116 struct _KAPC;
117 struct _KDPC;
118 struct _FILE_OBJECT;
119 struct _DMA_ADAPTER;
120 struct _DEVICE_OBJECT;
121 struct _DRIVER_OBJECT;
122 struct _IO_STATUS_BLOCK;
123 struct _DEVICE_DESCRIPTION;
124 struct _SCATTER_GATHER_LIST;
125 struct _DRIVE_LAYOUT_INFORMATION;
126 struct _COMPRESSED_DATA_INFO;
127 struct _IO_RESOURCE_DESCRIPTOR;
128
129 /* Structures not exposed to drivers */
130 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
131 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE;
132 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE;
133 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
134 typedef struct _EPROCESS *PEPROCESS;
135 typedef struct _ETHREAD *PETHREAD;
136 typedef struct _IO_TIMER *PIO_TIMER;
137 typedef struct _KINTERRUPT *PKINTERRUPT;
138 typedef struct _KPROCESS *PKPROCESS;
139 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
140 typedef struct _CONTEXT *PCONTEXT;
141
142 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && ( defined(_NTDDK_) || defined(_NTDRIVER_) || defined(_NTOSP_))
143 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
144 #elif defined(_WDM_INCLUDED_)
145 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
146 #else
147 typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
148 #endif
149
150
151 $define (_WDMDDK_)
152 $include (interlocked.h)
153 $include (rtltypes.h)
154 $include (ketypes.h)
155 $include (mmtypes.h)
156 $include (extypes.h)
157 $include (setypes.h)
158 $include (potypes.h)
159 $include (cmtypes.h)
160 $include (iotypes.h)
161 $include (obtypes.h)
162 $include (pstypes.h)
163 $include (wmitypes.h)
164
165 #if defined(_M_IX86)
166 $include(x86/ke.h)
167 #elif defined(_M_AMD64)
168 $include(amd64/ke.h)
169 #elif defined(_M_IA64)
170 $include(ia64/ke.h)
171 #elif defined(_M_PPC)
172 $include(ppc/ke.h)
173 #elif defined(_M_MIPS)
174 $include(mips/ke.h)
175 #elif defined(_M_ARM)
176 $include(arm/ke.h)
177 #else
178 #error Unknown Architecture
179 #endif
180
181 $include (rtlfuncs.h)
182 $include (kefuncs.h)
183 $include (mmfuncs.h)
184 $include (sefuncs.h)
185 $include (cmfuncs.h)
186 $include (iofuncs.h)
187 $include (pofuncs.h)
188 $include (exfuncs.h)
189 $include (obfuncs.h)
190 $include (psfuncs.h)
191 $include (wmifuncs.h)
192 $include (kdfuncs.h)
193 $include (halfuncs.h)
194 $include (nttmapi.h)
195 $include (zwfuncs.h)
196
197 /******************************************************************************
198 * Unsorted *
199 ******************************************************************************/
200
201 #ifdef _MAC
202
203 #ifndef _INC_STRING
204 #include <string.h>
205 #endif
206
207 #else
208 #include <string.h>
209 #endif /* _MAC */
210
211 #ifndef DEFINE_GUIDEX
212 #ifdef _MSC_VER
213 #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
214 #else
215 #define DEFINE_GUIDEX(name) EXTERN_C const GUID name
216 #endif
217 #endif /* DEFINE_GUIDEX */
218
219 #ifndef STATICGUIDOF
220 #define STATICGUIDOF(guid) STATIC_##guid
221 #endif
222
223 /* GUID Comparison */
224 #ifndef __IID_ALIGNED__
225 #define __IID_ALIGNED__
226 #ifdef __cplusplus
227 inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2)
228 {
229 return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) &&
230 (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) );
231 }
232 #else
233 #define IsEqualGUIDAligned(guid1, guid2) \
234 ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \
235 (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) )
236 #endif /* __cplusplus */
237 #endif /* !__IID_ALIGNED__ */
238
239 #define MAXIMUM_SUSPEND_COUNT MAXCHAR
240
241 #define MAXIMUM_FILENAME_LENGTH 256
242
243 #define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\')
244
245 #define OBJECT_TYPE_CREATE (0x0001)
246 #define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
247
248 #define DIRECTORY_QUERY (0x0001)
249 #define DIRECTORY_TRAVERSE (0x0002)
250 #define DIRECTORY_CREATE_OBJECT (0x0004)
251 #define DIRECTORY_CREATE_SUBDIRECTORY (0x0008)
252 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
253
254 #define SYMBOLIC_LINK_QUERY 0x0001
255 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
256
257 #define DUPLICATE_CLOSE_SOURCE 0x00000001
258 #define DUPLICATE_SAME_ACCESS 0x00000002
259 #define DUPLICATE_SAME_ATTRIBUTES 0x00000004
260
261 /* Global debug flag */
262 #if DEVL
263 extern ULONG NtGlobalFlag;
264 #define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_ ## FlagName))
265 #else
266 #define IF_NTOS_DEBUG(FlagName) if(FALSE)
267 #endif
268
269 #ifndef _TRACEHANDLE_DEFINED
270 #define _TRACEHANDLE_DEFINED
271 typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE;
272 #endif
273
274 extern PBOOLEAN Mm64BitPhysicalAddress;
275
276 extern PVOID MmBadPointer;
277
278 #ifdef __cplusplus
279 }
280 #endif
281
282 #endif /* !_WDMDDK_ */