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