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