[XDK/DDK/NDK]
[reactos.git] / reactos / include / ddk / wdm.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 (amine.khaldi@reactos.org)
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 #define WDM_MAJORVERSION 0x06
29 #define WDM_MINORVERSION 0x00
30
31 /* Included via ntddk.h? */
32 #ifndef _NTDDK_
33 #define _NTDDK_
34 #define _WDM_INCLUDED_
35 #define _DDK_DRIVER_
36 #define NO_INTERLOCKED_INTRINSICS
37 #endif /* _NTDDK_ */
38
39 /* Dependencies */
40 #define NT_INCLUDED
41 #include <excpt.h>
42 #include <ntdef.h>
43 #include <ntstatus.h>
44 #include <kernelspecs.h>
45 #include <ntiologc.h>
46
47 #ifndef GUID_DEFINED
48 #include <guiddef.h>
49 #endif
50
51 #ifdef _MAC
52 #ifndef _INC_STRING
53 #include <string.h>
54 #endif /* _INC_STRING */
55 #else
56 #include <string.h>
57 #endif /* _MAC */
58
59 #ifndef _KTMTYPES_
60 typedef GUID UOW, *PUOW;
61 #endif
62
63 typedef GUID *PGUID;
64
65 #if (NTDDI_VERSION >= NTDDI_WINXP)
66 #include <dpfilter.h>
67 #endif
68
69 #include "intrin.h"
70
71 __internal_kernel_driver
72 __drv_Mode_impl(WDM_INCLUDED)
73
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77
78 #if !defined(_NTHALDLL_) && !defined(_BLDR_)
79 #define NTHALAPI DECLSPEC_IMPORT
80 #else
81 #define NTHALAPI
82 #endif
83
84 /* For ReactOS */
85 #if !defined(_NTOSKRNL_) && !defined(_BLDR_) && !defined(_NTSYSTEM_)
86 #define NTKERNELAPI DECLSPEC_IMPORT
87 #else
88 #define NTKERNELAPI
89 #ifndef _NTSYSTEM_
90 #define _NTSYSTEM_
91 #endif
92 #endif
93
94 #if defined(_X86_) && !defined(_NTHAL_)
95 #define _DECL_HAL_KE_IMPORT DECLSPEC_IMPORT
96 #elif defined(_X86_)
97 #define _DECL_HAL_KE_IMPORT
98 #else
99 #define _DECL_HAL_KE_IMPORT NTKERNELAPI
100 #endif
101
102 #if defined(_WIN64)
103 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
104 #else
105 #define POINTER_ALIGNMENT
106 #endif
107
108 /* Helper macro to enable gcc's extension. */
109 #ifndef __GNU_EXTENSION
110 #ifdef __GNUC__
111 #define __GNU_EXTENSION __extension__
112 #else
113 #define __GNU_EXTENSION
114 #endif
115 #endif
116
117 #if defined(_MSC_VER)
118
119 /* Disable some warnings */
120 #pragma warning(disable:4115) /* Named type definition in parentheses */
121 #pragma warning(disable:4201) /* Nameless unions and structs */
122 #pragma warning(disable:4214) /* Bit fields of other types than int */
123 #pragma warning(disable:4820) /* Padding added, due to alignment requirement */
124
125 /* Indicate if #pragma alloc_text() is supported */
126 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64)
127 #define ALLOC_PRAGMA 1
128 #endif
129
130 /* Indicate if #pragma data_seg() is supported */
131 #if defined(_M_IX86) || defined(_M_AMD64)
132 #define ALLOC_DATA_PRAGMA 1
133 #endif
134
135 #endif /* _MSC_VER */
136
137 /* These macros are used to create aliases for imported data. We need to do
138 this to have declarations that are compatible with MS DDK */
139 #ifdef _M_IX86
140 #define __SYMBOL(_Name) "_"#_Name
141 #define __IMPORTSYMBOL(_Name) "__imp__"#_Name
142 #define __IMPORTNAME(_Name) __imp__##_Name
143 #else
144 #define __SYMBOL(_Name) #_Name
145 #define __IMPORTSYMBOL(_Name) "__imp_"#_Name
146 #define __IMPORTNAME(_Name) __imp_##_Name
147 #endif
148 #ifdef _MSC_VER
149 #define __CREATE_NTOS_DATA_IMPORT_ALIAS(_Name) \
150 __pragma(comment(linker, "/alternatename:"__SYMBOL(_Name) "=" __IMPORTSYMBOL(_Name)))
151 #else /* !_MSC_VER */
152 #ifndef __STRINGIFY
153 #define __STRINGIFY(_exp) #_exp
154 #endif
155 #define _Pragma_redefine_extname(_Name, _Target) _Pragma(__STRINGIFY(redefine_extname _Name _Target))
156 #define __CREATE_NTOS_DATA_IMPORT_ALIAS(_Name) \
157 _Pragma_redefine_extname(_Name,__IMPORTNAME(_Name))
158 #endif
159
160 #if defined(_WIN64)
161 #if !defined(USE_DMA_MACROS) && !defined(_NTHAL_)
162 #define USE_DMA_MACROS
163 #endif
164 #if !defined(NO_LEGACY_DRIVERS) && !defined(__REACTOS__)
165 #define NO_LEGACY_DRIVERS
166 #endif
167 #endif /* defined(_WIN64) */
168
169 /* Forward declarations */
170 struct _IRP;
171 struct _MDL;
172 struct _KAPC;
173 struct _KDPC;
174 struct _FILE_OBJECT;
175 struct _DMA_ADAPTER;
176 struct _DEVICE_OBJECT;
177 struct _DRIVER_OBJECT;
178 struct _IO_STATUS_BLOCK;
179 struct _DEVICE_DESCRIPTION;
180 struct _SCATTER_GATHER_LIST;
181 struct _DRIVE_LAYOUT_INFORMATION;
182 struct _COMPRESSED_DATA_INFO;
183 struct _IO_RESOURCE_DESCRIPTOR;
184
185 /* Structures not exposed to drivers */
186 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
187 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE;
188 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE;
189 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
190 typedef struct _EPROCESS *PEPROCESS;
191 typedef struct _ETHREAD *PETHREAD;
192 typedef struct _IO_TIMER *PIO_TIMER;
193 typedef struct _KINTERRUPT *PKINTERRUPT;
194 typedef struct _KPROCESS *PKPROCESS;
195 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
196 typedef struct _CONTEXT *PCONTEXT;
197
198 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_)
199 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
200 #elif defined(_WDM_INCLUDED_)
201 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
202 #else
203 typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
204 #endif
205
206 #ifndef DEFINE_GUIDEX
207 #ifdef _MSC_VER
208 #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
209 #else
210 #define DEFINE_GUIDEX(name) EXTERN_C const GUID name
211 #endif
212 #endif /* DEFINE_GUIDEX */
213
214 #ifndef STATICGUIDOF
215 #define STATICGUIDOF(guid) STATIC_##guid
216 #endif
217
218 /* GUID Comparison */
219 #ifndef __IID_ALIGNED__
220 #define __IID_ALIGNED__
221 #ifdef __cplusplus
222 inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2)
223 {
224 return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) &&
225 (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) );
226 }
227 #else
228 #define IsEqualGUIDAligned(guid1, guid2) \
229 ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \
230 (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) )
231 #endif /* __cplusplus */
232 #endif /* !__IID_ALIGNED__ */
233
234
235 /******************************************************************************
236 * INTERLOCKED Functions *
237 ******************************************************************************/
238
239 #define BitScanForward _BitScanForward
240 #define BitScanReverse _BitScanReverse
241 #define BitTest _bittest
242 #define BitTestAndComplement _bittestandcomplement
243 #define BitTestAndSet _bittestandset
244 #define BitTestAndReset _bittestandreset
245 #ifdef _WIN64
246 #define BitScanForward64 _BitScanForward64
247 #define BitScanReverse64 _BitScanReverse64
248 #define BitTest64 _bittest64
249 #define BitTestAndComplement64 _bittestandcomplement64
250 #define BitTestAndSet64 _bittestandset64
251 #define BitTestAndReset64 _bittestandreset64
252 #endif /* _WIN64 */
253
254 #if defined(_M_ARM) || defined(_M_IA64)
255 #define __ACQ_(x) x##_acq
256 #define __REL_(x) x##_rel
257 #define __NF_(x) x##_nf
258 #else
259 #define __ACQ_(x) x
260 #define __REL_(x) x
261 #define __NF_(x) x
262 #endif
263
264 #define InterlockedBitTestAndSet _interlockedbittestandset
265 #define InterlockedBitTestAndSetAcquire __ACQ_(_interlockedbittestandset)
266 #define InterlockedBitTestAndSetRelease __REL_(_interlockedbittestandset)
267 #define InterlockedBitTestAndSetNoFence __NF_(_interlockedbittestandset)
268
269 #define InterlockedBitTestAndReset _interlockedbittestandreset
270 #define InterlockedBitTestAndResetAcquire __ACQ_(_interlockedbittestandreset)
271 #define InterlockedBitTestAndResetRelease __REL_(_interlockedbittestandreset)
272 #define InterlockedBitTestAndResetNoFence __NF_(_interlockedbittestandreset)
273
274 #ifdef _WIN64
275 #define InterlockedBitTestAndSet64 _interlockedbittestandset64
276 #define InterlockedBitTestAndSet64Acquire __ACQ_(_interlockedbittestandset64)
277 #define InterlockedBitTestAndSet64Release __REL_(_interlockedbittestandset64)
278 #define InterlockedBitTestAndSet64NoFence __NF_(_interlockedbittestandset64)
279
280 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64
281 #define InterlockedBitTestAndReset64Acquire __ACQ_(_interlockedbittestandreset64)
282 #define InterlockedBitTestAndReset64Release __REL_(_interlockedbittestandreset64)
283 #define InterlockedBitTestAndReset64NoFence __NF_(_interlockedbittestandreset64)
284 #endif /* _WIN64 */
285
286 #define InterlockedAdd _InterlockedAdd
287 #define InterlockedAddAcquire __ACQ_(_InterlockedAdd)
288 #define InterlockedAddRelease __REL_(_InterlockedAdd)
289 #define InterlockedAddNoFence __NF_(_InterlockedAdd)
290
291 #define InterlockedAdd64 _InterlockedAdd64
292 #define InterlockedAddAcquire64 __ACQ_(_InterlockedAdd64)
293 #define InterlockedAddRelease64 __REL_(_InterlockedAdd64)
294 #define InterlockedAddNoFence64 __NF_(_InterlockedAdd64)
295
296 #define InterlockedAnd _InterlockedAnd
297 #define InterlockedAndAcquire __ACQ_(_InterlockedAnd)
298 #define InterlockedAndRelease __REL_(_InterlockedAnd)
299 #define InterlockedAndNoFence __NF_(_InterlockedAnd)
300
301 #define InterlockedAnd8 _InterlockedAnd8
302 #ifdef _M_ARM
303 #define InterlockedAndAcquire8 _InterlockedAnd8_acq
304 #define InterlockedAndRelease8 _InterlockedAnd8_rel
305 #define InterlockedAndNoFence8 _InterlockedAnd8_nf
306 #elif defined(_M_IA64)
307 #define InterlockedAnd8Acquire _InterlockedAnd8_acq
308 #define InterlockedAnd8Release _InterlockedAnd8_rel
309 #endif // _M_ARM
310
311 #define InterlockedAnd16 _InterlockedAnd16
312 #ifdef _M_ARM
313 #define InterlockedAndAcquire16 _InterlockedAnd16_acq
314 #define InterlockedAndRelease16 _InterlockedAnd16_rel
315 #define InterlockedAndNoFence16 _InterlockedAnd16_nf
316 #elif defined(_M_IA64)
317 #define InterlockedAnd16Acquire _InterlockedAnd16_acq
318 #define InterlockedAnd16Release _InterlockedAnd16_rel
319 #endif // _M_ARM
320
321 #define InterlockedAnd64 _InterlockedAnd64
322 #ifdef _M_ARM
323 #define InterlockedAndAcquire64 __ACQ_(_InterlockedAnd64)
324 #define InterlockedAndRelease64 __REL_(_InterlockedAnd64)
325 #define InterlockedAndNoFence64 __NF_(_InterlockedAnd64)
326 #else // _M_ARM
327 #define InterlockedAnd64Acquire __ACQ_(_InterlockedAnd64)
328 #define InterlockedAnd64Release __REL_(_InterlockedAnd64)
329 #define InterlockedAnd64NoFence __NF_(_InterlockedAnd64)
330 #endif // _M_ARM
331
332 #ifdef _WIN64
333 #define InterlockedAndAffinity InterlockedAnd64
334 #else
335 #define InterlockedAndAffinity InterlockedAnd
336 #endif // _WIN64
337
338 #define InterlockedCompareExchange _InterlockedCompareExchange
339 #define InterlockedCompareExchangeAcquire __ACQ_(_InterlockedCompareExchange)
340 #define InterlockedCompareExchangeRelease __REL_(_InterlockedCompareExchange)
341 #define InterlockedCompareExchangeNoFence __NF_(_InterlockedCompareExchange)
342
343 #define InterlockedCompareExchange16 _InterlockedCompareExchange16
344 #define InterlockedCompareExchangeAcquire16 __ACQ_(_InterlockedCompareExchange16)
345 #define InterlockedCompareExchangeRelease16 __REL_(_InterlockedCompareExchange16)
346 #define InterlockedCompareExchangeNoFence16 __NF_(_InterlockedCompareExchange16)
347
348 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
349 #define InterlockedCompareExchangeAcquire64 __ACQ_(_InterlockedCompareExchange64)
350 #define InterlockedCompareExchangeRelease64 __REL_(_InterlockedCompareExchange64)
351 #define InterlockedCompareExchangeNoFence64 __NF_(_InterlockedCompareExchange64)
352
353 #ifdef _WIN64
354 #define InterlockedCompareExchange128 _InterlockedCompareExchange128
355 #endif // _WIN64
356
357 #ifdef _M_IA64
358 #define InterlockedCompare64Exchange128 _InterlockedCompare64Exchange128
359 #define InterlockedCompare64ExchangeAcquire128 _InterlockedCompare64Exchange128_acq
360 #define InterlockedCompare64ExchangeRelease128 _InterlockedCompare64Exchange128_rel
361 #endif // _M_IA64
362
363 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
364 #define InterlockedCompareExchangePointerAcquire __ACQ_(_InterlockedCompareExchangePointer)
365 #define InterlockedCompareExchangePointerRelease __REL_(_InterlockedCompareExchangePointer)
366 #define InterlockedCompareExchangePointerNoFence __NF_(_InterlockedCompareExchangePointer)
367
368 #define InterlockedDecrement _InterlockedDecrement
369 #define InterlockedDecrementAcquire __ACQ_(_InterlockedDecrement)
370 #define InterlockedDecrementRelease __REL_(_InterlockedDecrement)
371 #define InterlockedDecrementNoFence __NF_(_InterlockedDecrement)
372
373 #define InterlockedDecrement16 _InterlockedDecrement16
374 #define InterlockedDecrementAcquire16 __ACQ_(_InterlockedDecrement16)
375 #define InterlockedDecrementRelease16 __REL_(_InterlockedDecrement16)
376 #define InterlockedDecrementNoFence16 __NF_(_InterlockedDecrement16)
377
378 #define InterlockedDecrement64 _InterlockedDecrement64
379 #define InterlockedDecrementAcquire64 __ACQ_(_InterlockedDecrement64)
380 #define InterlockedDecrementRelease64 __REL_(_InterlockedDecrement64)
381 #define InterlockedDecrementNoFence64 __NF_(_InterlockedDecrement64)
382
383 #ifdef _WIN64
384 #define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONG64 *)a)
385 #define InterlockedDecrementSizeTNoFence(a) InterlockedDecrementNoFence64((LONG64 *)a)
386 #else
387 #define InterlockedDecrementSizeT(a) InterlockedDecrement((LONG *)a)
388 #define InterlockedDecrementSizeTNoFence(a) InterlockedDecrementNoFence((LONG *)a)
389 #endif // _WIN64
390
391 #define InterlockedExchange _InterlockedExchange
392 #define InterlockedExchangeAcquire __ACQ_(_InterlockedExchange)
393 /* No release here */
394 #define InterlockedExchangeNoFence __NF_(_InterlockedExchange)
395
396 #if (_MSC_VER >= 1600)
397 #define InterlockedExchange8 _InterlockedExchange8
398 #endif // (_MSC_VER >= 1600)
399
400 #define InterlockedExchange16 _InterlockedExchange16
401 /* No release here */
402 #define InterlockedExchangeAcquire16 __ACQ_(_InterlockedExchange16)
403 #define InterlockedExchangeNoFence16 __NF_(_InterlockedExchange16)
404
405 #define InterlockedExchange64 _InterlockedExchange64
406 #define InterlockedExchangeAcquire64 __ACQ_(_InterlockedExchange64)
407 /* No release here */
408 #define InterlockedExchangeNoFence64 __NF_(_InterlockedExchange64)
409
410 #define InterlockedExchangePointer _InterlockedExchangePointer
411 #define InterlockedExchangePointerAcquire __ACQ_(_InterlockedExchangePointer)
412 /* No release here */
413 #define InterlockedExchangePointerNoFence __NF_(_InterlockedExchangePointer)
414
415 #define InterlockedExchangeAdd _InterlockedExchangeAdd
416 #define InterlockedExchangeAddAcquire __ACQ_(_InterlockedExchangeAdd)
417 #define InterlockedExchangeAddRelease __REL_(_InterlockedExchangeAdd)
418 #define InterlockedExchangeAddNoFence __NF_(_InterlockedExchangeAdd)
419
420 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
421 #define InterlockedExchangeAddAcquire64 __ACQ_(_InterlockedExchangeAdd64)
422 #define InterlockedExchangeAddRelease64 __REL_(_InterlockedExchangeAdd64)
423 #define InterlockedExchangeAddNoFence64 __NF_(_InterlockedExchangeAdd64)
424
425 #ifdef _WIN64
426 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONG64 *)a, b)
427 #define InterlockedExchangeAddSizeTAcquire(a, b) InterlockedExchangeAddAcquire64((LONG64 *)a, b)
428 #define InterlockedExchangeAddSizeTNoFence(a, b) InterlockedExchangeAddNoFence64((LONG64 *)a, b)
429 #else
430 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)a, b)
431 #define InterlockedExchangeAddSizeTAcquire(a, b) InterlockedExchangeAddAcquire((LONG *)a, b)
432 #define InterlockedExchangeAddSizeTNoFence(a, b) InterlockedExchangeAddNoFence((LONG *)a, b)
433 #endif // _WIN64
434
435 #define InterlockedIncrement _InterlockedIncrement
436 #define InterlockedIncrementAcquire __ACQ_(_InterlockedIncrement)
437 #define InterlockedIncrementRelease __REL_(_InterlockedIncrement)
438 #define InterlockedIncrementNoFence __NF_(_InterlockedIncrement)
439
440 #define InterlockedIncrement16 _InterlockedIncrement16
441 #define InterlockedIncrementAcquire16 __ACQ_(_InterlockedIncrement16)
442 #define InterlockedIncrementRelease16 __REL_(_InterlockedIncrement16)
443 #define InterlockedIncrementNoFence16 __NF_(_InterlockedIncrement16)
444
445 #define InterlockedIncrement64 _InterlockedIncrement64
446 #define InterlockedIncrementAcquire64 __ACQ_(_InterlockedIncrement64)
447 #define InterlockedIncrementRelease64 __REL_(_InterlockedIncrement64)
448 #define InterlockedIncrementNoFence64 __NF_(_InterlockedIncrement64)
449
450 #ifdef _WIN64
451 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONG64 *)a)
452 #define InterlockedIncrementSizeTNoFence(a) InterlockedIncrementNoFence64((LONG64 *)a)
453 #else
454 #define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)a)
455 #define InterlockedIncrementSizeTNoFence(a) InterlockedIncrementNoFence((LONG *)a)
456 #endif // _WIN64
457
458 #define InterlockedOr _InterlockedOr
459 #define InterlockedOrAcquire __ACQ_(_InterlockedOr)
460 #define InterlockedOrRelease __REL_(_InterlockedOr)
461 #define InterlockedOrNoFence __NF_(_InterlockedOr)
462
463 #define InterlockedOr8 _InterlockedOr8
464 #ifdef _M_ARM
465 #define InterlockedOrAcquire8 _InterlockedOr8_acq
466 #define InterlockedOrRelease8 _InterlockedOr8_rel
467 #define InterlockedOrNoFence8 _InterlockedOr8_nf
468 #elif defined(_M_IA64)
469 #define InterlockedOr8Acquire _InterlockedOr8_acq
470 #define InterlockedOr8Release _InterlockedOr8_rel
471 #endif // _M_ARM
472
473 #define InterlockedOr16 _InterlockedOr16
474 #ifdef _M_ARM
475 #define InterlockedOrAcquire16 _InterlockedOr16_acq
476 #define InterlockedOrRelease16 _InterlockedOr16_rel
477 #define InterlockedOrNoFence16 _InterlockedOr16_nf
478 #elif defined(_M_IA64)
479 #define InterlockedOr16Acquire _InterlockedOr16_acq
480 #define InterlockedOr16Release _InterlockedOr16_rel
481 #endif // _M_ARM
482
483 #define InterlockedOr64 _InterlockedOr64
484 #ifdef _M_ARM
485 #define InterlockedOrAcquire64 _InterlockedOr64_acq
486 #define InterlockedOrRelease64 _InterlockedOr64_rel
487 #define InterlockedOrNoFence64 _InterlockedOr64_nf
488 #elif defined(_M_IA64) || defined(_M_AMD64)
489 #define InterlockedOr64Acquire __ACQ_(_InterlockedOr64)
490 #define InterlockedOr64Release __REL_(_InterlockedOr64)
491 #define InterlockedOr64NoFence __NF_(_InterlockedOr64)
492 #endif // _M_ARM
493
494 #ifdef _WIN64
495 #define InterlockedOrAffinity InterlockedOr64
496 #else
497 #define InterlockedOrAffinity InterlockedOr
498 #endif // _WIN64
499
500 #define InterlockedXor _InterlockedXor
501 #define InterlockedXorAcquire __ACQ_(_InterlockedXor)
502 #define InterlockedXorRelease __REL_(_InterlockedXor)
503 #define InterlockedXorNoFence __NF_(_InterlockedXor)
504
505 #define InterlockedXor8 _InterlockedXor8
506 #ifdef _M_ARM
507 #define InterlockedXorAcquire8 _InterlockedXor8_acq
508 #define InterlockedXorRelease8 _InterlockedXor8_rel
509 #define InterlockedXorNoFence8 _InterlockedXor8_nf
510 #elif defined(_M_IA64)
511 #define InterlockedXor8Acquire _InterlockedXor8_acq
512 #define InterlockedXor8Release _InterlockedXor8_rel
513 #endif /* _M_ARM */
514
515 #define InterlockedXor16 _InterlockedXor16
516 #ifdef _M_ARM
517 #define InterlockedXorAcquire16 _InterlockedXor16_acq
518 #define InterlockedXorRelease16 _InterlockedXor16_rel
519 #define InterlockedXorNoFence16 _InterlockedXor16_nf
520 #elif defined(_M_IA64)
521 #define InterlockedXor16Acquire _InterlockedXor16_acq
522 #define InterlockedXor16Release _InterlockedXor16_rel
523 #endif /* _M_ARM */
524
525 #define InterlockedXor64 _InterlockedXor64
526 #ifdef _M_ARM
527 #define InterlockedXorAcquire64 _InterlockedXor64_acq
528 #define InterlockedXorRelease64 _InterlockedXor64_rel
529 #define InterlockedXorNoFence64 _InterlockedXor64_nf
530 #elif defined(_M_IA64) || defined(_M_AMD64)
531 #define InterlockedXor64Acquire __ACQ_(_InterlockedXor64)
532 #define InterlockedXor64Release __REL_(_InterlockedXor64)
533 #define InterlockedXor64NoFence __NF_(_InterlockedXor64)
534 #endif /* _M_ARM */
535
536 #ifdef _M_IX86
537
538 FORCEINLINE
539 LONG64
540 _InterlockedExchange64(
541 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
542 _In_ LONG64 Value)
543 {
544 LONG64 Old, Prev;
545 for (Old = *Target; ; Old = Prev)
546 {
547 Prev = _InterlockedCompareExchange64(Target, Value, Old);
548 if (Prev == Old)
549 return Prev;
550 }
551 }
552
553 FORCEINLINE
554 LONG64
555 _InterlockedAdd64(
556 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
557 _In_ LONG64 Value)
558 {
559 LONG64 Old, Prev, New;
560 for (Old = *Target; ; Old = Prev)
561 {
562 New = Old + Value;
563 Prev = _InterlockedCompareExchange64(Target, New, Old);
564 if (Prev == Old)
565 return New;
566 }
567 }
568
569 FORCEINLINE
570 LONG64
571 _InterlockedExchangeAdd64 (
572 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
573 _In_ LONG64 Value
574 )
575 {
576 LONG64 Old, Prev, New;
577 for (Old = *Target; ; Old = Prev)
578 {
579 New = Old + Value;
580 Prev = _InterlockedCompareExchange64(Target, New, Old);
581 if (Prev == Old)
582 return Prev;
583 }
584 }
585
586 FORCEINLINE
587 LONG64
588 _InterlockedAnd64(
589 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
590 _In_ LONG64 Value)
591 {
592 LONG64 Old, Prev, New;
593 for (Old = *Target; ; Old = Prev)
594 {
595 New = Old & Value;
596 Prev = _InterlockedCompareExchange64(Target, New, Old);
597 if (Prev == Old)
598 return New;
599 }
600 }
601
602 FORCEINLINE
603 LONG64
604 _InterlockedOr64(
605 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
606 _In_ LONG64 Value)
607 {
608 LONG64 Old, Prev, New;
609 for (Old = *Target; ; Old = Prev)
610 {
611 New = Old | Value;
612 Prev = _InterlockedCompareExchange64(Target, New, Old);
613 if (Prev == Old)
614 return New;
615 }
616 }
617
618 FORCEINLINE
619 LONG64
620 _InterlockedXor64(
621 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
622 _In_ LONG64 Value)
623 {
624 LONG64 Old, Prev, New;
625 for (Old = *Target; ; Old = Prev)
626 {
627 New = Old ^ Value;
628 Prev = _InterlockedCompareExchange64(Target, New, Old);
629 if (Prev == Old)
630 return New;
631 }
632 }
633
634 FORCEINLINE
635 LONG64
636 _InterlockedIncrement64(
637 _Inout_ _Interlocked_operand_ volatile LONG64 *Target)
638 {
639 return _InterlockedAdd64(Target, 1);
640 }
641
642 FORCEINLINE
643 LONG64
644 _InterlockedDecrement64(
645 _Inout_ _Interlocked_operand_ volatile LONG64 *Target)
646 {
647 return _InterlockedAdd64(Target, -1);
648 }
649
650 #undef _InterlockedExchangePointer
651 #define _InterlockedExchangePointer _InlineInterlockedExchangePointer
652 FORCEINLINE
653 _Ret_writes_(_Inexpressible_(Unknown))
654 PVOID
655 _InterlockedExchangePointer(
656 _Inout_ _At_(*Destination, _Pre_writable_byte_size_(_Inexpressible_(Unknown))
657 _Post_writable_byte_size_(_Inexpressible_(Unknown)))
658 _Interlocked_operand_ volatile PVOID *Destination,
659 _In_opt_ PVOID Value)
660 {
661 return (PVOID)InterlockedExchange((volatile long *)Destination, (long)Value);
662 }
663
664 #undef _InterlockedCompareExchangePointer
665 #define _InterlockedCompareExchangePointer _InlineInterlockedCompareExchangePointer
666 FORCEINLINE
667 _Ret_writes_(_Inexpressible_(Unknown))
668 PVOID
669 _InterlockedCompareExchangePointer(
670 _Inout_ _At_(*Destination, _Pre_writable_byte_size_(_Inexpressible_(Unknown))
671 _Post_writable_byte_size_(_Inexpressible_(Unknown)))
672 _Interlocked_operand_ volatile PVOID *Destination,
673 _In_opt_ PVOID ExChange,
674 _In_opt_ PVOID Comperand)
675 {
676 return (PVOID)InterlockedCompareExchange((volatile long *)Destination,
677 (long)ExChange,
678 (long)Comperand);
679 }
680
681 #endif /* _M_IX86 */
682
683 #ifdef _M_AMD64
684
685 FORCEINLINE
686 LONG64
687 _InterlockedAdd64(
688 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
689 _In_ LONG64 Value)
690
691 {
692 return _InterlockedExchangeAdd64(Target, Value) + Value;
693 }
694
695 #endif /* _M_AMD64 */
696
697 #ifdef _M_IA64
698
699 #undef _InterlockedBitTestAndSet
700 #define _InterlockedBitTestAndSet InterlockedBitTestAndSet_Inline
701 FORCEINLINE
702 BOOLEAN
703 _InterlockedBitTestAndSet(
704 _Inout_ _Interlocked_operand_ volatile LONG *Target,
705 _In_ LONG Bit)
706 {
707 ULONG Mask = 1 << (Bit & 31);
708 return (BOOLEAN)((InterlockedOr(&Target[Bit / 32], Mask) & Mask) != 0);
709 }
710
711 #undef _InterlockedBitTestAndReset
712 #define _InterlockedBitTestAndReset InterlockedBitTestAndReset_Inline
713 FORCEINLINE
714 BOOLEAN
715 _InterlockedBitTestAndReset(
716 _Inout_ _Interlocked_operand_ volatile LONG *Target,
717 _In_ LONG Bit)
718 {
719 ULONG Mask = 1 << (Bit & 31);
720 return (BOOLEAN)((InterlockedAnd(&Target[Bit / 32], ~Mask) & Mask) != 0);
721 }
722
723 #undef _InterlockedBitTestAndSet64
724 #define _InterlockedBitTestAndSet64 InterlockedBitTestAndSet64_Inline
725 FORCEINLINE
726 BOOLEAN
727 _InterlockedBitTestAndSet64(
728 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
729 _In_ LONG64 Bit)
730 {
731 ULONG64 Mask = 1LL << (Bit & 63);
732 return (BOOLEAN)((InterlockedOr64(&Target[Bit / 64], Mask) & Mask) != 0);
733 }
734
735 #undef _InterlockedBitTestAndReset64
736 #define _InterlockedBitTestAndReset64 InterlockedBitTestAndReset64_Inline
737 FORCEINLINE
738 BOOLEAN
739 _InterlockedBitTestAndReset64(
740 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
741 _In_ LONG64 Bit)
742 {
743 ULONG64 Mask = 1LL << (Bit & 63);
744 return (BOOLEAN)((InterlockedAnd64(&Target[Bit / 64], ~Mask) & Mask) != 0);
745 }
746
747 #undef _InterlockedBitTestAndComplement
748 #define _InterlockedBitTestAndComplement InterlockedBitTestAndComplement_Inline
749 FORCEINLINE
750 BOOLEAN
751 _InterlockedBitTestAndComplement(
752 _Inout_ _Interlocked_operand_ volatile LONG *Target,
753 _In_ LONG Bit)
754 {
755 ULONG Mask = 1 << (Bit & 31);
756 return (BOOLEAN)((InterlockedXor(&Target[Bit / 32], Mask) & Mask) != 0);
757 }
758
759 #undef _InterlockedBitTestAndComplement64
760 #define _InterlockedBitTestAndComplement64 InterlockedBitTestAndComplement64_Inline
761 FORCEINLINE
762 BOOLEAN
763 _InterlockedBitTestAndComplement64(
764 _Inout_ _Interlocked_operand_ volatile LONG64 *Target,
765 _In_ LONG64 Bit)
766 {
767 ULONG64 Mask = 1LL << (Bit & 63);
768 return (BOOLEAN)((InterlockedXor64(&Target[Bit / 64], Mask) & Mask) != 0);
769 }
770
771 #endif /* M_IA64 */
772
773 /******************************************************************************
774 * Runtime Library Types *
775 ******************************************************************************/
776
777 #define RTL_REGISTRY_ABSOLUTE 0
778 #define RTL_REGISTRY_SERVICES 1
779 #define RTL_REGISTRY_CONTROL 2
780 #define RTL_REGISTRY_WINDOWS_NT 3
781 #define RTL_REGISTRY_DEVICEMAP 4
782 #define RTL_REGISTRY_USER 5
783 #define RTL_REGISTRY_MAXIMUM 6
784 #define RTL_REGISTRY_HANDLE 0x40000000
785 #define RTL_REGISTRY_OPTIONAL 0x80000000
786
787 /* RTL_QUERY_REGISTRY_TABLE.Flags */
788 #define RTL_QUERY_REGISTRY_SUBKEY 0x00000001
789 #define RTL_QUERY_REGISTRY_TOPKEY 0x00000002
790 #define RTL_QUERY_REGISTRY_REQUIRED 0x00000004
791 #define RTL_QUERY_REGISTRY_NOVALUE 0x00000008
792 #define RTL_QUERY_REGISTRY_NOEXPAND 0x00000010
793 #define RTL_QUERY_REGISTRY_DIRECT 0x00000020
794 #define RTL_QUERY_REGISTRY_DELETE 0x00000040
795
796 #define HASH_STRING_ALGORITHM_DEFAULT 0
797 #define HASH_STRING_ALGORITHM_X65599 1
798 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
799
800 typedef struct _RTL_BITMAP {
801 ULONG SizeOfBitMap;
802 PULONG Buffer;
803 } RTL_BITMAP, *PRTL_BITMAP;
804
805 typedef struct _RTL_BITMAP_RUN {
806 ULONG StartingIndex;
807 ULONG NumberOfBits;
808 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
809
810 _Function_class_(RTL_QUERY_REGISTRY_ROUTINE)
811 _IRQL_requires_max_(PASSIVE_LEVEL)
812 _IRQL_requires_same_
813 typedef NTSTATUS
814 (NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)(
815 _In_z_ PWSTR ValueName,
816 _In_ ULONG ValueType,
817 _In_reads_bytes_opt_(ValueLength) PVOID ValueData,
818 _In_ ULONG ValueLength,
819 _In_opt_ PVOID Context,
820 _In_opt_ PVOID EntryContext);
821
822 typedef struct _RTL_QUERY_REGISTRY_TABLE {
823 PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
824 ULONG Flags;
825 PCWSTR Name;
826 PVOID EntryContext;
827 ULONG DefaultType;
828 PVOID DefaultData;
829 ULONG DefaultLength;
830 } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
831
832 typedef struct _TIME_FIELDS {
833 CSHORT Year;
834 CSHORT Month;
835 CSHORT Day;
836 CSHORT Hour;
837 CSHORT Minute;
838 CSHORT Second;
839 CSHORT Milliseconds;
840 CSHORT Weekday;
841 } TIME_FIELDS, *PTIME_FIELDS;
842
843 /* Slist Header */
844 #ifndef _SLIST_HEADER_
845 #define _SLIST_HEADER_
846
847 #if defined(_WIN64)
848
849 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
850 struct _SLIST_ENTRY *Next;
851 } SLIST_ENTRY, *PSLIST_ENTRY;
852
853 typedef struct _SLIST_ENTRY32 {
854 ULONG Next;
855 } SLIST_ENTRY32, *PSLIST_ENTRY32;
856
857 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
858 _ANONYMOUS_STRUCT struct {
859 ULONGLONG Alignment;
860 ULONGLONG Region;
861 } DUMMYSTRUCTNAME;
862 struct {
863 ULONGLONG Depth:16;
864 ULONGLONG Sequence:9;
865 ULONGLONG NextEntry:39;
866 ULONGLONG HeaderType:1;
867 ULONGLONG Init:1;
868 ULONGLONG Reserved:59;
869 ULONGLONG Region:3;
870 } Header8;
871 struct {
872 ULONGLONG Depth:16;
873 ULONGLONG Sequence:48;
874 ULONGLONG HeaderType:1;
875 ULONGLONG Init:1;
876 ULONGLONG Reserved:2;
877 ULONGLONG NextEntry:60;
878 } Header16;
879 struct {
880 ULONGLONG Depth:16;
881 ULONGLONG Sequence:48;
882 ULONGLONG HeaderType:1;
883 ULONGLONG Reserved:3;
884 ULONGLONG NextEntry:60;
885 } HeaderX64;
886 } SLIST_HEADER, *PSLIST_HEADER;
887
888 typedef union _SLIST_HEADER32 {
889 ULONGLONG Alignment;
890 _ANONYMOUS_STRUCT struct {
891 SLIST_ENTRY32 Next;
892 USHORT Depth;
893 USHORT Sequence;
894 } DUMMYSTRUCTNAME;
895 } SLIST_HEADER32, *PSLIST_HEADER32;
896
897 #else
898
899 #define SLIST_ENTRY SINGLE_LIST_ENTRY
900 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
901 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
902
903 typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32;
904
905 typedef union _SLIST_HEADER {
906 ULONGLONG Alignment;
907 _ANONYMOUS_STRUCT struct {
908 SLIST_ENTRY Next;
909 USHORT Depth;
910 USHORT Sequence;
911 } DUMMYSTRUCTNAME;
912 } SLIST_HEADER, *PSLIST_HEADER;
913
914 typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32;
915
916 #endif /* defined(_WIN64) */
917
918 #endif /* _SLIST_HEADER_ */
919
920 /* Exception record flags */
921 #define EXCEPTION_NONCONTINUABLE 0x01
922 #define EXCEPTION_UNWINDING 0x02
923 #define EXCEPTION_EXIT_UNWIND 0x04
924 #define EXCEPTION_STACK_INVALID 0x08
925 #define EXCEPTION_NESTED_CALL 0x10
926 #define EXCEPTION_TARGET_UNWIND 0x20
927 #define EXCEPTION_COLLIDED_UNWIND 0x40
928 #define EXCEPTION_UNWIND (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND | \
929 EXCEPTION_TARGET_UNWIND | EXCEPTION_COLLIDED_UNWIND)
930
931 #define IS_UNWINDING(Flag) ((Flag & EXCEPTION_UNWIND) != 0)
932 #define IS_DISPATCHING(Flag) ((Flag & EXCEPTION_UNWIND) == 0)
933 #define IS_TARGET_UNWIND(Flag) (Flag & EXCEPTION_TARGET_UNWIND)
934
935 #define EXCEPTION_MAXIMUM_PARAMETERS 15
936
937 /* Exception records */
938 typedef struct _EXCEPTION_RECORD {
939 NTSTATUS ExceptionCode;
940 ULONG ExceptionFlags;
941 struct _EXCEPTION_RECORD *ExceptionRecord;
942 PVOID ExceptionAddress;
943 ULONG NumberParameters;
944 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
945 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
946
947 typedef struct _EXCEPTION_RECORD32 {
948 NTSTATUS ExceptionCode;
949 ULONG ExceptionFlags;
950 ULONG ExceptionRecord;
951 ULONG ExceptionAddress;
952 ULONG NumberParameters;
953 ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
954 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
955
956 typedef struct _EXCEPTION_RECORD64 {
957 NTSTATUS ExceptionCode;
958 ULONG ExceptionFlags;
959 ULONG64 ExceptionRecord;
960 ULONG64 ExceptionAddress;
961 ULONG NumberParameters;
962 ULONG __unusedAlignment;
963 ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
964 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
965
966 typedef struct _EXCEPTION_POINTERS {
967 PEXCEPTION_RECORD ExceptionRecord;
968 PCONTEXT ContextRecord;
969 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
970
971 #ifdef _NTSYSTEM_
972 extern BOOLEAN NlsMbCodePageTag;
973 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
974 extern BOOLEAN NlsMbOemCodePageTag;
975 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
976 #else
977 __CREATE_NTOS_DATA_IMPORT_ALIAS(NlsMbCodePageTag)
978 extern BOOLEAN *NlsMbCodePageTag;
979 #define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
980 __CREATE_NTOS_DATA_IMPORT_ALIAS(NlsMbOemCodePageTag)
981 extern BOOLEAN *NlsMbOemCodePageTag;
982 #define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
983 #endif
984
985 #define SHORT_LEAST_SIGNIFICANT_BIT 0
986 #define SHORT_MOST_SIGNIFICANT_BIT 1
987
988 #define LONG_LEAST_SIGNIFICANT_BIT 0
989 #define LONG_3RD_MOST_SIGNIFICANT_BIT 1
990 #define LONG_2ND_MOST_SIGNIFICANT_BIT 2
991 #define LONG_MOST_SIGNIFICANT_BIT 3
992
993 #define RTLVERLIB_DDI(x) Wdmlib##x
994
995 typedef BOOLEAN
996 (*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)(
997 _In_ ULONG Version);
998
999 typedef BOOLEAN
1000 (*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)(
1001 _In_ ULONG Version);
1002
1003 typedef struct _OSVERSIONINFOA {
1004 ULONG dwOSVersionInfoSize;
1005 ULONG dwMajorVersion;
1006 ULONG dwMinorVersion;
1007 ULONG dwBuildNumber;
1008 ULONG dwPlatformId;
1009 CHAR szCSDVersion[128];
1010 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
1011
1012 typedef struct _OSVERSIONINFOW {
1013 ULONG dwOSVersionInfoSize;
1014 ULONG dwMajorVersion;
1015 ULONG dwMinorVersion;
1016 ULONG dwBuildNumber;
1017 ULONG dwPlatformId;
1018 WCHAR szCSDVersion[128];
1019 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
1020
1021 typedef struct _OSVERSIONINFOEXA {
1022 ULONG dwOSVersionInfoSize;
1023 ULONG dwMajorVersion;
1024 ULONG dwMinorVersion;
1025 ULONG dwBuildNumber;
1026 ULONG dwPlatformId;
1027 CHAR szCSDVersion[128];
1028 USHORT wServicePackMajor;
1029 USHORT wServicePackMinor;
1030 USHORT wSuiteMask;
1031 UCHAR wProductType;
1032 UCHAR wReserved;
1033 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
1034
1035 typedef struct _OSVERSIONINFOEXW {
1036 ULONG dwOSVersionInfoSize;
1037 ULONG dwMajorVersion;
1038 ULONG dwMinorVersion;
1039 ULONG dwBuildNumber;
1040 ULONG dwPlatformId;
1041 WCHAR szCSDVersion[128];
1042 USHORT wServicePackMajor;
1043 USHORT wServicePackMinor;
1044 USHORT wSuiteMask;
1045 UCHAR wProductType;
1046 UCHAR wReserved;
1047 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
1048
1049 #ifdef UNICODE
1050 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
1051 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
1052 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
1053 typedef OSVERSIONINFOW OSVERSIONINFO;
1054 typedef POSVERSIONINFOW POSVERSIONINFO;
1055 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
1056 #else
1057 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
1058 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
1059 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
1060 typedef OSVERSIONINFOA OSVERSIONINFO;
1061 typedef POSVERSIONINFOA POSVERSIONINFO;
1062 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
1063 #endif /* UNICODE */
1064
1065 /******************************************************************************
1066 * Kernel Types *
1067 ******************************************************************************/
1068
1069 typedef UCHAR KIRQL, *PKIRQL;
1070 typedef CCHAR KPROCESSOR_MODE;
1071 typedef LONG KPRIORITY;
1072
1073 typedef enum _MODE {
1074 KernelMode,
1075 UserMode,
1076 MaximumMode
1077 } MODE;
1078
1079 #define CACHE_FULLY_ASSOCIATIVE 0xFF
1080 #define MAXIMUM_SUSPEND_COUNT MAXCHAR
1081
1082 #define EVENT_QUERY_STATE (0x0001)
1083 #define EVENT_MODIFY_STATE (0x0002)
1084 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
1085
1086 #define LTP_PC_SMT 0x1
1087
1088 #if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS)
1089 #define SINGLE_GROUP_LEGACY_API 1
1090 #endif
1091
1092 #define SEMAPHORE_QUERY_STATE (0x0001)
1093 #define SEMAPHORE_MODIFY_STATE (0x0002)
1094 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
1095
1096 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP {
1097 RelationProcessorCore,
1098 RelationNumaNode,
1099 RelationCache,
1100 RelationProcessorPackage,
1101 RelationGroup,
1102 RelationAll = 0xffff
1103 } LOGICAL_PROCESSOR_RELATIONSHIP;
1104
1105 typedef enum _PROCESSOR_CACHE_TYPE {
1106 CacheUnified,
1107 CacheInstruction,
1108 CacheData,
1109 CacheTrace
1110 } PROCESSOR_CACHE_TYPE;
1111
1112 typedef struct _CACHE_DESCRIPTOR {
1113 UCHAR Level;
1114 UCHAR Associativity;
1115 USHORT LineSize;
1116 ULONG Size;
1117 PROCESSOR_CACHE_TYPE Type;
1118 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
1119
1120 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION {
1121 ULONG_PTR ProcessorMask;
1122 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
1123 _ANONYMOUS_UNION union {
1124 struct {
1125 UCHAR Flags;
1126 } ProcessorCore;
1127 struct {
1128 ULONG NodeNumber;
1129 } NumaNode;
1130 CACHE_DESCRIPTOR Cache;
1131 ULONGLONG Reserved[2];
1132 } DUMMYUNIONNAME;
1133 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
1134
1135 typedef struct _PROCESSOR_RELATIONSHIP {
1136 UCHAR Flags;
1137 UCHAR Reserved[21];
1138 USHORT GroupCount;
1139 _Field_size_(GroupCount) GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
1140 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
1141
1142 typedef struct _NUMA_NODE_RELATIONSHIP {
1143 ULONG NodeNumber;
1144 UCHAR Reserved[20];
1145 GROUP_AFFINITY GroupMask;
1146 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
1147
1148 typedef struct _CACHE_RELATIONSHIP {
1149 UCHAR Level;
1150 UCHAR Associativity;
1151 USHORT LineSize;
1152 ULONG CacheSize;
1153 PROCESSOR_CACHE_TYPE Type;
1154 UCHAR Reserved[20];
1155 GROUP_AFFINITY GroupMask;
1156 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
1157
1158 typedef struct _PROCESSOR_GROUP_INFO {
1159 UCHAR MaximumProcessorCount;
1160 UCHAR ActiveProcessorCount;
1161 UCHAR Reserved[38];
1162 KAFFINITY ActiveProcessorMask;
1163 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
1164
1165 typedef struct _GROUP_RELATIONSHIP {
1166 USHORT MaximumGroupCount;
1167 USHORT ActiveGroupCount;
1168 UCHAR Reserved[20];
1169 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
1170 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
1171
1172 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX {
1173 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
1174 ULONG Size;
1175 _ANONYMOUS_UNION union {
1176 PROCESSOR_RELATIONSHIP Processor;
1177 NUMA_NODE_RELATIONSHIP NumaNode;
1178 CACHE_RELATIONSHIP Cache;
1179 GROUP_RELATIONSHIP Group;
1180 } DUMMYUNIONNAME;
1181 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;;
1182
1183 /* Processor features */
1184 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
1185 #define PF_FLOATING_POINT_EMULATED 1
1186 #define PF_COMPARE_EXCHANGE_DOUBLE 2
1187 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
1188 #define PF_PPC_MOVEMEM_64BIT_OK 4
1189 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
1190 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
1191 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
1192 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
1193 #define PF_PAE_ENABLED 9
1194 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
1195 #define PF_SSE_DAZ_MODE_AVAILABLE 11
1196 #define PF_NX_ENABLED 12
1197 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
1198 #define PF_COMPARE_EXCHANGE128 14
1199 #define PF_COMPARE64_EXCHANGE128 15
1200 #define PF_CHANNELS_ENABLED 16
1201 #define PF_XSAVE_ENABLED 17
1202
1203 #define MAXIMUM_WAIT_OBJECTS 64
1204
1205 #define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject)
1206
1207 #define ASSERT_DPC(Object) \
1208 ASSERT(((Object)->Type == 0) || \
1209 ((Object)->Type == DpcObject) || \
1210 ((Object)->Type == ThreadedDpcObject))
1211
1212 #define ASSERT_GATE(object) \
1213 NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \
1214 (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject))
1215
1216 #define ASSERT_DEVICE_QUEUE(Object) \
1217 NT_ASSERT((Object)->Type == DeviceQueueObject)
1218
1219 #define ASSERT_TIMER(E) \
1220 NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \
1221 ((E)->Header.Type == TimerSynchronizationObject))
1222
1223 #define ASSERT_MUTANT(E) \
1224 NT_ASSERT((E)->Header.Type == MutantObject)
1225
1226 #define ASSERT_SEMAPHORE(E) \
1227 NT_ASSERT((E)->Header.Type == SemaphoreObject)
1228
1229 #define ASSERT_EVENT(E) \
1230 NT_ASSERT(((E)->Header.Type == NotificationEvent) || \
1231 ((E)->Header.Type == SynchronizationEvent))
1232
1233 #define DPC_NORMAL 0
1234 #define DPC_THREADED 1
1235
1236 #define GM_LOCK_BIT 0x1
1237 #define GM_LOCK_BIT_V 0x0
1238 #define GM_LOCK_WAITER_WOKEN 0x2
1239 #define GM_LOCK_WAITER_INC 0x4
1240
1241 #define LOCK_QUEUE_WAIT_BIT 0
1242 #define LOCK_QUEUE_OWNER_BIT 1
1243
1244 #define LOCK_QUEUE_WAIT 1
1245 #define LOCK_QUEUE_OWNER 2
1246 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4
1247 #define LOCK_QUEUE_TIMER_TABLE_LOCKS (1 << (8 - LOCK_QUEUE_TIMER_LOCK_SHIFT))
1248
1249 #define PROCESSOR_FEATURE_MAX 64
1250
1251 #define DBG_STATUS_CONTROL_C 1
1252 #define DBG_STATUS_SYSRQ 2
1253 #define DBG_STATUS_BUGCHECK_FIRST 3
1254 #define DBG_STATUS_BUGCHECK_SECOND 4
1255 #define DBG_STATUS_FATAL 5
1256 #define DBG_STATUS_DEBUG_CONTROL 6
1257 #define DBG_STATUS_WORKER 7
1258
1259 #if defined(_WIN64)
1260 #define MAXIMUM_PROC_PER_GROUP 64
1261 #else
1262 #define MAXIMUM_PROC_PER_GROUP 32
1263 #endif
1264 #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP
1265
1266 #define EXCEPTION_DIVIDED_BY_ZERO 0
1267 #define EXCEPTION_DEBUG 1
1268 #define EXCEPTION_NMI 2
1269 #define EXCEPTION_INT3 3
1270 #define EXCEPTION_BOUND_CHECK 5
1271 #define EXCEPTION_INVALID_OPCODE 6
1272 #define EXCEPTION_NPX_NOT_AVAILABLE 7
1273 #define EXCEPTION_DOUBLE_FAULT 8
1274 #define EXCEPTION_NPX_OVERRUN 9
1275 #define EXCEPTION_INVALID_TSS 0x0A
1276 #define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B
1277 #define EXCEPTION_STACK_FAULT 0x0C
1278 #define EXCEPTION_GP_FAULT 0x0D
1279 #define EXCEPTION_RESERVED_TRAP 0x0F
1280 #define EXCEPTION_NPX_ERROR 0x010
1281 #define EXCEPTION_ALIGNMENT_CHECK 0x011
1282
1283 typedef enum _KBUGCHECK_CALLBACK_REASON {
1284 KbCallbackInvalid,
1285 KbCallbackReserved1,
1286 KbCallbackSecondaryDumpData,
1287 KbCallbackDumpIo,
1288 KbCallbackAddPages
1289 } KBUGCHECK_CALLBACK_REASON;
1290
1291 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
1292
1293 _Function_class_(KBUGCHECK_REASON_CALLBACK_ROUTINE)
1294 _IRQL_requires_same_
1295 typedef VOID
1296 (NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)(
1297 _In_ KBUGCHECK_CALLBACK_REASON Reason,
1298 _In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
1299 _Inout_ PVOID ReasonSpecificData,
1300 _In_ ULONG ReasonSpecificDataLength);
1301 typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE;
1302
1303 typedef struct _KBUGCHECK_ADD_PAGES {
1304 _Inout_ PVOID Context;
1305 _Inout_ ULONG Flags;
1306 _In_ ULONG BugCheckCode;
1307 _Out_ ULONG_PTR Address;
1308 _Out_ ULONG_PTR Count;
1309 } KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES;
1310
1311 typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA {
1312 _In_ PVOID InBuffer;
1313 _In_ ULONG InBufferLength;
1314 _In_ ULONG MaximumAllowed;
1315 _Out_ GUID Guid;
1316 _Out_ PVOID OutBuffer;
1317 _Out_ ULONG OutBufferLength;
1318 } KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA;
1319
1320 typedef enum _KBUGCHECK_DUMP_IO_TYPE {
1321 KbDumpIoInvalid,
1322 KbDumpIoHeader,
1323 KbDumpIoBody,
1324 KbDumpIoSecondaryData,
1325 KbDumpIoComplete
1326 } KBUGCHECK_DUMP_IO_TYPE;
1327
1328 typedef struct _KBUGCHECK_DUMP_IO {
1329 _In_ ULONG64 Offset;
1330 _In_ PVOID Buffer;
1331 _In_ ULONG BufferLength;
1332 _In_ KBUGCHECK_DUMP_IO_TYPE Type;
1333 } KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO;
1334
1335 #define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL
1336 #define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL
1337 #define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL
1338
1339 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
1340 LIST_ENTRY Entry;
1341 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
1342 PUCHAR Component;
1343 ULONG_PTR Checksum;
1344 KBUGCHECK_CALLBACK_REASON Reason;
1345 UCHAR State;
1346 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
1347
1348 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
1349 BufferEmpty,
1350 BufferInserted,
1351 BufferStarted,
1352 BufferFinished,
1353 BufferIncomplete
1354 } KBUGCHECK_BUFFER_DUMP_STATE;
1355
1356 _Function_class_(KBUGCHECK_CALLBACK_ROUTINE)
1357 _IRQL_requires_same_
1358 typedef VOID
1359 (NTAPI KBUGCHECK_CALLBACK_ROUTINE)(
1360 IN PVOID Buffer,
1361 IN ULONG Length);
1362 typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE;
1363
1364 typedef struct _KBUGCHECK_CALLBACK_RECORD {
1365 LIST_ENTRY Entry;
1366 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
1367 _Field_size_bytes_opt_(Length) PVOID Buffer;
1368 ULONG Length;
1369 PUCHAR Component;
1370 ULONG_PTR Checksum;
1371 UCHAR State;
1372 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
1373
1374 _Function_class_(NMI_CALLBACK)
1375 _IRQL_requires_same_
1376 typedef BOOLEAN
1377 (NTAPI NMI_CALLBACK)(
1378 _In_opt_ PVOID Context,
1379 _In_ BOOLEAN Handled);
1380 typedef NMI_CALLBACK *PNMI_CALLBACK;
1381
1382 typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE {
1383 KeProcessorAddStartNotify = 0,
1384 KeProcessorAddCompleteNotify,
1385 KeProcessorAddFailureNotify
1386 } KE_PROCESSOR_CHANGE_NOTIFY_STATE;
1387
1388 typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT {
1389 KE_PROCESSOR_CHANGE_NOTIFY_STATE State;
1390 ULONG NtNumber;
1391 NTSTATUS Status;
1392 #if (NTDDI_VERSION >= NTDDI_WIN7)
1393 PROCESSOR_NUMBER ProcNumber;
1394 #endif
1395 } KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT;
1396
1397 _IRQL_requires_same_
1398 _Function_class_(PROCESSOR_CALLBACK_FUNCTION)
1399 typedef VOID
1400 (NTAPI PROCESSOR_CALLBACK_FUNCTION)(
1401 _In_ PVOID CallbackContext,
1402 _In_ PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext,
1403 _Inout_ PNTSTATUS OperationStatus);
1404 typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION;
1405
1406 #define KE_PROCESSOR_CHANGE_ADD_EXISTING 1
1407
1408 #define INVALID_PROCESSOR_INDEX 0xffffffff
1409
1410 typedef enum _KINTERRUPT_POLARITY {
1411 InterruptPolarityUnknown,
1412 InterruptActiveHigh,
1413 InterruptActiveLow
1414 } KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY;
1415
1416 typedef enum _KPROFILE_SOURCE {
1417 ProfileTime,
1418 ProfileAlignmentFixup,
1419 ProfileTotalIssues,
1420 ProfilePipelineDry,
1421 ProfileLoadInstructions,
1422 ProfilePipelineFrozen,
1423 ProfileBranchInstructions,
1424 ProfileTotalNonissues,
1425 ProfileDcacheMisses,
1426 ProfileIcacheMisses,
1427 ProfileCacheMisses,
1428 ProfileBranchMispredictions,
1429 ProfileStoreInstructions,
1430 ProfileFpInstructions,
1431 ProfileIntegerInstructions,
1432 Profile2Issue,
1433 Profile3Issue,
1434 Profile4Issue,
1435 ProfileSpecialInstructions,
1436 ProfileTotalCycles,
1437 ProfileIcacheIssues,
1438 ProfileDcacheAccesses,
1439 ProfileMemoryBarrierCycles,
1440 ProfileLoadLinkedIssues,
1441 ProfileMaximum
1442 } KPROFILE_SOURCE;
1443
1444 typedef enum _KWAIT_REASON {
1445 Executive,
1446 FreePage,
1447 PageIn,
1448 PoolAllocation,
1449 DelayExecution,
1450 Suspended,
1451 UserRequest,
1452 WrExecutive,
1453 WrFreePage,
1454 WrPageIn,
1455 WrPoolAllocation,
1456 WrDelayExecution,
1457 WrSuspended,
1458 WrUserRequest,
1459 WrEventPair,
1460 WrQueue,
1461 WrLpcReceive,
1462 WrLpcReply,
1463 WrVirtualMemory,
1464 WrPageOut,
1465 WrRendezvous,
1466 WrKeyedEvent,
1467 WrTerminated,
1468 WrProcessInSwap,
1469 WrCpuRateControl,
1470 WrCalloutStack,
1471 WrKernel,
1472 WrResource,
1473 WrPushLock,
1474 WrMutex,
1475 WrQuantumEnd,
1476 WrDispatchInt,
1477 WrPreempted,
1478 WrYieldExecution,
1479 WrFastMutex,
1480 WrGuardedMutex,
1481 WrRundown,
1482 MaximumWaitReason
1483 } KWAIT_REASON;
1484
1485 typedef struct _KWAIT_BLOCK {
1486 LIST_ENTRY WaitListEntry;
1487 struct _KTHREAD *Thread;
1488 PVOID Object;
1489 struct _KWAIT_BLOCK *NextWaitBlock;
1490 USHORT WaitKey;
1491 UCHAR WaitType;
1492 #if (NTDDI_VERSION >= NTDDI_WIN7)
1493 volatile UCHAR BlockState;
1494 #else
1495 UCHAR SpareByte;
1496 #endif
1497 #if defined(_WIN64)
1498 LONG SpareLong;
1499 #endif
1500 } KWAIT_BLOCK, *PKWAIT_BLOCK, *PRKWAIT_BLOCK;
1501
1502 typedef enum _KINTERRUPT_MODE {
1503 LevelSensitive,
1504 Latched
1505 } KINTERRUPT_MODE;
1506
1507 #define THREAD_WAIT_OBJECTS 3
1508
1509 _IRQL_requires_same_
1510 _Function_class_(KSTART_ROUTINE)
1511 typedef VOID
1512 (NTAPI KSTART_ROUTINE)(
1513 _In_ PVOID StartContext);
1514 typedef KSTART_ROUTINE *PKSTART_ROUTINE;
1515
1516 typedef VOID
1517 (NTAPI *PKINTERRUPT_ROUTINE)(
1518 VOID);
1519
1520 _Function_class_(KSERVICE_ROUTINE)
1521 _IRQL_requires_(HIGH_LEVEL)
1522 _IRQL_requires_same_
1523 typedef BOOLEAN
1524 (NTAPI KSERVICE_ROUTINE)(
1525 _In_ struct _KINTERRUPT *Interrupt,
1526 _In_ PVOID ServiceContext);
1527 typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
1528
1529 _Function_class_(KMESSAGE_SERVICE_ROUTINE)
1530 _IRQL_requires_same_
1531 typedef BOOLEAN
1532 (NTAPI KMESSAGE_SERVICE_ROUTINE)(
1533 _In_ struct _KINTERRUPT *Interrupt,
1534 _In_ PVOID ServiceContext,
1535 _In_ ULONG MessageID);
1536 typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE;
1537
1538 typedef enum _KD_OPTION {
1539 KD_OPTION_SET_BLOCK_ENABLE,
1540 } KD_OPTION;
1541
1542 #ifdef _NTSYSTEM_
1543 typedef VOID
1544 (NTAPI *PKNORMAL_ROUTINE)(
1545 IN PVOID NormalContext OPTIONAL,
1546 IN PVOID SystemArgument1 OPTIONAL,
1547 IN PVOID SystemArgument2 OPTIONAL);
1548
1549 typedef VOID
1550 (NTAPI *PKRUNDOWN_ROUTINE)(
1551 IN struct _KAPC *Apc);
1552
1553 typedef VOID
1554 (NTAPI *PKKERNEL_ROUTINE)(
1555 IN struct _KAPC *Apc,
1556 IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL,
1557 IN OUT PVOID *NormalContext OPTIONAL,
1558 IN OUT PVOID *SystemArgument1 OPTIONAL,
1559 IN OUT PVOID *SystemArgument2 OPTIONAL);
1560 #endif
1561
1562 typedef struct _KAPC {
1563 UCHAR Type;
1564 UCHAR SpareByte0;
1565 UCHAR Size;
1566 UCHAR SpareByte1;
1567 ULONG SpareLong0;
1568 struct _KTHREAD *Thread;
1569 LIST_ENTRY ApcListEntry;
1570 #ifdef _NTSYSTEM_
1571 PKKERNEL_ROUTINE KernelRoutine;
1572 PKRUNDOWN_ROUTINE RundownRoutine;
1573 PKNORMAL_ROUTINE NormalRoutine;
1574 #else
1575 PVOID Reserved[3];
1576 #endif
1577 PVOID NormalContext;
1578 PVOID SystemArgument1;
1579 PVOID SystemArgument2;
1580 CCHAR ApcStateIndex;
1581 KPROCESSOR_MODE ApcMode;
1582 BOOLEAN Inserted;
1583 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
1584
1585 #define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0)
1586 #define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1)
1587 #define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0)
1588 #define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1)
1589 #define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2)
1590 #define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex)
1591 #define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN))
1592
1593 typedef struct _KDEVICE_QUEUE_ENTRY {
1594 LIST_ENTRY DeviceListEntry;
1595 ULONG SortKey;
1596 BOOLEAN Inserted;
1597 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
1598 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
1599
1600 typedef PVOID PKIPI_CONTEXT;
1601
1602 typedef VOID
1603 (NTAPI *PKIPI_WORKER)(
1604 IN OUT PKIPI_CONTEXT PacketContext,
1605 IN PVOID Parameter1 OPTIONAL,
1606 IN PVOID Parameter2 OPTIONAL,
1607 IN PVOID Parameter3 OPTIONAL);
1608
1609 typedef struct _KIPI_COUNTS {
1610 ULONG Freeze;
1611 ULONG Packet;
1612 ULONG DPC;
1613 ULONG APC;
1614 ULONG FlushSingleTb;
1615 ULONG FlushMultipleTb;
1616 ULONG FlushEntireTb;
1617 ULONG GenericCall;
1618 ULONG ChangeColor;
1619 ULONG SweepDcache;
1620 ULONG SweepIcache;
1621 ULONG SweepIcacheRange;
1622 ULONG FlushIoBuffers;
1623 ULONG GratuitousDPC;
1624 } KIPI_COUNTS, *PKIPI_COUNTS;
1625
1626 _IRQL_requires_same_
1627 _Function_class_(KIPI_BROADCAST_WORKER)
1628 _IRQL_requires_(IPI_LEVEL)
1629 typedef ULONG_PTR
1630 (NTAPI KIPI_BROADCAST_WORKER)(
1631 _In_ ULONG_PTR Argument);
1632 typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER;
1633
1634 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
1635
1636 typedef struct _KSPIN_LOCK_QUEUE {
1637 struct _KSPIN_LOCK_QUEUE *volatile Next;
1638 PKSPIN_LOCK volatile Lock;
1639 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
1640
1641 typedef struct _KLOCK_QUEUE_HANDLE {
1642 KSPIN_LOCK_QUEUE LockQueue;
1643 KIRQL OldIrql;
1644 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
1645
1646 #if defined(_AMD64_)
1647
1648 typedef ULONG64 KSPIN_LOCK_QUEUE_NUMBER;
1649
1650 #define LockQueueDispatcherLock 0
1651 #define LockQueueExpansionLock 1
1652 #define LockQueuePfnLock 2
1653 #define LockQueueSystemSpaceLock 3
1654 #define LockQueueVacbLock 4
1655 #define LockQueueMasterLock 5
1656 #define LockQueueNonPagedPoolLock 6
1657 #define LockQueueIoCancelLock 7
1658 #define LockQueueWorkQueueLock 8
1659 #define LockQueueIoVpbLock 9
1660 #define LockQueueIoDatabaseLock 10
1661 #define LockQueueIoCompletionLock 11
1662 #define LockQueueNtfsStructLock 12
1663 #define LockQueueAfdWorkQueueLock 13
1664 #define LockQueueBcbLock 14
1665 #define LockQueueMmNonPagedPoolLock 15
1666 #define LockQueueUnusedSpare16 16
1667 #define LockQueueTimerTableLock 17
1668 #define LockQueueMaximumLock (LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS)
1669
1670 #else
1671
1672 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
1673 LockQueueDispatcherLock,
1674 LockQueueExpansionLock,
1675 LockQueuePfnLock,
1676 LockQueueSystemSpaceLock,
1677 LockQueueVacbLock,
1678 LockQueueMasterLock,
1679 LockQueueNonPagedPoolLock,
1680 LockQueueIoCancelLock,
1681 LockQueueWorkQueueLock,
1682 LockQueueIoVpbLock,
1683 LockQueueIoDatabaseLock,
1684 LockQueueIoCompletionLock,
1685 LockQueueNtfsStructLock,
1686 LockQueueAfdWorkQueueLock,
1687 LockQueueBcbLock,
1688 LockQueueMmNonPagedPoolLock,
1689 LockQueueUnusedSpare16,
1690 LockQueueTimerTableLock,
1691 LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS
1692 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
1693
1694 #endif /* defined(_AMD64_) */
1695
1696 _Function_class_(KDEFERRED_ROUTINE)
1697 _IRQL_requires_(DISPATCH_LEVEL)
1698 _IRQL_requires_same_
1699 typedef VOID
1700 (NTAPI KDEFERRED_ROUTINE)(
1701 _In_ struct _KDPC *Dpc,
1702 _In_opt_ PVOID DeferredContext,
1703 _In_opt_ PVOID SystemArgument1,
1704 _In_opt_ PVOID SystemArgument2);
1705 typedef KDEFERRED_ROUTINE *PKDEFERRED_ROUTINE;
1706
1707 typedef enum _KDPC_IMPORTANCE {
1708 LowImportance,
1709 MediumImportance,
1710 HighImportance,
1711 MediumHighImportance
1712 } KDPC_IMPORTANCE;
1713
1714 typedef struct _KDPC {
1715 UCHAR Type;
1716 UCHAR Importance;
1717 volatile USHORT Number;
1718 LIST_ENTRY DpcListEntry;
1719 PKDEFERRED_ROUTINE DeferredRoutine;
1720 PVOID DeferredContext;
1721 PVOID SystemArgument1;
1722 PVOID SystemArgument2;
1723 volatile PVOID DpcData;
1724 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
1725
1726 typedef struct _KDPC_WATCHDOG_INFORMATION {
1727 ULONG DpcTimeLimit;
1728 ULONG DpcTimeCount;
1729 ULONG DpcWatchdogLimit;
1730 ULONG DpcWatchdogCount;
1731 ULONG Reserved;
1732 } KDPC_WATCHDOG_INFORMATION, *PKDPC_WATCHDOG_INFORMATION;
1733
1734 typedef struct _KDEVICE_QUEUE {
1735 CSHORT Type;
1736 CSHORT Size;
1737 LIST_ENTRY DeviceListHead;
1738 KSPIN_LOCK Lock;
1739 # if defined(_AMD64_)
1740 _ANONYMOUS_UNION union {
1741 BOOLEAN Busy;
1742 _ANONYMOUS_STRUCT struct {
1743 LONG64 Reserved:8;
1744 LONG64 Hint:56;
1745 } DUMMYSTRUCTNAME;
1746 } DUMMYUNIONNAME;
1747 # else
1748 BOOLEAN Busy;
1749 # endif
1750 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
1751
1752 #define TIMER_EXPIRED_INDEX_BITS 6
1753 #define TIMER_PROCESSOR_INDEX_BITS 5
1754
1755 typedef struct _DISPATCHER_HEADER {
1756 _ANONYMOUS_UNION union {
1757 _ANONYMOUS_STRUCT struct {
1758 UCHAR Type;
1759 _ANONYMOUS_UNION union {
1760 _ANONYMOUS_UNION union {
1761 UCHAR TimerControlFlags;
1762 _ANONYMOUS_STRUCT struct {
1763 UCHAR Absolute:1;
1764 UCHAR Coalescable:1;
1765 UCHAR KeepShifting:1;
1766 UCHAR EncodedTolerableDelay:5;
1767 } DUMMYSTRUCTNAME;
1768 } DUMMYUNIONNAME;
1769 UCHAR Abandoned;
1770 #if (NTDDI_VERSION < NTDDI_WIN7)
1771 UCHAR NpxIrql;
1772 #endif
1773 BOOLEAN Signalling;
1774 } DUMMYUNIONNAME;
1775 _ANONYMOUS_UNION union {
1776 _ANONYMOUS_UNION union {
1777 UCHAR ThreadControlFlags;
1778 _ANONYMOUS_STRUCT struct {
1779 UCHAR CpuThrottled:1;
1780 UCHAR CycleProfiling:1;
1781 UCHAR CounterProfiling:1;
1782 UCHAR Reserved:5;
1783 } DUMMYSTRUCTNAME;
1784 } DUMMYUNIONNAME;
1785 UCHAR Size;
1786 UCHAR Hand;
1787 } DUMMYUNIONNAME2;
1788 _ANONYMOUS_UNION union {
1789 #if (NTDDI_VERSION >= NTDDI_WIN7)
1790 _ANONYMOUS_UNION union {
1791 UCHAR TimerMiscFlags;
1792 _ANONYMOUS_STRUCT struct {
1793 #if !defined(_X86_)
1794 UCHAR Index:TIMER_EXPIRED_INDEX_BITS;
1795 #else
1796 UCHAR Index:1;
1797 UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS;
1798 #endif
1799 UCHAR Inserted:1;
1800 volatile UCHAR Expired:1;
1801 } DUMMYSTRUCTNAME;
1802 } DUMMYUNIONNAME;
1803 #else
1804 /* Pre Win7 compatibility fix to latest WDK */
1805 UCHAR Inserted;
1806 #endif
1807 _ANONYMOUS_UNION union {
1808 BOOLEAN DebugActive;
1809 _ANONYMOUS_STRUCT struct {
1810 BOOLEAN ActiveDR7:1;
1811 BOOLEAN Instrumented:1;
1812 BOOLEAN Reserved2:4;
1813 BOOLEAN UmsScheduled:1;
1814 BOOLEAN UmsPrimary:1;
1815 } DUMMYSTRUCTNAME;
1816 } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */
1817 BOOLEAN DpcActive;
1818 } DUMMYUNIONNAME3;
1819 } DUMMYSTRUCTNAME;
1820 volatile LONG Lock;
1821 } DUMMYUNIONNAME;
1822 LONG SignalState;
1823 LIST_ENTRY WaitListHead;
1824 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
1825
1826 typedef struct _KEVENT {
1827 DISPATCHER_HEADER Header;
1828 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
1829
1830 typedef struct _KSEMAPHORE {
1831 DISPATCHER_HEADER Header;
1832 LONG Limit;
1833 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
1834
1835 #define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG))
1836
1837 typedef struct _KGATE {
1838 DISPATCHER_HEADER Header;
1839 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
1840
1841 typedef struct _KGUARDED_MUTEX {
1842 volatile LONG Count;
1843 PKTHREAD Owner;
1844 ULONG Contention;
1845 KGATE Gate;
1846 _ANONYMOUS_UNION union {
1847 _ANONYMOUS_STRUCT struct {
1848 SHORT KernelApcDisable;
1849 SHORT SpecialApcDisable;
1850 } DUMMYSTRUCTNAME;
1851 ULONG CombinedApcDisable;
1852 } DUMMYUNIONNAME;
1853 } KGUARDED_MUTEX, *PKGUARDED_MUTEX;
1854
1855 typedef struct _KMUTANT {
1856 DISPATCHER_HEADER Header;
1857 LIST_ENTRY MutantListEntry;
1858 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
1859 BOOLEAN Abandoned;
1860 UCHAR ApcDisable;
1861 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
1862
1863 #define TIMER_TABLE_SIZE 512
1864 #define TIMER_TABLE_SHIFT 9
1865
1866 typedef struct _KTIMER {
1867 DISPATCHER_HEADER Header;
1868 ULARGE_INTEGER DueTime;
1869 LIST_ENTRY TimerListEntry;
1870 struct _KDPC *Dpc;
1871 #if (NTDDI_VERSION >= NTDDI_WIN7) && !defined(_X86_)
1872 ULONG Processor;
1873 #endif
1874 ULONG Period;
1875 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
1876
1877 typedef enum _LOCK_OPERATION {
1878 IoReadAccess,
1879 IoWriteAccess,
1880 IoModifyAccess
1881 } LOCK_OPERATION;
1882
1883 #define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG))
1884
1885 _Function_class_(KSYNCHRONIZE_ROUTINE)
1886 _IRQL_requires_same_
1887 typedef BOOLEAN
1888 (NTAPI KSYNCHRONIZE_ROUTINE)(
1889 _In_ PVOID SynchronizeContext);
1890 typedef KSYNCHRONIZE_ROUTINE *PKSYNCHRONIZE_ROUTINE;
1891
1892 typedef enum _POOL_TYPE {
1893 NonPagedPool,
1894 PagedPool,
1895 NonPagedPoolMustSucceed,
1896 DontUseThisType,
1897 NonPagedPoolCacheAligned,
1898 PagedPoolCacheAligned,
1899 NonPagedPoolCacheAlignedMustS,
1900 MaxPoolType,
1901 NonPagedPoolSession = 32,
1902 PagedPoolSession,
1903 NonPagedPoolMustSucceedSession,
1904 DontUseThisTypeSession,
1905 NonPagedPoolCacheAlignedSession,
1906 PagedPoolCacheAlignedSession,
1907 NonPagedPoolCacheAlignedMustSSession
1908 } POOL_TYPE;
1909
1910 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE {
1911 StandardDesign,
1912 NEC98x86,
1913 EndAlternatives
1914 } ALTERNATIVE_ARCHITECTURE_TYPE;
1915
1916 #ifndef _X86_
1917
1918 #ifndef IsNEC_98
1919 #define IsNEC_98 (FALSE)
1920 #endif
1921
1922 #ifndef IsNotNEC_98
1923 #define IsNotNEC_98 (TRUE)
1924 #endif
1925
1926 #ifndef SetNEC_98
1927 #define SetNEC_98
1928 #endif
1929
1930 #ifndef SetNotNEC_98
1931 #define SetNotNEC_98
1932 #endif
1933
1934 #endif
1935
1936 typedef struct _KSYSTEM_TIME {
1937 ULONG LowPart;
1938 LONG High1Time;
1939 LONG High2Time;
1940 } KSYSTEM_TIME, *PKSYSTEM_TIME;
1941
1942 typedef struct DECLSPEC_ALIGN(16) _M128A {
1943 ULONGLONG Low;
1944 LONGLONG High;
1945 } M128A, *PM128A;
1946
1947 typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT {
1948 USHORT ControlWord;
1949 USHORT StatusWord;
1950 UCHAR TagWord;
1951 UCHAR Reserved1;
1952 USHORT ErrorOpcode;
1953 ULONG ErrorOffset;
1954 USHORT ErrorSelector;
1955 USHORT Reserved2;
1956 ULONG DataOffset;
1957 USHORT DataSelector;
1958 USHORT Reserved3;
1959 ULONG MxCsr;
1960 ULONG MxCsr_Mask;
1961 M128A FloatRegisters[8];
1962 #if defined(_WIN64)
1963 M128A XmmRegisters[16];
1964 UCHAR Reserved4[96];
1965 #else
1966 M128A XmmRegisters[8];
1967 UCHAR Reserved4[192];
1968 ULONG StackControl[7];
1969 ULONG Cr0NpxState;
1970 #endif
1971 } XSAVE_FORMAT, *PXSAVE_FORMAT;
1972
1973 typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER {
1974 ULONG64 Mask;
1975 ULONG64 Reserved[7];
1976 } XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER;
1977
1978 typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA {
1979 XSAVE_FORMAT LegacyState;
1980 XSAVE_AREA_HEADER Header;
1981 } XSAVE_AREA, *PXSAVE_AREA;
1982
1983 typedef struct _XSTATE_CONTEXT {
1984 ULONG64 Mask;
1985 ULONG Length;
1986 ULONG Reserved1;
1987 _Field_size_bytes_opt_(Length) PXSAVE_AREA Area;
1988 #if defined(_X86_)
1989 ULONG Reserved2;
1990 #endif
1991 PVOID Buffer;
1992 #if defined(_X86_)
1993 ULONG Reserved3;
1994 #endif
1995 } XSTATE_CONTEXT, *PXSTATE_CONTEXT;
1996
1997 typedef struct _XSTATE_SAVE {
1998 #if defined(_AMD64_)
1999 struct _XSTATE_SAVE* Prev;
2000 struct _KTHREAD* Thread;
2001 UCHAR Level;
2002 XSTATE_CONTEXT XStateContext;
2003 #elif defined(_IA64_) || defined(_ARM_)
2004 ULONG Dummy;
2005 #elif defined(_X86_)
2006 _ANONYMOUS_UNION union {
2007 _ANONYMOUS_STRUCT struct {
2008 LONG64 Reserved1;
2009 ULONG Reserved2;
2010 struct _XSTATE_SAVE* Prev;
2011 PXSAVE_AREA Reserved3;
2012 struct _KTHREAD* Thread;
2013 PVOID Reserved4;
2014 UCHAR Level;
2015 } DUMMYSTRUCTNAME;
2016 XSTATE_CONTEXT XStateContext;
2017 } DUMMYUNIONNAME;
2018 #endif
2019 } XSTATE_SAVE, *PXSTATE_SAVE;
2020
2021 #ifdef _X86_
2022
2023 #define MAXIMUM_SUPPORTED_EXTENSION 512
2024
2025 #if !defined(__midl) && !defined(MIDL_PASS)
2026 C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION);
2027 #endif
2028
2029 #endif /* _X86_ */
2030
2031 #define XSAVE_ALIGN 64
2032 #define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA)
2033
2034 #if !defined(__midl) && !defined(MIDL_PASS)
2035 C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0);
2036 C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0);
2037 C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64);
2038 #endif
2039
2040 typedef struct _CONTEXT_CHUNK {
2041 LONG Offset;
2042 ULONG Length;
2043 } CONTEXT_CHUNK, *PCONTEXT_CHUNK;
2044
2045 typedef struct _CONTEXT_EX {
2046 CONTEXT_CHUNK All;
2047 CONTEXT_CHUNK Legacy;
2048 CONTEXT_CHUNK XState;
2049 } CONTEXT_EX, *PCONTEXT_EX;
2050
2051 #define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN)
2052
2053 #if (NTDDI_VERSION >= NTDDI_VISTA)
2054 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
2055 #elif (NTDDI_VERSION >= NTDDI_WINXP)
2056 extern NTSYSAPI CCHAR KeNumberProcessors;
2057 #else
2058 __CREATE_NTOS_DATA_IMPORT_ALIAS(KeNumberProcessors)
2059 extern PCCHAR KeNumberProcessors;
2060 #endif
2061
2062
2063 /******************************************************************************
2064 * Memory manager Types *
2065 ******************************************************************************/
2066
2067 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2068 typedef ULONG NODE_REQUIREMENT;
2069 #define MM_ANY_NODE_OK 0x80000000
2070 #endif
2071
2072 #define MM_DONT_ZERO_ALLOCATION 0x00000001
2073 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002
2074 #define MM_ALLOCATE_FULLY_REQUIRED 0x00000004
2075 #define MM_ALLOCATE_NO_WAIT 0x00000008
2076 #define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010
2077 #define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020
2078
2079 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
2080 #define MDL_PAGES_LOCKED 0x0002
2081 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
2082 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
2083 #define MDL_PARTIAL 0x0010
2084 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
2085 #define MDL_IO_PAGE_READ 0x0040
2086 #define MDL_WRITE_OPERATION 0x0080
2087 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
2088 #define MDL_FREE_EXTRA_PTES 0x0200
2089 #define MDL_DESCRIBES_AWE 0x0400
2090 #define MDL_IO_SPACE 0x0800
2091 #define MDL_NETWORK_HEADER 0x1000
2092 #define MDL_MAPPING_CAN_FAIL 0x2000
2093 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
2094 #define MDL_INTERNAL 0x8000
2095
2096 #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \
2097 MDL_PAGES_LOCKED | \
2098 MDL_SOURCE_IS_NONPAGED_POOL | \
2099 MDL_PARTIAL_HAS_BEEN_MAPPED | \
2100 MDL_PARENT_MAPPED_SYSTEM_VA | \
2101 MDL_SYSTEM_VA | \
2102 MDL_IO_SPACE)
2103
2104 #define FLUSH_MULTIPLE_MAXIMUM 32
2105
2106 /* Section access rights */
2107 #define SECTION_QUERY 0x0001
2108 #define SECTION_MAP_WRITE 0x0002
2109 #define SECTION_MAP_READ 0x0004
2110 #define SECTION_MAP_EXECUTE 0x0008
2111 #define SECTION_EXTEND_SIZE 0x0010
2112 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
2113
2114 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| \
2115 SECTION_MAP_WRITE | \
2116 SECTION_MAP_READ | \
2117 SECTION_MAP_EXECUTE | \
2118 SECTION_EXTEND_SIZE)
2119
2120 #define SESSION_QUERY_ACCESS 0x0001
2121 #define SESSION_MODIFY_ACCESS 0x0002
2122
2123 #define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
2124 SESSION_QUERY_ACCESS | \
2125 SESSION_MODIFY_ACCESS)
2126
2127 #define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
2128
2129 #define PAGE_NOACCESS 0x01
2130 #define PAGE_READONLY 0x02
2131 #define PAGE_READWRITE 0x04
2132 #define PAGE_WRITECOPY 0x08
2133 #define PAGE_EXECUTE 0x10
2134 #define PAGE_EXECUTE_READ 0x20
2135 #define PAGE_EXECUTE_READWRITE 0x40
2136 #define PAGE_EXECUTE_WRITECOPY 0x80
2137 #define PAGE_GUARD 0x100
2138 #define PAGE_NOCACHE 0x200
2139 #define PAGE_WRITECOMBINE 0x400
2140
2141 #define MEM_COMMIT 0x1000
2142 #define MEM_RESERVE 0x2000
2143 #define MEM_DECOMMIT 0x4000
2144 #define MEM_RELEASE 0x8000
2145 #define MEM_FREE 0x10000
2146 #define MEM_PRIVATE 0x20000
2147 #define MEM_MAPPED 0x40000
2148 #define MEM_RESET 0x80000
2149 #define MEM_TOP_DOWN 0x100000
2150 #define MEM_LARGE_PAGES 0x20000000
2151 #define MEM_4MB_PAGES 0x80000000
2152
2153 #define SEC_RESERVE 0x4000000
2154 #define SEC_COMMIT 0x8000000
2155 #define SEC_LARGE_PAGES 0x80000000
2156
2157 /* Section map options */
2158 typedef enum _SECTION_INHERIT {
2159 ViewShare = 1,
2160 ViewUnmap = 2
2161 } SECTION_INHERIT;
2162
2163 typedef ULONG PFN_COUNT;
2164 typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
2165 typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
2166
2167 _Struct_size_bytes_(_Inexpressible_(sizeof(struct _MDL) +
2168 (ByteOffset + ByteCount + PAGE_SIZE-1) / PAGE_SIZE * sizeof(PFN_NUMBER)))
2169 typedef struct _MDL {
2170 struct _MDL *Next;
2171 CSHORT Size;
2172 CSHORT MdlFlags;
2173 struct _EPROCESS *Process;
2174 PVOID MappedSystemVa;
2175 PVOID StartVa;
2176 ULONG ByteCount;
2177 ULONG ByteOffset;
2178 } MDL, *PMDL;
2179 #if (_MSC_VER >= 1600)
2180 typedef _Readable_bytes_(_Inexpressible_(polymorphism)) MDL *PMDLX;
2181 #else
2182 typedef MDL *PMDLX;
2183 #endif
2184
2185 typedef enum _MEMORY_CACHING_TYPE_ORIG {
2186 MmFrameBufferCached = 2
2187 } MEMORY_CACHING_TYPE_ORIG;
2188
2189 typedef enum _MEMORY_CACHING_TYPE {
2190 MmNonCached = FALSE,
2191 MmCached = TRUE,
2192 MmWriteCombined = MmFrameBufferCached,
2193 MmHardwareCoherentCached,
2194 MmNonCachedUnordered,
2195 MmUSWCCached,
2196 MmMaximumCacheType
2197 } MEMORY_CACHING_TYPE;
2198
2199 typedef enum _MM_PAGE_PRIORITY {
2200 LowPagePriority,
2201 NormalPagePriority = 16,
2202 HighPagePriority = 32
2203 } MM_PAGE_PRIORITY;
2204
2205 typedef enum _MM_SYSTEM_SIZE {
2206 MmSmallSystem,
2207 MmMediumSystem,
2208 MmLargeSystem
2209 } MM_SYSTEMSIZE;
2210
2211 #ifndef _NTSYSTEM_
2212 __CREATE_NTOS_DATA_IMPORT_ALIAS(Mm64BitPhysicalAddress)
2213 extern PBOOLEAN Mm64BitPhysicalAddress;
2214 #endif
2215 extern NTKERNELAPI PVOID MmBadPointer;
2216
2217
2218 /******************************************************************************
2219 * Executive Types *
2220 ******************************************************************************/
2221 #define EX_RUNDOWN_ACTIVE 0x1
2222 #define EX_RUNDOWN_COUNT_SHIFT 0x1
2223 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT)
2224
2225 typedef struct _FAST_MUTEX {
2226 volatile LONG Count;
2227 PKTHREAD Owner;
2228 ULONG Contention;
2229 KEVENT Event;
2230 ULONG OldIrql;
2231 } FAST_MUTEX, *PFAST_MUTEX;
2232
2233 typedef enum _SUITE_TYPE {
2234 SmallBusiness,
2235 Enterprise,
2236 BackOffice,
2237 CommunicationServer,
2238 TerminalServer,
2239 SmallBusinessRestricted,
2240 EmbeddedNT,
2241 DataCenter,
2242 SingleUserTS,
2243 Personal,
2244 Blade,
2245 EmbeddedRestricted,
2246 SecurityAppliance,
2247 StorageServer,
2248 ComputeServer,
2249 WHServer,
2250 MaxSuiteType
2251 } SUITE_TYPE;
2252
2253 typedef enum _EX_POOL_PRIORITY {
2254 LowPoolPriority,
2255 LowPoolPrioritySpecialPoolOverrun = 8,
2256 LowPoolPrioritySpecialPoolUnderrun = 9,
2257 NormalPoolPriority = 16,
2258 NormalPoolPrioritySpecialPoolOverrun = 24,
2259 NormalPoolPrioritySpecialPoolUnderrun = 25,
2260 HighPoolPriority = 32,
2261 HighPoolPrioritySpecialPoolOverrun = 40,
2262 HighPoolPrioritySpecialPoolUnderrun = 41
2263 } EX_POOL_PRIORITY;
2264
2265 #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
2266 #define LOOKASIDE_ALIGN
2267 #else
2268 #define LOOKASIDE_ALIGN DECLSPEC_CACHEALIGN
2269 #endif
2270
2271 typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX;
2272
2273 _IRQL_requires_same_
2274 _Function_class_(ALLOCATE_FUNCTION)
2275 typedef PVOID
2276 (NTAPI *PALLOCATE_FUNCTION)(
2277 _In_ POOL_TYPE PoolType,
2278 _In_ SIZE_T NumberOfBytes,
2279 _In_ ULONG Tag);
2280
2281 _IRQL_requires_same_
2282 _Function_class_(ALLOCATE_FUNCTION_EX)
2283 typedef PVOID
2284 (NTAPI *PALLOCATE_FUNCTION_EX)(
2285 _In_ POOL_TYPE PoolType,
2286 _In_ SIZE_T NumberOfBytes,
2287 _In_ ULONG Tag,
2288 _Inout_ PLOOKASIDE_LIST_EX Lookaside);
2289
2290 _IRQL_requires_same_
2291 _Function_class_(FREE_FUNCTION)
2292 typedef VOID
2293 (NTAPI *PFREE_FUNCTION)(
2294 _In_ PVOID Buffer);
2295
2296 _IRQL_requires_same_
2297 _Function_class_(FREE_FUNCTION_EX)
2298 typedef VOID
2299 (NTAPI *PFREE_FUNCTION_EX)(
2300 _In_ PVOID Buffer,
2301 _Inout_ PLOOKASIDE_LIST_EX Lookaside);
2302
2303 _IRQL_requires_same_
2304 _Function_class_(CALLBACK_FUNCTION)
2305 typedef VOID
2306 (NTAPI CALLBACK_FUNCTION)(
2307 _In_opt_ PVOID CallbackContext,
2308 _In_opt_ PVOID Argument1,
2309 _In_opt_ PVOID Argument2);
2310 typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION;
2311
2312 #define GENERAL_LOOKASIDE_LAYOUT \
2313 _ANONYMOUS_UNION union { \
2314 SLIST_HEADER ListHead; \
2315 SINGLE_LIST_ENTRY SingleListHead; \
2316 } DUMMYUNIONNAME; \
2317 USHORT Depth; \
2318 USHORT MaximumDepth; \
2319 ULONG TotalAllocates; \
2320 _ANONYMOUS_UNION union { \
2321 ULONG AllocateMisses; \
2322 ULONG AllocateHits; \
2323 } DUMMYUNIONNAME2; \
2324 ULONG TotalFrees; \
2325 _ANONYMOUS_UNION union { \
2326 ULONG FreeMisses; \
2327 ULONG FreeHits; \
2328 } DUMMYUNIONNAME3; \
2329 POOL_TYPE Type; \
2330 ULONG Tag; \
2331 ULONG Size; \
2332 _ANONYMOUS_UNION union { \
2333 PALLOCATE_FUNCTION_EX AllocateEx; \
2334 PALLOCATE_FUNCTION Allocate; \
2335 } DUMMYUNIONNAME4; \
2336 _ANONYMOUS_UNION union { \
2337 PFREE_FUNCTION_EX FreeEx; \
2338 PFREE_FUNCTION Free; \
2339 } DUMMYUNIONNAME5; \
2340 LIST_ENTRY ListEntry; \
2341 ULONG LastTotalAllocates; \
2342 _ANONYMOUS_UNION union { \
2343 ULONG LastAllocateMisses; \
2344 ULONG LastAllocateHits; \
2345 } DUMMYUNIONNAME6; \
2346 ULONG Future[2];
2347
2348 typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE {
2349 GENERAL_LOOKASIDE_LAYOUT
2350 } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
2351
2352 typedef struct _GENERAL_LOOKASIDE_POOL {
2353 GENERAL_LOOKASIDE_LAYOUT
2354 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
2355
2356 #define LOOKASIDE_CHECK(f) \
2357 C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f))
2358
2359 LOOKASIDE_CHECK(TotalFrees);
2360 LOOKASIDE_CHECK(Tag);
2361 LOOKASIDE_CHECK(Future);
2362
2363 typedef struct LOOKASIDE_ALIGN _PAGED_LOOKASIDE_LIST {
2364 GENERAL_LOOKASIDE L;
2365 #if !defined(_AMD64_) && !defined(_IA64_)
2366 FAST_MUTEX Lock__ObsoleteButDoNotDelete;
2367 #endif
2368 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
2369
2370 typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST {
2371 GENERAL_LOOKASIDE L;
2372 #if !defined(_AMD64_) && !defined(_IA64_)
2373 KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
2374 #endif
2375 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
2376
2377 #define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next))
2378
2379 typedef struct _LOOKASIDE_LIST_EX {
2380 GENERAL_LOOKASIDE_POOL L;
2381 } LOOKASIDE_LIST_EX;
2382
2383 #if (NTDDI_VERSION >= NTDDI_VISTA)
2384
2385 #define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL
2386 #define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL
2387
2388 #define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256
2389 #define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024
2390
2391 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2392
2393 typedef struct _EX_RUNDOWN_REF {
2394 _ANONYMOUS_UNION union {
2395 volatile ULONG_PTR Count;
2396 volatile PVOID Ptr;
2397 } DUMMYUNIONNAME;
2398 } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
2399
2400 typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE;
2401
2402 typedef enum _WORK_QUEUE_TYPE {
2403 CriticalWorkQueue,
2404 DelayedWorkQueue,
2405 HyperCriticalWorkQueue,
2406 MaximumWorkQueue
2407 } WORK_QUEUE_TYPE;
2408
2409 _IRQL_requires_same_
2410 _Function_class_(WORKER_THREAD_ROUTINE)
2411 typedef VOID
2412 (NTAPI WORKER_THREAD_ROUTINE)(
2413 _In_ PVOID Parameter);
2414 typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE;
2415
2416 typedef struct _WORK_QUEUE_ITEM {
2417 LIST_ENTRY List;
2418 PWORKER_THREAD_ROUTINE WorkerRoutine;
2419 volatile PVOID Parameter;
2420 } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
2421
2422 typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
2423
2424 typedef struct _OWNER_ENTRY {
2425 ERESOURCE_THREAD OwnerThread;
2426 _ANONYMOUS_UNION union {
2427 _ANONYMOUS_STRUCT struct {
2428 ULONG IoPriorityBoosted:1;
2429 ULONG OwnerReferenced:1;
2430 ULONG OwnerCount:30;
2431 } DUMMYSTRUCTNAME;
2432 ULONG TableSize;
2433 } DUMMYUNIONNAME;
2434 } OWNER_ENTRY, *POWNER_ENTRY;
2435
2436 typedef struct _ERESOURCE {
2437 LIST_ENTRY SystemResourcesList;
2438 POWNER_ENTRY OwnerTable;
2439 SHORT ActiveCount;
2440 USHORT Flag;
2441 volatile PKSEMAPHORE SharedWaiters;
2442 volatile PKEVENT ExclusiveWaiters;
2443 OWNER_ENTRY OwnerEntry;
2444 ULONG ActiveEntries;
2445 ULONG ContentionCount;
2446 ULONG NumberOfSharedWaiters;
2447 ULONG NumberOfExclusiveWaiters;
2448 #if defined(_WIN64)
2449 PVOID Reserved2;
2450 #endif
2451 _ANONYMOUS_UNION union {
2452 PVOID Address;
2453 ULONG_PTR CreatorBackTraceIndex;
2454 } DUMMYUNIONNAME;
2455 KSPIN_LOCK SpinLock;
2456 } ERESOURCE, *PERESOURCE;
2457
2458 /* ERESOURCE.Flag */
2459 #define ResourceNeverExclusive 0x0010
2460 #define ResourceReleaseByOtherThread 0x0020
2461 #define ResourceOwnedExclusive 0x0080
2462
2463 #define RESOURCE_HASH_TABLE_SIZE 64
2464
2465 typedef struct _RESOURCE_HASH_ENTRY {
2466 LIST_ENTRY ListEntry;
2467 PVOID Address;
2468 ULONG ContentionCount;
2469 ULONG Number;
2470 } RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY;
2471
2472 typedef struct _RESOURCE_PERFORMANCE_DATA {
2473 ULONG ActiveResourceCount;
2474 ULONG TotalResourceCount;
2475 ULONG ExclusiveAcquire;
2476 ULONG SharedFirstLevel;
2477 ULONG SharedSecondLevel;
2478 ULONG StarveFirstLevel;
2479 ULONG StarveSecondLevel;
2480 ULONG WaitForExclusive;
2481 ULONG OwnerTableExpands;
2482 ULONG MaximumTableExpand;
2483 LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE];
2484 } RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA;
2485
2486 /* Global debug flag */
2487 #if DEVL
2488 extern NTKERNELAPI ULONG NtGlobalFlag;
2489 #define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName))
2490 #else
2491 #define IF_NTOS_DEBUG(FlagName) if(FALSE)
2492 #endif
2493
2494 /******************************************************************************
2495 * Security Manager Types *
2496 ******************************************************************************/
2497
2498 /* Simple types */
2499 typedef PVOID PSECURITY_DESCRIPTOR;
2500 typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
2501 typedef ULONG ACCESS_MASK, *PACCESS_MASK;
2502 typedef PVOID PACCESS_TOKEN;
2503 typedef PVOID PSID;
2504
2505 #define DELETE 0x00010000L
2506 #define READ_CONTROL 0x00020000L
2507 #define WRITE_DAC 0x00040000L
2508 #define WRITE_OWNER 0x00080000L
2509 #define SYNCHRONIZE 0x00100000L
2510 #define STANDARD_RIGHTS_REQUIRED 0x000F0000L
2511 #define STANDARD_RIGHTS_READ READ_CONTROL
2512 #define STANDARD_RIGHTS_WRITE READ_CONTROL
2513 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
2514 #define STANDARD_RIGHTS_ALL 0x001F0000L
2515 #define SPECIFIC_RIGHTS_ALL 0x0000FFFFL
2516 #define ACCESS_SYSTEM_SECURITY 0x01000000L
2517 #define MAXIMUM_ALLOWED 0x02000000L
2518 #define GENERIC_READ 0x80000000L
2519 #define GENERIC_WRITE 0x40000000L
2520 #define GENERIC_EXECUTE 0x20000000L
2521 #define GENERIC_ALL 0x10000000L
2522
2523 typedef struct _GENERIC_MAPPING {
2524 ACCESS_MASK GenericRead;
2525 ACCESS_MASK GenericWrite;
2526 ACCESS_MASK GenericExecute;
2527 ACCESS_MASK GenericAll;
2528 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2529
2530 #define ACL_REVISION 2
2531 #define ACL_REVISION_DS 4
2532
2533 #define ACL_REVISION1 1
2534 #define ACL_REVISION2 2
2535 #define ACL_REVISION3 3
2536 #define ACL_REVISION4 4
2537 #define MIN_ACL_REVISION ACL_REVISION2
2538 #define MAX_ACL_REVISION ACL_REVISION4
2539
2540 typedef struct _ACL {
2541 UCHAR AclRevision;
2542 UCHAR Sbz1;
2543 USHORT AclSize;
2544 USHORT AceCount;
2545 USHORT Sbz2;
2546 } ACL, *PACL;
2547
2548 /* Current security descriptor revision value */
2549 #define SECURITY_DESCRIPTOR_REVISION (1)
2550 #define SECURITY_DESCRIPTOR_REVISION1 (1)
2551
2552 /* Privilege attributes */
2553 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
2554 #define SE_PRIVILEGE_ENABLED (0x00000002L)
2555 #define SE_PRIVILEGE_REMOVED (0X00000004L)
2556 #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
2557
2558 #define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \
2559 SE_PRIVILEGE_ENABLED | \
2560 SE_PRIVILEGE_REMOVED | \
2561 SE_PRIVILEGE_USED_FOR_ACCESS)
2562
2563 #include <pshpack4.h>
2564 typedef struct _LUID_AND_ATTRIBUTES {
2565 LUID Luid;
2566 ULONG Attributes;
2567 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
2568 #include <poppack.h>
2569
2570 typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
2571 typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
2572
2573 /* Privilege sets */
2574 #define PRIVILEGE_SET_ALL_NECESSARY (1)
2575
2576 typedef struct _PRIVILEGE_SET {
2577 ULONG PrivilegeCount;
2578 ULONG Control;
2579 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
2580 } PRIVILEGE_SET,*PPRIVILEGE_SET;
2581
2582 typedef enum _SECURITY_IMPERSONATION_LEVEL {
2583 SecurityAnonymous,
2584 SecurityIdentification,
2585 SecurityImpersonation,
2586 SecurityDelegation
2587 } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
2588
2589 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
2590 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
2591 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
2592 #define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL))
2593
2594 #define SECURITY_DYNAMIC_TRACKING (TRUE)
2595 #define SECURITY_STATIC_TRACKING (FALSE)
2596
2597 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE;
2598
2599 typedef struct _SECURITY_QUALITY_OF_SERVICE {
2600 ULONG Length;
2601 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
2602 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
2603 BOOLEAN EffectiveOnly;
2604 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
2605
2606 typedef struct _SE_IMPERSONATION_STATE {
2607 PACCESS_TOKEN Token;
2608 BOOLEAN CopyOnOpen;
2609 BOOLEAN EffectiveOnly;
2610 SECURITY_IMPERSONATION_LEVEL Level;
2611 } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
2612
2613 #define OWNER_SECURITY_INFORMATION (0x00000001L)
2614 #define GROUP_SECURITY_INFORMATION (0x00000002L)
2615 #define DACL_SECURITY_INFORMATION (0x00000004L)
2616 #define SACL_SECURITY_INFORMATION (0x00000008L)
2617 #define LABEL_SECURITY_INFORMATION (0x00000010L)
2618
2619 #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
2620 #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
2621 #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
2622 #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
2623
2624 typedef enum _SECURITY_OPERATION_CODE {
2625 SetSecurityDescriptor,
2626 QuerySecurityDescriptor,
2627 DeleteSecurityDescriptor,
2628 AssignSecurityDescriptor
2629 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
2630
2631 #define INITIAL_PRIVILEGE_COUNT 3
2632
2633 typedef struct _INITIAL_PRIVILEGE_SET {
2634 ULONG PrivilegeCount;
2635 ULONG Control;
2636 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
2637 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
2638
2639 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
2640 #define SE_CREATE_TOKEN_PRIVILEGE 2
2641 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
2642 #define SE_LOCK_MEMORY_PRIVILEGE 4
2643 #define SE_INCREASE_QUOTA_PRIVILEGE 5
2644 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
2645 #define SE_TCB_PRIVILEGE 7
2646 #define SE_SECURITY_PRIVILEGE 8
2647 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
2648 #define SE_LOAD_DRIVER_PRIVILEGE 10
2649 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
2650 #define SE_SYSTEMTIME_PRIVILEGE 12
2651 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
2652 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
2653 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
2654 #define SE_CREATE_PERMANENT_PRIVILEGE 16
2655 #define SE_BACKUP_PRIVILEGE 17
2656 #define SE_RESTORE_PRIVILEGE 18
2657 #define SE_SHUTDOWN_PRIVILEGE 19
2658 #define SE_DEBUG_PRIVILEGE 20
2659 #define SE_AUDIT_PRIVILEGE 21
2660 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
2661 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
2662 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
2663 #define SE_UNDOCK_PRIVILEGE 25
2664 #define SE_SYNC_AGENT_PRIVILEGE 26
2665 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
2666 #define SE_MANAGE_VOLUME_PRIVILEGE 28
2667 #define SE_IMPERSONATE_PRIVILEGE 29
2668 #define SE_CREATE_GLOBAL_PRIVILEGE 30
2669 #define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31
2670 #define SE_RELABEL_PRIVILEGE 32
2671 #define SE_INC_WORKING_SET_PRIVILEGE 33
2672 #define SE_TIME_ZONE_PRIVILEGE 34
2673 #define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 35
2674 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
2675
2676 typedef struct _SECURITY_SUBJECT_CONTEXT {
2677 PACCESS_TOKEN ClientToken;
2678 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
2679 PACCESS_TOKEN PrimaryToken;
2680 PVOID ProcessAuditId;
2681 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
2682
2683 typedef struct _ACCESS_STATE {
2684 LUID OperationID;
2685 BOOLEAN SecurityEvaluated;
2686 BOOLEAN GenerateAudit;
2687 BOOLEAN GenerateOnClose;
2688 BOOLEAN PrivilegesAllocated;
2689 ULONG Flags;
2690 ACCESS_MASK RemainingDesiredAccess;
2691 ACCESS_MASK PreviouslyGrantedAccess;
2692 ACCESS_MASK OriginalDesiredAccess;
2693 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
2694 PSECURITY_DESCRIPTOR SecurityDescriptor;
2695 PVOID AuxData;
2696 union {
2697 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
2698 PRIVILEGE_SET PrivilegeSet;
2699 } Privileges;
2700 BOOLEAN AuditPrivileges;
2701 UNICODE_STRING ObjectName;
2702 UNICODE_STRING ObjectTypeName;
2703 } ACCESS_STATE, *PACCESS_STATE;
2704
2705 typedef VOID
2706 (NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)(
2707 _In_ PVOID Vcb,
2708 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor);
2709
2710 #ifndef _NTLSA_IFS_
2711
2712 #ifndef _NTLSA_AUDIT_
2713 #define _NTLSA_AUDIT_
2714
2715 #define SE_MAX_AUDIT_PARAMETERS 32
2716 #define SE_MAX_GENERIC_AUDIT_PARAMETERS 28
2717
2718 #define SE_ADT_OBJECT_ONLY 0x1
2719
2720 #define SE_ADT_PARAMETERS_SELF_RELATIVE 0x00000001
2721 #define SE_ADT_PARAMETERS_SEND_TO_LSA 0x00000002
2722 #define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT 0x00000004
2723 #define SE_ADT_PARAMETER_GENERIC_AUDIT 0x00000008
2724 #define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010
2725
2726 #define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \
2727 ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \
2728 (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) )
2729
2730 typedef enum _SE_ADT_PARAMETER_TYPE {
2731 SeAdtParmTypeNone = 0,
2732 SeAdtParmTypeString,
2733 SeAdtParmTypeFileSpec,
2734 SeAdtParmTypeUlong,
2735 SeAdtParmTypeSid,
2736 SeAdtParmTypeLogonId,
2737 SeAdtParmTypeNoLogonId,
2738 SeAdtParmTypeAccessMask,
2739 SeAdtParmTypePrivs,
2740 SeAdtParmTypeObjectTypes,
2741 SeAdtParmTypeHexUlong,
2742 SeAdtParmTypePtr,
2743 SeAdtParmTypeTime,
2744 SeAdtParmTypeGuid,
2745 SeAdtParmTypeLuid,
2746 SeAdtParmTypeHexInt64,
2747 SeAdtParmTypeStringList,
2748 SeAdtParmTypeSidList,
2749 SeAdtParmTypeDuration,
2750 SeAdtParmTypeUserAccountControl,
2751 SeAdtParmTypeNoUac,
2752 SeAdtParmTypeMessage,
2753 SeAdtParmTypeDateTime,
2754 SeAdtParmTypeSockAddr,
2755 SeAdtParmTypeSD,
2756 SeAdtParmTypeLogonHours,
2757 SeAdtParmTypeLogonIdNoSid,
2758 SeAdtParmTypeUlongNoConv,
2759 SeAdtParmTypeSockAddrNoPort,
2760 SeAdtParmTypeAccessReason
2761 } SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE;
2762
2763 typedef struct _SE_ADT_OBJECT_TYPE {
2764 GUID ObjectType;
2765 USHORT Flags;
2766 USHORT Level;
2767 ACCESS_MASK AccessMask;
2768 } SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE;
2769
2770 typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY {
2771 SE_ADT_PARAMETER_TYPE Type;
2772 ULONG Length;
2773 ULONG_PTR Data[2];
2774 PVOID Address;
2775 } SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY;
2776
2777 typedef struct _SE_ADT_ACCESS_REASON {
2778 ACCESS_MASK AccessMask;
2779 ULONG AccessReasons[32];
2780 ULONG ObjectTypeIndex;
2781 ULONG AccessGranted;
2782 PSECURITY_DESCRIPTOR SecurityDescriptor;
2783 } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON;
2784
2785 typedef struct _SE_ADT_PARAMETER_ARRAY {
2786 ULONG CategoryId;
2787 ULONG AuditId;
2788 ULONG ParameterCount;
2789 ULONG Length;
2790 USHORT FlatSubCategoryId;
2791 USHORT Type;
2792 ULONG Flags;
2793 SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ];
2794 } SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY;
2795
2796 #endif /* !_NTLSA_AUDIT_ */
2797 #endif /* !_NTLSA_IFS_ */
2798 /******************************************************************************
2799 * Power Management Support Types *
2800 ******************************************************************************/
2801
2802 #ifndef _PO_DDK_
2803 #define _PO_DDK_
2804
2805 #define PO_CB_SYSTEM_POWER_POLICY 0
2806 #define PO_CB_AC_STATUS 1
2807 #define PO_CB_BUTTON_COLLISION 2
2808 #define PO_CB_SYSTEM_STATE_LOCK 3
2809 #define PO_CB_LID_SWITCH_STATE 4
2810 #define PO_CB_PROCESSOR_POWER_POLICY 5
2811
2812 /* Power States/Levels */
2813 typedef enum _SYSTEM_POWER_STATE {
2814 PowerSystemUnspecified = 0,
2815 PowerSystemWorking,
2816 PowerSystemSleeping1,
2817 PowerSystemSleeping2,
2818 PowerSystemSleeping3,
2819 PowerSystemHibernate,
2820 PowerSystemShutdown,
2821 PowerSystemMaximum
2822 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
2823
2824 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
2825
2826 typedef enum _POWER_INFORMATION_LEVEL {
2827 SystemPowerPolicyAc,
2828 SystemPowerPolicyDc,
2829 VerifySystemPolicyAc,
2830 VerifySystemPolicyDc,
2831 SystemPowerCapabilities,
2832 SystemBatteryState,
2833 SystemPowerStateHandler,
2834 ProcessorStateHandler,
2835 SystemPowerPolicyCurrent,
2836 AdministratorPowerPolicy,
2837 SystemReserveHiberFile,
2838 ProcessorInformation,
2839 SystemPowerInformation,
2840 ProcessorStateHandler2,
2841 LastWakeTime,
2842 LastSleepTime,
2843 SystemExecutionState,
2844 SystemPowerStateNotifyHandler,
2845 ProcessorPowerPolicyAc,
2846 ProcessorPowerPolicyDc,
2847 VerifyProcessorPowerPolicyAc,
2848 VerifyProcessorPowerPolicyDc,
2849 ProcessorPowerPolicyCurrent,
2850 SystemPowerStateLogging,
2851 SystemPowerLoggingEntry,
2852 SetPowerSettingValue,
2853 NotifyUserPowerSetting,
2854 PowerInformationLevelUnused0,
2855 PowerInformationLevelUnused1,
2856 SystemVideoState,
2857 TraceApplicationPowerMessage,
2858 TraceApplicationPowerMessageEnd,
2859 ProcessorPerfStates,
2860 ProcessorIdleStates,
2861 ProcessorCap,
2862 SystemWakeSource,
2863 SystemHiberFileInformation,
2864 TraceServicePowerMessage,
2865 ProcessorLoad,
2866 PowerShutdownNotification,
2867 MonitorCapabilities,
2868 SessionPowerInit,
2869 SessionDisplayState,
2870 PowerRequestCreate,
2871 PowerRequestAction,
2872 GetPowerRequestList,
2873 ProcessorInformationEx,
2874 NotifyUserModeLegacyPowerEvent,
2875 GroupPark,
2876 ProcessorIdleDomains,
2877 WakeTimerList,
2878 SystemHiberFileSize,
2879 PowerInformationLevelMaximum
2880 } POWER_INFORMATION_LEVEL;
2881
2882 typedef enum {
2883 PowerActionNone = 0,
2884 PowerActionReserved,
2885 PowerActionSleep,
2886 PowerActionHibernate,
2887 PowerActionShutdown,
2888 PowerActionShutdownReset,
2889 PowerActionShutdownOff,
2890 PowerActionWarmEject
2891 } POWER_ACTION, *PPOWER_ACTION;
2892
2893 typedef enum _DEVICE_POWER_STATE {
2894 PowerDeviceUnspecified = 0,
2895 PowerDeviceD0,
2896 PowerDeviceD1,
2897 PowerDeviceD2,
2898 PowerDeviceD3,
2899 PowerDeviceMaximum
2900 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
2901
2902 typedef enum _MONITOR_DISPLAY_STATE {
2903 PowerMonitorOff = 0,
2904 PowerMonitorOn,
2905 PowerMonitorDim
2906 } MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE;
2907
2908 typedef union _POWER_STATE {
2909 SYSTEM_POWER_STATE SystemState;
2910 DEVICE_POWER_STATE DeviceState;
2911 } POWER_STATE, *PPOWER_STATE;
2912
2913 typedef enum _POWER_STATE_TYPE {
2914 SystemPowerState = 0,
2915 DevicePowerState
2916 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
2917
2918 #if (NTDDI_VERSION >= NTDDI_VISTA)
2919 typedef struct _SYSTEM_POWER_STATE_CONTEXT {
2920 _ANONYMOUS_UNION union {
2921 _ANONYMOUS_STRUCT struct {
2922 ULONG Reserved1:8;
2923 ULONG TargetSystemState:4;
2924 ULONG EffectiveSystemState:4;
2925 ULONG CurrentSystemState:4;
2926 ULONG IgnoreHibernationPath:1;
2927 ULONG PseudoTransition:1;
2928 ULONG Reserved2:10;
2929 } DUMMYSTRUCTNAME;
2930 ULONG ContextAsUlong;
2931 } DUMMYUNIONNAME;
2932 } SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT;
2933 #endif
2934
2935 #if (NTDDI_VERSION >= NTDDI_WIN7)
2936 typedef struct _COUNTED_REASON_CONTEXT {
2937 ULONG Version;
2938 ULONG Flags;
2939 _ANONYMOUS_UNION union {
2940 _ANONYMOUS_STRUCT struct {
2941 UNICODE_STRING ResourceFileName;
2942 USHORT ResourceReasonId;
2943 ULONG StringCount;
2944 PUNICODE_STRING ReasonStrings;
2945 } DUMMYSTRUCTNAME;
2946 UNICODE_STRING SimpleString;
2947 } DUMMYUNIONNAME;
2948 } COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT;
2949 #endif
2950
2951 #define IOCTL_QUERY_DEVICE_POWER_STATE \
2952 CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS)
2953
2954 #define IOCTL_SET_DEVICE_WAKE \
2955 CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
2956
2957 #define IOCTL_CANCEL_DEVICE_WAKE \
2958 CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
2959
2960 #define ES_SYSTEM_REQUIRED 0x00000001
2961 #define ES_DISPLAY_REQUIRED 0x00000002
2962 #define ES_USER_PRESENT 0x00000004
2963 #define ES_CONTINUOUS 0x80000000
2964
2965 typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE;
2966
2967 typedef enum {
2968 LT_DONT_CARE,
2969 LT_LOWEST_LATENCY
2970 } LATENCY_TIME;
2971
2972 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
2973 #define DIAGNOSTIC_REASON_VERSION 0
2974 #define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001
2975 #define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002
2976 #define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000
2977 #define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003)
2978 #endif
2979
2980 #define POWER_REQUEST_CONTEXT_VERSION 0
2981 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
2982 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
2983
2984 #define PowerRequestMaximum 3
2985
2986 typedef enum _POWER_REQUEST_TYPE {
2987 PowerRequestDisplayRequired,
2988 PowerRequestSystemRequired,
2989 PowerRequestAwayModeRequired
2990 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
2991
2992 #if (NTDDI_VERSION >= NTDDI_WINXP)
2993
2994 #define PDCAP_D0_SUPPORTED 0x00000001
2995 #define PDCAP_D1_SUPPORTED 0x00000002
2996 #define PDCAP_D2_SUPPORTED 0x00000004
2997 #define PDCAP_D3_SUPPORTED 0x00000008
2998 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
2999 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
3000 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
3001 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
3002 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
3003
3004 typedef struct CM_Power_Data_s {
3005 ULONG PD_Size;
3006 DEVICE_POWER_STATE PD_MostRecentPowerState;
3007 ULONG PD_Capabilities;
3008 ULONG PD_D1Latency;
3009 ULONG PD_D2Latency;
3010 ULONG PD_D3Latency;
3011 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
3012 SYSTEM_POWER_STATE PD_DeepestSystemWake;
3013 } CM_POWER_DATA, *PCM_POWER_DATA;
3014
3015 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3016
3017 typedef enum _SYSTEM_POWER_CONDITION {
3018 PoAc,
3019 PoDc,
3020 PoHot,
3021 PoConditionMaximum
3022 } SYSTEM_POWER_CONDITION;
3023
3024 typedef struct _SET_POWER_SETTING_VALUE {
3025 ULONG Version;
3026 GUID Guid;
3027 SYSTEM_POWER_CONDITION PowerCondition;
3028 ULONG DataLength;
3029 UCHAR Data[ANYSIZE_ARRAY];
3030 } SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE;
3031
3032 #define POWER_SETTING_VALUE_VERSION (0x1)
3033
3034 typedef struct _NOTIFY_USER_POWER_SETTING {
3035 GUID Guid;
3036 } NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING;
3037
3038 typedef struct _APPLICATIONLAUNCH_SETTING_VALUE {
3039 LARGE_INTEGER ActivationTime;
3040 ULONG Flags;
3041 ULONG ButtonInstanceID;
3042 } APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE;
3043
3044 typedef enum _POWER_PLATFORM_ROLE {
3045 PlatformRoleUnspecified = 0,
3046 PlatformRoleDesktop,
3047 PlatformRoleMobile,
3048 PlatformRoleWorkstation,
3049 PlatformRoleEnterpriseServer,
3050 PlatformRoleSOHOServer,
3051 PlatformRoleAppliancePC,
3052 PlatformRolePerformanceServer,
3053 PlatformRoleMaximum
3054 } POWER_PLATFORM_ROLE;
3055
3056 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
3057 typedef struct {
3058 ULONG Granularity;
3059 ULONG Capacity;
3060 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
3061 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
3062
3063 #endif /* !_PO_DDK_ */
3064
3065 #define CORE_PARKING_POLICY_CHANGE_IDEAL 0
3066 #define CORE_PARKING_POLICY_CHANGE_SINGLE 1
3067 #define CORE_PARKING_POLICY_CHANGE_ROCKET 2
3068 #define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET
3069
3070 DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A);
3071 DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C);
3072 DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E);
3073 DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94);
3074 DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0);
3075 DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7);
3076 DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63);
3077 DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99);
3078 DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E);
3079 DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63);
3080 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64);
3081 DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee);
3082 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B);
3083 DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA);
3084 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb);
3085 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96);
3086 DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff);
3087 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8);
3088 DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67);
3089 DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47);
3090 DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23);
3091 DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42);
3092 DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E);
3093 DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63);
3094 DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67);
3095 DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20);
3096 DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70);
3097 DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA);
3098 DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0);
3099 DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64);
3100 DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E);
3101 DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1);
3102 DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0);
3103 DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87);
3104 DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab);
3105 DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D);
3106 DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2);
3107 DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47);
3108 DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80);
3109 DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78);
3110 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB);
3111 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93);
3112 DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5);
3113 DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36);
3114 DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B);
3115 DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4);
3116 DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F);
3117 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46);
3118 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69);
3119 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f);
3120 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06);
3121 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A);
3122 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58);
3123 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4);
3124 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA);
3125 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82);
3126 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8);
3127 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65);
3128 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3);
3129 DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00);
3130 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36);
3131 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC);
3132 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C);
3133 DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb);
3134 DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c);
3135 DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0);
3136 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d);
3137 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6);
3138 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18);
3139 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6);
3140 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa);
3141 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8);
3142 DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5);
3143 DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59);
3144 DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6);
3145 DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad);
3146 DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b);
3147 DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19);
3148 DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c);
3149 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1);
3150 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa);
3151 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6);
3152 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b);
3153 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28);
3154 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83);
3155 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32);
3156 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82);
3157 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82);
3158 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9);
3159 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20);
3160 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d);
3161 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29);
3162 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb);
3163 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1);
3164 DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f);
3165 DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b);
3166 DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f);
3167 DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F);
3168 DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51);
3169 DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19);
3170 DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48);
3171 DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3);
3172 DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1);
3173 DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1);
3174 DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E);
3175 DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA);
3176 DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20);
3177 DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5);
3178 DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6);
3179
3180 #define PERFSTATE_POLICY_CHANGE_IDEAL 0
3181 #define PERFSTATE_POLICY_CHANGE_SINGLE 1
3182 #define PERFSTATE_POLICY_CHANGE_ROCKET 2
3183 #define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET
3184
3185 #define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0
3186 #define PROCESSOR_PERF_BOOST_POLICY_MAX 100
3187
3188 #define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0
3189 #define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1
3190
3191 _Function_class_(REQUEST_POWER_COMPLETE)
3192 _IRQL_requires_same_
3193 typedef VOID
3194 (NTAPI REQUEST_POWER_COMPLETE)(
3195 _In_ struct _DEVICE_OBJECT *DeviceObject,
3196 _In_ UCHAR MinorFunction,
3197 _In_ POWER_STATE PowerState,
3198 _In_opt_ PVOID Context,
3199 _In_ struct _IO_STATUS_BLOCK *IoStatus);
3200 typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE;
3201
3202 _Function_class_(POWER_SETTING_CALLBACK)
3203 _IRQL_requires_same_
3204 typedef NTSTATUS
3205 (NTAPI POWER_SETTING_CALLBACK)(
3206 _In_ LPCGUID SettingGuid,
3207 _In_reads_bytes_(ValueLength) PVOID Value,
3208 _In_ ULONG ValueLength,
3209 _Inout_opt_ PVOID Context);
3210 typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK;
3211
3212 /******************************************************************************
3213 * Configuration Manager Types *
3214 ******************************************************************************/
3215
3216 /* Resource list definitions */
3217 typedef int CM_RESOURCE_TYPE;
3218
3219 #define CmResourceTypeNull 0
3220 #define CmResourceTypePort 1
3221 #define CmResourceTypeInterrupt 2
3222 #define CmResourceTypeMemory 3
3223 #define CmResourceTypeDma 4
3224 #define CmResourceTypeDeviceSpecific 5
3225 #define CmResourceTypeBusNumber 6
3226 #define CmResourceTypeNonArbitrated 128
3227 #define CmResourceTypeConfigData 128
3228 #define CmResourceTypeDevicePrivate 129
3229 #define CmResourceTypePcCardConfig 130
3230 #define CmResourceTypeMfCardConfig 131
3231
3232 /* KEY_VALUE_Xxx.Type */
3233 #define REG_NONE 0
3234 #define REG_SZ 1
3235 #define REG_EXPAND_SZ 2
3236 #define REG_BINARY 3
3237 #define REG_DWORD 4
3238 #define REG_DWORD_LITTLE_ENDIAN 4
3239 #define REG_DWORD_BIG_ENDIAN 5
3240 #define REG_LINK 6
3241 #define REG_MULTI_SZ 7
3242 #define REG_RESOURCE_LIST 8
3243 #define REG_FULL_RESOURCE_DESCRIPTOR 9
3244 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3245 #define REG_QWORD 11
3246 #define REG_QWORD_LITTLE_ENDIAN 11
3247
3248 /* Registry Access Rights */
3249 #define KEY_QUERY_VALUE (0x0001)
3250 #define KEY_SET_VALUE (0x0002)
3251 #define KEY_CREATE_SUB_KEY (0x0004)
3252 #define KEY_ENUMERATE_SUB_KEYS (0x0008)
3253 #define KEY_NOTIFY (0x0010)
3254 #define KEY_CREATE_LINK (0x0020)
3255 #define KEY_WOW64_32KEY (0x0200)
3256 #define KEY_WOW64_64KEY (0x0100)
3257 #define KEY_WOW64_RES (0x0300)
3258
3259 #define KEY_READ ((STANDARD_RIGHTS_READ |\
3260 KEY_QUERY_VALUE |\
3261 KEY_ENUMERATE_SUB_KEYS |\
3262 KEY_NOTIFY) \
3263 & \
3264 (~SYNCHRONIZE))
3265
3266 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
3267 KEY_SET_VALUE |\
3268 KEY_CREATE_SUB_KEY) \
3269 & \
3270 (~SYNCHRONIZE))
3271
3272 #define KEY_EXECUTE ((KEY_READ) \
3273 & \
3274 (~SYNCHRONIZE))
3275
3276 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
3277 KEY_QUERY_VALUE |\
3278 KEY_SET_VALUE |\
3279 KEY_CREATE_SUB_KEY |\
3280 KEY_ENUMERATE_SUB_KEYS |\
3281 KEY_NOTIFY |\
3282 KEY_CREATE_LINK) \
3283 & \
3284 (~SYNCHRONIZE))
3285
3286 /* Registry Open/Create Options */
3287 #define REG_OPTION_RESERVED (0x00000000L)
3288 #define REG_OPTION_NON_VOLATILE (0x00000000L)
3289 #define REG_OPTION_VOLATILE (0x00000001L)
3290 #define REG_OPTION_CREATE_LINK (0x00000002L)
3291 #define REG_OPTION_BACKUP_RESTORE (0x00000004L)
3292 #define REG_OPTION_OPEN_LINK (0x00000008L)
3293
3294 #define REG_LEGAL_OPTION \
3295 (REG_OPTION_RESERVED |\
3296 REG_OPTION_NON_VOLATILE |\
3297 REG_OPTION_VOLATILE |\
3298 REG_OPTION_CREATE_LINK |\
3299 REG_OPTION_BACKUP_RESTORE |\
3300 REG_OPTION_OPEN_LINK)
3301
3302 #define REG_OPEN_LEGAL_OPTION \
3303 (REG_OPTION_RESERVED |\
3304 REG_OPTION_BACKUP_RESTORE |\
3305 REG_OPTION_OPEN_LINK)
3306
3307 #define REG_STANDARD_FORMAT 1
3308 #define REG_LATEST_FORMAT 2
3309 #define REG_NO_COMPRESSION 4
3310
3311 /* Key creation/open disposition */
3312 #define REG_CREATED_NEW_KEY (0x00000001L)
3313 #define REG_OPENED_EXISTING_KEY (0x00000002L)
3314
3315 /* Key restore & hive load flags */
3316 #define REG_WHOLE_HIVE_VOLATILE (0x00000001L)
3317 #define REG_REFRESH_HIVE (0x00000002L)
3318 #define REG_NO_LAZY_FLUSH (0x00000004L)
3319 #define REG_FORCE_RESTORE (0x00000008L)
3320 #define REG_APP_HIVE (0x00000010L)
3321 #define REG_PROCESS_PRIVATE (0x00000020L)
3322 #define REG_START_JOURNAL (0x00000040L)
3323 #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L)
3324 #define REG_HIVE_NO_RM (0x00000100L)
3325 #define REG_HIVE_SINGLE_LOG (0x00000200L)
3326 #define REG_BOOT_HIVE (0x00000400L)
3327
3328 /* Unload Flags */
3329 #define REG_FORCE_UNLOAD 1
3330
3331 /* Notify Filter Values */
3332 #define REG_NOTIFY_CHANGE_NAME (0x00000001L)
3333 #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
3334 #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L)
3335 #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
3336
3337 #define REG_LEGAL_CHANGE_FILTER \
3338 (REG_NOTIFY_CHANGE_NAME |\
3339 REG_NOTIFY_CHANGE_ATTRIBUTES |\
3340 REG_NOTIFY_CHANGE_LAST_SET |\
3341 REG_NOTIFY_CHANGE_SECURITY)
3342
3343 #include <pshpack4.h>
3344 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
3345 UCHAR Type;
3346 UCHAR ShareDisposition;
3347 USHORT Flags;
3348 union {
3349 struct {
3350 PHYSICAL_ADDRESS Start;
3351 ULONG Length;
3352 } Generic;
3353 struct {
3354 PHYSICAL_ADDRESS Start;
3355 ULONG Length;
3356 } Port;
3357 struct {
3358 #if defined(NT_PROCESSOR_GROUPS)
3359 USHORT Level;
3360 USHORT Group;
3361 #else
3362 ULONG Level;
3363 #endif
3364 ULONG Vector;
3365 KAFFINITY Affinity;
3366 } Interrupt;
3367 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
3368 struct {
3369 _ANONYMOUS_UNION union {
3370 struct {
3371 #if defined(NT_PROCESSOR_GROUPS)
3372 USHORT Group;
3373 #else
3374 USHORT Reserved;
3375 #endif
3376 USHORT MessageCount;
3377 ULONG Vector;
3378 KAFFINITY Affinity;
3379 } Raw;
3380 struct {
3381 #if defined(NT_PROCESSOR_GROUPS)
3382 USHORT Level;
3383 USHORT Group;
3384 #else
3385 ULONG Level;
3386 #endif
3387 ULONG Vector;
3388 KAFFINITY Affinity;
3389 } Translated;
3390 } DUMMYUNIONNAME;
3391 } MessageInterrupt;
3392 #endif
3393 struct {
3394 PHYSICAL_ADDRESS Start;
3395 ULONG Length;
3396 } Memory;
3397 struct {
3398 ULONG Channel;
3399 ULONG Port;
3400 ULONG Reserved1;
3401 } Dma;
3402 struct {
3403 ULONG Data[3];
3404 } DevicePrivate;
3405 struct {
3406 ULONG Start;
3407 ULONG Length;
3408 ULONG Reserved;
3409 } BusNumber;
3410 struct {
3411 ULONG DataSize;
3412 ULONG Reserved1;
3413 ULONG Reserved2;
3414 } DeviceSpecificData;
3415 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
3416 struct {
3417 PHYSICAL_ADDRESS Start;
3418 ULONG Length40;
3419 } Memory40;
3420 struct {
3421 PHYSICAL_ADDRESS Start;
3422 ULONG Length48;
3423 } Memory48;
3424 struct {
3425 PHYSICAL_ADDRESS Start;
3426 ULONG Length64;
3427 } Memory64;
3428 #endif
3429 } u;
3430 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
3431 #include <poppack.h>
3432
3433 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
3434 #define CmResourceTypeNull 0
3435 #define CmResourceTypePort 1
3436 #define CmResourceTypeInterrupt 2
3437 #define CmResourceTypeMemory 3
3438 #define CmResourceTypeDma 4
3439 #define CmResourceTypeDeviceSpecific 5
3440 #define CmResourceTypeBusNumber 6
3441 #define CmResourceTypeMemoryLarge 7
3442 #define CmResourceTypeNonArbitrated 128
3443 #define CmResourceTypeConfigData 128