01a320e8a8c001a2d0d318e84e54d2e2422587e1
[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
2520 typedef PVOID PACCESS_TOKEN;
2521 typedef PVOID PSID;
2522
2523
2524 #define DELETE 0x00010000L
2525 #define READ_CONTROL 0x00020000L
2526 #define WRITE_DAC 0x00040000L
2527 #define WRITE_OWNER 0x00080000L
2528 #define SYNCHRONIZE 0x00100000L
2529 #define STANDARD_RIGHTS_REQUIRED 0x000F0000L
2530 #define STANDARD_RIGHTS_READ READ_CONTROL
2531 #define STANDARD_RIGHTS_WRITE READ_CONTROL
2532 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
2533 #define STANDARD_RIGHTS_ALL 0x001F0000L
2534 #define SPECIFIC_RIGHTS_ALL 0x0000FFFFL
2535 #define ACCESS_SYSTEM_SECURITY 0x01000000L
2536 #define MAXIMUM_ALLOWED 0x02000000L
2537 #define GENERIC_READ 0x80000000L
2538 #define GENERIC_WRITE 0x40000000L
2539 #define GENERIC_EXECUTE 0x20000000L
2540 #define GENERIC_ALL 0x10000000L
2541
2542 typedef struct _GENERIC_MAPPING {
2543 ACCESS_MASK GenericRead;
2544 ACCESS_MASK GenericWrite;
2545 ACCESS_MASK GenericExecute;
2546 ACCESS_MASK GenericAll;
2547 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2548
2549 #define ACL_REVISION 2
2550 #define ACL_REVISION_DS 4
2551
2552 #define ACL_REVISION1 1
2553 #define ACL_REVISION2 2
2554 #define ACL_REVISION3 3
2555 #define ACL_REVISION4 4
2556 #define MIN_ACL_REVISION ACL_REVISION2
2557 #define MAX_ACL_REVISION ACL_REVISION4
2558
2559 typedef struct _ACL {
2560 UCHAR AclRevision;
2561 UCHAR Sbz1;
2562 USHORT AclSize;
2563 USHORT AceCount;
2564 USHORT Sbz2;
2565 } ACL, *PACL;
2566
2567 /* Current security descriptor revision value */
2568 #define SECURITY_DESCRIPTOR_REVISION (1)
2569 #define SECURITY_DESCRIPTOR_REVISION1 (1)
2570
2571 /* Privilege attributes */
2572 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
2573 #define SE_PRIVILEGE_ENABLED (0x00000002L)
2574 #define SE_PRIVILEGE_REMOVED (0X00000004L)
2575 #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
2576
2577 #define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \
2578 SE_PRIVILEGE_ENABLED | \
2579 SE_PRIVILEGE_REMOVED | \
2580 SE_PRIVILEGE_USED_FOR_ACCESS)
2581
2582 #include <pshpack4.h>
2583 typedef struct _LUID_AND_ATTRIBUTES {
2584 LUID Luid;
2585 ULONG Attributes;
2586 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
2587 #include <poppack.h>
2588
2589 typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
2590 typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
2591
2592 /* Privilege sets */
2593 #define PRIVILEGE_SET_ALL_NECESSARY (1)
2594
2595 typedef struct _PRIVILEGE_SET {
2596 ULONG PrivilegeCount;
2597 ULONG Control;
2598 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
2599 } PRIVILEGE_SET,*PPRIVILEGE_SET;
2600
2601
2602 typedef enum _SECURITY_IMPERSONATION_LEVEL {
2603 SecurityAnonymous,
2604 SecurityIdentification,
2605 SecurityImpersonation,
2606 SecurityDelegation
2607 } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
2608
2609
2610 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
2611 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
2612 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
2613 #define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL))
2614
2615 #define SECURITY_DYNAMIC_TRACKING (TRUE)
2616 #define SECURITY_STATIC_TRACKING (FALSE)
2617
2618
2619 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE;
2620
2621 typedef struct _SECURITY_QUALITY_OF_SERVICE {
2622 ULONG Length;
2623 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
2624 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
2625 BOOLEAN EffectiveOnly;
2626 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
2627
2628 typedef struct _SE_IMPERSONATION_STATE {
2629 PACCESS_TOKEN Token;
2630 BOOLEAN CopyOnOpen;
2631 BOOLEAN EffectiveOnly;
2632 SECURITY_IMPERSONATION_LEVEL Level;
2633 } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
2634
2635
2636 #define OWNER_SECURITY_INFORMATION (0x00000001L)
2637 #define GROUP_SECURITY_INFORMATION (0x00000002L)
2638 #define DACL_SECURITY_INFORMATION (0x00000004L)
2639 #define SACL_SECURITY_INFORMATION (0x00000008L)
2640 #define LABEL_SECURITY_INFORMATION (0x00000010L)
2641
2642 #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
2643 #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
2644 #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
2645 #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
2646
2647 typedef enum _SECURITY_OPERATION_CODE {
2648 SetSecurityDescriptor,
2649 QuerySecurityDescriptor,
2650 DeleteSecurityDescriptor,
2651 AssignSecurityDescriptor
2652 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
2653
2654 #define INITIAL_PRIVILEGE_COUNT 3
2655
2656 typedef struct _INITIAL_PRIVILEGE_SET {
2657 ULONG PrivilegeCount;
2658 ULONG Control;
2659 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
2660 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
2661
2662 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
2663 #define SE_CREATE_TOKEN_PRIVILEGE 2
2664 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
2665 #define SE_LOCK_MEMORY_PRIVILEGE 4
2666 #define SE_INCREASE_QUOTA_PRIVILEGE 5
2667 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
2668 #define SE_TCB_PRIVILEGE 7
2669 #define SE_SECURITY_PRIVILEGE 8
2670 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
2671 #define SE_LOAD_DRIVER_PRIVILEGE 10
2672 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
2673 #define SE_SYSTEMTIME_PRIVILEGE 12
2674 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
2675 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
2676 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
2677 #define SE_CREATE_PERMANENT_PRIVILEGE 16
2678 #define SE_BACKUP_PRIVILEGE 17
2679 #define SE_RESTORE_PRIVILEGE 18
2680 #define SE_SHUTDOWN_PRIVILEGE 19
2681 #define SE_DEBUG_PRIVILEGE 20
2682 #define SE_AUDIT_PRIVILEGE 21
2683 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
2684 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
2685 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
2686 #define SE_UNDOCK_PRIVILEGE 25
2687 #define SE_SYNC_AGENT_PRIVILEGE 26
2688 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
2689 #define SE_MANAGE_VOLUME_PRIVILEGE 28
2690 #define SE_IMPERSONATE_PRIVILEGE 29
2691 #define SE_CREATE_GLOBAL_PRIVILEGE 30
2692 #define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31
2693 #define SE_RELABEL_PRIVILEGE 32
2694 #define SE_INC_WORKING_SET_PRIVILEGE 33
2695 #define SE_TIME_ZONE_PRIVILEGE 34
2696 #define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 35
2697 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
2698
2699 typedef struct _SECURITY_SUBJECT_CONTEXT {
2700 PACCESS_TOKEN ClientToken;
2701 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
2702 PACCESS_TOKEN PrimaryToken;
2703 PVOID ProcessAuditId;
2704 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
2705
2706 typedef struct _ACCESS_STATE {
2707 LUID OperationID;
2708 BOOLEAN SecurityEvaluated;
2709 BOOLEAN GenerateAudit;
2710 BOOLEAN GenerateOnClose;
2711 BOOLEAN PrivilegesAllocated;
2712 ULONG Flags;
2713 ACCESS_MASK RemainingDesiredAccess;
2714 ACCESS_MASK PreviouslyGrantedAccess;
2715 ACCESS_MASK OriginalDesiredAccess;
2716 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
2717 PSECURITY_DESCRIPTOR SecurityDescriptor;
2718 PVOID AuxData;
2719 union {
2720 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
2721 PRIVILEGE_SET PrivilegeSet;
2722 } Privileges;
2723 BOOLEAN AuditPrivileges;
2724 UNICODE_STRING ObjectName;
2725 UNICODE_STRING ObjectTypeName;
2726 } ACCESS_STATE, *PACCESS_STATE;
2727
2728 typedef VOID
2729 (NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)(
2730 _In_ PVOID Vcb,
2731 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor);
2732
2733 #ifndef _NTLSA_IFS_
2734
2735 #ifndef _NTLSA_AUDIT_
2736 #define _NTLSA_AUDIT_
2737
2738 #define SE_MAX_AUDIT_PARAMETERS 32
2739 #define SE_MAX_GENERIC_AUDIT_PARAMETERS 28
2740
2741 #define SE_ADT_OBJECT_ONLY 0x1
2742
2743 #define SE_ADT_PARAMETERS_SELF_RELATIVE 0x00000001
2744 #define SE_ADT_PARAMETERS_SEND_TO_LSA 0x00000002
2745 #define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT 0x00000004
2746 #define SE_ADT_PARAMETER_GENERIC_AUDIT 0x00000008
2747 #define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010
2748
2749 #define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \
2750 ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \
2751 (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) )
2752
2753 typedef enum _SE_ADT_PARAMETER_TYPE {
2754 SeAdtParmTypeNone = 0,
2755 SeAdtParmTypeString,
2756 SeAdtParmTypeFileSpec,
2757 SeAdtParmTypeUlong,
2758 SeAdtParmTypeSid,
2759 SeAdtParmTypeLogonId,
2760 SeAdtParmTypeNoLogonId,
2761 SeAdtParmTypeAccessMask,
2762 SeAdtParmTypePrivs,
2763 SeAdtParmTypeObjectTypes,
2764 SeAdtParmTypeHexUlong,
2765 SeAdtParmTypePtr,
2766 SeAdtParmTypeTime,
2767 SeAdtParmTypeGuid,
2768 SeAdtParmTypeLuid,
2769 SeAdtParmTypeHexInt64,
2770 SeAdtParmTypeStringList,
2771 SeAdtParmTypeSidList,
2772 SeAdtParmTypeDuration,
2773 SeAdtParmTypeUserAccountControl,
2774 SeAdtParmTypeNoUac,
2775 SeAdtParmTypeMessage,
2776 SeAdtParmTypeDateTime,
2777 SeAdtParmTypeSockAddr,
2778 SeAdtParmTypeSD,
2779 SeAdtParmTypeLogonHours,
2780 SeAdtParmTypeLogonIdNoSid,
2781 SeAdtParmTypeUlongNoConv,
2782 SeAdtParmTypeSockAddrNoPort,
2783 SeAdtParmTypeAccessReason
2784 } SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE;
2785
2786 typedef struct _SE_ADT_OBJECT_TYPE {
2787 GUID ObjectType;
2788 USHORT Flags;
2789 USHORT Level;
2790 ACCESS_MASK AccessMask;
2791 } SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE;
2792
2793 typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY {
2794 SE_ADT_PARAMETER_TYPE Type;
2795 ULONG Length;
2796 ULONG_PTR Data[2];
2797 PVOID Address;
2798 } SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY;
2799
2800 typedef struct _SE_ADT_ACCESS_REASON {
2801 ACCESS_MASK AccessMask;
2802 ULONG AccessReasons[32];
2803 ULONG ObjectTypeIndex;
2804 ULONG AccessGranted;
2805 PSECURITY_DESCRIPTOR SecurityDescriptor;
2806 } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON;
2807
2808 typedef struct _SE_ADT_PARAMETER_ARRAY {
2809 ULONG CategoryId;
2810 ULONG AuditId;
2811 ULONG ParameterCount;
2812 ULONG Length;
2813 USHORT FlatSubCategoryId;
2814 USHORT Type;
2815 ULONG Flags;
2816 SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ];
2817 } SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY;
2818
2819 #endif /* !_NTLSA_AUDIT_ */
2820 #endif /* !_NTLSA_IFS_ */
2821 /******************************************************************************
2822 * Power Management Support Types *
2823 ******************************************************************************/
2824
2825 #ifndef _PO_DDK_
2826 #define _PO_DDK_
2827
2828 #define PO_CB_SYSTEM_POWER_POLICY 0
2829 #define PO_CB_AC_STATUS 1
2830 #define PO_CB_BUTTON_COLLISION 2
2831 #define PO_CB_SYSTEM_STATE_LOCK 3
2832 #define PO_CB_LID_SWITCH_STATE 4
2833 #define PO_CB_PROCESSOR_POWER_POLICY 5
2834
2835 /* Power States/Levels */
2836 typedef enum _SYSTEM_POWER_STATE {
2837 PowerSystemUnspecified = 0,
2838 PowerSystemWorking,
2839 PowerSystemSleeping1,
2840 PowerSystemSleeping2,
2841 PowerSystemSleeping3,
2842 PowerSystemHibernate,
2843 PowerSystemShutdown,
2844 PowerSystemMaximum
2845 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
2846
2847 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
2848
2849 typedef enum _POWER_INFORMATION_LEVEL {
2850 SystemPowerPolicyAc,
2851 SystemPowerPolicyDc,
2852 VerifySystemPolicyAc,
2853 VerifySystemPolicyDc,
2854 SystemPowerCapabilities,
2855 SystemBatteryState,
2856 SystemPowerStateHandler,
2857 ProcessorStateHandler,
2858 SystemPowerPolicyCurrent,
2859 AdministratorPowerPolicy,
2860 SystemReserveHiberFile,
2861 ProcessorInformation,
2862 SystemPowerInformation,
2863 ProcessorStateHandler2,
2864 LastWakeTime,
2865 LastSleepTime,
2866 SystemExecutionState,
2867 SystemPowerStateNotifyHandler,
2868 ProcessorPowerPolicyAc,
2869 ProcessorPowerPolicyDc,
2870 VerifyProcessorPowerPolicyAc,
2871 VerifyProcessorPowerPolicyDc,
2872 ProcessorPowerPolicyCurrent,
2873 SystemPowerStateLogging,
2874 SystemPowerLoggingEntry,
2875 SetPowerSettingValue,
2876 NotifyUserPowerSetting,
2877 PowerInformationLevelUnused0,
2878 PowerInformationLevelUnused1,
2879 SystemVideoState,
2880 TraceApplicationPowerMessage,
2881 TraceApplicationPowerMessageEnd,
2882 ProcessorPerfStates,
2883 ProcessorIdleStates,
2884 ProcessorCap,
2885 SystemWakeSource,
2886 SystemHiberFileInformation,
2887 TraceServicePowerMessage,
2888 ProcessorLoad,
2889 PowerShutdownNotification,
2890 MonitorCapabilities,
2891 SessionPowerInit,
2892 SessionDisplayState,
2893 PowerRequestCreate,
2894 PowerRequestAction,
2895 GetPowerRequestList,
2896 ProcessorInformationEx,
2897 NotifyUserModeLegacyPowerEvent,
2898 GroupPark,
2899 ProcessorIdleDomains,
2900 WakeTimerList,
2901 SystemHiberFileSize,
2902 PowerInformationLevelMaximum
2903 } POWER_INFORMATION_LEVEL;
2904
2905 typedef enum {
2906 PowerActionNone = 0,
2907 PowerActionReserved,
2908 PowerActionSleep,
2909 PowerActionHibernate,
2910 PowerActionShutdown,
2911 PowerActionShutdownReset,
2912 PowerActionShutdownOff,
2913 PowerActionWarmEject
2914 } POWER_ACTION, *PPOWER_ACTION;
2915
2916 typedef enum _DEVICE_POWER_STATE {
2917 PowerDeviceUnspecified = 0,
2918 PowerDeviceD0,
2919 PowerDeviceD1,
2920 PowerDeviceD2,
2921 PowerDeviceD3,
2922 PowerDeviceMaximum
2923 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
2924
2925 typedef enum _MONITOR_DISPLAY_STATE {
2926 PowerMonitorOff = 0,
2927 PowerMonitorOn,
2928 PowerMonitorDim
2929 } MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE;
2930
2931 typedef union _POWER_STATE {
2932 SYSTEM_POWER_STATE SystemState;
2933 DEVICE_POWER_STATE DeviceState;
2934 } POWER_STATE, *PPOWER_STATE;
2935
2936 typedef enum _POWER_STATE_TYPE {
2937 SystemPowerState = 0,
2938 DevicePowerState
2939 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
2940
2941 #if (NTDDI_VERSION >= NTDDI_VISTA)
2942 typedef struct _SYSTEM_POWER_STATE_CONTEXT {
2943 _ANONYMOUS_UNION union {
2944 _ANONYMOUS_STRUCT struct {
2945 ULONG Reserved1:8;
2946 ULONG TargetSystemState:4;
2947 ULONG EffectiveSystemState:4;
2948 ULONG CurrentSystemState:4;
2949 ULONG IgnoreHibernationPath:1;
2950 ULONG PseudoTransition:1;
2951 ULONG Reserved2:10;
2952 } DUMMYSTRUCTNAME;
2953 ULONG ContextAsUlong;
2954 } DUMMYUNIONNAME;
2955 } SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT;
2956 #endif
2957
2958 #if (NTDDI_VERSION >= NTDDI_WIN7)
2959 typedef struct _COUNTED_REASON_CONTEXT {
2960 ULONG Version;
2961 ULONG Flags;
2962 _ANONYMOUS_UNION union {
2963 _ANONYMOUS_STRUCT struct {
2964 UNICODE_STRING ResourceFileName;
2965 USHORT ResourceReasonId;
2966 ULONG StringCount;
2967 PUNICODE_STRING ReasonStrings;
2968 } DUMMYSTRUCTNAME;
2969 UNICODE_STRING SimpleString;
2970 } DUMMYUNIONNAME;
2971 } COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT;
2972 #endif
2973
2974 #define IOCTL_QUERY_DEVICE_POWER_STATE \
2975 CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS)
2976
2977 #define IOCTL_SET_DEVICE_WAKE \
2978 CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
2979
2980 #define IOCTL_CANCEL_DEVICE_WAKE \
2981 CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
2982
2983 #define ES_SYSTEM_REQUIRED 0x00000001
2984 #define ES_DISPLAY_REQUIRED 0x00000002
2985 #define ES_USER_PRESENT 0x00000004
2986 #define ES_CONTINUOUS 0x80000000
2987
2988 typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE;
2989
2990 typedef enum {
2991 LT_DONT_CARE,
2992 LT_LOWEST_LATENCY
2993 } LATENCY_TIME;
2994
2995 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
2996 #define DIAGNOSTIC_REASON_VERSION 0
2997 #define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001
2998 #define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002
2999 #define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000
3000 #define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003)
3001 #endif
3002
3003 #define POWER_REQUEST_CONTEXT_VERSION 0
3004 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
3005 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
3006
3007 #define PowerRequestMaximum 3
3008
3009 typedef enum _POWER_REQUEST_TYPE {
3010 PowerRequestDisplayRequired,
3011 PowerRequestSystemRequired,
3012 PowerRequestAwayModeRequired
3013 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
3014
3015 #if (NTDDI_VERSION >= NTDDI_WINXP)
3016
3017 #define PDCAP_D0_SUPPORTED 0x00000001
3018 #define PDCAP_D1_SUPPORTED 0x00000002
3019 #define PDCAP_D2_SUPPORTED 0x00000004
3020 #define PDCAP_D3_SUPPORTED 0x00000008
3021 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
3022 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
3023 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
3024 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
3025 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
3026
3027 typedef struct CM_Power_Data_s {
3028 ULONG PD_Size;
3029 DEVICE_POWER_STATE PD_MostRecentPowerState;
3030 ULONG PD_Capabilities;
3031 ULONG PD_D1Latency;
3032 ULONG PD_D2Latency;
3033 ULONG PD_D3Latency;
3034 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
3035 SYSTEM_POWER_STATE PD_DeepestSystemWake;
3036 } CM_POWER_DATA, *PCM_POWER_DATA;
3037
3038 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3039
3040 typedef enum _SYSTEM_POWER_CONDITION {
3041 PoAc,
3042 PoDc,
3043 PoHot,
3044 PoConditionMaximum
3045 } SYSTEM_POWER_CONDITION;
3046
3047 typedef struct _SET_POWER_SETTING_VALUE {
3048 ULONG Version;
3049 GUID Guid;
3050 SYSTEM_POWER_CONDITION PowerCondition;
3051 ULONG DataLength;
3052 UCHAR Data[ANYSIZE_ARRAY];
3053 } SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE;
3054
3055 #define POWER_SETTING_VALUE_VERSION (0x1)
3056
3057 typedef struct _NOTIFY_USER_POWER_SETTING {
3058 GUID Guid;
3059 } NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING;
3060
3061 typedef struct _APPLICATIONLAUNCH_SETTING_VALUE {
3062 LARGE_INTEGER ActivationTime;
3063 ULONG Flags;
3064 ULONG ButtonInstanceID;
3065 } APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE;
3066
3067 typedef enum _POWER_PLATFORM_ROLE {
3068 PlatformRoleUnspecified = 0,
3069 PlatformRoleDesktop,
3070 PlatformRoleMobile,
3071 PlatformRoleWorkstation,
3072 PlatformRoleEnterpriseServer,
3073 PlatformRoleSOHOServer,
3074 PlatformRoleAppliancePC,
3075 PlatformRolePerformanceServer,
3076 PlatformRoleMaximum
3077 } POWER_PLATFORM_ROLE;
3078
3079 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
3080 typedef struct {
3081 ULONG Granularity;
3082 ULONG Capacity;
3083 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
3084 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
3085
3086 #endif /* !_PO_DDK_ */
3087
3088 #define CORE_PARKING_POLICY_CHANGE_IDEAL 0
3089 #define CORE_PARKING_POLICY_CHANGE_SINGLE 1
3090 #define CORE_PARKING_POLICY_CHANGE_ROCKET 2
3091 #define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET
3092
3093 DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A);
3094 DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C);
3095 DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E);
3096 DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94);
3097 DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0);
3098 DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7);
3099 DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63);
3100 DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99);
3101 DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E);
3102 DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63);
3103 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64);
3104 DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee);
3105 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B);
3106 DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA);
3107 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb);
3108 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96);
3109 DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff);
3110 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8);
3111 DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67);
3112 DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47);
3113 DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23);
3114 DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42);
3115 DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E);
3116 DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63);
3117 DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67);
3118 DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20);
3119 DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70);
3120 DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA);
3121 DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0);
3122 DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64);
3123 DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E);
3124 DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1);
3125 DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0);
3126 DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87);
3127 DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab);
3128 DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D);
3129 DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2);
3130 DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47);
3131 DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80);
3132 DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78);
3133 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB);
3134 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93);
3135 DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5);
3136 DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36);
3137 DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B);
3138 DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4);
3139 DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F);
3140 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46);
3141 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69);
3142 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f);
3143 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06);
3144 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A);
3145 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58);
3146 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4);
3147 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA);
3148 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82);
3149 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8);
3150 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65);
3151 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3);
3152 DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00);
3153 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36);
3154 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC);
3155 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C);
3156 DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb);
3157 DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c);
3158 DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0);
3159 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d);
3160 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6);
3161 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18);
3162 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6);
3163 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa);
3164 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8);
3165 DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5);
3166 DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59);
3167 DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6);
3168 DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad);
3169 DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b);
3170 DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19);
3171 DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c);
3172 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1);
3173 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa);
3174 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6);
3175 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b);
3176 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28);
3177 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83);
3178 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32);
3179 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82);
3180 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82);
3181 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9);
3182 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20);
3183 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d);
3184 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29);
3185 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb);
3186 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1);
3187 DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f);
3188 DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b);
3189 DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f);
3190 DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F);
3191 DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51);
3192 DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19);
3193 DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48);
3194 DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3);
3195 DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1);
3196 DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1);
3197 DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E);
3198 DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA);
3199 DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20);
3200 DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5);
3201 DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6);
3202
3203 #define PERFSTATE_POLICY_CHANGE_IDEAL 0
3204 #define PERFSTATE_POLICY_CHANGE_SINGLE 1
3205 #define PERFSTATE_POLICY_CHANGE_ROCKET 2
3206 #define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET
3207
3208 #define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0
3209 #define PROCESSOR_PERF_BOOST_POLICY_MAX 100
3210
3211 #define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0
3212 #define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1
3213
3214 _Function_class_(REQUEST_POWER_COMPLETE)
3215 _IRQL_requires_same_
3216 typedef VOID
3217 (NTAPI REQUEST_POWER_COMPLETE)(
3218 _In_ struct _DEVICE_OBJECT *DeviceObject,
3219 _In_ UCHAR MinorFunction,
3220 _In_ POWER_STATE PowerState,
3221 _In_opt_ PVOID Context,
3222 _In_ struct _IO_STATUS_BLOCK *IoStatus);
3223 typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE;
3224
3225 _Function_class_(POWER_SETTING_CALLBACK)
3226 _IRQL_requires_same_
3227 typedef NTSTATUS
3228 (NTAPI POWER_SETTING_CALLBACK)(
3229 _In_ LPCGUID SettingGuid,
3230 _In_reads_bytes_(ValueLength) PVOID Value,
3231 _In_ ULONG ValueLength,
3232 _Inout_opt_ PVOID Context);
3233 typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK;
3234
3235 /******************************************************************************
3236 * Configuration Manager Types *
3237 ******************************************************************************/
3238
3239 /* Resource list definitions */
3240 typedef int CM_RESOURCE_TYPE;
3241
3242 #define CmResourceTypeNull 0
3243 #define CmResourceTypePort 1
3244 #define CmResourceTypeInterrupt 2
3245 #define CmResourceTypeMemory 3
3246 #define CmResourceTypeDma 4
3247 #define CmResourceTypeDeviceSpecific 5
3248 #define CmResourceTypeBusNumber 6
3249 #define CmResourceTypeNonArbitrated 128
3250 #define CmResourceTypeConfigData 128
3251 #define CmResourceTypeDevicePrivate 129
3252 #define CmResourceTypePcCardConfig 130
3253 #define CmResourceTypeMfCardConfig 131
3254
3255 /* KEY_VALUE_Xxx.Type */
3256 #define REG_NONE 0
3257 #define REG_SZ 1
3258 #define REG_EXPAND_SZ 2
3259 #define REG_BINARY 3
3260 #define REG_DWORD 4
3261 #define REG_DWORD_LITTLE_ENDIAN 4
3262 #define REG_DWORD_BIG_ENDIAN 5
3263 #define REG_LINK 6
3264 #define REG_MULTI_SZ 7
3265 #define REG_RESOURCE_LIST 8
3266 #define REG_FULL_RESOURCE_DESCRIPTOR 9
3267 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3268 #define REG_QWORD 11
3269 #define REG_QWORD_LITTLE_ENDIAN 11
3270
3271 /* Registry Access Rights */
3272 #define KEY_QUERY_VALUE (0x0001)
3273 #define KEY_SET_VALUE (0x0002)
3274 #define KEY_CREATE_SUB_KEY (0x0004)
3275 #define KEY_ENUMERATE_SUB_KEYS (0x0008)
3276 #define KEY_NOTIFY (0x0010)
3277 #define KEY_CREATE_LINK (0x0020)
3278 #define KEY_WOW64_32KEY (0x0200)
3279 #define KEY_WOW64_64KEY (0x0100)
3280 #define KEY_WOW64_RES (0x0300)
3281
3282 #define KEY_READ ((STANDARD_RIGHTS_READ |\
3283 KEY_QUERY_VALUE |\
3284 KEY_ENUMERATE_SUB_KEYS |\
3285 KEY_NOTIFY) \
3286 & \
3287 (~SYNCHRONIZE))
3288
3289 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
3290 KEY_SET_VALUE |\
3291 KEY_CREATE_SUB_KEY) \
3292 & \
3293 (~SYNCHRONIZE))
3294
3295 #define KEY_EXECUTE ((KEY_READ) \
3296 & \
3297 (~SYNCHRONIZE))
3298
3299 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
3300 KEY_QUERY_VALUE |\
3301 KEY_SET_VALUE |\
3302 KEY_CREATE_SUB_KEY |\
3303 KEY_ENUMERATE_SUB_KEYS |\
3304 KEY_NOTIFY |\
3305 KEY_CREATE_LINK) \
3306 & \
3307 (~SYNCHRONIZE))
3308
3309 /* Registry Open/Create Options */
3310 #define REG_OPTION_RESERVED (0x00000000L)
3311 #define REG_OPTION_NON_VOLATILE (0x00000000L)
3312 #define REG_OPTION_VOLATILE (0x00000001L)
3313 #define REG_OPTION_CREATE_LINK (0x00000002L)
3314 #define REG_OPTION_BACKUP_RESTORE (0x00000004L)
3315 #define REG_OPTION_OPEN_LINK (0x00000008L)
3316
3317 #define REG_LEGAL_OPTION \
3318 (REG_OPTION_RESERVED |\
3319 REG_OPTION_NON_VOLATILE |\
3320 REG_OPTION_VOLATILE |\
3321 REG_OPTION_CREATE_LINK |\
3322 REG_OPTION_BACKUP_RESTORE |\
3323 REG_OPTION_OPEN_LINK)
3324
3325 #define REG_OPEN_LEGAL_OPTION \
3326 (REG_OPTION_RESERVED |\
3327 REG_OPTION_BACKUP_RESTORE |\
3328 REG_OPTION_OPEN_LINK)
3329
3330 #define REG_STANDARD_FORMAT 1
3331 #define REG_LATEST_FORMAT 2
3332 #define REG_NO_COMPRESSION 4
3333
3334 /* Key creation/open disposition */
3335 #define REG_CREATED_NEW_KEY (0x00000001L)
3336 #define REG_OPENED_EXISTING_KEY (0x00000002L)
3337
3338 /* Key restore & hive load flags */
3339 #define REG_WHOLE_HIVE_VOLATILE (0x00000001L)
3340 #define REG_REFRESH_HIVE (0x00000002L)
3341 #define REG_NO_LAZY_FLUSH (0x00000004L)
3342 #define REG_FORCE_RESTORE (0x00000008L)
3343 #define REG_APP_HIVE (0x00000010L)
3344 #define REG_PROCESS_PRIVATE (0x00000020L)
3345 #define REG_START_JOURNAL (0x00000040L)
3346 #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L)
3347 #define REG_HIVE_NO_RM (0x00000100L)
3348 #define REG_HIVE_SINGLE_LOG (0x00000200L)
3349 #define REG_BOOT_HIVE (0x00000400L)
3350
3351 /* Unload Flags */
3352 #define REG_FORCE_UNLOAD 1
3353
3354 /* Notify Filter Values */
3355 #define REG_NOTIFY_CHANGE_NAME (0x00000001L)
3356 #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
3357 #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L)
3358 #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
3359
3360 #define REG_LEGAL_CHANGE_FILTER \
3361 (REG_NOTIFY_CHANGE_NAME |\
3362 REG_NOTIFY_CHANGE_ATTRIBUTES |\
3363 REG_NOTIFY_CHANGE_LAST_SET |\
3364 REG_NOTIFY_CHANGE_SECURITY)
3365
3366 #include <pshpack4.h>
3367 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
3368 UCHAR Type;
3369 UCHAR ShareDisposition;
3370 USHORT Flags;
3371 union {
3372 struct {
3373 PHYSICAL_ADDRESS Start;
3374 ULONG Length;
3375 } Generic;
3376 struct {
3377 PHYSICAL_ADDRESS Start;
3378 ULONG Length;
3379 } Port;
3380 struct {
3381 #if defined(NT_PROCESSOR_GROUPS)
3382 USHORT Level;
3383 USHORT Group;
3384 #else
3385 ULONG Level;
3386 #endif
3387 ULONG Vector;
3388 KAFFINITY Affinity;
3389 } Interrupt;
3390 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
3391 struct {
3392 _ANONYMOUS_UNION union {
3393 struct {
3394 #if defined(NT_PROCESSOR_GROUPS)
3395 USHORT Group;
3396 #else
3397 USHORT Reserved;
3398 #endif
3399 USHORT MessageCount;
3400 ULONG Vector;
3401 KAFFINITY Affinity;
3402 } Raw;
3403 struct {
3404 #if defined(NT_PROCESSOR_GROUPS)
3405 USHORT Level;
3406 USHORT Group;
3407 #else
3408 ULONG Level;
3409 #endif
3410 ULONG Vector;
3411 KAFFINITY Affinity;
3412 } Translated;
3413 } DUMMYUNIONNAME;
3414 } MessageInterrupt;
3415 #endif
3416 struct {
3417 PHYSICAL_ADDRESS Start;
3418 ULONG Length;
3419 } Memory;
3420 struct {
3421 ULONG Channel;
3422 ULONG Port;
3423 ULONG Reserved1;
3424 } Dma;
3425 struct {
3426 ULONG Data[3];
3427 } DevicePrivate;
3428 struct {
3429 ULONG Start;
3430 ULONG Length;
3431 ULONG Reserved;
3432 } BusNumber;
3433 struct {
3434 ULONG DataSize;
3435 ULONG Reserved1;
3436 ULONG Reserved2;
3437 } DeviceSpecificData;
3438 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
3439 struct {
3440 PHYSICAL_ADDRESS Start;
3441 ULONG Length40;
3442 } Memory40;
3443 struct {
3444 PHYSICAL_ADDRESS Start;
3445 ULONG Length48;
3446 } Memory48;
3447 struct {
3448 PHYSICAL_ADDRESS Start;
3449 ULONG Length64;
3450 } Memory64;
3451 #endif
3452 } u;
3453 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
3454 #include <poppack.h>
3455
3456 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
3457 #define CmResourceTypeNull 0
3458 #define CmResourceTypePort 1
3459 #define CmResourceTypeInterrupt 2
3460 #define CmResourceTypeMemory 3
3461 #define CmResourceTypeDma 4
3462 #define CmResourceTypeDeviceSpecific 5
3463 #define CmResourceTypeBusNumber 6
3464 #define CmResourceTypeMemoryLarge 7
3465 #define CmResourceTypeNonArbitrated 128
3466 #define CmResourceTypeConfigData 128
3467 #define CmResourceTypeDevicePrivate 129
3468 #define CmResourceTypePcCardConfig 130
3469 #define CmResourceTypeMfCardConfig 131
3470
3471 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
3472 typedef enum _CM_SHARE_DISPOSITION {
3473 CmResourceShareUndetermined = 0,
3474 CmResourceShareDeviceExclusive,
3475 CmResourceShareDriverExclusive,
3476 CmResourceShareShared
3477 } CM_SHARE_DISPOSITION;
3478
3479 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
3480 #define CM_RESOURCE_PORT_MEMORY 0x0000
3481 #define CM_RESOURCE_PORT_IO 0x0001
3482 #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
3483 #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
3484 #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
3485 #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
3486 #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
3487 #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
3488 #define CM_RESOURCE_PORT_BAR 0x0100
3489
3490 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
3491 #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
3492 #define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
3493 #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002
3494 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004
3495
3496 #define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001
3497
3498 #define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2)
3499
3500 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
3501 #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
3502 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
3503 #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
3504 #define CM_RESOURCE_MEMORY_WRITEABILITY_MASK 0x0003
3505 #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
3506 #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
3507 #define CM_RESOURCE_MEMORY_24 0x0010
3508 #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
3509 #define CM_RESOURCE_MEMORY_WINDOW_DECODE 0x0040
3510 #define CM_RESOURCE_MEMORY_BAR 0x0080
3511 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100
3512
3513 #define CM_RESOURCE_MEMORY_LARGE 0x0E00
3514 #define CM_RESOURCE_MEMORY_LARGE_40 0x0200
3515 #define CM_RESOURCE_MEMORY_LARGE_48 0x0400
3516 #define CM_RESOURCE_MEMORY_LARGE_64 0x0800
3517
3518 #define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00
3519 #define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000
3520 #define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000
3521
3522 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
3523 #define CM_RESOURCE_DMA_8 0x0000
3524 #define CM_RESOURCE_DMA_16 0x0001
3525 #define CM_RESOURCE_DMA_32 0x0002
3526 #define CM_RESOURCE_DMA_8_AND_16 0x0004
3527 #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
3528 #define CM_RESOURCE_DMA_TYPE_A 0x0010
3529 #define CM_RESOURCE_DMA_TYPE_B 0x0020
3530 #define CM_RESOURCE_DMA_TYPE_F 0x0040
3531
3532 typedef struct _DEVICE_FLAGS {
3533 ULONG Failed:1;
3534 ULONG ReadOnly:1;
3535 ULONG Removable:1;
3536 ULONG ConsoleIn:1;
3537 ULONG ConsoleOut:1;
3538 ULONG Input:1;
3539 ULONG Output:1;
3540 } DEVICE_FLAGS, *PDEVICE_FLAGS;
3541
3542 typedef enum _INTERFACE_TYPE {
3543 InterfaceTypeUndefined = -1,
3544 Internal,
3545 Isa,
3546 Eisa,
3547 MicroChannel,
3548 TurboChannel,
3549 PCIBus,
3550 VMEBus,
3551 NuBus,
3552 PCMCIABus,
3553 CBus,
3554 MPIBus,
3555 MPSABus,
3556 ProcessorInternal,
3557 InternalPowerBus,
3558 PNPISABus,
3559 PNPBus,
3560 Vmcs,
3561 MaximumInterfaceType
3562 } INTERFACE_TYPE, *PINTERFACE_TYPE;
3563
3564 typedef struct _CM_COMPONENT_INFORMATION {
3565 DEVICE_FLAGS Flags;
3566 ULONG Version;
3567 ULONG Key;
3568 KAFFINITY AffinityMask;
3569 } CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
3570
3571 typedef struct _CM_ROM_BLOCK {
3572 ULONG Address;
3573 ULONG Size;
3574 } CM_ROM_BLOCK, *PCM_ROM_BLOCK;
3575
3576 typedef struct _CM_PARTIAL_RESOURCE_LIST {
3577 USHORT Version;
3578 USHORT Revision;
3579 ULONG Count;
3580 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
3581 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
3582
3583 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
3584 INTERFACE_TYPE InterfaceType;
3585 ULONG BusNumber;
3586 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
3587 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
3588
3589 typedef struct _CM_RESOURCE_LIST {
3590 ULONG Count;
3591 CM_FULL_RESOURCE_DESCRIPTOR List[1];
3592 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
3593
3594 typedef struct _PNP_BUS_INFORMATION {
3595 GUID BusTypeGuid;
3596 INTERFACE_TYPE LegacyBusType;
3597 ULONG BusNumber;
3598 } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
3599
3600 #include <pshpack1.h>
3601
3602 typedef struct _CM_INT13_DRIVE_PARAMETER {
3603 USHORT DriveSelect;
3604 ULONG MaxCylinders;
3605 USHORT SectorsPerTrack;
3606 USHORT MaxHeads;
3607 USHORT NumberDrives;
3608 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
3609
3610 typedef struct _CM_MCA_POS_DATA {
3611 USHORT AdapterId;
3612 UCHAR PosData1;
3613 UCHAR PosData2;
3614 UCHAR PosData3;
3615 UCHAR PosData4;
3616 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
3617
3618 typedef struct _CM_PNP_BIOS_DEVICE_NODE {
3619 USHORT Size;
3620 UCHAR Node;
3621 ULONG ProductId;
3622 UCHAR DeviceType[3];
3623 USHORT DeviceAttributes;
3624 } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
3625
3626 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
3627 UCHAR Signature[4];
3628 UCHAR Revision;
3629 UCHAR Length;
3630 USHORT ControlField;
3631 UCHAR Checksum;
3632 ULONG EventFlagAddress;
3633 USHORT RealModeEntryOffset;
3634 USHORT RealModeEntrySegment;
3635 USHORT ProtectedModeEntryOffset;
3636 ULONG ProtectedModeCodeBaseAddress;
3637 ULONG OemDeviceId;
3638 USHORT RealModeDataBaseAddress;
3639 ULONG ProtectedModeDataBaseAddress;
3640 } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
3641
3642 #include <poppack.h>
3643
3644 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA {
3645 ULONG BytesPerSector;
3646 ULONG NumberOfCylinders;
3647 ULONG SectorsPerTrack;
3648 ULONG NumberOfHeads;
3649 } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
3650
3651 typedef struct _CM_KEYBOARD_DEVICE_DATA {
3652 USHORT Version;
3653 USHORT Revision;
3654 UCHAR Type;
3655 UCHAR Subtype;
3656 USHORT KeyboardFlags;
3657 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
3658
3659 typedef struct _CM_SCSI_DEVICE_DATA {
3660 USHORT Version;
3661 USHORT Revision;
3662 UCHAR HostIdentifier;
3663 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
3664
3665 typedef struct _CM_VIDEO_DEVICE_DATA {
3666 USHORT Version;
3667 USHORT Revision;
3668 ULONG VideoClock;
3669 } CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA;
3670
3671 typedef struct _CM_SONIC_DEVICE_DATA {
3672 USHORT Version;
3673 USHORT Revision;
3674 USHORT DataConfigurationRegister;
3675 UCHAR EthernetAddress[8];
3676 } CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA;
3677
3678 typedef struct _CM_SERIAL_DEVICE_DATA {
3679 USHORT Version;
3680 USHORT Revision;
3681 ULONG BaudClock;
3682 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
3683
3684 typedef struct _CM_MONITOR_DEVICE_DATA {
3685 USHORT Version;
3686 USHORT Revision;
3687 USHORT HorizontalScreenSize;
3688 USHORT VerticalScreenSize;
3689 USHORT HorizontalResolution;
3690 USHORT VerticalResolution;
3691 USHORT HorizontalDisplayTimeLow;
3692 USHORT HorizontalDisplayTime;
3693 USHORT HorizontalDisplayTimeHigh;
3694 USHORT HorizontalBackPorchLow;
3695 USHORT HorizontalBackPorch;
3696 USHORT HorizontalBackPorchHigh;
3697 USHORT HorizontalFrontPorchLow;
3698 USHORT HorizontalFrontPorch;
3699 USHORT HorizontalFrontPorchHigh;
3700 USHORT HorizontalSyncLow;
3701 USHORT HorizontalSync;
3702 USHORT HorizontalSyncHigh;
3703 USHORT VerticalBackPorchLow;
3704 USHORT VerticalBackPorch;
3705 USHORT VerticalBackPorchHigh;
3706 USHORT VerticalFrontPorchLow;
3707 USHORT VerticalFrontPorch;
3708 USHORT VerticalFrontPorchHigh;
3709 USHORT VerticalSyncLow;
3710 USHORT VerticalSync;
3711 USHORT VerticalSyncHigh;
3712 } CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA;
3713
3714 typedef struct _CM_FLOPPY_DEVICE_DATA {
3715 USHORT Version;
3716 USHORT Revision;
3717 CHAR Size[8];
3718 ULONG MaxDensity;
3719 ULONG MountDensity;
3720 UCHAR StepRateHeadUnloadTime;
3721 UCHAR HeadLoadTime;
3722 UCHAR MotorOffTime;
3723 UCHAR SectorLengthCode;
3724 UCHAR SectorPerTrack;
3725 UCHAR ReadWriteGapLength;
3726 UCHAR DataTransferLength;
3727 UCHAR FormatGapLength;
3728 UCHAR FormatFillCharacter;
3729 UCHAR HeadSettleTime;
3730 UCHAR MotorSettleTime;
3731 UCHAR MaximumTrackValue;
3732 UCHAR DataTransferRate;
3733 } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
3734
3735 typedef enum _KEY_INFORMATION_CLASS {
3736 KeyBasicInformation,
3737 KeyNodeInformation,
3738 KeyFullInformation,
3739 KeyNameInformation,
3740 KeyCachedInformation,
3741 KeyFlagsInformation,
3742 KeyVirtualizationInformation,
3743 KeyHandleTagsInformation,
3744 MaxKeyInfoClass
3745 } KEY_INFORMATION_CLASS;
3746
3747 typedef struct _KEY_BASIC_INFORMATION {
3748 LARGE_INTEGER LastWriteTime;
3749 ULONG TitleIndex;
3750 ULONG NameLength;
3751 WCHAR Name[1];
3752 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
3753
3754 typedef struct _KEY_CONTROL_FLAGS_INFORMATION {
3755 ULONG ControlFlags;
3756 } KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION;
3757
3758 typedef struct _KEY_FULL_INFORMATION {
3759 LARGE_INTEGER LastWriteTime;
3760 ULONG TitleIndex;
3761 ULONG ClassOffset;
3762 ULONG ClassLength;
3763 ULONG SubKeys;
3764 ULONG MaxNameLen;
3765 ULONG MaxClassLen;
3766 ULONG Values;
3767 ULONG MaxValueNameLen;
3768 ULONG MaxValueDataLen;
3769 WCHAR Class[1];
3770 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
3771
3772 typedef struct _KEY_HANDLE_TAGS_INFORMATION {
3773 ULONG HandleTags;
3774 } KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION;
3775
3776 typedef struct _KEY_NODE_INFORMATION {
3777 LARGE_INTEGER LastWriteTime;
3778 ULONG TitleIndex;
3779 ULONG ClassOffset;
3780 ULONG ClassLength;
3781 ULONG NameLength;
3782 WCHAR Name[1];
3783 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
3784
3785 typedef enum _KEY_SET_INFORMATION_CLASS {
3786 KeyWriteTimeInformation,
3787 KeyWow64FlagsInformation,
3788 KeyControlFlagsInformation,
3789 KeySetVirtualizationInformation,
3790 KeySetDebugInformation,
3791 KeySetHandleTagsInformation,
3792 MaxKeySetInfoClass
3793 } KEY_SET_INFORMATION_CLASS;
3794
3795 typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION {
3796 ULONG VirtualTarget:1;
3797 ULONG VirtualStore:1;
3798 ULONG VirtualSource:1;
3799 ULONG Reserved:29;
3800 } KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION;
3801
3802 typedef struct _KEY_VALUE_BASIC_INFORMATION {
3803 ULONG TitleIndex;
3804 ULONG Type;
3805 ULONG NameLength;
3806 WCHAR Name[1];
3807 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
3808
3809 typedef struct _KEY_VALUE_FULL_INFORMATION {
3810 ULONG TitleIndex;
3811 ULONG Type;
3812 ULONG DataOffset;
3813 ULONG DataLength;
3814 ULONG NameLength;
3815 WCHAR Name[1];
3816 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
3817
3818 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
3819 ULONG TitleIndex;
3820 ULONG Type;
3821 ULONG DataLength;
3822 _Field_size_bytes_(DataLength) UCHAR Data[1];
3823 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
3824
3825 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
3826 ULONG Type;
3827 ULONG DataLength;
3828 _Field_size_bytes_(DataLength) UCHAR Data[1];
3829 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
3830
3831 typedef struct _KEY_VALUE_ENTRY {
3832 PUNICODE_STRING ValueName;
3833 ULONG DataLength;
3834 ULONG DataOffset;
3835 ULONG Type;
3836 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
3837
3838 typedef enum _KEY_VALUE_INFORMATION_CLASS {
3839 KeyValueBasicInformation,
3840 KeyValueFullInformation,
3841 KeyValuePartialInformation,
3842 KeyValueFullInformationAlign64,
3843 KeyValuePartialInformationAlign64
3844 } KEY_VALUE_INFORMATION_CLASS;
3845
3846 typedef struct _KEY_WOW64_FLAGS_INFORMATION {
3847 ULONG UserFlags;
3848 } KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION;
3849
3850 typedef struct _KEY_WRITE_TIME_INFORMATION {
3851 LARGE_INTEGER LastWriteTime;
3852 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
3853
3854 #if (NTDDI_VERSION < NTDDI_VISTA)
3855 typedef struct _KEY_USER_FLAGS_INFORMATION {
3856 ULONG UserFlags;
3857 } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
3858 #endif
3859
3860 typedef enum _REG_NOTIFY_CLASS {
3861 RegNtDeleteKey,
3862 RegNtPreDeleteKey = RegNtDeleteKey,
3863 RegNtSetValueKey,
3864 RegNtPreSetValueKey = RegNtSetValueKey,
3865 RegNtDeleteValueKey,
3866 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
3867 RegNtSetInformationKey,
3868 RegNtPreSetInformationKey = RegNtSetInformationKey,
3869 RegNtRenameKey,
3870 RegNtPreRenameKey = RegNtRenameKey,
3871 RegNtEnumerateKey,
3872 RegNtPreEnumerateKey = RegNtEnumerateKey,
3873 RegNtEnumerateValueKey,
3874 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
3875 RegNtQueryKey,
3876 RegNtPreQueryKey = RegNtQueryKey,
3877 RegNtQueryValueKey,
3878 RegNtPreQueryValueKey = RegNtQueryValueKey,
3879 RegNtQueryMultipleValueKey,
3880 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
3881 RegNtPreCreateKey,
3882 RegNtPostCreateKey,
3883 RegNtPreOpenKey,
3884 RegNtPostOpenKey,
3885 RegNtKeyHandleClose,
3886 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
3887 RegNtPostDeleteKey,
3888 RegNtPostSetValueKey,
3889 RegNtPostDeleteValueKey,
3890 RegNtPostSetInformationKey,
3891 RegNtPostRenameKey,
3892 RegNtPostEnumerateKey,
3893 RegNtPostEnumerateValueKey,
3894 RegNtPostQueryKey,
3895 RegNtPostQueryValueKey,
3896 RegNtPostQueryMultipleValueKey,
3897 RegNtPostKeyHandleClose,
3898 RegNtPreCreateKeyEx,
3899 RegNtPostCreateKeyEx,
3900 RegNtPreOpenKeyEx,
3901 RegNtPostOpenKeyEx,
3902 RegNtPreFlushKey,
3903 RegNtPostFlushKey,
3904 RegNtPreLoadKey,
3905 RegNtPostLoadKey,
3906 RegNtPreUnLoadKey,
3907 RegNtPostUnLoadKey,
3908 RegNtPreQueryKeySecurity,
3909 RegNtPostQueryKeySecurity,
3910 RegNtPreSetKeySecurity,
3911 RegNtPostSetKeySecurity,
3912 RegNtCallbackObjectContextCleanup,
3913 RegNtPreRestoreKey,
3914 RegNtPostRestoreKey,
3915 RegNtPreSaveKey,
3916 RegNtPostSaveKey,
3917 RegNtPreReplaceKey,
3918 RegNtPostReplaceKey,
3919 MaxRegNtNotifyClass
3920 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
3921
3922 _IRQL_requires_same_
3923 _Function_class_(EX_CALLBACK_FUNCTION)
3924 typedef NTSTATUS
3925 (NTAPI EX_CALLBACK_FUNCTION)(
3926 _In_ PVOID CallbackContext,
3927 _In_opt_ PVOID Argument1,
3928 _In_opt_ PVOID Argument2);
3929 typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION;
3930
3931 typedef struct _REG_DELETE_KEY_INFORMATION {
3932 PVOID Object;
3933 PVOID CallContext;
3934 PVOID ObjectContext;
3935 PVOID Reserved;
3936 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION
3937 #if (NTDDI_VERSION >= NTDDI_VISTA)
3938 , REG_FLUSH_KEY_INFORMATION, *PREG_FLUSH_KEY_INFORMATION
3939 #endif
3940 ;
3941
3942 typedef struct _REG_SET_VALUE_KEY_INFORMATION {
3943 PVOID Object;
3944 PUNICODE_STRING ValueName;
3945 ULONG TitleIndex;
3946 ULONG Type;
3947 PVOID Data;
3948 ULONG DataSize;
3949 PVOID CallContext;
3950 PVOID ObjectContext;
3951 PVOID Reserved;
3952 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
3953
3954 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION {
3955 PVOID Object;
3956 PUNICODE_STRING ValueName;
3957 PVOID CallContext;
3958 PVOID ObjectContext;
3959 PVOID Reserved;
3960 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
3961
3962 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION {
3963 PVOID Object;
3964 KEY_SET_INFORMATION_CLASS KeySetInformationClass;
3965 PVOID KeySetInformation;
3966 ULONG KeySetInformationLength;
3967 PVOID CallContext;
3968 PVOID ObjectContext;
3969 PVOID Reserved;
3970 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
3971
3972 typedef struct _REG_ENUMERATE_KEY_INFORMATION {
3973 PVOID Object;
3974 ULONG Index;
3975 KEY_INFORMATION_CLASS KeyInformationClass;
3976 PVOID KeyInformation;
3977 ULONG Length;
3978 PULONG ResultLength;
3979 PVOID CallContext;
3980 PVOID ObjectContext;
3981 PVOID Reserved;
3982 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
3983
3984 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION {
3985 PVOID Object;
3986 ULONG Index;
3987 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
3988 PVOID KeyValueInformation;
3989 ULONG Length;
3990 PULONG ResultLength;
3991 PVOID CallContext;
3992 PVOID ObjectContext;
3993 PVOID Reserved;
3994 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
3995
3996 typedef struct _REG_QUERY_KEY_INFORMATION {
3997 PVOID Object;
3998 KEY_INFORMATION_CLASS KeyInformationClass;
3999 PVOID KeyInformation;
4000 ULONG Length;
4001 PULONG ResultLength;
4002 PVOID CallContext;
4003 PVOID ObjectContext;
4004 PVOID Reserved;
4005 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
4006
4007 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION {
4008 PVOID Object;
4009 PUNICODE_STRING ValueName;
4010 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
4011 PVOID KeyValueInformation;
4012 ULONG Length;
4013 PULONG ResultLength;
4014 PVOID CallContext;
4015 PVOID ObjectContext;
4016 PVOID Reserved;
4017 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
4018
4019 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION {
4020 PVOID Object;
4021 PKEY_VALUE_ENTRY ValueEntries;
4022 ULONG EntryCount;
4023 PVOID ValueBuffer;
4024 PULONG BufferLength;
4025 PULONG RequiredBufferLength;
4026 PVOID CallContext;
4027 PVOID ObjectContext;
4028 PVOID Reserved;
4029 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
4030
4031 typedef struct _REG_RENAME_KEY_INFORMATION {
4032 PVOID Object;
4033 PUNICODE_STRING NewName;
4034 PVOID CallContext;
4035 PVOID ObjectContext;
4036 PVOID Reserved;
4037 } REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION;
4038
4039 typedef struct _REG_CREATE_KEY_INFORMATION {
4040 PUNICODE_STRING CompleteName;
4041 PVOID RootObject;
4042 PVOID ObjectType;
4043 ULONG CreateOptions;
4044 PUNICODE_STRING Class;
4045 PVOID SecurityDescriptor;
4046 PVOID SecurityQualityOfService;
4047 ACCESS_MASK DesiredAccess;
4048 ACCESS_MASK GrantedAccess;
4049 PULONG Disposition;
4050 PVOID *ResultObject;
4051 PVOID CallContext;
4052 PVOID RootObjectContext;
4053 PVOID Transaction;
4054 PVOID Reserved;
4055 } REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION;
4056
4057 typedef struct _REG_CREATE_KEY_INFORMATION_V1 {
4058 PUNICODE_STRING CompleteName;
4059 PVOID RootObject;
4060 PVOID ObjectType;
4061 ULONG Options;
4062 PUNICODE_STRING Class;
4063 PVOID SecurityDescriptor;
4064 PVOID SecurityQualityOfService;
4065 ACCESS_MASK DesiredAccess;
4066 ACCESS_MASK GrantedAccess;
4067 PULONG Disposition;
4068 PVOID *ResultObject;
4069 PVOID CallContext;
4070 PVOID RootObjectContext;
4071 PVOID Transaction;
4072 ULONG_PTR Version;
4073 PUNICODE_STRING RemainingName;
4074 ULONG Wow64Flags;
4075 ULONG Attributes;
4076 KPROCESSOR_MODE CheckAccessMode;
4077 } REG_CREATE_KEY_INFORMATION_V1, REG_OPEN_KEY_INFORMATION_V1,*PREG_CREATE_KEY_INFORMATION_V1, *PREG_OPEN_KEY_INFORMATION_V1;
4078
4079 typedef struct _REG_PRE_CREATE_KEY_INFORMATION {
4080 PUNICODE_STRING CompleteName;
4081 } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;;
4082
4083 typedef struct _REG_POST_CREATE_KEY_INFORMATION {
4084 PUNICODE_STRING CompleteName;
4085 PVOID Object;
4086 NTSTATUS Status;
4087 } REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
4088
4089 typedef struct _REG_POST_OPERATION_INFORMATION {
4090 PVOID Object;
4091 NTSTATUS Status;
4092 PVOID PreInformation;
4093 NTSTATUS ReturnStatus;
4094 PVOID CallContext;