xref: /reactos/sdk/include/xdk/ntddk.template.h (revision a8491259)
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 /* Forward declarations */
69 struct _LOADER_PARAMETER_BLOCK;
70 struct _CREATE_DISK;
71 struct _DRIVE_LAYOUT_INFORMATION_EX;
72 struct _SET_PARTITION_INFORMATION_EX;
73 struct _DISK_GEOMETRY_EX;
74 
75 /* Structures not exposed to drivers */
76 typedef struct _BUS_HANDLER *PBUS_HANDLER;
77 typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
78 #if defined(_NTHAL_INCLUDED_)
79 typedef struct _KAFFINITY_EX *PKAFFINITY_EX;
80 #endif
81 typedef struct _PEB *PPEB;
82 
83 #ifndef _NTIMAGE_
84 
85 typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32;
86 typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
87 
88 #ifdef _WIN64
89 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
90 #else
91 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
92 #endif
93 
94 #endif /* _NTIMAGE_ */
95 
96 $define (_NTDDK_)
97 $include (extypes.h)
98 $include (cmtypes.h)
99 $include (iotypes.h)
100 $include (haltypes.h)
101 $include (ketypes.h)
102 $include (kdtypes.h)
103 $include (mmtypes.h)
104 $include (pstypes.h)
105 $include (rtltypes.h)
106 $include (setypes.h)
107 
108 #if defined(_M_IX86)
109 $include(x86/ke.h)
110 $include(x86/mm.h)
111 #elif defined(_M_AMD64)
112 $include(amd64/ke.h)
113 $include(amd64/mm.h)
114 #elif defined(_M_IA64)
115 $include(ia64/ke.h)
116 #elif defined(_M_PPC)
117 $include(ppc/ke.h)
118 #elif defined(_M_MIPS)
119 $include(mips/ke.h)
120 #elif defined(_M_ARM)
121 $include(arm/ke.h)
122 $include(arm/mm.h)
123 #elif defined(_M_ARM64)
124 $include(arm64/ke.h)
125 #else
126 #error Unknown Architecture
127 #endif
128 
129 $include (exfuncs.h)
130 $include (halfuncs.h)
131 $include (iofuncs.h)
132 $include (kdfuncs.h)
133 $include (kefuncs.h)
134 $include (mmfuncs.h)
135 $include (psfuncs.h)
136 $include (rtlfuncs.h)
137 $include (sefuncs.h)
138 $include (zwfuncs.h)
139 
140 
141 /* UNSORTED */
142 
143 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
144   ((ConditionMask) = VerSetConditionMask((ConditionMask),             \
145   (TypeBitMask), (ComparisonType)))
146 
147 #if (NTDDI_VERSION >= NTDDI_WIN2K)
148 NTSYSAPI
149 ULONGLONG
150 NTAPI
151 VerSetConditionMask(
152   IN ULONGLONG ConditionMask,
153   IN ULONG TypeMask,
154   IN UCHAR Condition);
155 #endif
156 
157 typedef struct _KERNEL_USER_TIMES {
158   LARGE_INTEGER CreateTime;
159   LARGE_INTEGER ExitTime;
160   LARGE_INTEGER KernelTime;
161   LARGE_INTEGER UserTime;
162 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
163 
164 /* NtXxx Functions */
165 
166 typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION {
167   SystemFirmwareTable_Enumerate,
168   SystemFirmwareTable_Get
169 } SYSTEM_FIRMWARE_TABLE_ACTION;
170 
171 typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION {
172   ULONG ProviderSignature;
173   SYSTEM_FIRMWARE_TABLE_ACTION Action;
174   ULONG TableID;
175   ULONG TableBufferLength;
176   UCHAR TableBuffer[ANYSIZE_ARRAY];
177 } SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
178 
179 typedef NTSTATUS
180 (__cdecl *PFNFTH)(
181   _Inout_ PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo);
182 
183 typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER {
184   ULONG ProviderSignature;
185   BOOLEAN Register;
186   PFNFTH FirmwareTableHandler;
187   PVOID DriverObject;
188 } SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER;
189 
190 typedef ULONG_PTR
191 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
192   _In_ PVOID Context);
193 
194 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
195   PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
196   PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
197 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
198 
199 #define DRIVER_VERIFIER_SPECIAL_POOLING             0x0001
200 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING         0x0002
201 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES  0x0004
202 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS      0x0008
203 #define DRIVER_VERIFIER_IO_CHECKING                 0x0010
204 
205 #define SHARED_GLOBAL_FLAGS_ERROR_PORT_V        0x0
206 #define SHARED_GLOBAL_FLAGS_ERROR_PORT          (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V)
207 
208 #define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1
209 #define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED   (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V)
210 
211 #define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V      0x2
212 #define SHARED_GLOBAL_FLAGS_VIRT_ENABLED        (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V)
213 
214 #define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V  0x3
215 #define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED    \
216   (1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V)
217 
218 #define SHARED_GLOBAL_FLAGS_SPARE_V                     0x4
219 #define SHARED_GLOBAL_FLAGS_SPARE                       \
220   (1UL << SHARED_GLOBAL_FLAGS_SPARE_V)
221 
222 #define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V      0x5
223 #define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED        \
224   (1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V)
225 
226 #define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V    0x6
227 #define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED        \
228   (1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V)
229 
230 #define EX_INIT_BITS(Flags, Bit) \
231   *((Flags)) |= (Bit)             // Safe to use before concurrently accessible
232 
233 #define EX_TEST_SET_BIT(Flags, Bit) \
234   InterlockedBitTestAndSet ((PLONG)(Flags), (Bit))
235 
236 #define EX_TEST_CLEAR_BIT(Flags, Bit) \
237   InterlockedBitTestAndReset ((PLONG)(Flags), (Bit))
238 
239 #define PCCARD_MAP_ERROR               0x01
240 #define PCCARD_DEVICE_PCI              0x10
241 
242 #define PCCARD_SCAN_DISABLED           0x01
243 #define PCCARD_MAP_ZERO                0x02
244 #define PCCARD_NO_TIMER                0x03
245 #define PCCARD_NO_PIC                  0x04
246 #define PCCARD_NO_LEGACY_BASE          0x05
247 #define PCCARD_DUP_LEGACY_BASE         0x06
248 #define PCCARD_NO_CONTROLLERS          0x07
249 
250 #define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2))
251 
252 /* Filesystem runtime library routines */
253 
254 #if (NTDDI_VERSION >= NTDDI_WIN2K)
255 _Must_inspect_result_
256 NTKERNELAPI
257 BOOLEAN
258 NTAPI
259 FsRtlIsTotalDeviceFailure(
260   _In_ NTSTATUS Status);
261 #endif
262 
263 #ifdef __cplusplus
264 }
265 #endif
266