[XDK][DDK] Take the gcc path for __assert_annotation{A,W} and __CREATE_NTOS_DATA_IMPO...
[reactos.git] / sdk / include / xdk / ntddk.template.h
1 /*
2 * ntddk.h
3 *
4 * Windows NT Device Driver 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
24 #pragma once
25
26 #define _NTDDK_
27
28 #if !defined(_NTHAL_) && !defined(_NTIFS_)
29 #define _NTDDK_INCLUDED_
30 #define _DDK_DRIVER_
31 #endif
32
33 /* Dependencies */
34
35 #define NT_INCLUDED
36 #define _CTYPE_DISABLE_MACROS
37
38 #include <wdm.h>
39 #include <excpt.h>
40 #include <ntdef.h>
41 #include <ntstatus.h>
42 #include <mce.h>
43 #include <bugcodes.h>
44 #include <ntiologc.h>
45
46 #include <stdarg.h> // FIXME
47 #include <basetyps.h> // FIXME
48
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 /* GUID and UUID */
55 #ifndef _NTLSA_IFS_
56 #ifndef _NTLSA_AUDIT_
57 #define _NTLSA_AUDIT_
58
59 #ifndef GUID_DEFINED
60 #include <guiddef.h>
61 #endif
62
63 #endif /* _NTLSA_AUDIT_ */
64 #endif /* _NTLSA_IFS_ */
65
66 typedef GUID UUID;
67
68 struct _LOADER_PARAMETER_BLOCK;
69 struct _CREATE_DISK;
70 struct _DRIVE_LAYOUT_INFORMATION_EX;
71 struct _SET_PARTITION_INFORMATION_EX;
72 struct _DISK_GEOMETRY_EX;
73
74 typedef struct _BUS_HANDLER *PBUS_HANDLER;
75 typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
76 #if defined(_NTHAL_INCLUDED_)
77 typedef struct _KAFFINITY_EX *PKAFFINITY_EX;
78 #endif
79 typedef struct _PEB *PPEB;
80
81 #ifndef _NTIMAGE_
82
83 typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32;
84 typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
85
86 #ifdef _WIN64
87 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
88 #else
89 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
90 #endif
91
92 #endif /* _NTIMAGE_ */
93
94 $define (_NTDDK_)
95 $include (extypes.h)
96 $include (cmtypes.h)
97 $include (iotypes.h)
98 $include (haltypes.h)
99 $include (ketypes.h)
100 $include (kdtypes.h)
101 $include (mmtypes.h)
102 $include (pstypes.h)
103 $include (rtltypes.h)
104 $include (setypes.h)
105
106 #if defined(_M_IX86)
107 $include(x86/ke.h)
108 $include(x86/mm.h)
109 #elif defined(_M_AMD64)
110 $include(amd64/ke.h)
111 $include(amd64/mm.h)
112 #elif defined(_M_IA64)
113 $include(ia64/ke.h)
114 #elif defined(_M_PPC)
115 $include(ppc/ke.h)
116 #elif defined(_M_MIPS)
117 $include(mips/ke.h)
118 #elif defined(_M_ARM)
119 $include(arm/ke.h)
120 $include(arm/mm.h)
121 #else
122 #error Unknown Architecture
123 #endif
124
125 $include (exfuncs.h)
126 $include (halfuncs.h)
127 $include (iofuncs.h)
128 $include (kdfuncs.h)
129 $include (kefuncs.h)
130 $include (mmfuncs.h)
131 $include (psfuncs.h)
132 $include (rtlfuncs.h)
133 $include (sefuncs.h)
134 $include (zwfuncs.h)
135
136
137 /* UNSORTED */
138
139 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
140 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
141 (TypeBitMask), (ComparisonType)))
142
143 #if (NTDDI_VERSION >= NTDDI_WIN2K)
144 NTSYSAPI
145 ULONGLONG
146 NTAPI
147 VerSetConditionMask(
148 IN ULONGLONG ConditionMask,
149 IN ULONG TypeMask,
150 IN UCHAR Condition);
151 #endif
152
153 typedef struct _KERNEL_USER_TIMES {
154 LARGE_INTEGER CreateTime;
155 LARGE_INTEGER ExitTime;
156 LARGE_INTEGER KernelTime;
157 LARGE_INTEGER UserTime;
158 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
159
160 /* NtXxx Functions */
161
162 typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION {
163 SystemFirmwareTable_Enumerate,
164 SystemFirmwareTable_Get
165 } SYSTEM_FIRMWARE_TABLE_ACTION;
166
167 typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION {
168 ULONG ProviderSignature;
169 SYSTEM_FIRMWARE_TABLE_ACTION Action;
170 ULONG TableID;
171 ULONG TableBufferLength;
172 UCHAR TableBuffer[ANYSIZE_ARRAY];
173 } SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
174
175 typedef NTSTATUS
176 (__cdecl *PFNFTH)(
177 _Inout_ PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo);
178
179 typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER {
180 ULONG ProviderSignature;
181 BOOLEAN Register;
182 PFNFTH FirmwareTableHandler;
183 PVOID DriverObject;
184 } SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER;
185
186 typedef ULONG_PTR
187 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
188 _In_ PVOID Context);
189
190 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
191 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
192 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
193 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
194
195 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
196 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
197 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
198 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
199 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
200
201 #define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0
202 #define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V)
203
204 #define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1
205 #define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V)
206
207 #define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2
208 #define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V)
209
210 #define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3
211 #define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \
212 (1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V)
213
214 #define SHARED_GLOBAL_FLAGS_SPARE_V 0x4
215 #define SHARED_GLOBAL_FLAGS_SPARE \
216 (1UL << SHARED_GLOBAL_FLAGS_SPARE_V)
217
218 #define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5
219 #define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \
220 (1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V)
221
222 #define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6
223 #define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \
224 (1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V)
225
226 #define EX_INIT_BITS(Flags, Bit) \
227 *((Flags)) |= (Bit) // Safe to use before concurrently accessible
228
229 #define EX_TEST_SET_BIT(Flags, Bit) \
230 InterlockedBitTestAndSet ((PLONG)(Flags), (Bit))
231
232 #define EX_TEST_CLEAR_BIT(Flags, Bit) \
233 InterlockedBitTestAndReset ((PLONG)(Flags), (Bit))
234
235 #define PCCARD_MAP_ERROR 0x01
236 #define PCCARD_DEVICE_PCI 0x10
237
238 #define PCCARD_SCAN_DISABLED 0x01
239 #define PCCARD_MAP_ZERO 0x02
240 #define PCCARD_NO_TIMER 0x03
241 #define PCCARD_NO_PIC 0x04
242 #define PCCARD_NO_LEGACY_BASE 0x05
243 #define PCCARD_DUP_LEGACY_BASE 0x06
244 #define PCCARD_NO_CONTROLLERS 0x07
245
246 #define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2))
247
248 /* Filesystem runtime library routines */
249
250 #if (NTDDI_VERSION >= NTDDI_WIN2K)
251 _Must_inspect_result_
252 NTKERNELAPI
253 BOOLEAN
254 NTAPI
255 FsRtlIsTotalDeviceFailure(
256 _In_ NTSTATUS Status);
257 #endif
258
259 #ifdef __cplusplus
260 }
261 #endif