[DDK/XDK]
[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 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
1203 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
1204 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
1205 #define PF_VIRT_FIRMWARE_ENABLED 21
1206 #define PF_RDWRFSGSBASE_AVAILABLE 22
1207 #define PF_FASTFAIL_AVAILABLE 23
1208 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
1209 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
1210 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
1211 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
1212 #define PF_RDRAND_INSTRUCTION_AVAILABLE 28
1213 #define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
1214 #define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
1215 #define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
1216
1217 #define MAXIMUM_WAIT_OBJECTS 64
1218
1219 #define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject)
1220
1221 #define ASSERT_DPC(Object) \
1222 ASSERT(((Object)->Type == 0) || \
1223 ((Object)->Type == DpcObject) || \
1224 ((Object)->Type == ThreadedDpcObject))
1225
1226 #define ASSERT_GATE(object) \
1227 NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \
1228 (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject))
1229
1230 #define ASSERT_DEVICE_QUEUE(Object) \
1231 NT_ASSERT((Object)->Type == DeviceQueueObject)
1232
1233 #define ASSERT_TIMER(E) \
1234 NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \
1235 ((E)->Header.Type == TimerSynchronizationObject))
1236
1237 #define ASSERT_MUTANT(E) \
1238 NT_ASSERT((E)->Header.Type == MutantObject)
1239
1240 #define ASSERT_SEMAPHORE(E) \
1241 NT_ASSERT((E)->Header.Type == SemaphoreObject)
1242
1243 #define ASSERT_EVENT(E) \
1244 NT_ASSERT(((E)->Header.Type == NotificationEvent) || \
1245 ((E)->Header.Type == SynchronizationEvent))
1246
1247 #define DPC_NORMAL 0
1248 #define DPC_THREADED 1
1249
1250 #define GM_LOCK_BIT 0x1
1251 #define GM_LOCK_BIT_V 0x0
1252 #define GM_LOCK_WAITER_WOKEN 0x2
1253 #define GM_LOCK_WAITER_INC 0x4
1254
1255 #define LOCK_QUEUE_WAIT_BIT 0
1256 #define LOCK_QUEUE_OWNER_BIT 1
1257
1258 #define LOCK_QUEUE_WAIT 1
1259 #define LOCK_QUEUE_OWNER 2
1260 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4
1261 #define LOCK_QUEUE_TIMER_TABLE_LOCKS (1 << (8 - LOCK_QUEUE_TIMER_LOCK_SHIFT))
1262
1263 #define PROCESSOR_FEATURE_MAX 64
1264
1265 #define DBG_STATUS_CONTROL_C 1
1266 #define DBG_STATUS_SYSRQ 2
1267 #define DBG_STATUS_BUGCHECK_FIRST 3
1268 #define DBG_STATUS_BUGCHECK_SECOND 4
1269 #define DBG_STATUS_FATAL 5
1270 #define DBG_STATUS_DEBUG_CONTROL 6
1271 #define DBG_STATUS_WORKER 7
1272
1273 #if defined(_WIN64)
1274 #define MAXIMUM_PROC_PER_GROUP 64
1275 #else
1276 #define MAXIMUM_PROC_PER_GROUP 32
1277 #endif
1278 #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP
1279
1280 #define EXCEPTION_DIVIDED_BY_ZERO 0
1281 #define EXCEPTION_DEBUG 1
1282 #define EXCEPTION_NMI 2
1283 #define EXCEPTION_INT3 3
1284 #define EXCEPTION_BOUND_CHECK 5
1285 #define EXCEPTION_INVALID_OPCODE 6
1286 #define EXCEPTION_NPX_NOT_AVAILABLE 7
1287 #define EXCEPTION_DOUBLE_FAULT 8
1288 #define EXCEPTION_NPX_OVERRUN 9
1289 #define EXCEPTION_INVALID_TSS 0x0A
1290 #define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B
1291 #define EXCEPTION_STACK_FAULT 0x0C
1292 #define EXCEPTION_GP_FAULT 0x0D
1293 #define EXCEPTION_RESERVED_TRAP 0x0F
1294 #define EXCEPTION_NPX_ERROR 0x010
1295 #define EXCEPTION_ALIGNMENT_CHECK 0x011
1296
1297 typedef enum _KBUGCHECK_CALLBACK_REASON {
1298 KbCallbackInvalid,
1299 KbCallbackReserved1,
1300 KbCallbackSecondaryDumpData,
1301 KbCallbackDumpIo,
1302 KbCallbackAddPages
1303 } KBUGCHECK_CALLBACK_REASON;
1304
1305 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
1306
1307 _Function_class_(KBUGCHECK_REASON_CALLBACK_ROUTINE)
1308 _IRQL_requires_same_
1309 typedef VOID
1310 (NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)(
1311 _In_ KBUGCHECK_CALLBACK_REASON Reason,
1312 _In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
1313 _Inout_ PVOID ReasonSpecificData,
1314 _In_ ULONG ReasonSpecificDataLength);
1315 typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE;
1316
1317 typedef struct _KBUGCHECK_ADD_PAGES {
1318 _Inout_ PVOID Context;
1319 _Inout_ ULONG Flags;
1320 _In_ ULONG BugCheckCode;
1321 _Out_ ULONG_PTR Address;
1322 _Out_ ULONG_PTR Count;
1323 } KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES;
1324
1325 typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA {
1326 _In_ PVOID InBuffer;
1327 _In_ ULONG InBufferLength;
1328 _In_ ULONG MaximumAllowed;
1329 _Out_ GUID Guid;
1330 _Out_ PVOID OutBuffer;
1331 _Out_ ULONG OutBufferLength;
1332 } KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA;
1333
1334 typedef enum _KBUGCHECK_DUMP_IO_TYPE {
1335 KbDumpIoInvalid,
1336 KbDumpIoHeader,
1337 KbDumpIoBody,
1338 KbDumpIoSecondaryData,
1339 KbDumpIoComplete
1340 } KBUGCHECK_DUMP_IO_TYPE;
1341
1342 typedef struct _KBUGCHECK_DUMP_IO {
1343 _In_ ULONG64 Offset;
1344 _In_ PVOID Buffer;
1345 _In_ ULONG BufferLength;
1346 _In_ KBUGCHECK_DUMP_IO_TYPE Type;
1347 } KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO;
1348
1349 #define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL
1350 #define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL
1351 #define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL
1352
1353 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
1354 LIST_ENTRY Entry;
1355 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
1356 PUCHAR Component;
1357 ULONG_PTR Checksum;
1358 KBUGCHECK_CALLBACK_REASON Reason;
1359 UCHAR State;
1360 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
1361
1362 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
1363 BufferEmpty,
1364 BufferInserted,
1365 BufferStarted,
1366 BufferFinished,
1367 BufferIncomplete
1368 } KBUGCHECK_BUFFER_DUMP_STATE;
1369
1370 _Function_class_(KBUGCHECK_CALLBACK_ROUTINE)
1371 _IRQL_requires_same_
1372 typedef VOID
1373 (NTAPI KBUGCHECK_CALLBACK_ROUTINE)(
1374 IN PVOID Buffer,
1375 IN ULONG Length);
1376 typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE;
1377
1378 typedef struct _KBUGCHECK_CALLBACK_RECORD {
1379 LIST_ENTRY Entry;
1380 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
1381 _Field_size_bytes_opt_(Length) PVOID Buffer;
1382 ULONG Length;
1383 PUCHAR Component;
1384 ULONG_PTR Checksum;
1385 UCHAR State;
1386 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
1387
1388 _Function_class_(NMI_CALLBACK)
1389 _IRQL_requires_same_
1390 typedef BOOLEAN
1391 (NTAPI NMI_CALLBACK)(
1392 _In_opt_ PVOID Context,
1393 _In_ BOOLEAN Handled);
1394 typedef NMI_CALLBACK *PNMI_CALLBACK;
1395
1396 typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE {
1397 KeProcessorAddStartNotify = 0,
1398 KeProcessorAddCompleteNotify,
1399 KeProcessorAddFailureNotify
1400 } KE_PROCESSOR_CHANGE_NOTIFY_STATE;
1401
1402 typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT {
1403 KE_PROCESSOR_CHANGE_NOTIFY_STATE State;
1404 ULONG NtNumber;
1405 NTSTATUS Status;
1406 #if (NTDDI_VERSION >= NTDDI_WIN7)
1407 PROCESSOR_NUMBER ProcNumber;
1408 #endif
1409 } KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT;
1410
1411 _IRQL_requires_same_
1412 _Function_class_(PROCESSOR_CALLBACK_FUNCTION)
1413 typedef VOID
1414 (NTAPI PROCESSOR_CALLBACK_FUNCTION)(
1415 _In_ PVOID CallbackContext,
1416 _In_ PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext,
1417 _Inout_ PNTSTATUS OperationStatus);
1418 typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION;
1419
1420 #define KE_PROCESSOR_CHANGE_ADD_EXISTING 1
1421
1422 #define INVALID_PROCESSOR_INDEX 0xffffffff
1423
1424 typedef enum _KINTERRUPT_POLARITY {
1425 InterruptPolarityUnknown,
1426 InterruptActiveHigh,
1427 InterruptActiveLow
1428 } KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY;
1429
1430 typedef enum _KPROFILE_SOURCE {
1431 ProfileTime,
1432 ProfileAlignmentFixup,
1433 ProfileTotalIssues,
1434 ProfilePipelineDry,
1435 ProfileLoadInstructions,
1436 ProfilePipelineFrozen,
1437 ProfileBranchInstructions,
1438 ProfileTotalNonissues,
1439 ProfileDcacheMisses,
1440 ProfileIcacheMisses,
1441 ProfileCacheMisses,
1442 ProfileBranchMispredictions,
1443 ProfileStoreInstructions,
1444 ProfileFpInstructions,
1445 ProfileIntegerInstructions,
1446 Profile2Issue,
1447 Profile3Issue,
1448 Profile4Issue,
1449 ProfileSpecialInstructions,
1450 ProfileTotalCycles,
1451 ProfileIcacheIssues,
1452 ProfileDcacheAccesses,
1453 ProfileMemoryBarrierCycles,
1454 ProfileLoadLinkedIssues,
1455 ProfileMaximum
1456 } KPROFILE_SOURCE;
1457
1458 typedef enum _KWAIT_REASON {
1459 Executive,
1460 FreePage,
1461 PageIn,
1462 PoolAllocation,
1463 DelayExecution,
1464 Suspended,
1465 UserRequest,
1466 WrExecutive,
1467 WrFreePage,
1468 WrPageIn,
1469 WrPoolAllocation,
1470 WrDelayExecution,
1471 WrSuspended,
1472 WrUserRequest,
1473 WrEventPair,
1474 WrQueue,
1475 WrLpcReceive,
1476 WrLpcReply,
1477 WrVirtualMemory,
1478 WrPageOut,
1479 WrRendezvous,
1480 WrKeyedEvent,
1481 WrTerminated,
1482 WrProcessInSwap,
1483 WrCpuRateControl,
1484 WrCalloutStack,
1485 WrKernel,
1486 WrResource,
1487 WrPushLock,
1488 WrMutex,
1489 WrQuantumEnd,
1490 WrDispatchInt,
1491 WrPreempted,
1492 WrYieldExecution,
1493 WrFastMutex,
1494 WrGuardedMutex,
1495 WrRundown,
1496 MaximumWaitReason
1497 } KWAIT_REASON;
1498
1499 typedef struct _KWAIT_BLOCK {
1500 LIST_ENTRY WaitListEntry;
1501 struct _KTHREAD *Thread;
1502 PVOID Object;
1503 struct _KWAIT_BLOCK *NextWaitBlock;
1504 USHORT WaitKey;
1505 UCHAR WaitType;
1506 #if (NTDDI_VERSION >= NTDDI_WIN7)
1507 volatile UCHAR BlockState;
1508 #else
1509 UCHAR SpareByte;
1510 #endif
1511 #if defined(_WIN64)
1512 LONG SpareLong;
1513 #endif
1514 } KWAIT_BLOCK, *PKWAIT_BLOCK, *PRKWAIT_BLOCK;
1515
1516 typedef enum _KINTERRUPT_MODE {
1517 LevelSensitive,
1518 Latched
1519 } KINTERRUPT_MODE;
1520
1521 #define THREAD_WAIT_OBJECTS 3
1522
1523 _IRQL_requires_same_
1524 _Function_class_(KSTART_ROUTINE)
1525 typedef VOID
1526 (NTAPI KSTART_ROUTINE)(
1527 _In_ PVOID StartContext);
1528 typedef KSTART_ROUTINE *PKSTART_ROUTINE;
1529
1530 typedef VOID
1531 (NTAPI *PKINTERRUPT_ROUTINE)(
1532 VOID);
1533
1534 _Function_class_(KSERVICE_ROUTINE)
1535 _IRQL_requires_(HIGH_LEVEL)
1536 _IRQL_requires_same_
1537 typedef BOOLEAN
1538 (NTAPI KSERVICE_ROUTINE)(
1539 _In_ struct _KINTERRUPT *Interrupt,
1540 _In_ PVOID ServiceContext);
1541 typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
1542
1543 _Function_class_(KMESSAGE_SERVICE_ROUTINE)
1544 _IRQL_requires_same_
1545 typedef BOOLEAN
1546 (NTAPI KMESSAGE_SERVICE_ROUTINE)(
1547 _In_ struct _KINTERRUPT *Interrupt,
1548 _In_ PVOID ServiceContext,
1549 _In_ ULONG MessageID);
1550 typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE;
1551
1552 typedef enum _KD_OPTION {
1553 KD_OPTION_SET_BLOCK_ENABLE,
1554 } KD_OPTION;
1555
1556 #ifdef _NTSYSTEM_
1557 typedef VOID
1558 (NTAPI *PKNORMAL_ROUTINE)(
1559 IN PVOID NormalContext OPTIONAL,
1560 IN PVOID SystemArgument1 OPTIONAL,
1561 IN PVOID SystemArgument2 OPTIONAL);
1562
1563 typedef VOID
1564 (NTAPI *PKRUNDOWN_ROUTINE)(
1565 IN struct _KAPC *Apc);
1566
1567 typedef VOID
1568 (NTAPI *PKKERNEL_ROUTINE)(
1569 IN struct _KAPC *Apc,
1570 IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL,
1571 IN OUT PVOID *NormalContext OPTIONAL,
1572 IN OUT PVOID *SystemArgument1 OPTIONAL,
1573 IN OUT PVOID *SystemArgument2 OPTIONAL);
1574 #endif
1575
1576 typedef struct _KAPC {
1577 UCHAR Type;
1578 UCHAR SpareByte0;
1579 UCHAR Size;
1580 UCHAR SpareByte1;
1581 ULONG SpareLong0;
1582 struct _KTHREAD *Thread;
1583 LIST_ENTRY ApcListEntry;
1584 #ifdef _NTSYSTEM_
1585 PKKERNEL_ROUTINE KernelRoutine;
1586 PKRUNDOWN_ROUTINE RundownRoutine;
1587 PKNORMAL_ROUTINE NormalRoutine;
1588 #else
1589 PVOID Reserved[3];
1590 #endif
1591 PVOID NormalContext;
1592 PVOID SystemArgument1;
1593 PVOID SystemArgument2;
1594 CCHAR ApcStateIndex;
1595 KPROCESSOR_MODE ApcMode;
1596 BOOLEAN Inserted;
1597 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
1598
1599 #define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0)
1600 #define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1)
1601 #define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0)
1602 #define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1)
1603 #define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2)
1604 #define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex)
1605 #define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN))
1606
1607 typedef struct _KDEVICE_QUEUE_ENTRY {
1608 LIST_ENTRY DeviceListEntry;
1609 ULONG SortKey;
1610 BOOLEAN Inserted;
1611 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
1612 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
1613
1614 typedef PVOID PKIPI_CONTEXT;
1615
1616 typedef VOID
1617 (NTAPI *PKIPI_WORKER)(
1618 IN OUT PKIPI_CONTEXT PacketContext,
1619 IN PVOID Parameter1 OPTIONAL,
1620 IN PVOID Parameter2 OPTIONAL,
1621 IN PVOID Parameter3 OPTIONAL);
1622
1623 typedef struct _KIPI_COUNTS {
1624 ULONG Freeze;
1625 ULONG Packet;
1626 ULONG DPC;
1627 ULONG APC;
1628 ULONG FlushSingleTb;
1629 ULONG FlushMultipleTb;
1630 ULONG FlushEntireTb;
1631 ULONG GenericCall;
1632 ULONG ChangeColor;
1633 ULONG SweepDcache;
1634 ULONG SweepIcache;
1635 ULONG SweepIcacheRange;
1636 ULONG FlushIoBuffers;
1637 ULONG GratuitousDPC;
1638 } KIPI_COUNTS, *PKIPI_COUNTS;
1639
1640 _IRQL_requires_same_
1641 _Function_class_(KIPI_BROADCAST_WORKER)
1642 _IRQL_requires_(IPI_LEVEL)
1643 typedef ULONG_PTR
1644 (NTAPI KIPI_BROADCAST_WORKER)(
1645 _In_ ULONG_PTR Argument);
1646 typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER;
1647
1648 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
1649
1650 typedef struct _KSPIN_LOCK_QUEUE {
1651 struct _KSPIN_LOCK_QUEUE *volatile Next;
1652 PKSPIN_LOCK volatile Lock;
1653 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
1654
1655 typedef struct _KLOCK_QUEUE_HANDLE {
1656 KSPIN_LOCK_QUEUE LockQueue;
1657 KIRQL OldIrql;
1658 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
1659
1660 #if defined(_AMD64_)
1661
1662 typedef ULONG64 KSPIN_LOCK_QUEUE_NUMBER;
1663
1664 #define LockQueueDispatcherLock 0
1665 #define LockQueueExpansionLock 1
1666 #define LockQueuePfnLock 2
1667 #define LockQueueSystemSpaceLock 3
1668 #define LockQueueVacbLock 4
1669 #define LockQueueMasterLock 5
1670 #define LockQueueNonPagedPoolLock 6
1671 #define LockQueueIoCancelLock 7
1672 #define LockQueueWorkQueueLock 8
1673 #define LockQueueIoVpbLock 9
1674 #define LockQueueIoDatabaseLock 10
1675 #define LockQueueIoCompletionLock 11
1676 #define LockQueueNtfsStructLock 12
1677 #define LockQueueAfdWorkQueueLock 13
1678 #define LockQueueBcbLock 14
1679 #define LockQueueMmNonPagedPoolLock 15
1680 #define LockQueueUnusedSpare16 16
1681 #define LockQueueTimerTableLock 17
1682 #define LockQueueMaximumLock (LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS)
1683
1684 #else
1685
1686 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
1687 LockQueueDispatcherLock,
1688 LockQueueExpansionLock,
1689 LockQueuePfnLock,
1690 LockQueueSystemSpaceLock,
1691 LockQueueVacbLock,
1692 LockQueueMasterLock,
1693 LockQueueNonPagedPoolLock,
1694 LockQueueIoCancelLock,
1695 LockQueueWorkQueueLock,
1696 LockQueueIoVpbLock,
1697 LockQueueIoDatabaseLock,
1698 LockQueueIoCompletionLock,
1699 LockQueueNtfsStructLock,
1700 LockQueueAfdWorkQueueLock,
1701 LockQueueBcbLock,
1702 LockQueueMmNonPagedPoolLock,
1703 LockQueueUnusedSpare16,
1704 LockQueueTimerTableLock,
1705 LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS
1706 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
1707
1708 #endif /* defined(_AMD64_) */
1709
1710 _Function_class_(KDEFERRED_ROUTINE)
1711 _IRQL_requires_(DISPATCH_LEVEL)
1712 _IRQL_requires_same_
1713 typedef VOID
1714 (NTAPI KDEFERRED_ROUTINE)(
1715 _In_ struct _KDPC *Dpc,
1716 _In_opt_ PVOID DeferredContext,
1717 _In_opt_ PVOID SystemArgument1,
1718 _In_opt_ PVOID SystemArgument2);
1719 typedef KDEFERRED_ROUTINE *PKDEFERRED_ROUTINE;
1720
1721 typedef enum _KDPC_IMPORTANCE {
1722 LowImportance,
1723 MediumImportance,
1724 HighImportance,
1725 MediumHighImportance
1726 } KDPC_IMPORTANCE;
1727
1728 typedef struct _KDPC {
1729 UCHAR Type;
1730 UCHAR Importance;
1731 volatile USHORT Number;
1732 LIST_ENTRY DpcListEntry;
1733 PKDEFERRED_ROUTINE DeferredRoutine;
1734 PVOID DeferredContext;
1735 PVOID SystemArgument1;
1736 PVOID SystemArgument2;
1737 volatile PVOID DpcData;
1738 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
1739
1740 typedef struct _KDPC_WATCHDOG_INFORMATION {
1741 ULONG DpcTimeLimit;
1742 ULONG DpcTimeCount;
1743 ULONG DpcWatchdogLimit;
1744 ULONG DpcWatchdogCount;
1745 ULONG Reserved;
1746 } KDPC_WATCHDOG_INFORMATION, *PKDPC_WATCHDOG_INFORMATION;
1747
1748 typedef struct _KDEVICE_QUEUE {
1749 CSHORT Type;
1750 CSHORT Size;
1751 LIST_ENTRY DeviceListHead;
1752 KSPIN_LOCK Lock;
1753 # if defined(_AMD64_)
1754 _ANONYMOUS_UNION union {
1755 BOOLEAN Busy;
1756 _ANONYMOUS_STRUCT struct {
1757 LONG64 Reserved:8;
1758 LONG64 Hint:56;
1759 } DUMMYSTRUCTNAME;
1760 } DUMMYUNIONNAME;
1761 # else
1762 BOOLEAN Busy;
1763 # endif
1764 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
1765
1766 #define TIMER_EXPIRED_INDEX_BITS 6
1767 #define TIMER_PROCESSOR_INDEX_BITS 5
1768
1769 typedef struct _DISPATCHER_HEADER {
1770 _ANONYMOUS_UNION union {
1771 _ANONYMOUS_STRUCT struct {
1772 UCHAR Type;
1773 _ANONYMOUS_UNION union {
1774 _ANONYMOUS_UNION union {
1775 UCHAR TimerControlFlags;
1776 _ANONYMOUS_STRUCT struct {
1777 UCHAR Absolute:1;
1778 UCHAR Coalescable:1;
1779 UCHAR KeepShifting:1;
1780 UCHAR EncodedTolerableDelay:5;
1781 } DUMMYSTRUCTNAME;
1782 } DUMMYUNIONNAME;
1783 UCHAR Abandoned;
1784 #if (NTDDI_VERSION < NTDDI_WIN7)
1785 UCHAR NpxIrql;
1786 #endif
1787 BOOLEAN Signalling;
1788 } DUMMYUNIONNAME;
1789 _ANONYMOUS_UNION union {
1790 _ANONYMOUS_UNION union {
1791 UCHAR ThreadControlFlags;
1792 _ANONYMOUS_STRUCT struct {
1793 UCHAR CpuThrottled:1;
1794 UCHAR CycleProfiling:1;
1795 UCHAR CounterProfiling:1;
1796 UCHAR Reserved:5;
1797 } DUMMYSTRUCTNAME;
1798 } DUMMYUNIONNAME;
1799 UCHAR Size;
1800 UCHAR Hand;
1801 } DUMMYUNIONNAME2;
1802 _ANONYMOUS_UNION union {
1803 #if (NTDDI_VERSION >= NTDDI_WIN7)
1804 _ANONYMOUS_UNION union {
1805 UCHAR TimerMiscFlags;
1806 _ANONYMOUS_STRUCT struct {
1807 #if !defined(_X86_)
1808 UCHAR Index:TIMER_EXPIRED_INDEX_BITS;
1809 #else
1810 UCHAR Index:1;
1811 UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS;
1812 #endif
1813 UCHAR Inserted:1;
1814 volatile UCHAR Expired:1;
1815 } DUMMYSTRUCTNAME;
1816 } DUMMYUNIONNAME;
1817 #else
1818 /* Pre Win7 compatibility fix to latest WDK */
1819 UCHAR Inserted;
1820 #endif
1821 _ANONYMOUS_UNION union {
1822 BOOLEAN DebugActive;
1823 _ANONYMOUS_STRUCT struct {
1824 BOOLEAN ActiveDR7:1;
1825 BOOLEAN Instrumented:1;
1826 BOOLEAN Reserved2:4;
1827 BOOLEAN UmsScheduled:1;
1828 BOOLEAN UmsPrimary:1;
1829 } DUMMYSTRUCTNAME;
1830 } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */
1831 BOOLEAN DpcActive;
1832 } DUMMYUNIONNAME3;
1833 } DUMMYSTRUCTNAME;
1834 volatile LONG Lock;
1835 } DUMMYUNIONNAME;
1836 LONG SignalState;
1837 LIST_ENTRY WaitListHead;
1838 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
1839
1840 typedef struct _KEVENT {
1841 DISPATCHER_HEADER Header;
1842 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
1843
1844 typedef struct _KSEMAPHORE {
1845 DISPATCHER_HEADER Header;
1846 LONG Limit;
1847 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
1848
1849 #define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG))
1850
1851 typedef struct _KGATE {
1852 DISPATCHER_HEADER Header;
1853 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
1854
1855 typedef struct _KGUARDED_MUTEX {
1856 volatile LONG Count;
1857 PKTHREAD Owner;
1858 ULONG Contention;
1859 KGATE Gate;
1860 _ANONYMOUS_UNION union {
1861 _ANONYMOUS_STRUCT struct {
1862 SHORT KernelApcDisable;
1863 SHORT SpecialApcDisable;
1864 } DUMMYSTRUCTNAME;
1865 ULONG CombinedApcDisable;
1866 } DUMMYUNIONNAME;
1867 } KGUARDED_MUTEX, *PKGUARDED_MUTEX;
1868
1869 typedef struct _KMUTANT {
1870 DISPATCHER_HEADER Header;
1871 LIST_ENTRY MutantListEntry;
1872 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
1873 BOOLEAN Abandoned;
1874 UCHAR ApcDisable;
1875 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
1876
1877 #define TIMER_TABLE_SIZE 512
1878 #define TIMER_TABLE_SHIFT 9
1879
1880 typedef struct _KTIMER {
1881 DISPATCHER_HEADER Header;
1882 ULARGE_INTEGER DueTime;
1883 LIST_ENTRY TimerListEntry;
1884 struct _KDPC *Dpc;
1885 #if (NTDDI_VERSION >= NTDDI_WIN7) && !defined(_X86_)
1886 ULONG Processor;
1887 #endif
1888 ULONG Period;
1889 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
1890
1891 typedef enum _LOCK_OPERATION {
1892 IoReadAccess,
1893 IoWriteAccess,
1894 IoModifyAccess
1895 } LOCK_OPERATION;
1896
1897 #define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG))
1898
1899 _Function_class_(KSYNCHRONIZE_ROUTINE)
1900 _IRQL_requires_same_
1901 typedef BOOLEAN
1902 (NTAPI KSYNCHRONIZE_ROUTINE)(
1903 _In_ PVOID SynchronizeContext);
1904 typedef KSYNCHRONIZE_ROUTINE *PKSYNCHRONIZE_ROUTINE;
1905
1906 typedef enum _POOL_TYPE {
1907 NonPagedPool,
1908 PagedPool,
1909 NonPagedPoolMustSucceed,
1910 DontUseThisType,
1911 NonPagedPoolCacheAligned,
1912 PagedPoolCacheAligned,
1913 NonPagedPoolCacheAlignedMustS,
1914 MaxPoolType,
1915 NonPagedPoolSession = 32,
1916 PagedPoolSession,
1917 NonPagedPoolMustSucceedSession,
1918 DontUseThisTypeSession,
1919 NonPagedPoolCacheAlignedSession,
1920 PagedPoolCacheAlignedSession,
1921 NonPagedPoolCacheAlignedMustSSession
1922 } POOL_TYPE;
1923
1924 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE {
1925 StandardDesign,
1926 NEC98x86,
1927 EndAlternatives
1928 } ALTERNATIVE_ARCHITECTURE_TYPE;
1929
1930 #ifndef _X86_
1931
1932 #ifndef IsNEC_98
1933 #define IsNEC_98 (FALSE)
1934 #endif
1935
1936 #ifndef IsNotNEC_98
1937 #define IsNotNEC_98 (TRUE)
1938 #endif
1939
1940 #ifndef SetNEC_98
1941 #define SetNEC_98
1942 #endif
1943
1944 #ifndef SetNotNEC_98
1945 #define SetNotNEC_98
1946 #endif
1947
1948 #endif
1949
1950 typedef struct _KSYSTEM_TIME {
1951 ULONG LowPart;
1952 LONG High1Time;
1953 LONG High2Time;
1954 } KSYSTEM_TIME, *PKSYSTEM_TIME;
1955
1956 typedef struct DECLSPEC_ALIGN(16) _M128A {
1957 ULONGLONG Low;
1958 LONGLONG High;
1959 } M128A, *PM128A;
1960
1961 typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT {
1962 USHORT ControlWord;
1963 USHORT StatusWord;
1964 UCHAR TagWord;
1965 UCHAR Reserved1;
1966 USHORT ErrorOpcode;
1967 ULONG ErrorOffset;
1968 USHORT ErrorSelector;
1969 USHORT Reserved2;
1970 ULONG DataOffset;
1971 USHORT DataSelector;
1972 USHORT Reserved3;
1973 ULONG MxCsr;
1974 ULONG MxCsr_Mask;
1975 M128A FloatRegisters[8];
1976 #if defined(_WIN64)
1977 M128A XmmRegisters[16];
1978 UCHAR Reserved4[96];
1979 #else
1980 M128A XmmRegisters[8];
1981 UCHAR Reserved4[192];
1982 ULONG StackControl[7];
1983 ULONG Cr0NpxState;
1984 #endif
1985 } XSAVE_FORMAT, *PXSAVE_FORMAT;
1986
1987 typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER {
1988 ULONG64 Mask;
1989 ULONG64 Reserved[7];
1990 } XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER;
1991
1992 typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA {
1993 XSAVE_FORMAT LegacyState;
1994 XSAVE_AREA_HEADER Header;
1995 } XSAVE_AREA, *PXSAVE_AREA;
1996
1997 typedef struct _XSTATE_CONTEXT {
1998 ULONG64 Mask;
1999 ULONG Length;
2000 ULONG Reserved1;
2001 _Field_size_bytes_opt_(Length) PXSAVE_AREA Area;
2002 #if defined(_X86_)
2003 ULONG Reserved2;
2004 #endif
2005 PVOID Buffer;
2006 #if defined(_X86_)
2007 ULONG Reserved3;
2008 #endif
2009 } XSTATE_CONTEXT, *PXSTATE_CONTEXT;
2010
2011 typedef struct _XSTATE_SAVE {
2012 #if defined(_AMD64_)
2013 struct _XSTATE_SAVE* Prev;
2014 struct _KTHREAD* Thread;
2015 UCHAR Level;
2016 XSTATE_CONTEXT XStateContext;
2017 #elif defined(_IA64_) || defined(_ARM_)
2018 ULONG Dummy;
2019 #elif defined(_X86_)
2020 _ANONYMOUS_UNION union {
2021 _ANONYMOUS_STRUCT struct {
2022 LONG64 Reserved1;
2023 ULONG Reserved2;
2024 struct _XSTATE_SAVE* Prev;
2025 PXSAVE_AREA Reserved3;
2026 struct _KTHREAD* Thread;
2027 PVOID Reserved4;
2028 UCHAR Level;
2029 } DUMMYSTRUCTNAME;
2030 XSTATE_CONTEXT XStateContext;
2031 } DUMMYUNIONNAME;
2032 #endif
2033 } XSTATE_SAVE, *PXSTATE_SAVE;
2034
2035 #ifdef _X86_
2036
2037 #define MAXIMUM_SUPPORTED_EXTENSION 512
2038
2039 #if !defined(__midl) && !defined(MIDL_PASS)
2040 C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION);
2041 #endif
2042
2043 #endif /* _X86_ */
2044
2045 #define XSAVE_ALIGN 64
2046 #define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA)
2047
2048 #if !defined(__midl) && !defined(MIDL_PASS)
2049 C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0);
2050 C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0);
2051 C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64);
2052 #endif
2053
2054 typedef struct _CONTEXT_CHUNK {
2055 LONG Offset;
2056 ULONG Length;
2057 } CONTEXT_CHUNK, *PCONTEXT_CHUNK;
2058
2059 typedef struct _CONTEXT_EX {
2060 CONTEXT_CHUNK All;
2061 CONTEXT_CHUNK Legacy;
2062 CONTEXT_CHUNK XState;
2063 } CONTEXT_EX, *PCONTEXT_EX;
2064
2065 #define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN)
2066
2067 #if (NTDDI_VERSION >= NTDDI_VISTA)
2068 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
2069 #elif (NTDDI_VERSION >= NTDDI_WINXP)
2070 extern NTSYSAPI CCHAR KeNumberProcessors;
2071 #else
2072 __CREATE_NTOS_DATA_IMPORT_ALIAS(KeNumberProcessors)
2073 extern PCCHAR KeNumberProcessors;
2074 #endif
2075
2076
2077 /******************************************************************************
2078 * Memory manager Types *
2079 ******************************************************************************/
2080
2081 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2082 typedef ULONG NODE_REQUIREMENT;
2083 #define MM_ANY_NODE_OK 0x80000000
2084 #endif
2085
2086 #define MM_DONT_ZERO_ALLOCATION 0x00000001
2087 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002
2088 #define MM_ALLOCATE_FULLY_REQUIRED 0x00000004
2089 #define MM_ALLOCATE_NO_WAIT 0x00000008
2090 #define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010
2091 #define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020
2092
2093 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
2094 #define MDL_PAGES_LOCKED 0x0002
2095 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
2096 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
2097 #define MDL_PARTIAL 0x0010
2098 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
2099 #define MDL_IO_PAGE_READ 0x0040
2100 #define MDL_WRITE_OPERATION 0x0080
2101 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
2102 #define MDL_FREE_EXTRA_PTES 0x0200
2103 #define MDL_DESCRIBES_AWE 0x0400
2104 #define MDL_IO_SPACE 0x0800
2105 #define MDL_NETWORK_HEADER 0x1000
2106 #define MDL_MAPPING_CAN_FAIL 0x2000
2107 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
2108 #define MDL_INTERNAL 0x8000
2109
2110 #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \
2111 MDL_PAGES_LOCKED | \
2112 MDL_SOURCE_IS_NONPAGED_POOL | \
2113 MDL_PARTIAL_HAS_BEEN_MAPPED | \
2114 MDL_PARENT_MAPPED_SYSTEM_VA | \
2115 MDL_SYSTEM_VA | \
2116 MDL_IO_SPACE)
2117
2118 #define FLUSH_MULTIPLE_MAXIMUM 32
2119
2120 /* Section access rights */
2121 #define SECTION_QUERY 0x0001
2122 #define SECTION_MAP_WRITE 0x0002
2123 #define SECTION_MAP_READ 0x0004
2124 #define SECTION_MAP_EXECUTE 0x0008
2125 #define SECTION_EXTEND_SIZE 0x0010
2126 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
2127
2128 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| \
2129 SECTION_MAP_WRITE | \
2130 SECTION_MAP_READ | \
2131 SECTION_MAP_EXECUTE | \
2132 SECTION_EXTEND_SIZE)
2133
2134 #define SESSION_QUERY_ACCESS 0x0001
2135 #define SESSION_MODIFY_ACCESS 0x0002
2136
2137 #define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
2138 SESSION_QUERY_ACCESS | \
2139 SESSION_MODIFY_ACCESS)
2140
2141 #define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
2142
2143 #define PAGE_NOACCESS 0x01
2144 #define PAGE_READONLY 0x02
2145 #define PAGE_READWRITE 0x04
2146 #define PAGE_WRITECOPY 0x08
2147 #define PAGE_EXECUTE 0x10
2148 #define PAGE_EXECUTE_READ 0x20
2149 #define PAGE_EXECUTE_READWRITE 0x40
2150 #define PAGE_EXECUTE_WRITECOPY 0x80
2151 #define PAGE_GUARD 0x100
2152 #define PAGE_NOCACHE 0x200
2153 #define PAGE_WRITECOMBINE 0x400
2154
2155 #define MEM_COMMIT 0x1000
2156 #define MEM_RESERVE 0x2000
2157 #define MEM_DECOMMIT 0x4000
2158 #define MEM_RELEASE 0x8000
2159 #define MEM_FREE 0x10000
2160 #define MEM_PRIVATE 0x20000
2161 #define MEM_MAPPED 0x40000
2162 #define MEM_RESET 0x80000
2163 #define MEM_TOP_DOWN 0x100000
2164 #define MEM_LARGE_PAGES 0x20000000
2165 #define MEM_4MB_PAGES 0x80000000
2166
2167 #define SEC_RESERVE 0x4000000
2168 #define SEC_COMMIT 0x8000000
2169 #define SEC_LARGE_PAGES 0x80000000
2170
2171 /* Section map options */
2172 typedef enum _SECTION_INHERIT {
2173 ViewShare = 1,
2174 ViewUnmap = 2
2175 } SECTION_INHERIT;
2176
2177 typedef ULONG PFN_COUNT;
2178 typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
2179 typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
2180
2181 _Struct_size_bytes_(_Inexpressible_(sizeof(struct _MDL) +
2182 (ByteOffset + ByteCount + PAGE_SIZE-1) / PAGE_SIZE * sizeof(PFN_NUMBER)))
2183 typedef struct _MDL {
2184 struct _MDL *Next;
2185 CSHORT Size;
2186 CSHORT MdlFlags;
2187 struct _EPROCESS *Process;
2188 PVOID MappedSystemVa;
2189 PVOID StartVa;
2190 ULONG ByteCount;
2191 ULONG ByteOffset;
2192 } MDL, *PMDL;
2193 #if (_MSC_VER >= 1600)
2194 typedef _Readable_bytes_(_Inexpressible_(polymorphism)) MDL *PMDLX;
2195 #else
2196 typedef MDL *PMDLX;
2197 #endif
2198
2199 typedef enum _MEMORY_CACHING_TYPE_ORIG {
2200 MmFrameBufferCached = 2
2201 } MEMORY_CACHING_TYPE_ORIG;
2202
2203 typedef enum _MEMORY_CACHING_TYPE {
2204 MmNonCached = FALSE,
2205 MmCached = TRUE,
2206 MmWriteCombined = MmFrameBufferCached,
2207 MmHardwareCoherentCached,
2208 MmNonCachedUnordered,
2209 MmUSWCCached,
2210 MmMaximumCacheType
2211 } MEMORY_CACHING_TYPE;
2212
2213 typedef enum _MM_PAGE_PRIORITY {
2214 LowPagePriority,
2215 NormalPagePriority = 16,
2216 HighPagePriority = 32
2217 } MM_PAGE_PRIORITY;
2218
2219 typedef enum _MM_SYSTEM_SIZE {
2220 MmSmallSystem,
2221 MmMediumSystem,
2222 MmLargeSystem
2223 } MM_SYSTEMSIZE;
2224
2225 #ifndef _NTSYSTEM_
2226 __CREATE_NTOS_DATA_IMPORT_ALIAS(Mm64BitPhysicalAddress)
2227 extern PBOOLEAN Mm64BitPhysicalAddress;
2228 #endif
2229 extern NTKERNELAPI PVOID MmBadPointer;
2230
2231
2232 /******************************************************************************
2233 * Executive Types *
2234 ******************************************************************************/
2235 #define EX_RUNDOWN_ACTIVE 0x1
2236 #define EX_RUNDOWN_COUNT_SHIFT 0x1
2237 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT)
2238
2239 typedef struct _FAST_MUTEX {
2240 volatile LONG Count;
2241 PKTHREAD Owner;
2242 ULONG Contention;
2243 KEVENT Event;
2244 ULONG OldIrql;
2245 } FAST_MUTEX, *PFAST_MUTEX;
2246
2247 typedef enum _SUITE_TYPE {
2248 SmallBusiness,
2249 Enterprise,
2250 BackOffice,
2251 CommunicationServer,
2252 TerminalServer,
2253 SmallBusinessRestricted,
2254 EmbeddedNT,
2255 DataCenter,
2256 SingleUserTS,
2257 Personal,
2258 Blade,
2259 EmbeddedRestricted,
2260 SecurityAppliance,
2261 StorageServer,
2262 ComputeServer,
2263 WHServer,
2264 MaxSuiteType
2265 } SUITE_TYPE;
2266
2267 typedef enum _EX_POOL_PRIORITY {
2268 LowPoolPriority,
2269 LowPoolPrioritySpecialPoolOverrun = 8,
2270 LowPoolPrioritySpecialPoolUnderrun = 9,
2271 NormalPoolPriority = 16,
2272 NormalPoolPrioritySpecialPoolOverrun = 24,
2273 NormalPoolPrioritySpecialPoolUnderrun = 25,
2274 HighPoolPriority = 32,
2275 HighPoolPrioritySpecialPoolOverrun = 40,
2276 HighPoolPrioritySpecialPoolUnderrun = 41
2277 } EX_POOL_PRIORITY;
2278
2279 #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
2280 #define LOOKASIDE_ALIGN
2281 #else
2282 #define LOOKASIDE_ALIGN DECLSPEC_CACHEALIGN
2283 #endif
2284
2285 typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX;
2286
2287 _IRQL_requires_same_
2288 _Function_class_(ALLOCATE_FUNCTION)
2289 typedef PVOID
2290 (NTAPI *PALLOCATE_FUNCTION)(
2291 _In_ POOL_TYPE PoolType,
2292 _In_ SIZE_T NumberOfBytes,
2293 _In_ ULONG Tag);
2294
2295 _IRQL_requires_same_
2296 _Function_class_(ALLOCATE_FUNCTION_EX)
2297 typedef PVOID
2298 (NTAPI *PALLOCATE_FUNCTION_EX)(
2299 _In_ POOL_TYPE PoolType,
2300 _In_ SIZE_T NumberOfBytes,
2301 _In_ ULONG Tag,
2302 _Inout_ PLOOKASIDE_LIST_EX Lookaside);
2303
2304 _IRQL_requires_same_
2305 _Function_class_(FREE_FUNCTION)
2306 typedef VOID
2307 (NTAPI *PFREE_FUNCTION)(
2308 _In_ PVOID Buffer);
2309
2310 _IRQL_requires_same_
2311 _Function_class_(FREE_FUNCTION_EX)
2312 typedef VOID
2313 (NTAPI *PFREE_FUNCTION_EX)(
2314 _In_ PVOID Buffer,
2315 _Inout_ PLOOKASIDE_LIST_EX Lookaside);
2316
2317 _IRQL_requires_same_
2318 _Function_class_(CALLBACK_FUNCTION)
2319 typedef VOID
2320 (NTAPI CALLBACK_FUNCTION)(
2321 _In_opt_ PVOID CallbackContext,
2322 _In_opt_ PVOID Argument1,
2323 _In_opt_ PVOID Argument2);
2324 typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION;
2325
2326 #define GENERAL_LOOKASIDE_LAYOUT \
2327 _ANONYMOUS_UNION union { \
2328 SLIST_HEADER ListHead; \
2329 SINGLE_LIST_ENTRY SingleListHead; \
2330 } DUMMYUNIONNAME; \
2331 USHORT Depth; \
2332 USHORT MaximumDepth; \
2333 ULONG TotalAllocates; \
2334 _ANONYMOUS_UNION union { \
2335 ULONG AllocateMisses; \
2336 ULONG AllocateHits; \
2337 } DUMMYUNIONNAME2; \
2338 ULONG TotalFrees; \
2339 _ANONYMOUS_UNION union { \
2340 ULONG FreeMisses; \
2341 ULONG FreeHits; \
2342 } DUMMYUNIONNAME3; \
2343 POOL_TYPE Type; \
2344 ULONG Tag; \
2345 ULONG Size; \
2346 _ANONYMOUS_UNION union { \
2347 PALLOCATE_FUNCTION_EX AllocateEx; \
2348 PALLOCATE_FUNCTION Allocate; \
2349 } DUMMYUNIONNAME4; \
2350 _ANONYMOUS_UNION union { \
2351 PFREE_FUNCTION_EX FreeEx; \
2352 PFREE_FUNCTION Free; \
2353 } DUMMYUNIONNAME5; \
2354 LIST_ENTRY ListEntry; \
2355 ULONG LastTotalAllocates; \
2356 _ANONYMOUS_UNION union { \
2357 ULONG LastAllocateMisses; \
2358 ULONG LastAllocateHits; \
2359 } DUMMYUNIONNAME6; \
2360 ULONG Future[2];
2361
2362 typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE {
2363 GENERAL_LOOKASIDE_LAYOUT
2364 } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
2365
2366 typedef struct _GENERAL_LOOKASIDE_POOL {
2367 GENERAL_LOOKASIDE_LAYOUT
2368 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
2369
2370 #define LOOKASIDE_CHECK(f) \
2371 C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f))
2372
2373 LOOKASIDE_CHECK(TotalFrees);
2374 LOOKASIDE_CHECK(Tag);
2375 LOOKASIDE_CHECK(Future);
2376
2377 typedef struct LOOKASIDE_ALIGN _PAGED_LOOKASIDE_LIST {
2378 GENERAL_LOOKASIDE L;
2379 #if !defined(_AMD64_) && !defined(_IA64_)
2380 FAST_MUTEX Lock__ObsoleteButDoNotDelete;
2381 #endif
2382 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
2383
2384 typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST {
2385 GENERAL_LOOKASIDE L;
2386 #if !defined(_AMD64_) && !defined(_IA64_)
2387 KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
2388 #endif
2389 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
2390
2391 #define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next))
2392
2393 typedef struct _LOOKASIDE_LIST_EX {
2394 GENERAL_LOOKASIDE_POOL L;
2395 } LOOKASIDE_LIST_EX;
2396
2397 #if (NTDDI_VERSION >= NTDDI_VISTA)
2398
2399 #define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL
2400 #define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL
2401
2402 #define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256
2403 #define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024
2404
2405 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2406
2407 typedef struct _EX_RUNDOWN_REF {
2408 _ANONYMOUS_UNION union {
2409 volatile ULONG_PTR Count;
2410 volatile PVOID Ptr;
2411 } DUMMYUNIONNAME;
2412 } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
2413
2414 typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE;
2415
2416 typedef enum _WORK_QUEUE_TYPE {
2417 CriticalWorkQueue,
2418 DelayedWorkQueue,
2419 HyperCriticalWorkQueue,
2420 MaximumWorkQueue
2421 } WORK_QUEUE_TYPE;
2422
2423 _IRQL_requires_same_
2424 _Function_class_(WORKER_THREAD_ROUTINE)
2425 typedef VOID
2426 (NTAPI WORKER_THREAD_ROUTINE)(
2427 _In_ PVOID Parameter);
2428 typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE;
2429
2430 typedef struct _WORK_QUEUE_ITEM {
2431 LIST_ENTRY List;
2432 PWORKER_THREAD_ROUTINE WorkerRoutine;
2433 volatile PVOID Parameter;
2434 } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
2435
2436 typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
2437
2438 typedef struct _OWNER_ENTRY {
2439 ERESOURCE_THREAD OwnerThread;
2440 _ANONYMOUS_UNION union {
2441 _ANONYMOUS_STRUCT struct {
2442 ULONG IoPriorityBoosted:1;
2443 ULONG OwnerReferenced:1;
2444 ULONG OwnerCount:30;
2445 } DUMMYSTRUCTNAME;
2446 ULONG TableSize;
2447 } DUMMYUNIONNAME;
2448 } OWNER_ENTRY, *POWNER_ENTRY;
2449
2450 typedef struct _ERESOURCE {
2451 LIST_ENTRY SystemResourcesList;
2452 POWNER_ENTRY OwnerTable;
2453 SHORT ActiveCount;
2454 USHORT Flag;
2455 volatile PKSEMAPHORE SharedWaiters;
2456 volatile PKEVENT ExclusiveWaiters;
2457 OWNER_ENTRY OwnerEntry;
2458 ULONG ActiveEntries;
2459 ULONG ContentionCount;
2460 ULONG NumberOfSharedWaiters;
2461 ULONG NumberOfExclusiveWaiters;
2462 #if defined(_WIN64)
2463 PVOID Reserved2;
2464 #endif
2465 _ANONYMOUS_UNION union {
2466 PVOID Address;
2467 ULONG_PTR CreatorBackTraceIndex;
2468 } DUMMYUNIONNAME;
2469 KSPIN_LOCK SpinLock;
2470 } ERESOURCE, *PERESOURCE;
2471
2472 /* ERESOURCE.Flag */
2473 #define ResourceNeverExclusive 0x0010
2474 #define ResourceReleaseByOtherThread 0x0020
2475 #define ResourceOwnedExclusive 0x0080
2476
2477 #define RESOURCE_HASH_TABLE_SIZE 64
2478
2479 typedef struct _RESOURCE_HASH_ENTRY {
2480 LIST_ENTRY ListEntry;
2481 PVOID Address;
2482 ULONG ContentionCount;
2483 ULONG Number;
2484 } RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY;
2485
2486 typedef struct _RESOURCE_PERFORMANCE_DATA {
2487 ULONG ActiveResourceCount;
2488 ULONG TotalResourceCount;
2489 ULONG ExclusiveAcquire;
2490 ULONG SharedFirstLevel;
2491 ULONG SharedSecondLevel;
2492 ULONG StarveFirstLevel;
2493 ULONG StarveSecondLevel;
2494 ULONG WaitForExclusive;
2495 ULONG OwnerTableExpands;
2496 ULONG MaximumTableExpand;
2497 LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE];
2498 } RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA;
2499
2500 /* Global debug flag */
2501 #if DEVL
2502 extern NTKERNELAPI ULONG NtGlobalFlag;
2503 #define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName))
2504 #else
2505 #define IF_NTOS_DEBUG(FlagName) if(FALSE)
2506 #endif
2507
2508 /******************************************************************************
2509 * Security Manager Types *
2510 ******************************************************************************/
2511
2512 /* Simple types */
2513 typedef PVOID PSECURITY_DESCRIPTOR;
2514 typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
2515 typedef ULONG ACCESS_MASK, *PACCESS_MASK;
2516 typedef PVOID PACCESS_TOKEN;
2517 typedef PVOID PSID;
2518
2519 #define DELETE 0x00010000L
2520 #define READ_CONTROL 0x00020000L
2521 #define WRITE_DAC 0x00040000L
2522 #define WRITE_OWNER 0x00080000L
2523 #define SYNCHRONIZE 0x00100000L
2524 #define STANDARD_RIGHTS_REQUIRED 0x000F0000L
2525 #define STANDARD_RIGHTS_READ READ_CONTROL
2526 #define STANDARD_RIGHTS_WRITE READ_CONTROL
2527 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
2528 #define STANDARD_RIGHTS_ALL 0x001F0000L
2529 #define SPECIFIC_RIGHTS_ALL 0x0000FFFFL
2530 #define ACCESS_SYSTEM_SECURITY 0x01000000L
2531 #define MAXIMUM_ALLOWED 0x02000000L
2532 #define GENERIC_READ 0x80000000L
2533 #define GENERIC_WRITE 0x40000000L
2534 #define GENERIC_EXECUTE 0x20000000L
2535 #define GENERIC_ALL 0x10000000L
2536
2537 typedef struct _GENERIC_MAPPING {
2538 ACCESS_MASK GenericRead;
2539 ACCESS_MASK GenericWrite;
2540 ACCESS_MASK GenericExecute;
2541 ACCESS_MASK GenericAll;
2542 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2543
2544 #define ACL_REVISION 2
2545 #define ACL_REVISION_DS 4
2546
2547 #define ACL_REVISION1 1
2548 #define ACL_REVISION2 2
2549 #define ACL_REVISION3 3
2550 #define ACL_REVISION4 4
2551 #define MIN_ACL_REVISION ACL_REVISION2
2552 #define MAX_ACL_REVISION ACL_REVISION4
2553
2554 typedef struct _ACL {
2555 UCHAR AclRevision;
2556 UCHAR Sbz1;
2557 USHORT AclSize;
2558 USHORT AceCount;
2559 USHORT Sbz2;
2560 } ACL, *PACL;
2561
2562 /* Current security descriptor revision value */
2563 #define SECURITY_DESCRIPTOR_REVISION (1)
2564 #define SECURITY_DESCRIPTOR_REVISION1 (1)
2565
2566 /* Privilege attributes */
2567 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
2568 #define SE_PRIVILEGE_ENABLED (0x00000002L)
2569 #define SE_PRIVILEGE_REMOVED (0X00000004L)
2570 #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
2571
2572 #define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \
2573 SE_PRIVILEGE_ENABLED | \
2574 SE_PRIVILEGE_REMOVED | \
2575 SE_PRIVILEGE_USED_FOR_ACCESS)
2576
2577 #include <pshpack4.h>
2578 typedef struct _LUID_AND_ATTRIBUTES {
2579 LUID Luid;
2580 ULONG Attributes;
2581 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
2582 #include <poppack.h>
2583
2584 typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
2585 typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
2586
2587 /* Privilege sets */
2588 #define PRIVILEGE_SET_ALL_NECESSARY (1)
2589
2590 typedef struct _PRIVILEGE_SET {
2591 ULONG PrivilegeCount;
2592 ULONG Control;
2593 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
2594 } PRIVILEGE_SET,*PPRIVILEGE_SET;
2595
2596 typedef enum _SECURITY_IMPERSONATION_LEVEL {
2597 SecurityAnonymous,
2598 SecurityIdentification,
2599 SecurityImpersonation,
2600 SecurityDelegation
2601 } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
2602
2603 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
2604 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
2605 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
2606 #define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL))
2607
2608 #define SECURITY_DYNAMIC_TRACKING (TRUE)
2609 #define SECURITY_STATIC_TRACKING (FALSE)
2610
2611 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE;
2612
2613 typedef struct _SECURITY_QUALITY_OF_SERVICE {
2614 ULONG Length;
2615 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
2616 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
2617 BOOLEAN EffectiveOnly;
2618 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
2619
2620 typedef struct _SE_IMPERSONATION_STATE {
2621 PACCESS_TOKEN Token;
2622 BOOLEAN CopyOnOpen;
2623 BOOLEAN EffectiveOnly;
2624 SECURITY_IMPERSONATION_LEVEL Level;
2625 } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
2626
2627 #define OWNER_SECURITY_INFORMATION (0x00000001L)
2628 #define GROUP_SECURITY_INFORMATION (0x00000002L)
2629 #define DACL_SECURITY_INFORMATION (0x00000004L)
2630 #define SACL_SECURITY_INFORMATION (0x00000008L)
2631 #define LABEL_SECURITY_INFORMATION (0x00000010L)
2632
2633 #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
2634 #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
2635 #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
2636 #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
2637
2638 typedef enum _SECURITY_OPERATION_CODE {
2639 SetSecurityDescriptor,
2640 QuerySecurityDescriptor,
2641 DeleteSecurityDescriptor,
2642 AssignSecurityDescriptor
2643 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
2644
2645 #define INITIAL_PRIVILEGE_COUNT 3
2646
2647 typedef struct _INITIAL_PRIVILEGE_SET {
2648 ULONG PrivilegeCount;
2649 ULONG Control;
2650 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
2651 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
2652
2653 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
2654 #define SE_CREATE_TOKEN_PRIVILEGE 2
2655 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
2656 #define SE_LOCK_MEMORY_PRIVILEGE 4
2657 #define SE_INCREASE_QUOTA_PRIVILEGE 5
2658 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
2659 #define SE_TCB_PRIVILEGE 7
2660 #define SE_SECURITY_PRIVILEGE 8
2661 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
2662 #define SE_LOAD_DRIVER_PRIVILEGE 10
2663 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
2664 #define SE_SYSTEMTIME_PRIVILEGE 12
2665 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
2666 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
2667 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
2668 #define SE_CREATE_PERMANENT_PRIVILEGE 16
2669 #define SE_BACKUP_PRIVILEGE 17
2670 #define SE_RESTORE_PRIVILEGE 18
2671 #define SE_SHUTDOWN_PRIVILEGE 19
2672 #define SE_DEBUG_PRIVILEGE 20
2673 #define SE_AUDIT_PRIVILEGE 21
2674 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
2675 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
2676 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
2677 #define SE_UNDOCK_PRIVILEGE 25
2678 #define SE_SYNC_AGENT_PRIVILEGE 26
2679 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
2680 #define SE_MANAGE_VOLUME_PRIVILEGE 28
2681 #define SE_IMPERSONATE_PRIVILEGE 29
2682 #define SE_CREATE_GLOBAL_PRIVILEGE 30
2683 #define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31
2684 #define SE_RELABEL_PRIVILEGE 32
2685 #define SE_INC_WORKING_SET_PRIVILEGE 33
2686 #define SE_TIME_ZONE_PRIVILEGE 34
2687 #define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 35
2688 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
2689
2690 typedef struct _SECURITY_SUBJECT_CONTEXT {
2691 PACCESS_TOKEN ClientToken;
2692 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
2693 PACCESS_TOKEN PrimaryToken;
2694 PVOID ProcessAuditId;
2695 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
2696
2697 typedef struct _ACCESS_STATE {
2698 LUID OperationID;
2699 BOOLEAN SecurityEvaluated;
2700 BOOLEAN GenerateAudit;
2701 BOOLEAN GenerateOnClose;
2702 BOOLEAN PrivilegesAllocated;
2703 ULONG Flags;
2704 ACCESS_MASK RemainingDesiredAccess;
2705 ACCESS_MASK PreviouslyGrantedAccess;
2706 ACCESS_MASK OriginalDesiredAccess;
2707 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
2708 PSECURITY_DESCRIPTOR SecurityDescriptor;
2709 PVOID AuxData;
2710 union {
2711 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
2712 PRIVILEGE_SET PrivilegeSet;
2713 } Privileges;
2714 BOOLEAN AuditPrivileges;
2715 UNICODE_STRING ObjectName;
2716 UNICODE_STRING ObjectTypeName;
2717 } ACCESS_STATE, *PACCESS_STATE;
2718
2719 typedef VOID
2720 (NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)(
2721 _In_ PVOID Vcb,
2722 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor);
2723
2724 #ifndef _NTLSA_IFS_
2725
2726 #ifndef _NTLSA_AUDIT_
2727 #define _NTLSA_AUDIT_
2728
2729 #define SE_MAX_AUDIT_PARAMETERS 32
2730 #define SE_MAX_GENERIC_AUDIT_PARAMETERS 28
2731
2732 #define SE_ADT_OBJECT_ONLY 0x1
2733
2734 #define SE_ADT_PARAMETERS_SELF_RELATIVE 0x00000001
2735 #define SE_ADT_PARAMETERS_SEND_TO_LSA 0x00000002
2736 #define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT 0x00000004
2737 #define SE_ADT_PARAMETER_GENERIC_AUDIT 0x00000008
2738 #define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010
2739
2740 #define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \
2741 ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \
2742 (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) )
2743
2744 typedef enum _SE_ADT_PARAMETER_TYPE {
2745 SeAdtParmTypeNone = 0,
2746 SeAdtParmTypeString,
2747 SeAdtParmTypeFileSpec,
2748 SeAdtParmTypeUlong,
2749 SeAdtParmTypeSid,
2750 SeAdtParmTypeLogonId,
2751 SeAdtParmTypeNoLogonId,
2752 SeAdtParmTypeAccessMask,
2753 SeAdtParmTypePrivs,
2754 SeAdtParmTypeObjectTypes,
2755 SeAdtParmTypeHexUlong,
2756 SeAdtParmTypePtr,
2757 SeAdtParmTypeTime,
2758 SeAdtParmTypeGuid,
2759 SeAdtParmTypeLuid,
2760 SeAdtParmTypeHexInt64,
2761 SeAdtParmTypeStringList,
2762 SeAdtParmTypeSidList,
2763 SeAdtParmTypeDuration,
2764 SeAdtParmTypeUserAccountControl,
2765 SeAdtParmTypeNoUac,
2766 SeAdtParmTypeMessage,
2767 SeAdtParmTypeDateTime,
2768 SeAdtParmTypeSockAddr,
2769 SeAdtParmTypeSD,
2770 SeAdtParmTypeLogonHours,
2771 SeAdtParmTypeLogonIdNoSid,
2772 SeAdtParmTypeUlongNoConv,
2773 SeAdtParmTypeSockAddrNoPort,
2774 SeAdtParmTypeAccessReason
2775 } SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE;
2776
2777 typedef struct _SE_ADT_OBJECT_TYPE {
2778 GUID ObjectType;
2779 USHORT Flags;
2780 USHORT Level;
2781 ACCESS_MASK AccessMask;
2782 } SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE;
2783
2784 typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY {
2785 SE_ADT_PARAMETER_TYPE Type;
2786 ULONG Length;
2787 ULONG_PTR Data[2];
2788 PVOID Address;
2789 } SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY;
2790
2791 typedef struct _SE_ADT_ACCESS_REASON {
2792 ACCESS_MASK AccessMask;
2793 ULONG AccessReasons[32];
2794 ULONG ObjectTypeIndex;
2795 ULONG AccessGranted;
2796 PSECURITY_DESCRIPTOR SecurityDescriptor;
2797 } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON;
2798
2799 typedef struct _SE_ADT_PARAMETER_ARRAY {
2800 ULONG CategoryId;
2801 ULONG AuditId;
2802 ULONG ParameterCount;
2803 ULONG Length;
2804 USHORT FlatSubCategoryId;
2805 USHORT Type;
2806 ULONG Flags;
2807 SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ];
2808 } SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY;
2809
2810 #endif /* !_NTLSA_AUDIT_ */
2811 #endif /* !_NTLSA_IFS_ */
2812 /******************************************************************************
2813 * Power Management Support Types *
2814 ******************************************************************************/
2815
2816 #ifndef _PO_DDK_
2817 #define _PO_DDK_
2818
2819 #define PO_CB_SYSTEM_POWER_POLICY 0
2820 #define PO_CB_AC_STATUS 1
2821 #define PO_CB_BUTTON_COLLISION 2
2822 #define PO_CB_SYSTEM_STATE_LOCK 3
2823 #define PO_CB_LID_SWITCH_STATE 4
2824 #define PO_CB_PROCESSOR_POWER_POLICY 5
2825
2826 /* Power States/Levels */
2827 typedef enum _SYSTEM_POWER_STATE {
2828 PowerSystemUnspecified = 0,
2829 PowerSystemWorking,
2830 PowerSystemSleeping1,
2831 PowerSystemSleeping2,
2832 PowerSystemSleeping3,
2833 PowerSystemHibernate,
2834 PowerSystemShutdown,
2835 PowerSystemMaximum
2836 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
2837
2838 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
2839
2840 typedef enum _POWER_INFORMATION_LEVEL {
2841 SystemPowerPolicyAc,
2842 SystemPowerPolicyDc,
2843 VerifySystemPolicyAc,
2844 VerifySystemPolicyDc,
2845 SystemPowerCapabilities,
2846 SystemBatteryState,
2847 SystemPowerStateHandler,
2848 ProcessorStateHandler,
2849 SystemPowerPolicyCurrent,
2850 AdministratorPowerPolicy,
2851 SystemReserveHiberFile,
2852 ProcessorInformation,
2853 SystemPowerInformation,
2854 ProcessorStateHandler2,
2855 LastWakeTime,
2856 LastSleepTime,
2857 SystemExecutionState,
2858 SystemPowerStateNotifyHandler,
2859 ProcessorPowerPolicyAc,
2860 ProcessorPowerPolicyDc,
2861 VerifyProcessorPowerPolicyAc,
2862 VerifyProcessorPowerPolicyDc,
2863 ProcessorPowerPolicyCurrent,
2864 SystemPowerStateLogging,
2865 SystemPowerLoggingEntry,
2866 SetPowerSettingValue,
2867 NotifyUserPowerSetting,
2868 PowerInformationLevelUnused0,
2869 PowerInformationLevelUnused1,
2870 SystemVideoState,
2871 TraceApplicationPowerMessage,
2872 TraceApplicationPowerMessageEnd,
2873 ProcessorPerfStates,
2874 ProcessorIdleStates,
2875 ProcessorCap,
2876 SystemWakeSource,
2877 SystemHiberFileInformation,
2878 TraceServicePowerMessage,
2879 ProcessorLoad,
2880 PowerShutdownNotification,
2881 MonitorCapabilities,
2882 SessionPowerInit,
2883 SessionDisplayState,
2884 PowerRequestCreate,
2885 PowerRequestAction,
2886 GetPowerRequestList,
2887 ProcessorInformationEx,
2888 NotifyUserModeLegacyPowerEvent,
2889 GroupPark,
2890 ProcessorIdleDomains,
2891 WakeTimerList,
2892 SystemHiberFileSize,
2893 PowerInformationLevelMaximum
2894 } POWER_INFORMATION_LEVEL;
2895
2896 typedef enum {
2897 PowerActionNone = 0,
2898 PowerActionReserved,
2899 PowerActionSleep,
2900 PowerActionHibernate,
2901 PowerActionShutdown,
2902 PowerActionShutdownReset,
2903 PowerActionShutdownOff,
2904 PowerActionWarmEject
2905 } POWER_ACTION, *PPOWER_ACTION;
2906
2907 typedef enum _DEVICE_POWER_STATE {
2908 PowerDeviceUnspecified = 0,
2909 PowerDeviceD0,
2910 PowerDeviceD1,
2911 PowerDeviceD2,
2912 PowerDeviceD3,
2913 PowerDeviceMaximum
2914 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
2915
2916 typedef enum _MONITOR_DISPLAY_STATE {
2917 PowerMonitorOff = 0,
2918 PowerMonitorOn,
2919 PowerMonitorDim
2920 } MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE;
2921
2922 typedef union _POWER_STATE {
2923 SYSTEM_POWER_STATE SystemState;
2924 DEVICE_POWER_STATE DeviceState;
2925 } POWER_STATE, *PPOWER_STATE;
2926
2927 typedef enum _POWER_STATE_TYPE {
2928 SystemPowerState = 0,
2929 DevicePowerState
2930 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
2931
2932 #if (NTDDI_VERSION >= NTDDI_VISTA)
2933 typedef struct _SYSTEM_POWER_STATE_CONTEXT {
2934 _ANONYMOUS_UNION union {
2935 _ANONYMOUS_STRUCT struct {
2936 ULONG Reserved1:8;
2937 ULONG TargetSystemState:4;
2938 ULONG EffectiveSystemState:4;
2939 ULONG CurrentSystemState:4;
2940 ULONG IgnoreHibernationPath:1;
2941 ULONG PseudoTransition:1;
2942 ULONG Reserved2:10;
2943 } DUMMYSTRUCTNAME;
2944 ULONG ContextAsUlong;
2945 } DUMMYUNIONNAME;
2946 } SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT;
2947 #endif
2948
2949 #if (NTDDI_VERSION >= NTDDI_WIN7)
2950 typedef struct _COUNTED_REASON_CONTEXT {
2951 ULONG Version;
2952 ULONG Flags;
2953 _ANONYMOUS_UNION union {
2954 _ANONYMOUS_STRUCT struct {
2955 UNICODE_STRING ResourceFileName;
2956 USHORT ResourceReasonId;
2957 ULONG StringCount;
2958 PUNICODE_STRING ReasonStrings;
2959 } DUMMYSTRUCTNAME;
2960 UNICODE_STRING SimpleString;
2961 } DUMMYUNIONNAME;
2962 } COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT;
2963 #endif
2964
2965 #define IOCTL_QUERY_DEVICE_POWER_STATE \
2966 CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS)
2967
2968 #define IOCTL_SET_DEVICE_WAKE \
2969 CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
2970
2971 #define IOCTL_CANCEL_DEVICE_WAKE \
2972 CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
2973
2974 #define ES_SYSTEM_REQUIRED 0x00000001
2975 #define ES_DISPLAY_REQUIRED 0x00000002
2976 #define ES_USER_PRESENT 0x00000004
2977 #define ES_CONTINUOUS 0x80000000
2978
2979 typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE;
2980
2981 typedef enum {
2982 LT_DONT_CARE,
2983 LT_LOWEST_LATENCY
2984 } LATENCY_TIME;
2985
2986 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
2987 #define DIAGNOSTIC_REASON_VERSION 0
2988 #define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001
2989 #define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002
2990 #define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000
2991 #define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003)
2992 #endif
2993
2994 #define POWER_REQUEST_CONTEXT_VERSION 0
2995 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
2996 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
2997
2998 #define PowerRequestMaximum 3
2999
3000 typedef enum _POWER_REQUEST_TYPE {
3001 PowerRequestDisplayRequired,
3002 PowerRequestSystemRequired,
3003 PowerRequestAwayModeRequired
3004 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
3005
3006 #if (NTDDI_VERSION >= NTDDI_WINXP)
3007
3008 #define PDCAP_D0_SUPPORTED 0x00000001
3009 #define PDCAP_D1_SUPPORTED 0x00000002
3010 #define PDCAP_D2_SUPPORTED 0x00000004
3011 #define PDCAP_D3_SUPPORTED 0x00000008
3012 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
3013 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
3014 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
3015 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
3016 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
3017
3018 typedef struct CM_Power_Data_s {
3019 ULONG PD_Size;
3020 DEVICE_POWER_STATE PD_MostRecentPowerState;
3021 ULONG PD_Capabilities;
3022 ULONG PD_D1Latency;
3023 ULONG PD_D2Latency;
3024 ULONG PD_D3Latency;
3025 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
3026 SYSTEM_POWER_STATE PD_DeepestSystemWake;
3027 } CM_POWER_DATA, *PCM_POWER_DATA;
3028
3029 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3030
3031 typedef enum _SYSTEM_POWER_CONDITION {
3032 PoAc,
3033 PoDc,
3034 PoHot,
3035 PoConditionMaximum
3036 } SYSTEM_POWER_CONDITION;
3037
3038 typedef struct _SET_POWER_SETTING_VALUE {
3039 ULONG Version;
3040 GUID Guid;
3041 SYSTEM_POWER_CONDITION PowerCondition;
3042 ULONG DataLength;
3043 UCHAR Data[ANYSIZE_ARRAY];
3044 } SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE;
3045
3046 #define POWER_SETTING_VALUE_VERSION (0x1)
3047
3048 typedef struct _NOTIFY_USER_POWER_SETTING {
3049 GUID Guid;
3050 } NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING;
3051
3052 typedef struct _APPLICATIONLAUNCH_SETTING_VALUE {
3053 LARGE_INTEGER ActivationTime;
3054 ULONG Flags;
3055 ULONG ButtonInstanceID;
3056 } APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE;
3057
3058 typedef enum _POWER_PLATFORM_ROLE {
3059 PlatformRoleUnspecified = 0,
3060 PlatformRoleDesktop,
3061 PlatformRoleMobile,
3062 PlatformRoleWorkstation,
3063 PlatformRoleEnterpriseServer,
3064 PlatformRoleSOHOServer,
3065 PlatformRoleAppliancePC,
3066 PlatformRolePerformanceServer,
3067 PlatformRoleMaximum
3068 } POWER_PLATFORM_ROLE;
3069
3070 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
3071 typedef struct {
3072 ULONG Granularity;
3073 ULONG Capacity;
3074 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
3075 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
3076
3077 #endif /* !_PO_DDK_ */
3078
3079 #define CORE_PARKING_POLICY_CHANGE_IDEAL 0
3080 #define CORE_PARKING_POLICY_CHANGE_SINGLE 1
3081 #define CORE_PARKING_POLICY_CHANGE_ROCKET 2
3082 #define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET
3083
3084 DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A);
3085 DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C);
3086 DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E);
3087 DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94);
3088 DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0);
3089 DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7);
3090 DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63);
3091 DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99);
3092 DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E);
3093 DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63);
3094 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64);
3095 DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee);
3096 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B);
3097 DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA);
3098 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb);
3099 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96);
3100 DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff);
3101 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8);
3102 DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67);
3103 DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47);
3104 DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23);
3105 DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42);
3106 DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E);
3107 DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63);
3108 DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67);
3109 DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20);
3110 DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70);
3111 DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA);
3112 DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0);
3113 DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64);
3114 DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E);
3115 DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1);
3116 DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0);
3117 DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87);
3118 DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab);
3119 DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D);
3120 DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2);
3121 DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47);
3122 DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80);
3123 DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78);
3124 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB);
3125 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93);
3126 DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5);
3127 DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36);
3128 DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B);
3129 DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4);
3130 DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F);
3131 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46);
3132 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69);
3133 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f);
3134 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06);
3135 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A);
3136 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58);
3137 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4);
3138 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA);
3139 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82);
3140 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8);
3141 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65);
3142 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3);
3143 DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00);
3144 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36);
3145 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC);
3146 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C);
3147 DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb);
3148 DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c);
3149 DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0);
3150 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d);
3151 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6);
3152 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18);
3153 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6);
3154 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa);
3155 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8);
3156 DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5);
3157 DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59);
3158 DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6);
3159 DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad);
3160 DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b);
3161 DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19);
3162 DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c);
3163 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1);
3164 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa);
3165 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6);
3166 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b);
3167 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28);
3168 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83);
3169 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32);
3170 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82);
3171 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82);
3172 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9);
3173 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20);
3174 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d);
3175 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29);
3176 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb);
3177 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1);
3178 DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f);
3179 DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b);
3180 DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f);
3181 DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F);
3182 DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51);
3183 DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19);
3184 DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48);
3185 DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3);
3186 DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1);
3187 DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1);
3188 DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E);
3189 DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA);
3190 DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20);
3191 DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5);
3192 DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6);
3193
3194 #define PERFSTATE_POLICY_CHANGE_IDEAL 0
3195 #define PERFSTATE_POLICY_CHANGE_SINGLE 1
3196 #define PERFSTATE_POLICY_CHANGE_ROCKET 2
3197 #define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET
3198
3199 #define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0
3200 #define PROCESSOR_PERF_BOOST_POLICY_MAX 100
3201
3202 #define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0
3203 #define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1
3204
3205 _Function_class_(REQUEST_POWER_COMPLETE)
3206 _IRQL_requires_same_
3207 typedef VOID
3208 (NTAPI REQUEST_POWER_COMPLETE)(
3209 _In_ struct _DEVICE_OBJECT *DeviceObject,
3210 _In_ UCHAR MinorFunction,
3211 _In_ POWER_STATE PowerState,
3212 _In_opt_ PVOID Context,
3213 _In_ struct _IO_STATUS_BLOCK *IoStatus);
3214 typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE;
3215
3216 _Function_class_(POWER_SETTING_CALLBACK)
3217 _IRQL_requires_same_
3218 typedef NTSTATUS
3219 (NTAPI POWER_SETTING_CALLBACK)(
3220 _In_ LPCGUID SettingGuid,
3221 _In_reads_bytes_(ValueLength) PVOID Value,
3222 _In_ ULONG ValueLength,
3223 _Inout_opt_ PVOID Context);
3224 typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK;
3225
3226 /******************************************************************************
3227 * Configuration Manager Types *
3228 ******************************************************************************/
3229
3230 /* Resource list definitions */
3231 typedef int CM_RESOURCE_TYPE;
3232
3233 #define CmResourceTypeNull 0
3234 #define CmResourceTypePort 1
3235 #define CmResourceTypeInterrupt 2
3236 #define CmResourceTypeMemory 3
3237 #define CmResourceTypeDma 4
3238 #define CmResourceTypeDeviceSpecific 5
3239 #define CmResourceTypeBusNumber 6
3240 #define CmResourceTypeNonArbitrated 128
3241 #define CmResourceTypeConfigData 128
3242 #define CmResourceTypeDevicePrivate 129
3243 #define CmResourceTypePcCardConfig 130
3244 #define CmResourceTypeMfCardConfig 131
3245
3246 /* KEY_VALUE_Xxx.Type */
3247 #define REG_NONE 0
3248 #define REG_SZ 1
3249 #define REG_EXPAND_SZ 2
3250 #define REG_BINARY 3
3251 #define REG_DWORD 4
3252 #define REG_DWORD_LITTLE_ENDIAN 4
3253 #define REG_DWORD_BIG_ENDIAN 5
3254 #define REG_LINK 6
3255 #define REG_MULTI_SZ 7
3256 #define REG_RESOURCE_LIST 8
3257 #define REG_FULL_RESOURCE_DESCRIPTOR 9
3258 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3259 #define REG_QWORD 11
3260 #define REG_QWORD_LITTLE_ENDIAN 11
3261
3262 /* Registry Access Rights */
3263 #define KEY_QUERY_VALUE (0x0001)
3264 #define KEY_SET_VALUE (0x0002)
3265 #define KEY_CREATE_SUB_KEY (0x0004)
3266 #define KEY_ENUMERATE_SUB_KEYS (0x0008)
3267 #define KEY_NOTIFY (0x0010)
3268 #define KEY_CREATE_LINK (0x0020)
3269 #define KEY_WOW64_32KEY (0x0200)
3270 #define KEY_WOW64_64KEY (0x0100)
3271 #define KEY_WOW64_RES (0x0300)
3272
3273 #define KEY_READ ((STANDARD_RIGHTS_READ |\
3274 KEY_QUERY_VALUE |\
3275 KEY_ENUMERATE_SUB_KEYS |\
3276 KEY_NOTIFY) \
3277 & \
3278 (~SYNCHRONIZE))
3279
3280 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
3281 KEY_SET_VALUE |\
3282 KEY_CREATE_SUB_KEY) \
3283 & \
3284 (~SYNCHRONIZE))
3285
3286 #define KEY_EXECUTE ((KEY_READ) \
3287 & \
3288 (~SYNCHRONIZE))
3289
3290 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
3291 KEY_QUERY_VALUE |\
3292 KEY_SET_VALUE |\
3293 KEY_CREATE_SUB_KEY |\
3294 KEY_ENUMERATE_SUB_KEYS |\
3295 KEY_NOTIFY |\
3296 KEY_CREATE_LINK) \
3297 & \
3298 (~SYNCHRONIZE))
3299
3300 /* Registry Open/Create Options */
3301 #define REG_OPTION_RESERVED (0x00000000L)
3302 #define REG_OPTION_NON_VOLATILE (0x00000000L)
3303 #define REG_OPTION_VOLATILE (0x00000001L)
3304 #define REG_OPTION_CREATE_LINK (0x00000002L)
3305 #define REG_OPTION_BACKUP_RESTORE (0x00000004L)
3306 #define REG_OPTION_OPEN_LINK (0x00000008L)
3307
3308 #define REG_LEGAL_OPTION \
3309 (REG_OPTION_RESERVED |\
3310 REG_OPTION_NON_VOLATILE |\
3311 REG_OPTION_VOLATILE |\
3312 REG_OPTION_CREATE_LINK |\
3313 REG_OPTION_BACKUP_RESTORE |\
3314 REG_OPTION_OPEN_LINK)
3315
3316 #define REG_OPEN_LEGAL_OPTION \
3317 (REG_OPTION_RESERVED |\
3318 REG_OPTION_BACKUP_RESTORE |\
3319 REG_OPTION_OPEN_LINK)
3320
3321 #define REG_STANDARD_FORMAT 1
3322 #define REG_LATEST_FORMAT 2
3323 #define REG_NO_COMPRESSION 4
3324
3325 /* Key creation/open disposition */
3326 #define REG_CREATED_NEW_KEY (0x00000001L)
3327 #define REG_OPENED_EXISTING_KEY (0x00000002L)
3328
3329 /* Key restore & hive load flags */
3330 #define REG_WHOLE_HIVE_VOLATILE (0x00000001L)
3331 #define REG_REFRESH_HIVE (0x00000002L)
3332 #define REG_NO_LAZY_FLUSH (0x00000004L)
3333 #define REG_FORCE_RESTORE (0x00000008L)
3334 #define REG_APP_HIVE (0x00000010L)
3335 #define REG_PROCESS_PRIVATE (0x00000020L)
3336 #define REG_START_JOURNAL (0x00000040L)
3337 #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L)
3338 #define REG_HIVE_NO_RM (0x00000100L)
3339 #define REG_HIVE_SINGLE_LOG (0x00000200L)
3340 #define REG_BOOT_HIVE (0x00000400L)
3341
3342 /* Unload Flags */
3343 #define REG_FORCE_UNLOAD 1
3344
3345 /* Notify Filter Values */
3346 #define REG_NOTIFY_CHANGE_NAME (0x00000001L)
3347 #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
3348 #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L)
3349 #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
3350
3351 #define REG_LEGAL_CHANGE_FILTER \
3352 (REG_NOTIFY_CHANGE_NAME |\
3353 REG_NOTIFY_CHANGE_ATTRIBUTES |\
3354 REG_NOTIFY_CHANGE_LAST_SET |\
3355 REG_NOTIFY_CHANGE_SECURITY)
3356
3357 #include <pshpack4.h>
3358 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
3359 UCHAR Type;
3360 UCHAR ShareDisposition;
3361 USHORT Flags;
3362 union {
3363 struct {
3364 PHYSICAL_ADDRESS Start;
3365 ULONG Length;
3366 } Generic;
3367 struct {
3368 PHYSICAL_ADDRESS Start;
3369 ULONG Length;
3370 } Port;
3371 struct {
3372 #if defined(NT_PROCESSOR_GROUPS)
3373 USHORT Level;
3374 USHORT Group;
3375 #else
3376 ULONG Level;
3377 #endif
3378 ULONG Vector;
3379 KAFFINITY Affinity;
3380 } Interrupt;
3381 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
3382 struct {
3383 _ANONYMOUS_UNION union {
3384 struct {
3385 #if defined(NT_PROCESSOR_GROUPS)
3386 USHORT Group;
3387 #else
3388 USHORT Reserved;
3389 #endif
3390 USHORT MessageCount;
3391 ULONG Vector;
3392 KAFFINITY Affinity;
3393 } Raw;
3394 struct {
3395 #if defined(NT_PROCESSOR_GROUPS)
3396 USHORT Level;
3397 USHORT Group;
3398 #else
3399 ULONG Level;
3400 #endif
3401 ULONG Vector;
3402 KAFFINITY Affinity;
3403 } Translated;
3404 } DUMMYUNIONNAME;
3405 } MessageInterrupt;
3406 #endif
3407 struct {
3408 PHYSICAL_ADDRESS Start;
3409 ULONG Length;
3410 } Memory;
3411 struct {
3412 ULONG Channel;
3413 ULONG Port;
3414 ULONG Reserved1;
3415 } Dma;
3416 struct {
3417 ULONG Data[3];
3418 } DevicePrivate;
3419 struct {
3420 ULONG Start;
3421 ULONG Length;
3422 ULONG Reserved;
3423 } BusNumber;
3424 struct {
3425 ULONG DataSize;
3426 ULONG Reserved1;
3427 ULONG Reserved2;
3428 } DeviceSpecificData;
3429 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
3430 struct {
3431 PHYSICAL_ADDRESS Start;
3432 ULONG Length40;
3433 } Memory40;
3434 struct {
3435 PHYSICAL_ADDRESS Start;
3436 ULONG Length48;
3437 } Memory48;
3438 struct {
3439 PHYSICAL_ADDRESS Start;
3440 ULONG Length64;
3441 } Memory64;
3442 #endif