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