Home | History | Annotate | Download | only in ddk
      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
     10  *   Timo Kreuzer (timo.kreuzer (at) 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 <ntiologc.h>
     45 
     46 #ifndef GUID_DEFINED
     47 #include <guiddef.h>
     48 #endif
     49 
     50 #ifdef _MAC
     51 #ifndef _INC_STRING
     52 #include <string.h>
     53 #endif /* _INC_STRING */
     54 #else
     55 #include <string.h>
     56 #endif /* _MAC */
     57 
     58 #ifndef _KTMTYPES_
     59 typedef GUID UOW, *PUOW;
     60 #endif
     61 
     62 typedef GUID *PGUID;
     63 
     64 #if (NTDDI_VERSION >= NTDDI_WINXP)
     65 #include <dpfilter.h>
     66 #endif
     67 
     68 #include "intrin.h"
     69 
     70 #ifdef __cplusplus
     71 extern "C" {
     72 #endif
     73 
     74 #if !defined(_NTHALDLL_) && !defined(_BLDR_)
     75 #define NTHALAPI DECLSPEC_IMPORT
     76 #else
     77 #define NTHALAPI
     78 #endif
     79 
     80 /* For ReactOS */
     81 #if !defined(_NTOSKRNL_) && !defined(_BLDR_)
     82 #define NTKERNELAPI DECLSPEC_IMPORT
     83 #else
     84 #define NTKERNELAPI
     85 #endif
     86 
     87 #if defined(_X86_) && !defined(_NTHAL_)
     88 #define _DECL_HAL_KE_IMPORT  DECLSPEC_IMPORT
     89 #elif defined(_X86_)
     90 #define _DECL_HAL_KE_IMPORT
     91 #else
     92 #define _DECL_HAL_KE_IMPORT NTKERNELAPI
     93 #endif
     94 
     95 #if defined(_WIN64)
     96 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
     97 #else
     98 #define POINTER_ALIGNMENT
     99 #endif
    100 
    101 #if defined(_MSC_VER)
    102 /* Disable some warnings */
    103 #pragma warning(disable:4115) /* Named type definition in parentheses */
    104 #pragma warning(disable:4201) /* Nameless unions and structs */
    105 #pragma warning(disable:4214) /* Bit fields of other types than int */
    106 #pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */
    107 
    108 /* Indicate if #pragma alloc_text() is supported */
    109 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64)
    110 #define ALLOC_PRAGMA 1
    111 #endif
    112 
    113 /* Indicate if #pragma data_seg() is supported */
    114 #if defined(_M_IX86) || defined(_M_AMD64)
    115 #define ALLOC_DATA_PRAGMA 1
    116 #endif
    117 
    118 #endif /* _MSC_VER */
    119 
    120 #if defined(_WIN64)
    121 #if !defined(USE_DMA_MACROS) && !defined(_NTHAL_)
    122 #define USE_DMA_MACROS
    123 #endif
    124 #if !defined(NO_LEGACY_DRIVERS) && !defined(__REACTOS__)
    125 #define NO_LEGACY_DRIVERS
    126 #endif
    127 #endif /* defined(_WIN64) */
    128 
    129 /* Forward declarations */
    130 struct _IRP;
    131 struct _MDL;
    132 struct _KAPC;
    133 struct _KDPC;
    134 struct _FILE_OBJECT;
    135 struct _DMA_ADAPTER;
    136 struct _DEVICE_OBJECT;
    137 struct _DRIVER_OBJECT;
    138 struct _IO_STATUS_BLOCK;
    139 struct _DEVICE_DESCRIPTION;
    140 struct _SCATTER_GATHER_LIST;
    141 struct _DRIVE_LAYOUT_INFORMATION;
    142 struct _COMPRESSED_DATA_INFO;
    143 struct _IO_RESOURCE_DESCRIPTOR;
    144 
    145 /* Structures not exposed to drivers */
    146 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
    147 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE;
    148 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE;
    149 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
    150 typedef struct _EPROCESS *PEPROCESS;
    151 typedef struct _ETHREAD *PETHREAD;
    152 typedef struct _IO_TIMER *PIO_TIMER;
    153 typedef struct _KINTERRUPT *PKINTERRUPT;
    154 typedef struct _KPROCESS *PKPROCESS;
    155 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
    156 typedef struct _CONTEXT *PCONTEXT;
    157 
    158 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_)
    159 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
    160 #elif defined(_WDM_INCLUDED_)
    161 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
    162 #else
    163 typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
    164 #endif
    165 
    166 #ifndef DEFINE_GUIDEX
    167 #ifdef _MSC_VER
    168 #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
    169 #else
    170 #define DEFINE_GUIDEX(name) EXTERN_C const GUID name
    171 #endif
    172 #endif /* DEFINE_GUIDEX */
    173 
    174 #ifndef STATICGUIDOF
    175 #define STATICGUIDOF(guid) STATIC_##guid
    176 #endif
    177 
    178 /* GUID Comparison */
    179 #ifndef __IID_ALIGNED__
    180 #define __IID_ALIGNED__
    181 #ifdef __cplusplus
    182 inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2)
    183 {
    184     return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) &&
    185              (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) );
    186 }
    187 #else
    188 #define IsEqualGUIDAligned(guid1, guid2) \
    189            ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \
    190              (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) )
    191 #endif /* __cplusplus */
    192 #endif /* !__IID_ALIGNED__ */
    193 
    194 
    195 /******************************************************************************
    196  *                           INTERLOCKED Functions                            *
    197  ******************************************************************************/
    198 //
    199 // Intrinsics (note: taken from our winnt.h)
    200 // FIXME: 64-bit
    201 //
    202 #if defined(__GNUC__)
    203 
    204 static __inline__ BOOLEAN
    205 InterlockedBitTestAndSet(
    206   IN LONG volatile *Base,
    207   IN LONG Bit)
    208 {
    209 #if defined(_M_IX86)
    210   LONG OldBit;
    211   __asm__ __volatile__("lock "
    212                        "btsl %2,%1\n\t"
    213                        "sbbl %0,%0\n\t"
    214                        :"=r" (OldBit),"+m" (*Base)
    215                        :"Ir" (Bit)
    216                        : "memory");
    217   return OldBit;
    218 #else
    219   return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1;
    220 #endif
    221 }
    222 
    223 static __inline__ BOOLEAN
    224 InterlockedBitTestAndReset(
    225   IN LONG volatile *Base,
    226   IN LONG Bit)
    227 {
    228 #if defined(_M_IX86)
    229   LONG OldBit;
    230   __asm__ __volatile__("lock "
    231                        "btrl %2,%1\n\t"
    232                        "sbbl %0,%0\n\t"
    233                        :"=r" (OldBit),"+m" (*Base)
    234                        :"Ir" (Bit)
    235                        : "memory");
    236   return OldBit;
    237 #else
    238   return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1;
    239 #endif
    240 }
    241 
    242 #endif /* defined(__GNUC__) */
    243 
    244 #define BitScanForward _BitScanForward
    245 #define BitScanReverse _BitScanReverse
    246 #define BitTest _bittest
    247 #define BitTestAndComplement _bittestandcomplement
    248 #define BitTestAndSet _bittestandset
    249 #define BitTestAndReset _bittestandreset
    250 #define InterlockedBitTestAndSet _interlockedbittestandset
    251 #define InterlockedBitTestAndReset _interlockedbittestandreset
    252 
    253 #ifdef _M_AMD64
    254 #define BitTest64 _bittest64
    255 #define BitTestAndComplement64 _bittestandcomplement64
    256 #define BitTestAndSet64 _bittestandset64
    257 #define BitTestAndReset64 _bittestandreset64
    258 #define InterlockedBitTestAndSet64 _interlockedbittestandset64
    259 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64
    260 #endif
    261 
    262 #if !defined(__INTERLOCKED_DECLARED)
    263 #define __INTERLOCKED_DECLARED
    264 
    265 #if defined (_X86_)
    266 #if defined(NO_INTERLOCKED_INTRINSICS)
    267 NTKERNELAPI
    268 LONG
    269 FASTCALL
    270 InterlockedIncrement(
    271   IN OUT LONG volatile *Addend);
    272 
    273 NTKERNELAPI
    274 LONG
    275 FASTCALL
    276 InterlockedDecrement(
    277   IN OUT LONG volatile *Addend);
    278 
    279 NTKERNELAPI
    280 LONG
    281 FASTCALL
    282 InterlockedCompareExchange(
    283   IN OUT LONG volatile *Destination,
    284   IN LONG Exchange,
    285   IN LONG Comparand);
    286 
    287 NTKERNELAPI
    288 LONG
    289 FASTCALL
    290 InterlockedExchange(
    291   IN OUT LONG volatile *Destination,
    292   IN LONG Value);
    293 
    294 NTKERNELAPI
    295 LONG
    296 FASTCALL
    297 InterlockedExchangeAdd(
    298   IN OUT LONG volatile *Addend,
    299   IN LONG  Value);
    300 
    301 #else /* !defined(NO_INTERLOCKED_INTRINSICS) */
    302 
    303 #define InterlockedExchange _InterlockedExchange
    304 #define InterlockedIncrement _InterlockedIncrement
    305 #define InterlockedDecrement _InterlockedDecrement
    306 #define InterlockedExchangeAdd _InterlockedExchangeAdd
    307 #define InterlockedCompareExchange _InterlockedCompareExchange
    308 #define InterlockedOr _InterlockedOr
    309 #define InterlockedAnd _InterlockedAnd
    310 #define InterlockedXor _InterlockedXor
    311 
    312 #endif /* !defined(NO_INTERLOCKED_INTRINSICS) */
    313 
    314 #endif /* defined (_X86_) */
    315 
    316 #if !defined (_WIN64)
    317 /*
    318  * PVOID
    319  * InterlockedExchangePointer(
    320  *   IN OUT PVOID volatile  *Target,
    321  *   IN PVOID  Value)
    322  */
    323 #define InterlockedExchangePointer(Target, Value) \
    324   ((PVOID) InterlockedExchange((PLONG) Target, (LONG) Value))
    325 
    326 /*
    327  * PVOID
    328  * InterlockedCompareExchangePointer(
    329  *   IN OUT PVOID  *Destination,
    330  *   IN PVOID  Exchange,
    331  *   IN PVOID  Comparand)
    332  */
    333 #define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) \
    334   ((PVOID) InterlockedCompareExchange((PLONG) Destination, (LONG) Exchange, (LONG) Comparand))
    335 
    336 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)a, b)
    337 #define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)a)
    338 #define InterlockedDecrementSizeT(a) InterlockedDecrement((LONG *)a)
    339 
    340 #endif // !defined (_WIN64)
    341 
    342 #if defined (_M_AMD64)
    343 
    344 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)a, (LONGLONG)b)
    345 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONGLONG *)a)
    346 #define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONGLONG *)a)
    347 #define InterlockedAnd _InterlockedAnd
    348 #define InterlockedOr _InterlockedOr
    349 #define InterlockedXor _InterlockedXor
    350 #define InterlockedIncrement _InterlockedIncrement
    351 #define InterlockedDecrement _InterlockedDecrement
    352 #define InterlockedAdd _InterlockedAdd
    353 #define InterlockedExchange _InterlockedExchange
    354 #define InterlockedExchangeAdd _InterlockedExchangeAdd
    355 #define InterlockedCompareExchange _InterlockedCompareExchange
    356 #define InterlockedAnd64 _InterlockedAnd64
    357 #define InterlockedOr64 _InterlockedOr64
    358 #define InterlockedXor64 _InterlockedXor64
    359 #define InterlockedIncrement64 _InterlockedIncrement64
    360 #define InterlockedDecrement64 _InterlockedDecrement64
    361 #define InterlockedAdd64 _InterlockedAdd64
    362 #define InterlockedExchange64 _InterlockedExchange64
    363 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
    364 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
    365 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
    366 #define InterlockedExchangePointer _InterlockedExchangePointer
    367 #define InterlockedBitTestAndSet64 _interlockedbittestandset64
    368 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64
    369 
    370 #endif // _M_AMD64
    371 
    372 #if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
    373 //#if !defined(_X86AMD64_) // FIXME: what's _X86AMD64_ used for?
    374 FORCEINLINE
    375 LONG64
    376 InterlockedAdd64(
    377   IN OUT LONG64 volatile *Addend,
    378   IN LONG64 Value)
    379 {
    380   return InterlockedExchangeAdd64(Addend, Value) + Value;
    381 }
    382 //#endif
    383 #endif
    384 
    385 #endif /* !__INTERLOCKED_DECLARED */
    386 
    387 
    388 /******************************************************************************
    389  *                           Runtime Library Types                            *
    390  ******************************************************************************/
    391 
    392 #define RTL_REGISTRY_ABSOLUTE             0
    393 #define RTL_REGISTRY_SERVICES             1
    394 #define RTL_REGISTRY_CONTROL              2
    395 #define RTL_REGISTRY_WINDOWS_NT           3
    396 #define RTL_REGISTRY_DEVICEMAP            4
    397 #define RTL_REGISTRY_USER                 5
    398 #define RTL_REGISTRY_MAXIMUM              6
    399 #define RTL_REGISTRY_HANDLE               0x40000000
    400 #define RTL_REGISTRY_OPTIONAL             0x80000000
    401 
    402 /* RTL_QUERY_REGISTRY_TABLE.Flags */
    403 #define RTL_QUERY_REGISTRY_SUBKEY         0x00000001
    404 #define RTL_QUERY_REGISTRY_TOPKEY         0x00000002
    405 #define RTL_QUERY_REGISTRY_REQUIRED       0x00000004
    406 #define RTL_QUERY_REGISTRY_NOVALUE        0x00000008
    407 #define RTL_QUERY_REGISTRY_NOEXPAND       0x00000010
    408 #define RTL_QUERY_REGISTRY_DIRECT         0x00000020
    409 #define RTL_QUERY_REGISTRY_DELETE         0x00000040
    410 
    411 #define HASH_STRING_ALGORITHM_DEFAULT     0
    412 #define HASH_STRING_ALGORITHM_X65599      1
    413 #define HASH_STRING_ALGORITHM_INVALID     0xffffffff
    414 
    415 typedef struct _RTL_BITMAP {
    416   ULONG SizeOfBitMap;
    417   PULONG Buffer;
    418 } RTL_BITMAP, *PRTL_BITMAP;
    419 
    420 typedef struct _RTL_BITMAP_RUN {
    421   ULONG StartingIndex;
    422   ULONG NumberOfBits;
    423 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
    424 
    425 typedef NTSTATUS
    426 (NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)(
    427   IN PWSTR ValueName,
    428   IN ULONG ValueType,
    429   IN PVOID ValueData,
    430   IN ULONG ValueLength,
    431   IN PVOID Context,
    432   IN PVOID EntryContext);
    433 
    434 typedef struct _RTL_QUERY_REGISTRY_TABLE {
    435   PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
    436   ULONG Flags;
    437   PCWSTR Name;
    438   PVOID EntryContext;
    439   ULONG DefaultType;
    440   PVOID DefaultData;
    441   ULONG DefaultLength;
    442 } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
    443 
    444 typedef struct _TIME_FIELDS {
    445   CSHORT Year;
    446   CSHORT Month;
    447   CSHORT Day;
    448   CSHORT Hour;
    449   CSHORT Minute;
    450   CSHORT Second;
    451   CSHORT Milliseconds;
    452   CSHORT Weekday;
    453 } TIME_FIELDS, *PTIME_FIELDS;
    454 
    455 /* Slist Header */
    456 #ifndef _SLIST_HEADER_
    457 #define _SLIST_HEADER_
    458 
    459 #if defined(_WIN64)
    460 
    461 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
    462   struct _SLIST_ENTRY *Next;
    463 } SLIST_ENTRY, *PSLIST_ENTRY;
    464 
    465 typedef struct _SLIST_ENTRY32 {
    466   ULONG Next;
    467 } SLIST_ENTRY32, *PSLIST_ENTRY32;
    468 
    469 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
    470   _ANONYMOUS_STRUCT struct {
    471     ULONGLONG Alignment;
    472     ULONGLONG Region;
    473   } DUMMYSTRUCTNAME;
    474   struct {
    475     ULONGLONG Depth:16;
    476     ULONGLONG Sequence:9;
    477     ULONGLONG NextEntry:39;
    478     ULONGLONG HeaderType:1;
    479     ULONGLONG Init:1;
    480     ULONGLONG Reserved:59;
    481     ULONGLONG Region:3;
    482   } Header8;
    483   struct {
    484     ULONGLONG Depth:16;
    485     ULONGLONG Sequence:48;
    486     ULONGLONG HeaderType:1;
    487     ULONGLONG Init:1;
    488     ULONGLONG Reserved:2;
    489     ULONGLONG NextEntry:60;
    490   } Header16;
    491   struct {
    492     ULONGLONG Depth:16;
    493     ULONGLONG Sequence:48;
    494     ULONGLONG HeaderType:1;
    495     ULONGLONG Reserved:3;
    496     ULONGLONG NextEntry:60;
    497   } HeaderX64;
    498 } SLIST_HEADER, *PSLIST_HEADER;
    499 
    500 typedef union _SLIST_HEADER32 {
    501   ULONGLONG Alignment;
    502   _ANONYMOUS_STRUCT struct {
    503     SLIST_ENTRY32 Next;
    504     USHORT Depth;
    505     USHORT Sequence;
    506   } DUMMYSTRUCTNAME;
    507 } SLIST_HEADER32, *PSLIST_HEADER32;
    508 
    509 #else
    510 
    511 #define SLIST_ENTRY SINGLE_LIST_ENTRY
    512 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
    513 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
    514 
    515 typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32;
    516 
    517 typedef union _SLIST_HEADER {
    518   ULONGLONG Alignment;
    519   _ANONYMOUS_STRUCT struct {
    520     SLIST_ENTRY Next;
    521     USHORT Depth;
    522     USHORT Sequence;
    523   } DUMMYSTRUCTNAME;
    524 } SLIST_HEADER, *PSLIST_HEADER;
    525 
    526 typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32;
    527 
    528 #endif /* defined(_WIN64) */
    529 
    530 #endif /* _SLIST_HEADER_ */
    531 
    532 /* MS definition is broken! */
    533 extern BOOLEAN NTSYSAPI NlsMbCodePageTag;
    534 extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag;
    535 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
    536 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
    537 
    538 #define SHORT_LEAST_SIGNIFICANT_BIT       0
    539 #define SHORT_MOST_SIGNIFICANT_BIT        1
    540 
    541 #define LONG_LEAST_SIGNIFICANT_BIT        0
    542 #define LONG_3RD_MOST_SIGNIFICANT_BIT     1
    543 #define LONG_2ND_MOST_SIGNIFICANT_BIT     2
    544 #define LONG_MOST_SIGNIFICANT_BIT         3
    545 
    546 #define RTLVERLIB_DDI(x) Wdmlib##x
    547 
    548 typedef BOOLEAN
    549 (*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)(
    550   IN ULONG Version);
    551 
    552 typedef BOOLEAN
    553 (*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)(
    554   IN ULONG Version);
    555 
    556 /******************************************************************************
    557  *                              Kernel Types                                  *
    558  ******************************************************************************/
    559 
    560 typedef UCHAR KIRQL, *PKIRQL;
    561 typedef CCHAR KPROCESSOR_MODE;
    562 typedef LONG KPRIORITY;
    563 
    564 typedef enum _MODE {
    565   KernelMode,
    566   UserMode,
    567   MaximumMode
    568 } MODE;
    569 
    570 #define CACHE_FULLY_ASSOCIATIVE 0xFF
    571 #define MAXIMUM_SUSPEND_COUNT   MAXCHAR
    572 
    573 #define EVENT_QUERY_STATE (0x0001)
    574 #define EVENT_MODIFY_STATE (0x0002)
    575 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
    576 
    577 #define LTP_PC_SMT 0x1
    578 
    579 #if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS)
    580 #define SINGLE_GROUP_LEGACY_API        1
    581 #endif
    582 
    583 #define SEMAPHORE_QUERY_STATE (0x0001)
    584 #define SEMAPHORE_MODIFY_STATE (0x0002)
    585 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
    586 
    587 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP {
    588   RelationProcessorCore,
    589   RelationNumaNode,
    590   RelationCache,
    591   RelationProcessorPackage,
    592   RelationGroup,
    593   RelationAll = 0xffff
    594 } LOGICAL_PROCESSOR_RELATIONSHIP;
    595 
    596 typedef enum _PROCESSOR_CACHE_TYPE {
    597   CacheUnified,
    598   CacheInstruction,
    599   CacheData,
    600   CacheTrace
    601 } PROCESSOR_CACHE_TYPE;
    602 
    603 typedef struct _CACHE_DESCRIPTOR {
    604   UCHAR Level;
    605   UCHAR Associativity;
    606   USHORT LineSize;
    607   ULONG Size;
    608   PROCESSOR_CACHE_TYPE Type;
    609 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
    610 
    611 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION {
    612   ULONG_PTR ProcessorMask;
    613   LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
    614   _ANONYMOUS_UNION union {
    615     struct {
    616       UCHAR Flags;
    617     } ProcessorCore;
    618     struct {
    619       ULONG NodeNumber;
    620     } NumaNode;
    621     CACHE_DESCRIPTOR Cache;
    622     ULONGLONG Reserved[2];
    623   } DUMMYUNIONNAME;
    624 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
    625 
    626 typedef struct _PROCESSOR_RELATIONSHIP {
    627   UCHAR Flags;
    628   UCHAR Reserved[21];
    629   USHORT GroupCount;
    630   GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
    631 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
    632 
    633 typedef struct _NUMA_NODE_RELATIONSHIP {
    634   ULONG NodeNumber;
    635   UCHAR Reserved[20];
    636   GROUP_AFFINITY GroupMask;
    637 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
    638 
    639 typedef struct _CACHE_RELATIONSHIP {
    640   UCHAR Level;
    641   UCHAR Associativity;
    642   USHORT LineSize;
    643   ULONG CacheSize;
    644   PROCESSOR_CACHE_TYPE Type;
    645   UCHAR Reserved[20];
    646   GROUP_AFFINITY GroupMask;
    647 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
    648 
    649 typedef struct _PROCESSOR_GROUP_INFO {
    650   UCHAR MaximumProcessorCount;
    651   UCHAR ActiveProcessorCount;
    652   UCHAR Reserved[38];
    653   KAFFINITY ActiveProcessorMask;
    654 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
    655 
    656 typedef struct _GROUP_RELATIONSHIP {
    657   USHORT MaximumGroupCount;
    658   USHORT ActiveGroupCount;
    659   UCHAR Reserved[20];
    660   PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
    661 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
    662 
    663 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX {
    664   LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
    665   ULONG Size;
    666   _ANONYMOUS_UNION union {
    667     PROCESSOR_RELATIONSHIP Processor;
    668     NUMA_NODE_RELATIONSHIP NumaNode;
    669     CACHE_RELATIONSHIP Cache;
    670     GROUP_RELATIONSHIP Group;
    671   } DUMMYUNIONNAME;
    672 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;;
    673 
    674 /* Processor features */
    675 #define PF_FLOATING_POINT_PRECISION_ERRATA  0
    676 #define PF_FLOATING_POINT_EMULATED          1
    677 #define PF_COMPARE_EXCHANGE_DOUBLE          2
    678 #define PF_MMX_INSTRUCTIONS_AVAILABLE       3
    679 #define PF_PPC_MOVEMEM_64BIT_OK             4
    680 #define PF_ALPHA_BYTE_INSTRUCTIONS          5
    681 #define PF_XMMI_INSTRUCTIONS_AVAILABLE      6
    682 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE     7
    683 #define PF_RDTSC_INSTRUCTION_AVAILABLE      8
    684 #define PF_PAE_ENABLED                      9
    685 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE   10
    686 #define PF_SSE_DAZ_MODE_AVAILABLE          11
    687 #define PF_NX_ENABLED                      12
    688 #define PF_SSE3_INSTRUCTIONS_AVAILABLE     13
    689 #define PF_COMPARE_EXCHANGE128             14
    690 #define PF_COMPARE64_EXCHANGE128           15
    691 #define PF_CHANNELS_ENABLED                16
    692 #define PF_XSAVE_ENABLED                   17
    693 
    694 #define MAXIMUM_WAIT_OBJECTS              64
    695 
    696 #define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject)
    697 
    698 #define ASSERT_DPC(Object) \
    699     ASSERT(((Object)->Type == 0) || \
    700            ((Object)->Type == DpcObject) || \
    701            ((Object)->Type == ThreadedDpcObject))
    702 
    703 #define ASSERT_GATE(object) \
    704     NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \
    705               (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject))
    706 
    707 #define ASSERT_DEVICE_QUEUE(Object) \
    708     NT_ASSERT((Object)->Type == DeviceQueueObject)
    709 
    710 #define ASSERT_TIMER(E) \
    711     NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \
    712               ((E)->Header.Type == TimerSynchronizationObject))
    713 
    714 #define ASSERT_MUTANT(E) \
    715     NT_ASSERT((E)->Header.Type == MutantObject)
    716 
    717 #define ASSERT_SEMAPHORE(E) \
    718     NT_ASSERT((E)->Header.Type == SemaphoreObject)
    719 
    720 #define ASSERT_EVENT(E) \
    721     NT_ASSERT(((E)->Header.Type == NotificationEvent) || \
    722               ((E)->Header.Type == SynchronizationEvent))
    723 
    724 #define DPC_NORMAL 0
    725 #define DPC_THREADED 1
    726 
    727 #define GM_LOCK_BIT          0x1
    728 #define GM_LOCK_BIT_V        0x0
    729 #define GM_LOCK_WAITER_WOKEN 0x2
    730 #define GM_LOCK_WAITER_INC   0x4
    731 
    732 #define LOCK_QUEUE_WAIT_BIT               0
    733 #define LOCK_QUEUE_OWNER_BIT              1
    734 
    735 #define LOCK_QUEUE_WAIT                   1
    736 #define LOCK_QUEUE_OWNER                  2
    737 #define LOCK_QUEUE_TIMER_LOCK_SHIFT       4
    738 #define LOCK_QUEUE_TIMER_TABLE_LOCKS (1 << (8 - LOCK_QUEUE_TIMER_LOCK_SHIFT))
    739 
    740 #define PROCESSOR_FEATURE_MAX 64
    741 
    742 #define DBG_STATUS_CONTROL_C              1
    743 #define DBG_STATUS_SYSRQ                  2
    744 #define DBG_STATUS_BUGCHECK_FIRST         3
    745 #define DBG_STATUS_BUGCHECK_SECOND        4
    746 #define DBG_STATUS_FATAL                  5
    747 #define DBG_STATUS_DEBUG_CONTROL          6
    748 #define DBG_STATUS_WORKER                 7
    749 
    750 #if defined(_WIN64)
    751 #define MAXIMUM_PROC_PER_GROUP 64
    752 #else
    753 #define MAXIMUM_PROC_PER_GROUP 32
    754 #endif
    755 #define MAXIMUM_PROCESSORS          MAXIMUM_PROC_PER_GROUP
    756 
    757 /* Exception Records */
    758 #define EXCEPTION_NONCONTINUABLE     1
    759 #define EXCEPTION_MAXIMUM_PARAMETERS 15
    760 
    761 #define EXCEPTION_DIVIDED_BY_ZERO       0
    762 #define EXCEPTION_DEBUG                 1
    763 #define EXCEPTION_NMI                   2
    764 #define EXCEPTION_INT3                  3
    765 #define EXCEPTION_BOUND_CHECK           5
    766 #define EXCEPTION_INVALID_OPCODE        6
    767 #define EXCEPTION_NPX_NOT_AVAILABLE     7
    768 #define EXCEPTION_DOUBLE_FAULT          8
    769 #define EXCEPTION_NPX_OVERRUN           9
    770 #define EXCEPTION_INVALID_TSS           0x0A
    771 #define EXCEPTION_SEGMENT_NOT_PRESENT   0x0B
    772 #define EXCEPTION_STACK_FAULT           0x0C
    773 #define EXCEPTION_GP_FAULT              0x0D
    774 #define EXCEPTION_RESERVED_TRAP         0x0F
    775 #define EXCEPTION_NPX_ERROR             0x010
    776 #define EXCEPTION_ALIGNMENT_CHECK       0x011
    777 
    778 typedef struct _EXCEPTION_RECORD {
    779   NTSTATUS ExceptionCode;
    780   ULONG ExceptionFlags;
    781   struct _EXCEPTION_RECORD *ExceptionRecord;
    782   PVOID ExceptionAddress;
    783   ULONG NumberParameters;
    784   ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
    785 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
    786 
    787 typedef struct _EXCEPTION_RECORD32 {
    788   NTSTATUS ExceptionCode;
    789   ULONG ExceptionFlags;
    790   ULONG ExceptionRecord;
    791   ULONG ExceptionAddress;
    792   ULONG NumberParameters;
    793   ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
    794 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
    795 
    796 typedef struct _EXCEPTION_RECORD64 {
    797   NTSTATUS ExceptionCode;
    798   ULONG ExceptionFlags;
    799   ULONG64 ExceptionRecord;
    800   ULONG64 ExceptionAddress;
    801   ULONG NumberParameters;
    802   ULONG __unusedAlignment;
    803   ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
    804 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
    805 
    806 typedef struct _EXCEPTION_POINTERS {
    807   PEXCEPTION_RECORD ExceptionRecord;
    808   PCONTEXT ContextRecord;
    809 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
    810 
    811 typedef enum _KBUGCHECK_CALLBACK_REASON {
    812   KbCallbackInvalid,
    813   KbCallbackReserved1,
    814   KbCallbackSecondaryDumpData,
    815   KbCallbackDumpIo,
    816   KbCallbackAddPages
    817 } KBUGCHECK_CALLBACK_REASON;
    818 
    819 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
    820 
    821 typedef VOID
    822 (NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)(
    823   IN KBUGCHECK_CALLBACK_REASON Reason,
    824   IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
    825   IN OUT PVOID ReasonSpecificData,
    826   IN ULONG ReasonSpecificDataLength);
    827 typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE;
    828 
    829 typedef struct _KBUGCHECK_ADD_PAGES {
    830   IN OUT PVOID Context;
    831   IN OUT ULONG Flags;
    832   IN ULONG BugCheckCode;
    833   OUT ULONG_PTR Address;
    834   OUT ULONG_PTR Count;
    835 } KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES;
    836 
    837 typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA {
    838   IN PVOID InBuffer;
    839   IN ULONG InBufferLength;
    840   IN ULONG MaximumAllowed;
    841   OUT GUID Guid;
    842   OUT PVOID OutBuffer;
    843   OUT ULONG OutBufferLength;
    844 } KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA;
    845 
    846 typedef enum _KBUGCHECK_DUMP_IO_TYPE {
    847   KbDumpIoInvalid,
    848   KbDumpIoHeader,
    849   KbDumpIoBody,
    850   KbDumpIoSecondaryData,
    851   KbDumpIoComplete
    852 } KBUGCHECK_DUMP_IO_TYPE;
    853 
    854 typedef struct _KBUGCHECK_DUMP_IO {
    855   IN ULONG64 Offset;
    856   IN PVOID Buffer;
    857   IN ULONG BufferLength;
    858   IN KBUGCHECK_DUMP_IO_TYPE Type;
    859 } KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO;
    860 
    861 #define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS         0x00000001UL
    862 #define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS        0x00000002UL
    863 #define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL
    864 
    865 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
    866   LIST_ENTRY Entry;
    867   PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
    868   PUCHAR Component;
    869   ULONG_PTR Checksum;
    870   KBUGCHECK_CALLBACK_REASON Reason;
    871   UCHAR State;
    872 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
    873 
    874 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
    875   BufferEmpty,
    876   BufferInserted,
    877   BufferStarted,
    878   BufferFinished,
    879   BufferIncomplete
    880 } KBUGCHECK_BUFFER_DUMP_STATE;
    881 
    882 typedef VOID
    883 (NTAPI KBUGCHECK_CALLBACK_ROUTINE)(
    884   IN PVOID Buffer,
    885   IN ULONG Length);
    886 typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE;
    887 
    888 typedef struct _KBUGCHECK_CALLBACK_RECORD {
    889   LIST_ENTRY Entry;
    890   PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
    891   PVOID Buffer;
    892   ULONG Length;
    893   PUCHAR Component;
    894   ULONG_PTR Checksum;
    895   UCHAR State;
    896 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
    897 
    898 typedef BOOLEAN
    899 (NTAPI NMI_CALLBACK)(
    900   IN PVOID Context,
    901   IN BOOLEAN Handled);
    902 typedef NMI_CALLBACK *PNMI_CALLBACK;
    903 
    904 typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE {
    905   KeProcessorAddStartNotify = 0,
    906   KeProcessorAddCompleteNotify,
    907   KeProcessorAddFailureNotify
    908 } KE_PROCESSOR_CHANGE_NOTIFY_STATE;
    909 
    910 typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT {
    911   KE_PROCESSOR_CHANGE_NOTIFY_STATE State;
    912   ULONG NtNumber;
    913   NTSTATUS Status;
    914 #if (NTDDI_VERSION >= NTDDI_WIN7)
    915   PROCESSOR_NUMBER ProcNumber;
    916 #endif
    917 } KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT;
    918 
    919 typedef VOID
    920 (NTAPI PROCESSOR_CALLBACK_FUNCTION)(
    921   IN PVOID CallbackContext,
    922   IN PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext,
    923   IN OUT PNTSTATUS OperationStatus);
    924 typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION;
    925 
    926 #define KE_PROCESSOR_CHANGE_ADD_EXISTING         1
    927 
    928 #define INVALID_PROCESSOR_INDEX     0xffffffff
    929 
    930 typedef enum _KINTERRUPT_POLARITY {
    931   InterruptPolarityUnknown,
    932   InterruptActiveHigh,
    933   InterruptActiveLow
    934 } KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY;
    935 
    936 typedef enum _KPROFILE_SOURCE {
    937   ProfileTime,
    938   ProfileAlignmentFixup,
    939   ProfileTotalIssues,
    940   ProfilePipelineDry,
    941   ProfileLoadInstructions,
    942   ProfilePipelineFrozen,
    943   ProfileBranchInstructions,
    944   ProfileTotalNonissues,
    945   ProfileDcacheMisses,
    946   ProfileIcacheMisses,
    947   ProfileCacheMisses,
    948   ProfileBranchMispredictions,
    949   ProfileStoreInstructions,
    950   ProfileFpInstructions,
    951   ProfileIntegerInstructions,
    952   Profile2Issue,
    953   Profile3Issue,
    954   Profile4Issue,
    955   ProfileSpecialInstructions,
    956   ProfileTotalCycles,
    957   ProfileIcacheIssues,
    958   ProfileDcacheAccesses,
    959   ProfileMemoryBarrierCycles,
    960   ProfileLoadLinkedIssues,
    961   ProfileMaximum
    962 } KPROFILE_SOURCE;
    963 
    964 typedef enum _KWAIT_REASON {
    965   Executive,
    966   FreePage,
    967   PageIn,
    968   PoolAllocation,
    969   DelayExecution,
    970   Suspended,
    971   UserRequest,
    972   WrExecutive,
    973   WrFreePage,
    974   WrPageIn,
    975   WrPoolAllocation,
    976   WrDelayExecution,
    977   WrSuspended,
    978   WrUserRequest,
    979   WrEventPair,
    980   WrQueue,
    981   WrLpcReceive,
    982   WrLpcReply,
    983   WrVirtualMemory,
    984   WrPageOut,
    985   WrRendezvous,
    986   WrKeyedEvent,
    987   WrTerminated,
    988   WrProcessInSwap,
    989   WrCpuRateControl,
    990   WrCalloutStack,
    991   WrKernel,
    992   WrResource,
    993   WrPushLock,
    994   WrMutex,
    995   WrQuantumEnd,
    996   WrDispatchInt,
    997   WrPreempted,
    998   WrYieldExecution,
    999   WrFastMutex,
   1000   WrGuardedMutex,
   1001   WrRundown,
   1002   MaximumWaitReason
   1003 } KWAIT_REASON;
   1004 
   1005 typedef struct _KWAIT_BLOCK {
   1006   LIST_ENTRY WaitListEntry;
   1007   struct _KTHREAD *Thread;
   1008   PVOID Object;
   1009   struct _KWAIT_BLOCK *NextWaitBlock;
   1010   USHORT WaitKey;
   1011   UCHAR WaitType;
   1012   volatile UCHAR BlockState;
   1013 #if defined(_WIN64)
   1014   LONG SpareLong;
   1015 #endif
   1016 } KWAIT_BLOCK, *PKWAIT_BLOCK, *PRKWAIT_BLOCK;
   1017 
   1018 typedef enum _KINTERRUPT_MODE {
   1019   LevelSensitive,
   1020   Latched
   1021 } KINTERRUPT_MODE;
   1022 
   1023 #define THREAD_WAIT_OBJECTS 3
   1024 
   1025 typedef VOID
   1026 (NTAPI KSTART_ROUTINE)(
   1027   IN PVOID StartContext);
   1028 typedef KSTART_ROUTINE *PKSTART_ROUTINE;
   1029 
   1030 typedef VOID
   1031 (NTAPI *PKINTERRUPT_ROUTINE)(
   1032   VOID);
   1033 
   1034 typedef BOOLEAN
   1035 (NTAPI KSERVICE_ROUTINE)(
   1036   IN struct _KINTERRUPT *Interrupt,
   1037   IN PVOID ServiceContext);
   1038 typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
   1039 
   1040 typedef BOOLEAN
   1041 (NTAPI KMESSAGE_SERVICE_ROUTINE)(
   1042   IN struct _KINTERRUPT *Interrupt,
   1043   IN PVOID ServiceContext,
   1044   IN ULONG MessageID);
   1045 typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE;
   1046 
   1047 typedef enum _KD_OPTION {
   1048   KD_OPTION_SET_BLOCK_ENABLE,
   1049 } KD_OPTION;
   1050 
   1051 typedef VOID
   1052 (NTAPI *PKNORMAL_ROUTINE)(
   1053   IN PVOID NormalContext OPTIONAL,
   1054   IN PVOID SystemArgument1 OPTIONAL,
   1055   IN PVOID SystemArgument2 OPTIONAL);
   1056 
   1057 typedef VOID
   1058 (NTAPI *PKRUNDOWN_ROUTINE)(
   1059   IN struct _KAPC *Apc);
   1060 
   1061 typedef VOID
   1062 (NTAPI *PKKERNEL_ROUTINE)(
   1063   IN struct _KAPC *Apc,
   1064   IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL,
   1065   IN OUT PVOID *NormalContext OPTIONAL,
   1066   IN OUT PVOID *SystemArgument1 OPTIONAL,
   1067   IN OUT PVOID *SystemArgument2 OPTIONAL);
   1068 
   1069 typedef struct _KAPC {
   1070   UCHAR Type;
   1071   UCHAR SpareByte0;
   1072   UCHAR Size;
   1073   UCHAR SpareByte1;
   1074   ULONG SpareLong0;
   1075   struct _KTHREAD *Thread;
   1076   LIST_ENTRY ApcListEntry;
   1077   PKKERNEL_ROUTINE KernelRoutine;
   1078   PKRUNDOWN_ROUTINE RundownRoutine;
   1079   PKNORMAL_ROUTINE NormalRoutine;
   1080   PVOID NormalContext;
   1081   PVOID SystemArgument1;
   1082   PVOID SystemArgument2;
   1083   CCHAR ApcStateIndex;
   1084   KPROCESSOR_MODE ApcMode;
   1085   BOOLEAN Inserted;
   1086 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
   1087 
   1088 #define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0)
   1089 #define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1)
   1090 #define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0)
   1091 #define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1)
   1092 #define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2)
   1093 #define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex)
   1094 #define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN))
   1095 
   1096 typedef struct _KDEVICE_QUEUE_ENTRY {
   1097   LIST_ENTRY DeviceListEntry;
   1098   ULONG SortKey;
   1099   BOOLEAN Inserted;
   1100 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
   1101 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
   1102 
   1103 typedef PVOID PKIPI_CONTEXT;
   1104 
   1105 typedef VOID
   1106 (NTAPI *PKIPI_WORKER)(
   1107   IN OUT PKIPI_CONTEXT PacketContext,
   1108   IN PVOID Parameter1 OPTIONAL,
   1109   IN PVOID Parameter2 OPTIONAL,
   1110   IN PVOID Parameter3 OPTIONAL);
   1111 
   1112 typedef struct _KIPI_COUNTS {
   1113   ULONG Freeze;
   1114   ULONG Packet;
   1115   ULONG DPC;
   1116   ULONG APC;
   1117   ULONG FlushSingleTb;
   1118   ULONG FlushMultipleTb;
   1119   ULONG FlushEntireTb;
   1120   ULONG GenericCall;
   1121   ULONG ChangeColor;
   1122   ULONG SweepDcache;
   1123   ULONG SweepIcache;
   1124   ULONG SweepIcacheRange;
   1125   ULONG FlushIoBuffers;
   1126   ULONG GratuitousDPC;
   1127 } KIPI_COUNTS, *PKIPI_COUNTS;
   1128 
   1129 typedef ULONG_PTR
   1130 (NTAPI KIPI_BROADCAST_WORKER)(
   1131   IN ULONG_PTR Argument);
   1132 typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER;
   1133 
   1134 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
   1135 
   1136 typedef struct _KSPIN_LOCK_QUEUE {
   1137   struct _KSPIN_LOCK_QUEUE *volatile Next;
   1138   PKSPIN_LOCK volatile Lock;
   1139 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
   1140 
   1141 typedef struct _KLOCK_QUEUE_HANDLE {
   1142   KSPIN_LOCK_QUEUE LockQueue;
   1143   KIRQL OldIrql;
   1144 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
   1145 
   1146 #if defined(_AMD64_)
   1147 
   1148 typedef ULONG64 KSPIN_LOCK_QUEUE_NUMBER;
   1149 
   1150 #define LockQueueDispatcherLock 0
   1151 #define LockQueueExpansionLock 1
   1152 #define LockQueuePfnLock 2
   1153 #define LockQueueSystemSpaceLock 3
   1154 #define LockQueueVacbLock 4
   1155 #define LockQueueMasterLock 5
   1156 #define LockQueueNonPagedPoolLock 6
   1157 #define LockQueueIoCancelLock 7
   1158 #define LockQueueWorkQueueLock 8
   1159 #define LockQueueIoVpbLock 9
   1160 #define LockQueueIoDatabaseLock 10
   1161 #define LockQueueIoCompletionLock 11
   1162 #define LockQueueNtfsStructLock 12
   1163 #define LockQueueAfdWorkQueueLock 13
   1164 #define LockQueueBcbLock 14
   1165 #define LockQueueMmNonPagedPoolLock 15
   1166 #define LockQueueUnusedSpare16 16
   1167 #define LockQueueTimerTableLock 17
   1168 #define LockQueueMaximumLock (LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS)
   1169 
   1170 #else
   1171 
   1172 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
   1173   LockQueueDispatcherLock,
   1174   LockQueueExpansionLock,
   1175   LockQueuePfnLock,
   1176   LockQueueSystemSpaceLock,
   1177   LockQueueVacbLock,
   1178   LockQueueMasterLock,
   1179   LockQueueNonPagedPoolLock,
   1180   LockQueueIoCancelLock,
   1181   LockQueueWorkQueueLock,
   1182   LockQueueIoVpbLock,
   1183   LockQueueIoDatabaseLock,
   1184   LockQueueIoCompletionLock,
   1185   LockQueueNtfsStructLock,
   1186   LockQueueAfdWorkQueueLock,
   1187   LockQueueBcbLock,
   1188   LockQueueMmNonPagedPoolLock,
   1189   LockQueueUnusedSpare16,
   1190   LockQueueTimerTableLock,
   1191   LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS
   1192 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
   1193 
   1194 #endif /* defined(_AMD64_) */
   1195 
   1196 typedef VOID
   1197 (NTAPI KDEFERRED_ROUTINE)(
   1198   IN struct _KDPC *Dpc,
   1199   IN PVOID DeferredContext OPTIONAL,
   1200   IN PVOID SystemArgument1 OPTIONAL,
   1201   IN PVOID SystemArgument2 OPTIONAL);
   1202 typedef KDEFERRED_ROUTINE *PKDEFERRED_ROUTINE;
   1203 
   1204 typedef enum _KDPC_IMPORTANCE {
   1205   LowImportance,
   1206   MediumImportance,
   1207   HighImportance,
   1208   MediumHighImportance
   1209 } KDPC_IMPORTANCE;
   1210 
   1211 typedef struct _KDPC {
   1212   UCHAR Type;
   1213   UCHAR Importance;
   1214   volatile USHORT Number;
   1215   LIST_ENTRY DpcListEntry;
   1216   PKDEFERRED_ROUTINE DeferredRoutine;
   1217   PVOID DeferredContext;
   1218   PVOID SystemArgument1;
   1219   PVOID SystemArgument2;
   1220   volatile PVOID DpcData;
   1221 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
   1222 
   1223 typedef struct _KDPC_WATCHDOG_INFORMATION {
   1224   ULONG DpcTimeLimit;
   1225   ULONG DpcTimeCount;
   1226   ULONG DpcWatchdogLimit;
   1227   ULONG DpcWatchdogCount;
   1228   ULONG Reserved;
   1229 } KDPC_WATCHDOG_INFORMATION, *PKDPC_WATCHDOG_INFORMATION;
   1230 
   1231 typedef struct _KDEVICE_QUEUE {
   1232   CSHORT Type;
   1233   CSHORT Size;
   1234   LIST_ENTRY DeviceListHead;
   1235   KSPIN_LOCK Lock;
   1236 # if defined(_AMD64_)
   1237   _ANONYMOUS_UNION union {
   1238     BOOLEAN Busy;
   1239     _ANONYMOUS_STRUCT struct {
   1240       LONG64 Reserved:8;
   1241       LONG64 Hint:56;
   1242     } DUMMYSTRUCTNAME;
   1243   } DUMMYUNIONNAME;
   1244 # else
   1245   BOOLEAN Busy;
   1246 # endif
   1247 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
   1248 
   1249 #define TIMER_EXPIRED_INDEX_BITS        6
   1250 #define TIMER_PROCESSOR_INDEX_BITS      5
   1251 
   1252 typedef struct _DISPATCHER_HEADER {
   1253   _ANONYMOUS_UNION union {
   1254     _ANONYMOUS_STRUCT struct {
   1255       UCHAR Type;
   1256       _ANONYMOUS_UNION union {
   1257         _ANONYMOUS_UNION union {
   1258           UCHAR TimerControlFlags;
   1259           _ANONYMOUS_STRUCT struct {
   1260             UCHAR Absolute:1;
   1261             UCHAR Coalescable:1;
   1262             UCHAR KeepShifting:1;
   1263             UCHAR EncodedTolerableDelay:5;
   1264           } DUMMYSTRUCTNAME;
   1265         } DUMMYUNIONNAME;
   1266         UCHAR Abandoned;
   1267 #if (NTDDI_VERSION < NTDDI_WIN7)
   1268         UCHAR NpxIrql;
   1269 #endif
   1270         BOOLEAN Signalling;
   1271       } DUMMYUNIONNAME;
   1272       _ANONYMOUS_UNION union {
   1273         _ANONYMOUS_UNION union {
   1274           UCHAR ThreadControlFlags;
   1275           _ANONYMOUS_STRUCT struct {
   1276             UCHAR CpuThrottled:1;
   1277             UCHAR CycleProfiling:1;
   1278             UCHAR CounterProfiling:1;
   1279             UCHAR Reserved:5;
   1280           } DUMMYSTRUCTNAME;
   1281         } DUMMYUNIONNAME;
   1282         UCHAR Size;
   1283         UCHAR Hand;
   1284       } DUMMYUNIONNAME2;
   1285       _ANONYMOUS_UNION union {
   1286 #if (NTDDI_VERSION >= NTDDI_WIN7)
   1287         _ANONYMOUS_UNION union {
   1288           UCHAR TimerMiscFlags;
   1289           _ANONYMOUS_STRUCT struct {
   1290 #if !defined(_X86_)
   1291             UCHAR Index:TIMER_EXPIRED_INDEX_BITS;
   1292 #else
   1293             UCHAR Index:1;
   1294             UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS;
   1295 #endif
   1296             UCHAR Inserted:1;
   1297             volatile UCHAR Expired:1;
   1298           } DUMMYSTRUCTNAME;
   1299         } DUMMYUNIONNAME;
   1300 #else
   1301         /* Pre Win7 compatibility fix to latest WDK */
   1302         UCHAR Inserted;
   1303 #endif
   1304         _ANONYMOUS_UNION union {
   1305           BOOLEAN DebugActive;
   1306           _ANONYMOUS_STRUCT struct {
   1307             BOOLEAN ActiveDR7:1;
   1308             BOOLEAN Instrumented:1;
   1309             BOOLEAN Reserved2:4;
   1310             BOOLEAN UmsScheduled:1;
   1311             BOOLEAN UmsPrimary:1;
   1312           } DUMMYSTRUCTNAME;
   1313         } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */
   1314         BOOLEAN DpcActive;
   1315       } DUMMYUNIONNAME3;
   1316     } DUMMYSTRUCTNAME;
   1317     volatile LONG Lock;
   1318   } DUMMYUNIONNAME;
   1319   LONG SignalState;
   1320   LIST_ENTRY WaitListHead;
   1321 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
   1322 
   1323 typedef struct _KEVENT {
   1324   DISPATCHER_HEADER Header;
   1325 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
   1326 
   1327 typedef struct _KSEMAPHORE {
   1328   DISPATCHER_HEADER Header;
   1329   LONG Limit;
   1330 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
   1331 
   1332 #define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG))
   1333 
   1334 typedef struct _KGATE {
   1335   DISPATCHER_HEADER Header;
   1336 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
   1337 
   1338 typedef struct _KGUARDED_MUTEX {
   1339   volatile LONG Count;
   1340   PKTHREAD Owner;
   1341   ULONG Contention;
   1342   KGATE Gate;
   1343   _ANONYMOUS_UNION union {
   1344     _ANONYMOUS_STRUCT struct {
   1345       SHORT KernelApcDisable;
   1346       SHORT SpecialApcDisable;
   1347     } DUMMYSTRUCTNAME;
   1348     ULONG CombinedApcDisable;
   1349   } DUMMYUNIONNAME;
   1350 } KGUARDED_MUTEX, *PKGUARDED_MUTEX;
   1351 
   1352 typedef struct _KMUTANT {
   1353   DISPATCHER_HEADER Header;
   1354   LIST_ENTRY MutantListEntry;
   1355   struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
   1356   BOOLEAN Abandoned;
   1357   UCHAR ApcDisable;
   1358 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
   1359 
   1360 #define TIMER_TABLE_SIZE 512
   1361 #define TIMER_TABLE_SHIFT 9
   1362 
   1363 typedef struct _KTIMER {
   1364   DISPATCHER_HEADER Header;
   1365   ULARGE_INTEGER DueTime;
   1366   LIST_ENTRY TimerListEntry;
   1367   struct _KDPC *Dpc;
   1368 # if !defined(_X86_)
   1369   ULONG Processor;
   1370 # endif
   1371   ULONG Period;
   1372 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
   1373 
   1374 typedef enum _LOCK_OPERATION {
   1375   IoReadAccess,
   1376   IoWriteAccess,
   1377   IoModifyAccess
   1378 } LOCK_OPERATION;
   1379 
   1380 #define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG))
   1381 
   1382 typedef BOOLEAN
   1383 (NTAPI *PKSYNCHRONIZE_ROUTINE)(
   1384   IN PVOID SynchronizeContext);
   1385 
   1386 typedef enum _POOL_TYPE {
   1387   NonPagedPool,
   1388   PagedPool,
   1389   NonPagedPoolMustSucceed,
   1390   DontUseThisType,
   1391   NonPagedPoolCacheAligned,
   1392   PagedPoolCacheAligned,
   1393   NonPagedPoolCacheAlignedMustS,
   1394   MaxPoolType,
   1395   NonPagedPoolSession = 32,
   1396   PagedPoolSession,
   1397   NonPagedPoolMustSucceedSession,
   1398   DontUseThisTypeSession,
   1399   NonPagedPoolCacheAlignedSession,
   1400   PagedPoolCacheAlignedSession,
   1401   NonPagedPoolCacheAlignedMustSSession
   1402 } POOL_TYPE;
   1403 
   1404 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE {
   1405   StandardDesign,
   1406   NEC98x86,
   1407   EndAlternatives
   1408 } ALTERNATIVE_ARCHITECTURE_TYPE;
   1409 
   1410 #ifndef _X86_
   1411 
   1412 #ifndef IsNEC_98
   1413 #define IsNEC_98 (FALSE)
   1414 #endif
   1415 
   1416 #ifndef IsNotNEC_98
   1417 #define IsNotNEC_98 (TRUE)
   1418 #endif
   1419 
   1420 #ifndef SetNEC_98
   1421 #define SetNEC_98
   1422 #endif
   1423 
   1424 #ifndef SetNotNEC_98
   1425 #define SetNotNEC_98
   1426 #endif
   1427 
   1428 #endif
   1429 
   1430 typedef struct _KSYSTEM_TIME {
   1431   ULONG LowPart;
   1432   LONG High1Time;
   1433   LONG High2Time;
   1434 } KSYSTEM_TIME, *PKSYSTEM_TIME;
   1435 
   1436 typedef struct DECLSPEC_ALIGN(16) _M128A {
   1437   ULONGLONG Low;
   1438   LONGLONG High;
   1439 } M128A, *PM128A;
   1440 
   1441 typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT {
   1442   USHORT ControlWord;
   1443   USHORT StatusWord;
   1444   UCHAR TagWord;
   1445   UCHAR Reserved1;
   1446   USHORT ErrorOpcode;
   1447   ULONG ErrorOffset;
   1448   USHORT ErrorSelector;
   1449   USHORT Reserved2;
   1450   ULONG DataOffset;
   1451   USHORT DataSelector;
   1452   USHORT Reserved3;
   1453   ULONG MxCsr;
   1454   ULONG MxCsr_Mask;
   1455   M128A FloatRegisters[8];
   1456 #if defined(_WIN64)
   1457   M128A XmmRegisters[16];
   1458   UCHAR Reserved4[96];
   1459 #else
   1460   M128A XmmRegisters[8];
   1461   UCHAR Reserved4[192];
   1462   ULONG StackControl[7];
   1463   ULONG Cr0NpxState;
   1464 #endif
   1465 } XSAVE_FORMAT, *PXSAVE_FORMAT;
   1466 
   1467 typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER {
   1468   ULONG64 Mask;
   1469   ULONG64 Reserved[7];
   1470 } XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER;
   1471 
   1472 typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA {
   1473   XSAVE_FORMAT LegacyState;
   1474   XSAVE_AREA_HEADER Header;
   1475 } XSAVE_AREA, *PXSAVE_AREA;
   1476 
   1477 typedef struct _XSTATE_CONTEXT {
   1478   ULONG64 Mask;
   1479   ULONG Length;
   1480   ULONG Reserved1;
   1481   PXSAVE_AREA Area;
   1482 #if defined(_X86_)
   1483   ULONG Reserved2;
   1484 #endif
   1485   PVOID Buffer;
   1486 #if defined(_X86_)
   1487   ULONG Reserved3;
   1488 #endif
   1489 } XSTATE_CONTEXT, *PXSTATE_CONTEXT;
   1490 
   1491 typedef struct _XSTATE_SAVE {
   1492 #if defined(_AMD64_)
   1493   struct _XSTATE_SAVE* Prev;
   1494   struct _KTHREAD* Thread;
   1495   UCHAR Level;
   1496   XSTATE_CONTEXT XStateContext;
   1497 #elif defined(_IA64_)
   1498   ULONG Dummy;
   1499 #elif defined(_X86_)
   1500   _ANONYMOUS_UNION union {
   1501     _ANONYMOUS_STRUCT struct {
   1502       LONG64 Reserved1;
   1503       ULONG Reserved2;
   1504       struct _XSTATE_SAVE* Prev;
   1505       PXSAVE_AREA Reserved3;
   1506       struct _KTHREAD* Thread;
   1507       PVOID Reserved4;
   1508       UCHAR Level;
   1509     } DUMMYSTRUCTNAME;
   1510     XSTATE_CONTEXT XStateContext;
   1511   } DUMMYUNIONNAME;
   1512 #endif
   1513 } XSTATE_SAVE, *PXSTATE_SAVE;
   1514 
   1515 #ifdef _X86_
   1516 
   1517 #define MAXIMUM_SUPPORTED_EXTENSION  512
   1518 
   1519 #if !defined(__midl) && !defined(MIDL_PASS)
   1520 C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION);
   1521 #endif
   1522 
   1523 #endif /* _X86_ */
   1524 
   1525 #define XSAVE_ALIGN                    64
   1526 #define MINIMAL_XSTATE_AREA_LENGTH     sizeof(XSAVE_AREA)
   1527 
   1528 #if !defined(__midl) && !defined(MIDL_PASS)
   1529 C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0);
   1530 C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0);
   1531 C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64);
   1532 #endif
   1533 
   1534 typedef struct _CONTEXT_CHUNK {
   1535   LONG Offset;
   1536   ULONG Length;
   1537 } CONTEXT_CHUNK, *PCONTEXT_CHUNK;
   1538 
   1539 typedef struct _CONTEXT_EX {
   1540   CONTEXT_CHUNK All;
   1541   CONTEXT_CHUNK Legacy;
   1542   CONTEXT_CHUNK XState;
   1543 } CONTEXT_EX, *PCONTEXT_EX;
   1544 
   1545 #define CONTEXT_EX_LENGTH         ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN)
   1546 
   1547 #if (NTDDI_VERSION >= NTDDI_VISTA)
   1548 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
   1549 #elif (NTDDI_VERSION >= NTDDI_WINXP)
   1550 extern NTSYSAPI CCHAR KeNumberProcessors;
   1551 #else
   1552 extern PCCHAR KeNumberProcessors;
   1553 #endif
   1554 
   1555 
   1556 /******************************************************************************
   1557  *                         Memory manager Types                               *
   1558  ******************************************************************************/
   1559 
   1560 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   1561 typedef ULONG NODE_REQUIREMENT;
   1562 #define MM_ANY_NODE_OK                           0x80000000
   1563 #endif
   1564 
   1565 #define MM_DONT_ZERO_ALLOCATION                  0x00000001
   1566 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY         0x00000002
   1567 #define MM_ALLOCATE_FULLY_REQUIRED               0x00000004
   1568 #define MM_ALLOCATE_NO_WAIT                      0x00000008
   1569 #define MM_ALLOCATE_PREFER_CONTIGUOUS            0x00000010
   1570 #define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS    0x00000020
   1571 
   1572 #define MDL_MAPPED_TO_SYSTEM_VA     0x0001
   1573 #define MDL_PAGES_LOCKED            0x0002
   1574 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
   1575 #define MDL_ALLOCATED_FIXED_SIZE    0x0008
   1576 #define MDL_PARTIAL                 0x0010
   1577 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
   1578 #define MDL_IO_PAGE_READ            0x0040
   1579 #define MDL_WRITE_OPERATION         0x0080
   1580 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
   1581 #define MDL_FREE_EXTRA_PTES         0x0200
   1582 #define MDL_DESCRIBES_AWE           0x0400
   1583 #define MDL_IO_SPACE                0x0800
   1584 #define MDL_NETWORK_HEADER          0x1000
   1585 #define MDL_MAPPING_CAN_FAIL        0x2000
   1586 #define MDL_ALLOCATED_MUST_SUCCEED  0x4000
   1587 #define MDL_INTERNAL                0x8000
   1588 
   1589 #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA     | \
   1590                            MDL_PAGES_LOCKED            | \
   1591                            MDL_SOURCE_IS_NONPAGED_POOL | \
   1592                            MDL_PARTIAL_HAS_BEEN_MAPPED | \
   1593                            MDL_PARENT_MAPPED_SYSTEM_VA | \
   1594                            MDL_SYSTEM_VA               | \
   1595                            MDL_IO_SPACE)
   1596 
   1597 #define FLUSH_MULTIPLE_MAXIMUM       32
   1598 
   1599 /* Section access rights */
   1600 #define SECTION_QUERY                0x0001
   1601 #define SECTION_MAP_WRITE            0x0002
   1602 #define SECTION_MAP_READ             0x0004
   1603 #define SECTION_MAP_EXECUTE          0x0008
   1604 #define SECTION_EXTEND_SIZE          0x0010
   1605 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
   1606 
   1607 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| \
   1608                             SECTION_MAP_WRITE |                     \
   1609                             SECTION_MAP_READ |                      \
   1610                             SECTION_MAP_EXECUTE |                   \
   1611                             SECTION_EXTEND_SIZE)
   1612 
   1613 #define SESSION_QUERY_ACCESS         0x0001
   1614 #define SESSION_MODIFY_ACCESS        0x0002
   1615 
   1616 #define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |  \
   1617                             SESSION_QUERY_ACCESS     |  \
   1618                             SESSION_MODIFY_ACCESS)
   1619 
   1620 #define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
   1621 
   1622 #define PAGE_NOACCESS          0x01
   1623 #define PAGE_READONLY          0x02
   1624 #define PAGE_READWRITE         0x04
   1625 #define PAGE_WRITECOPY         0x08
   1626 #define PAGE_EXECUTE           0x10
   1627 #define PAGE_EXECUTE_READ      0x20
   1628 #define PAGE_EXECUTE_READWRITE 0x40
   1629 #define PAGE_EXECUTE_WRITECOPY 0x80
   1630 #define PAGE_GUARD            0x100
   1631 #define PAGE_NOCACHE          0x200
   1632 #define PAGE_WRITECOMBINE     0x400
   1633 
   1634 #define MEM_COMMIT           0x1000
   1635 #define MEM_RESERVE          0x2000
   1636 #define MEM_DECOMMIT         0x4000
   1637 #define MEM_RELEASE          0x8000
   1638 #define MEM_FREE            0x10000
   1639 #define MEM_PRIVATE         0x20000
   1640 #define MEM_MAPPED          0x40000
   1641 #define MEM_RESET           0x80000
   1642 #define MEM_TOP_DOWN       0x100000
   1643 #define MEM_LARGE_PAGES  0x20000000
   1644 #define MEM_4MB_PAGES    0x80000000
   1645 
   1646 #define SEC_RESERVE       0x4000000
   1647 #define SEC_COMMIT        0x8000000
   1648 #define SEC_LARGE_PAGES  0x80000000
   1649 
   1650 /* Section map options */
   1651 typedef enum _SECTION_INHERIT {
   1652   ViewShare = 1,
   1653   ViewUnmap = 2
   1654 } SECTION_INHERIT;
   1655 
   1656 typedef ULONG PFN_COUNT;
   1657 typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
   1658 typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
   1659 
   1660 typedef struct _MDL {
   1661   struct _MDL *Next;
   1662   CSHORT Size;
   1663   CSHORT MdlFlags;
   1664   struct _EPROCESS *Process;
   1665   PVOID MappedSystemVa;
   1666   PVOID StartVa;
   1667   ULONG ByteCount;
   1668   ULONG ByteOffset;
   1669 } MDL, *PMDL;
   1670 typedef MDL *PMDLX;
   1671 
   1672 typedef enum _MEMORY_CACHING_TYPE_ORIG {
   1673   MmFrameBufferCached = 2
   1674 } MEMORY_CACHING_TYPE_ORIG;
   1675 
   1676 typedef enum _MEMORY_CACHING_TYPE {
   1677   MmNonCached = FALSE,
   1678   MmCached = TRUE,
   1679   MmWriteCombined = MmFrameBufferCached,
   1680   MmHardwareCoherentCached,
   1681   MmNonCachedUnordered,
   1682   MmUSWCCached,
   1683   MmMaximumCacheType
   1684 } MEMORY_CACHING_TYPE;
   1685 
   1686 typedef enum _MM_PAGE_PRIORITY {
   1687   LowPagePriority,
   1688   NormalPagePriority = 16,
   1689   HighPagePriority = 32
   1690 } MM_PAGE_PRIORITY;
   1691 
   1692 typedef enum _MM_SYSTEM_SIZE {
   1693   MmSmallSystem,
   1694   MmMediumSystem,
   1695   MmLargeSystem
   1696 } MM_SYSTEMSIZE;
   1697 
   1698 extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress;
   1699 extern PVOID MmBadPointer;
   1700 
   1701 
   1702 /******************************************************************************
   1703  *                            Executive Types                                 *
   1704  ******************************************************************************/
   1705 #define EX_RUNDOWN_ACTIVE                 0x1
   1706 #define EX_RUNDOWN_COUNT_SHIFT            0x1
   1707 #define EX_RUNDOWN_COUNT_INC              (1 << EX_RUNDOWN_COUNT_SHIFT)
   1708 
   1709 typedef struct _FAST_MUTEX {
   1710   volatile LONG Count;
   1711   PKTHREAD Owner;
   1712   ULONG Contention;
   1713   KEVENT Event;
   1714   ULONG OldIrql;
   1715 } FAST_MUTEX, *PFAST_MUTEX;
   1716 
   1717 typedef enum _SUITE_TYPE {
   1718   SmallBusiness,
   1719   Enterprise,
   1720   BackOffice,
   1721   CommunicationServer,
   1722   TerminalServer,
   1723   SmallBusinessRestricted,
   1724   EmbeddedNT,
   1725   DataCenter,
   1726   SingleUserTS,
   1727   Personal,
   1728   Blade,
   1729   EmbeddedRestricted,
   1730   SecurityAppliance,
   1731   StorageServer,
   1732   ComputeServer,
   1733   WHServer,
   1734   MaxSuiteType
   1735 } SUITE_TYPE;
   1736 
   1737 typedef enum _EX_POOL_PRIORITY {
   1738   LowPoolPriority,
   1739   LowPoolPrioritySpecialPoolOverrun = 8,
   1740   LowPoolPrioritySpecialPoolUnderrun = 9,
   1741   NormalPoolPriority = 16,
   1742   NormalPoolPrioritySpecialPoolOverrun = 24,
   1743   NormalPoolPrioritySpecialPoolUnderrun = 25,
   1744   HighPoolPriority = 32,
   1745   HighPoolPrioritySpecialPoolOverrun = 40,
   1746   HighPoolPrioritySpecialPoolUnderrun = 41
   1747 } EX_POOL_PRIORITY;
   1748 
   1749 #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
   1750 #define LOOKASIDE_ALIGN
   1751 #else
   1752 #define LOOKASIDE_ALIGN /* FIXME: DECLSPEC_CACHEALIGN */
   1753 #endif
   1754 
   1755 typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX;
   1756 
   1757 typedef PVOID
   1758 (NTAPI *PALLOCATE_FUNCTION)(
   1759   IN POOL_TYPE PoolType,
   1760   IN SIZE_T NumberOfBytes,
   1761   IN ULONG Tag);
   1762 
   1763 typedef PVOID
   1764 (NTAPI *PALLOCATE_FUNCTION_EX)(
   1765   IN POOL_TYPE PoolType,
   1766   IN SIZE_T NumberOfBytes,
   1767   IN ULONG Tag,
   1768   IN OUT PLOOKASIDE_LIST_EX Lookaside);
   1769 
   1770 typedef VOID
   1771 (NTAPI *PFREE_FUNCTION)(
   1772   IN PVOID Buffer);
   1773 
   1774 typedef VOID
   1775 (NTAPI *PFREE_FUNCTION_EX)(
   1776   IN PVOID Buffer,
   1777   IN OUT PLOOKASIDE_LIST_EX Lookaside);
   1778 
   1779 typedef VOID
   1780 (NTAPI CALLBACK_FUNCTION)(
   1781   IN PVOID CallbackContext OPTIONAL,
   1782   IN PVOID Argument1 OPTIONAL,
   1783   IN PVOID Argument2 OPTIONAL);
   1784 typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION;
   1785 
   1786 #define GENERAL_LOOKASIDE_LAYOUT                \
   1787     _ANONYMOUS_UNION union {                    \
   1788         SLIST_HEADER ListHead;                  \
   1789         SINGLE_LIST_ENTRY SingleListHead;       \
   1790     } DUMMYUNIONNAME;                           \
   1791     USHORT Depth;                               \
   1792     USHORT MaximumDepth;                        \
   1793     ULONG TotalAllocates;                       \
   1794     _ANONYMOUS_UNION union {                    \
   1795         ULONG AllocateMisses;                   \
   1796         ULONG AllocateHits;                     \
   1797     } DUMMYUNIONNAME2;                          \
   1798     ULONG TotalFrees;                           \
   1799     _ANONYMOUS_UNION union {                    \
   1800         ULONG FreeMisses;                       \
   1801         ULONG FreeHits;                         \
   1802     } DUMMYUNIONNAME3;                          \
   1803     POOL_TYPE Type;                             \
   1804     ULONG Tag;                                  \
   1805     ULONG Size;                                 \
   1806     _ANONYMOUS_UNION union {                    \
   1807         PALLOCATE_FUNCTION_EX AllocateEx;       \
   1808         PALLOCATE_FUNCTION Allocate;            \
   1809     } DUMMYUNIONNAME4;                          \
   1810     _ANONYMOUS_UNION union {                    \
   1811         PFREE_FUNCTION_EX FreeEx;               \
   1812         PFREE_FUNCTION Free;                    \
   1813     } DUMMYUNIONNAME5;                          \
   1814     LIST_ENTRY ListEntry;                       \
   1815     ULONG LastTotalAllocates;                   \
   1816     _ANONYMOUS_UNION union {                    \
   1817         ULONG LastAllocateMisses;               \
   1818         ULONG LastAllocateHits;                 \
   1819     } DUMMYUNIONNAME6;                          \
   1820     ULONG Future[2];
   1821 
   1822 typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE {
   1823   GENERAL_LOOKASIDE_LAYOUT
   1824 } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
   1825 
   1826 typedef struct _GENERAL_LOOKASIDE_POOL {
   1827   GENERAL_LOOKASIDE_LAYOUT
   1828 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
   1829 
   1830 #define LOOKASIDE_CHECK(f)  \
   1831     C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f))
   1832 
   1833 LOOKASIDE_CHECK(TotalFrees);
   1834 LOOKASIDE_CHECK(Tag);
   1835 LOOKASIDE_CHECK(Future);
   1836 
   1837 typedef struct _PAGED_LOOKASIDE_LIST {
   1838   GENERAL_LOOKASIDE L;
   1839 #if !defined(_AMD64_) && !defined(_IA64_)
   1840   FAST_MUTEX Lock__ObsoleteButDoNotDelete;
   1841 #endif
   1842 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
   1843 
   1844 typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST {
   1845   GENERAL_LOOKASIDE L;
   1846 #if !defined(_AMD64_) && !defined(_IA64_)
   1847   KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
   1848 #endif
   1849 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
   1850 
   1851 #define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next))
   1852 
   1853 typedef struct _LOOKASIDE_LIST_EX {
   1854   GENERAL_LOOKASIDE_POOL L;
   1855 } LOOKASIDE_LIST_EX;
   1856 
   1857 #if (NTDDI_VERSION >= NTDDI_VISTA)
   1858 
   1859 #define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL
   1860 #define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL
   1861 
   1862 #define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE          256
   1863 #define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT         1024
   1864 
   1865 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   1866 
   1867 typedef struct _EX_RUNDOWN_REF {
   1868   _ANONYMOUS_UNION union {
   1869     volatile ULONG_PTR Count;
   1870     volatile PVOID Ptr;
   1871   } DUMMYUNIONNAME;
   1872 } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
   1873 
   1874 typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE;
   1875 
   1876 typedef enum _WORK_QUEUE_TYPE {
   1877   CriticalWorkQueue,
   1878   DelayedWorkQueue,
   1879   HyperCriticalWorkQueue,
   1880   MaximumWorkQueue
   1881 } WORK_QUEUE_TYPE;
   1882 
   1883 typedef VOID
   1884 (NTAPI WORKER_THREAD_ROUTINE)(
   1885   IN PVOID Parameter);
   1886 typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE;
   1887 
   1888 typedef struct _WORK_QUEUE_ITEM {
   1889   LIST_ENTRY List;
   1890   PWORKER_THREAD_ROUTINE WorkerRoutine;
   1891   volatile PVOID Parameter;
   1892 } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
   1893 
   1894 typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
   1895 
   1896 typedef struct _OWNER_ENTRY {
   1897   ERESOURCE_THREAD OwnerThread;
   1898   _ANONYMOUS_UNION union {
   1899     _ANONYMOUS_STRUCT struct {
   1900       ULONG IoPriorityBoosted:1;
   1901       ULONG OwnerReferenced:1;
   1902       ULONG OwnerCount:30;
   1903     } DUMMYSTRUCTNAME;
   1904     ULONG TableSize;
   1905   } DUMMYUNIONNAME;
   1906 } OWNER_ENTRY, *POWNER_ENTRY;
   1907 
   1908 typedef struct _ERESOURCE {
   1909   LIST_ENTRY SystemResourcesList;
   1910   POWNER_ENTRY OwnerTable;
   1911   SHORT ActiveCount;
   1912   USHORT Flag;
   1913   volatile PKSEMAPHORE SharedWaiters;
   1914   volatile PKEVENT ExclusiveWaiters;
   1915   OWNER_ENTRY OwnerEntry;
   1916   ULONG ActiveEntries;
   1917   ULONG ContentionCount;
   1918   ULONG NumberOfSharedWaiters;
   1919   ULONG NumberOfExclusiveWaiters;
   1920 #if defined(_WIN64)
   1921   PVOID Reserved2;
   1922 #endif
   1923   _ANONYMOUS_UNION union {
   1924     PVOID Address;
   1925     ULONG_PTR CreatorBackTraceIndex;
   1926   } DUMMYUNIONNAME;
   1927   KSPIN_LOCK SpinLock;
   1928 } ERESOURCE, *PERESOURCE;
   1929 
   1930 /* ERESOURCE.Flag */
   1931 #define ResourceNeverExclusive            0x0010
   1932 #define ResourceReleaseByOtherThread      0x0020
   1933 #define ResourceOwnedExclusive            0x0080
   1934 
   1935 #define RESOURCE_HASH_TABLE_SIZE          64
   1936 
   1937 typedef struct _RESOURCE_HASH_ENTRY {
   1938   LIST_ENTRY ListEntry;
   1939   PVOID Address;
   1940   ULONG ContentionCount;
   1941   ULONG Number;
   1942 } RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY;
   1943 
   1944 typedef struct _RESOURCE_PERFORMANCE_DATA {
   1945   ULONG ActiveResourceCount;
   1946   ULONG TotalResourceCount;
   1947   ULONG ExclusiveAcquire;
   1948   ULONG SharedFirstLevel;
   1949   ULONG SharedSecondLevel;
   1950   ULONG StarveFirstLevel;
   1951   ULONG StarveSecondLevel;
   1952   ULONG WaitForExclusive;
   1953   ULONG OwnerTableExpands;
   1954   ULONG MaximumTableExpand;
   1955   LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE];
   1956 } RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA;
   1957 
   1958 /* Global debug flag */
   1959 #if DEVL
   1960 extern ULONG NtGlobalFlag;
   1961 #define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName))
   1962 #else
   1963 #define IF_NTOS_DEBUG(FlagName) if(FALSE)
   1964 #endif
   1965 
   1966 /******************************************************************************
   1967  *                            Security Manager Types                          *
   1968  ******************************************************************************/
   1969 
   1970 /* Simple types */
   1971 typedef PVOID PSECURITY_DESCRIPTOR;
   1972 typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
   1973 typedef ULONG ACCESS_MASK, *PACCESS_MASK;
   1974 typedef PVOID PACCESS_TOKEN;
   1975 typedef PVOID PSID;
   1976 
   1977 #define DELETE                           0x00010000L
   1978 #define READ_CONTROL                     0x00020000L
   1979 #define WRITE_DAC                        0x00040000L
   1980 #define WRITE_OWNER                      0x00080000L
   1981 #define SYNCHRONIZE                      0x00100000L
   1982 #define STANDARD_RIGHTS_REQUIRED         0x000F0000L
   1983 #define STANDARD_RIGHTS_READ             READ_CONTROL
   1984 #define STANDARD_RIGHTS_WRITE            READ_CONTROL
   1985 #define STANDARD_RIGHTS_EXECUTE          READ_CONTROL
   1986 #define STANDARD_RIGHTS_ALL              0x001F0000L
   1987 #define SPECIFIC_RIGHTS_ALL              0x0000FFFFL
   1988 #define ACCESS_SYSTEM_SECURITY           0x01000000L
   1989 #define MAXIMUM_ALLOWED                  0x02000000L
   1990 #define GENERIC_READ                     0x80000000L
   1991 #define GENERIC_WRITE                    0x40000000L
   1992 #define GENERIC_EXECUTE                  0x20000000L
   1993 #define GENERIC_ALL                      0x10000000L
   1994 
   1995 typedef struct _GENERIC_MAPPING {
   1996   ACCESS_MASK GenericRead;
   1997   ACCESS_MASK GenericWrite;
   1998   ACCESS_MASK GenericExecute;
   1999   ACCESS_MASK GenericAll;
   2000 } GENERIC_MAPPING, *PGENERIC_MAPPING;
   2001 
   2002 #define ACL_REVISION                      2
   2003 #define ACL_REVISION_DS                   4
   2004 
   2005 #define ACL_REVISION1                     1
   2006 #define ACL_REVISION2                     2
   2007 #define ACL_REVISION3                     3
   2008 #define ACL_REVISION4                     4
   2009 #define MIN_ACL_REVISION                  ACL_REVISION2
   2010 #define MAX_ACL_REVISION                  ACL_REVISION4
   2011 
   2012 typedef struct _ACL {
   2013   UCHAR AclRevision;
   2014   UCHAR Sbz1;
   2015   USHORT AclSize;
   2016   USHORT AceCount;
   2017   USHORT Sbz2;
   2018 } ACL, *PACL;
   2019 
   2020 /* Current security descriptor revision value */
   2021 #define SECURITY_DESCRIPTOR_REVISION     (1)
   2022 #define SECURITY_DESCRIPTOR_REVISION1    (1)
   2023 
   2024 /* Privilege attributes */
   2025 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
   2026 #define SE_PRIVILEGE_ENABLED            (0x00000002L)
   2027 #define SE_PRIVILEGE_REMOVED            (0X00000004L)
   2028 #define SE_PRIVILEGE_USED_FOR_ACCESS    (0x80000000L)
   2029 
   2030 #define SE_PRIVILEGE_VALID_ATTRIBUTES   (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \
   2031                                          SE_PRIVILEGE_ENABLED            | \
   2032                                          SE_PRIVILEGE_REMOVED            | \
   2033                                          SE_PRIVILEGE_USED_FOR_ACCESS)
   2034 
   2035 #include <pshpack4.h>
   2036 typedef struct _LUID_AND_ATTRIBUTES {
   2037   LUID Luid;
   2038   ULONG Attributes;
   2039 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
   2040 #include <poppack.h>
   2041 
   2042 typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
   2043 typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
   2044 
   2045 /* Privilege sets */
   2046 #define PRIVILEGE_SET_ALL_NECESSARY (1)
   2047 
   2048 typedef struct _PRIVILEGE_SET {
   2049   ULONG PrivilegeCount;
   2050   ULONG Control;
   2051   LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
   2052 } PRIVILEGE_SET,*PPRIVILEGE_SET;
   2053 
   2054 typedef enum _SECURITY_IMPERSONATION_LEVEL {
   2055   SecurityAnonymous,
   2056   SecurityIdentification,
   2057   SecurityImpersonation,
   2058   SecurityDelegation
   2059 } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
   2060 
   2061 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
   2062 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
   2063 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
   2064 #define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL))
   2065 
   2066 #define SECURITY_DYNAMIC_TRACKING (TRUE)
   2067 #define SECURITY_STATIC_TRACKING (FALSE)
   2068 
   2069 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE;
   2070 
   2071 typedef struct _SECURITY_QUALITY_OF_SERVICE {
   2072   ULONG Length;
   2073   SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
   2074   SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
   2075   BOOLEAN EffectiveOnly;
   2076 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
   2077 
   2078 typedef struct _SE_IMPERSONATION_STATE {
   2079   PACCESS_TOKEN Token;
   2080   BOOLEAN CopyOnOpen;
   2081   BOOLEAN EffectiveOnly;
   2082   SECURITY_IMPERSONATION_LEVEL Level;
   2083 } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
   2084 
   2085 #define OWNER_SECURITY_INFORMATION       (0x00000001L)
   2086 #define GROUP_SECURITY_INFORMATION       (0x00000002L)
   2087 #define DACL_SECURITY_INFORMATION        (0x00000004L)
   2088 #define SACL_SECURITY_INFORMATION        (0x00000008L)
   2089 #define LABEL_SECURITY_INFORMATION       (0x00000010L)
   2090 
   2091 #define PROTECTED_DACL_SECURITY_INFORMATION     (0x80000000L)
   2092 #define PROTECTED_SACL_SECURITY_INFORMATION     (0x40000000L)
   2093 #define UNPROTECTED_DACL_SECURITY_INFORMATION   (0x20000000L)
   2094 #define UNPROTECTED_SACL_SECURITY_INFORMATION   (0x10000000L)
   2095 
   2096 typedef enum _SECURITY_OPERATION_CODE {
   2097   SetSecurityDescriptor,
   2098   QuerySecurityDescriptor,
   2099   DeleteSecurityDescriptor,
   2100   AssignSecurityDescriptor
   2101 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
   2102 
   2103 #define INITIAL_PRIVILEGE_COUNT           3
   2104 
   2105 typedef struct _INITIAL_PRIVILEGE_SET {
   2106   ULONG PrivilegeCount;
   2107   ULONG Control;
   2108   LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
   2109 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
   2110 
   2111 #define SE_MIN_WELL_KNOWN_PRIVILEGE         2
   2112 #define SE_CREATE_TOKEN_PRIVILEGE           2
   2113 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE     3
   2114 #define SE_LOCK_MEMORY_PRIVILEGE            4
   2115 #define SE_INCREASE_QUOTA_PRIVILEGE         5
   2116 #define SE_MACHINE_ACCOUNT_PRIVILEGE        6
   2117 #define SE_TCB_PRIVILEGE                    7
   2118 #define SE_SECURITY_PRIVILEGE               8
   2119 #define SE_TAKE_OWNERSHIP_PRIVILEGE         9
   2120 #define SE_LOAD_DRIVER_PRIVILEGE            10
   2121 #define SE_SYSTEM_PROFILE_PRIVILEGE         11
   2122 #define SE_SYSTEMTIME_PRIVILEGE             12
   2123 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE    13
   2124 #define SE_INC_BASE_PRIORITY_PRIVILEGE      14
   2125 #define SE_CREATE_PAGEFILE_PRIVILEGE        15
   2126 #define SE_CREATE_PERMANENT_PRIVILEGE       16
   2127 #define SE_BACKUP_PRIVILEGE                 17
   2128 #define SE_RESTORE_PRIVILEGE                18
   2129 #define SE_SHUTDOWN_PRIVILEGE               19
   2130 #define SE_DEBUG_PRIVILEGE                  20
   2131 #define SE_AUDIT_PRIVILEGE                  21
   2132 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE     22
   2133 #define SE_CHANGE_NOTIFY_PRIVILEGE          23
   2134 #define SE_REMOTE_SHUTDOWN_PRIVILEGE        24
   2135 #define SE_UNDOCK_PRIVILEGE                 25
   2136 #define SE_SYNC_AGENT_PRIVILEGE             26
   2137 #define SE_ENABLE_DELEGATION_PRIVILEGE      27
   2138 #define SE_MANAGE_VOLUME_PRIVILEGE          28
   2139 #define SE_IMPERSONATE_PRIVILEGE            29
   2140 #define SE_CREATE_GLOBAL_PRIVILEGE          30
   2141 #define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31
   2142 #define SE_RELABEL_PRIVILEGE                32
   2143 #define SE_INC_WORKING_SET_PRIVILEGE        33
   2144 #define SE_TIME_ZONE_PRIVILEGE              34
   2145 #define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE   35
   2146 #define SE_MAX_WELL_KNOWN_PRIVILEGE         SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
   2147 
   2148 typedef struct _SECURITY_SUBJECT_CONTEXT {
   2149   PACCESS_TOKEN ClientToken;
   2150   SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
   2151   PACCESS_TOKEN PrimaryToken;
   2152   PVOID ProcessAuditId;
   2153 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
   2154 
   2155 typedef struct _ACCESS_STATE {
   2156   LUID OperationID;
   2157   BOOLEAN SecurityEvaluated;
   2158   BOOLEAN GenerateAudit;
   2159   BOOLEAN GenerateOnClose;
   2160   BOOLEAN PrivilegesAllocated;
   2161   ULONG Flags;
   2162   ACCESS_MASK RemainingDesiredAccess;
   2163   ACCESS_MASK PreviouslyGrantedAccess;
   2164   ACCESS_MASK OriginalDesiredAccess;
   2165   SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
   2166   PSECURITY_DESCRIPTOR SecurityDescriptor;
   2167   PVOID AuxData;
   2168   union {
   2169     INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
   2170     PRIVILEGE_SET PrivilegeSet;
   2171   } Privileges;
   2172   BOOLEAN AuditPrivileges;
   2173   UNICODE_STRING ObjectName;
   2174   UNICODE_STRING ObjectTypeName;
   2175 } ACCESS_STATE, *PACCESS_STATE;
   2176 
   2177 typedef VOID
   2178 (NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)(
   2179   IN PVOID Vcb,
   2180   IN PSECURITY_DESCRIPTOR SecurityDescriptor);
   2181 
   2182 #ifndef _NTLSA_IFS_
   2183 
   2184 #ifndef _NTLSA_AUDIT_
   2185 #define _NTLSA_AUDIT_
   2186 
   2187 #define SE_MAX_AUDIT_PARAMETERS 32
   2188 #define SE_MAX_GENERIC_AUDIT_PARAMETERS 28
   2189 
   2190 #define SE_ADT_OBJECT_ONLY 0x1
   2191 
   2192 #define SE_ADT_PARAMETERS_SELF_RELATIVE    0x00000001
   2193 #define SE_ADT_PARAMETERS_SEND_TO_LSA      0x00000002
   2194 #define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT  0x00000004
   2195 #define SE_ADT_PARAMETER_GENERIC_AUDIT     0x00000008
   2196 #define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010
   2197 
   2198 #define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \
   2199   ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \
   2200     (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) )
   2201 
   2202 typedef enum _SE_ADT_PARAMETER_TYPE {
   2203   SeAdtParmTypeNone = 0,
   2204   SeAdtParmTypeString,
   2205   SeAdtParmTypeFileSpec,
   2206   SeAdtParmTypeUlong,
   2207   SeAdtParmTypeSid,
   2208   SeAdtParmTypeLogonId,
   2209   SeAdtParmTypeNoLogonId,
   2210   SeAdtParmTypeAccessMask,
   2211   SeAdtParmTypePrivs,
   2212   SeAdtParmTypeObjectTypes,
   2213   SeAdtParmTypeHexUlong,
   2214   SeAdtParmTypePtr,
   2215   SeAdtParmTypeTime,
   2216   SeAdtParmTypeGuid,
   2217   SeAdtParmTypeLuid,
   2218   SeAdtParmTypeHexInt64,
   2219   SeAdtParmTypeStringList,
   2220   SeAdtParmTypeSidList,
   2221   SeAdtParmTypeDuration,
   2222   SeAdtParmTypeUserAccountControl,
   2223   SeAdtParmTypeNoUac,
   2224   SeAdtParmTypeMessage,
   2225   SeAdtParmTypeDateTime,
   2226   SeAdtParmTypeSockAddr,
   2227   SeAdtParmTypeSD,
   2228   SeAdtParmTypeLogonHours,
   2229   SeAdtParmTypeLogonIdNoSid,
   2230   SeAdtParmTypeUlongNoConv,
   2231   SeAdtParmTypeSockAddrNoPort,
   2232   SeAdtParmTypeAccessReason
   2233 } SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE;
   2234 
   2235 typedef struct _SE_ADT_OBJECT_TYPE {
   2236   GUID ObjectType;
   2237   USHORT Flags;
   2238   USHORT Level;
   2239   ACCESS_MASK AccessMask;
   2240 } SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE;
   2241 
   2242 typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY {
   2243   SE_ADT_PARAMETER_TYPE Type;
   2244   ULONG Length;
   2245   ULONG_PTR Data[2];
   2246   PVOID Address;
   2247 } SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY;
   2248 
   2249 typedef struct _SE_ADT_ACCESS_REASON {
   2250   ACCESS_MASK AccessMask;
   2251   ULONG AccessReasons[32];
   2252   ULONG ObjectTypeIndex;
   2253   ULONG AccessGranted;
   2254   PSECURITY_DESCRIPTOR SecurityDescriptor;
   2255 } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON;
   2256 
   2257 typedef struct _SE_ADT_PARAMETER_ARRAY {
   2258   ULONG CategoryId;
   2259   ULONG AuditId;
   2260   ULONG ParameterCount;
   2261   ULONG Length;
   2262   USHORT FlatSubCategoryId;
   2263   USHORT Type;
   2264   ULONG Flags;
   2265   SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ];
   2266 } SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY;
   2267 
   2268 #endif /* !_NTLSA_AUDIT_ */
   2269 #endif /* !_NTLSA_IFS_ */
   2270 
   2271 /******************************************************************************
   2272  *                            Power Management Support Types                  *
   2273  ******************************************************************************/
   2274 
   2275 #ifndef _PO_DDK_
   2276 #define _PO_DDK_
   2277 
   2278 #define PO_CB_SYSTEM_POWER_POLICY                0
   2279 #define PO_CB_AC_STATUS                          1
   2280 #define PO_CB_BUTTON_COLLISION                   2
   2281 #define PO_CB_SYSTEM_STATE_LOCK                  3
   2282 #define PO_CB_LID_SWITCH_STATE                   4
   2283 #define PO_CB_PROCESSOR_POWER_POLICY             5
   2284 
   2285 /* Power States/Levels */
   2286 typedef enum _SYSTEM_POWER_STATE {
   2287   PowerSystemUnspecified = 0,
   2288   PowerSystemWorking,
   2289   PowerSystemSleeping1,
   2290   PowerSystemSleeping2,
   2291   PowerSystemSleeping3,
   2292   PowerSystemHibernate,
   2293   PowerSystemShutdown,
   2294   PowerSystemMaximum
   2295 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
   2296 
   2297 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
   2298 
   2299 typedef enum _POWER_INFORMATION_LEVEL {
   2300   SystemPowerPolicyAc,
   2301   SystemPowerPolicyDc,
   2302   VerifySystemPolicyAc,
   2303   VerifySystemPolicyDc,
   2304   SystemPowerCapabilities,
   2305   SystemBatteryState,
   2306   SystemPowerStateHandler,
   2307   ProcessorStateHandler,
   2308   SystemPowerPolicyCurrent,
   2309   AdministratorPowerPolicy,
   2310   SystemReserveHiberFile,
   2311   ProcessorInformation,
   2312   SystemPowerInformation,
   2313   ProcessorStateHandler2,
   2314   LastWakeTime,
   2315   LastSleepTime,
   2316   SystemExecutionState,
   2317   SystemPowerStateNotifyHandler,
   2318   ProcessorPowerPolicyAc,
   2319   ProcessorPowerPolicyDc,
   2320   VerifyProcessorPowerPolicyAc,
   2321   VerifyProcessorPowerPolicyDc,
   2322   ProcessorPowerPolicyCurrent,
   2323   SystemPowerStateLogging,
   2324   SystemPowerLoggingEntry,
   2325   SetPowerSettingValue,
   2326   NotifyUserPowerSetting,
   2327   PowerInformationLevelUnused0,
   2328   PowerInformationLevelUnused1,
   2329   SystemVideoState,
   2330   TraceApplicationPowerMessage,
   2331   TraceApplicationPowerMessageEnd,
   2332   ProcessorPerfStates,
   2333   ProcessorIdleStates,
   2334   ProcessorCap,
   2335   SystemWakeSource,
   2336   SystemHiberFileInformation,
   2337   TraceServicePowerMessage,
   2338   ProcessorLoad,
   2339   PowerShutdownNotification,
   2340   MonitorCapabilities,
   2341   SessionPowerInit,
   2342   SessionDisplayState,
   2343   PowerRequestCreate,
   2344   PowerRequestAction,
   2345   GetPowerRequestList,
   2346   ProcessorInformationEx,
   2347   NotifyUserModeLegacyPowerEvent,
   2348   GroupPark,
   2349   ProcessorIdleDomains,
   2350   WakeTimerList,
   2351   SystemHiberFileSize,
   2352   PowerInformationLevelMaximum
   2353 } POWER_INFORMATION_LEVEL;
   2354 
   2355 typedef enum {
   2356   PowerActionNone = 0,
   2357   PowerActionReserved,
   2358   PowerActionSleep,
   2359   PowerActionHibernate,
   2360   PowerActionShutdown,
   2361   PowerActionShutdownReset,
   2362   PowerActionShutdownOff,
   2363   PowerActionWarmEject
   2364 } POWER_ACTION, *PPOWER_ACTION;
   2365 
   2366 typedef enum _DEVICE_POWER_STATE {
   2367   PowerDeviceUnspecified = 0,
   2368   PowerDeviceD0,
   2369   PowerDeviceD1,
   2370   PowerDeviceD2,
   2371   PowerDeviceD3,
   2372   PowerDeviceMaximum
   2373 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
   2374 
   2375 typedef enum _MONITOR_DISPLAY_STATE {
   2376   PowerMonitorOff = 0,
   2377   PowerMonitorOn,
   2378   PowerMonitorDim
   2379 } MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE;
   2380 
   2381 typedef union _POWER_STATE {
   2382   SYSTEM_POWER_STATE SystemState;
   2383   DEVICE_POWER_STATE DeviceState;
   2384 } POWER_STATE, *PPOWER_STATE;
   2385 
   2386 typedef enum _POWER_STATE_TYPE {
   2387   SystemPowerState = 0,
   2388   DevicePowerState
   2389 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
   2390 
   2391 #if (NTDDI_VERSION >= NTDDI_VISTA)
   2392 typedef struct _SYSTEM_POWER_STATE_CONTEXT {
   2393   _ANONYMOUS_UNION union {
   2394     _ANONYMOUS_STRUCT struct {
   2395       ULONG Reserved1:8;
   2396       ULONG TargetSystemState:4;
   2397       ULONG EffectiveSystemState:4;
   2398       ULONG CurrentSystemState:4;
   2399       ULONG IgnoreHibernationPath:1;
   2400       ULONG PseudoTransition:1;
   2401       ULONG Reserved2:10;
   2402     } DUMMYSTRUCTNAME;
   2403     ULONG ContextAsUlong;
   2404   } DUMMYUNIONNAME;
   2405 } SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT;
   2406 #endif
   2407 
   2408 #if (NTDDI_VERSION >= NTDDI_WIN7)
   2409 typedef struct _COUNTED_REASON_CONTEXT {
   2410   ULONG Version;
   2411   ULONG Flags;
   2412   _ANONYMOUS_UNION union {
   2413     _ANONYMOUS_STRUCT struct {
   2414       UNICODE_STRING ResourceFileName;
   2415       USHORT ResourceReasonId;
   2416       ULONG StringCount;
   2417       PUNICODE_STRING ReasonStrings;
   2418     } DUMMYSTRUCTNAME;
   2419     UNICODE_STRING SimpleString;
   2420   } DUMMYUNIONNAME;
   2421 } COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT;
   2422 #endif
   2423 
   2424 #define IOCTL_QUERY_DEVICE_POWER_STATE  \
   2425         CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS)
   2426 
   2427 #define IOCTL_SET_DEVICE_WAKE           \
   2428         CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
   2429 
   2430 #define IOCTL_CANCEL_DEVICE_WAKE        \
   2431         CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
   2432 
   2433 #define ES_SYSTEM_REQUIRED                       0x00000001
   2434 #define ES_DISPLAY_REQUIRED                      0x00000002
   2435 #define ES_USER_PRESENT                          0x00000004
   2436 #define ES_CONTINUOUS                            0x80000000
   2437 
   2438 typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE;
   2439 
   2440 typedef enum {
   2441   LT_DONT_CARE,
   2442   LT_LOWEST_LATENCY
   2443 } LATENCY_TIME;
   2444 
   2445 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
   2446 #define DIAGNOSTIC_REASON_VERSION                0
   2447 #define DIAGNOSTIC_REASON_SIMPLE_STRING          0x00000001
   2448 #define DIAGNOSTIC_REASON_DETAILED_STRING        0x00000002
   2449 #define DIAGNOSTIC_REASON_NOT_SPECIFIED          0x80000000
   2450 #define DIAGNOSTIC_REASON_INVALID_FLAGS          (~0x80000003)
   2451 #endif
   2452 
   2453 #define POWER_REQUEST_CONTEXT_VERSION            0
   2454 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING      0x00000001
   2455 #define POWER_REQUEST_CONTEXT_DETAILED_STRING    0x00000002
   2456 
   2457 #define PowerRequestMaximum                      3
   2458 
   2459 typedef enum _POWER_REQUEST_TYPE {
   2460   PowerRequestDisplayRequired,
   2461   PowerRequestSystemRequired,
   2462   PowerRequestAwayModeRequired
   2463 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
   2464 
   2465 #if (NTDDI_VERSION >= NTDDI_WINXP)
   2466 
   2467 #define PDCAP_D0_SUPPORTED                       0x00000001
   2468 #define PDCAP_D1_SUPPORTED                       0x00000002
   2469 #define PDCAP_D2_SUPPORTED                       0x00000004
   2470 #define PDCAP_D3_SUPPORTED                       0x00000008
   2471 #define PDCAP_WAKE_FROM_D0_SUPPORTED             0x00000010
   2472 #define PDCAP_WAKE_FROM_D1_SUPPORTED             0x00000020
   2473 #define PDCAP_WAKE_FROM_D2_SUPPORTED             0x00000040
   2474 #define PDCAP_WAKE_FROM_D3_SUPPORTED             0x00000080
   2475 #define PDCAP_WARM_EJECT_SUPPORTED               0x00000100
   2476 
   2477 typedef struct CM_Power_Data_s {
   2478   ULONG PD_Size;
   2479   DEVICE_POWER_STATE PD_MostRecentPowerState;
   2480   ULONG PD_Capabilities;
   2481   ULONG PD_D1Latency;
   2482   ULONG PD_D2Latency;
   2483   ULONG PD_D3Latency;
   2484   DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
   2485   SYSTEM_POWER_STATE PD_DeepestSystemWake;
   2486 } CM_POWER_DATA, *PCM_POWER_DATA;
   2487 
   2488 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
   2489 
   2490 typedef enum _SYSTEM_POWER_CONDITION {
   2491   PoAc,
   2492   PoDc,
   2493   PoHot,
   2494   PoConditionMaximum
   2495 } SYSTEM_POWER_CONDITION;
   2496 
   2497 typedef struct _SET_POWER_SETTING_VALUE {
   2498   ULONG Version;
   2499   GUID Guid;
   2500   SYSTEM_POWER_CONDITION PowerCondition;
   2501   ULONG DataLength;
   2502   UCHAR Data[ANYSIZE_ARRAY];
   2503 } SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE;
   2504 
   2505 #define POWER_SETTING_VALUE_VERSION              (0x1)
   2506 
   2507 typedef struct _NOTIFY_USER_POWER_SETTING {
   2508   GUID Guid;
   2509 } NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING;
   2510 
   2511 typedef struct _APPLICATIONLAUNCH_SETTING_VALUE {
   2512   LARGE_INTEGER ActivationTime;
   2513   ULONG Flags;
   2514   ULONG ButtonInstanceID;
   2515 } APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE;
   2516 
   2517 typedef enum _POWER_PLATFORM_ROLE {
   2518   PlatformRoleUnspecified = 0,
   2519   PlatformRoleDesktop,
   2520   PlatformRoleMobile,
   2521   PlatformRoleWorkstation,
   2522   PlatformRoleEnterpriseServer,
   2523   PlatformRoleSOHOServer,
   2524   PlatformRoleAppliancePC,
   2525   PlatformRolePerformanceServer,
   2526   PlatformRoleMaximum
   2527 } POWER_PLATFORM_ROLE;
   2528 
   2529 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
   2530 typedef struct {
   2531   ULONG Granularity;
   2532   ULONG Capacity;
   2533 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
   2534 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
   2535 
   2536 #endif /* !_PO_DDK_ */
   2537 
   2538 #define CORE_PARKING_POLICY_CHANGE_IDEAL         0
   2539 #define CORE_PARKING_POLICY_CHANGE_SINGLE        1
   2540 #define CORE_PARKING_POLICY_CHANGE_ROCKET        2
   2541 #define CORE_PARKING_POLICY_CHANGE_MAX           CORE_PARKING_POLICY_CHANGE_ROCKET
   2542 
   2543 DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A);
   2544 DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C);
   2545 DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E);
   2546 DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94);
   2547 DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0);
   2548 DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7);
   2549 DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63);
   2550 DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99);
   2551 DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E);
   2552 DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63);
   2553 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64);
   2554 DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee);
   2555 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B);
   2556 DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA);
   2557 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb);
   2558 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96);
   2559 DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff);
   2560 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8);
   2561 DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67);
   2562 DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47);
   2563 DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23);
   2564 DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42);
   2565 DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E);
   2566 DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63);
   2567 DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67);
   2568 DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20);
   2569 DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70);
   2570 DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA);
   2571 DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0);
   2572 DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64);
   2573 DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E);
   2574 DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION,  0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1);
   2575 DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0);
   2576 DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87);
   2577 DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab);
   2578 DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D);
   2579 DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2);
   2580 DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47);
   2581 DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80);
   2582 DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78);
   2583 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB);
   2584 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93);
   2585 DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5);
   2586 DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36);
   2587 DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B);
   2588 DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4);
   2589 DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F);
   2590 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46);
   2591 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69);
   2592 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f);
   2593 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06);
   2594 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A);
   2595 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58);
   2596 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4);
   2597 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA);
   2598 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82);
   2599 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8);
   2600 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65);
   2601 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3);
   2602 DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00);
   2603 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36);
   2604 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC);
   2605 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C);
   2606 DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb);
   2607 DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c);
   2608 DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0);
   2609 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d);
   2610 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6);
   2611 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18);
   2612 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6);
   2613 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa);
   2614 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8);
   2615 DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5);
   2616 DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59);
   2617 DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6);
   2618 DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad);
   2619 DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b);
   2620 DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19);
   2621 DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c);
   2622 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1);
   2623 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa);
   2624 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6);
   2625 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b);
   2626 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28);
   2627 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83);
   2628 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32);
   2629 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82);
   2630 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82);
   2631 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9);
   2632 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20);
   2633 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d);
   2634 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29);
   2635 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb);
   2636 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1);
   2637 DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f);
   2638 DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b);
   2639 DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f);
   2640 DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F);
   2641 DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51);
   2642 DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19);
   2643 DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48);
   2644 DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE,  0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3);
   2645 DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1);
   2646 DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1);
   2647 DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E);
   2648 DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA);
   2649 DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20);
   2650 DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5);
   2651 DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6);
   2652 
   2653 #define PERFSTATE_POLICY_CHANGE_IDEAL            0
   2654 #define PERFSTATE_POLICY_CHANGE_SINGLE           1
   2655 #define PERFSTATE_POLICY_CHANGE_ROCKET           2
   2656 #define PERFSTATE_POLICY_CHANGE_MAX              PERFSTATE_POLICY_CHANGE_ROCKET
   2657 
   2658 #define PROCESSOR_PERF_BOOST_POLICY_DISABLED     0
   2659 #define PROCESSOR_PERF_BOOST_POLICY_MAX          100
   2660 
   2661 #define POWER_DEVICE_IDLE_POLICY_PERFORMANCE     0
   2662 #define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE    1
   2663 
   2664 typedef VOID
   2665 (NTAPI REQUEST_POWER_COMPLETE)(
   2666   IN struct _DEVICE_OBJECT *DeviceObject,
   2667   IN UCHAR MinorFunction,
   2668   IN POWER_STATE PowerState,
   2669   IN PVOID Context,
   2670   IN struct _IO_STATUS_BLOCK *IoStatus);
   2671 typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE;
   2672 
   2673 typedef
   2674 NTSTATUS
   2675 (NTAPI POWER_SETTING_CALLBACK)(
   2676   IN LPCGUID SettingGuid,
   2677   IN PVOID Value,
   2678   IN ULONG ValueLength,
   2679   IN OUT PVOID Context OPTIONAL);
   2680 typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK;
   2681 
   2682 /******************************************************************************
   2683  *                            Configuration Manager Types                     *
   2684  ******************************************************************************/
   2685 
   2686 /* Resource list definitions */
   2687 typedef int CM_RESOURCE_TYPE;
   2688 
   2689 #define CmResourceTypeNull              0
   2690 #define CmResourceTypePort              1
   2691 #define CmResourceTypeInterrupt         2
   2692 #define CmResourceTypeMemory            3
   2693 #define CmResourceTypeDma               4
   2694 #define CmResourceTypeDeviceSpecific    5
   2695 #define CmResourceTypeBusNumber         6
   2696 #define CmResourceTypeNonArbitrated     128
   2697 #define CmResourceTypeConfigData        128
   2698 #define CmResourceTypeDevicePrivate     129
   2699 #define CmResourceTypePcCardConfig      130
   2700 #define CmResourceTypeMfCardConfig      131
   2701 
   2702 /* KEY_VALUE_Xxx.Type */
   2703 #define REG_NONE                           0
   2704 #define REG_SZ                             1
   2705 #define REG_EXPAND_SZ                      2
   2706 #define REG_BINARY                         3
   2707 #define REG_DWORD                          4
   2708 #define REG_DWORD_LITTLE_ENDIAN            4
   2709 #define REG_DWORD_BIG_ENDIAN               5
   2710 #define REG_LINK                           6
   2711 #define REG_MULTI_SZ                       7
   2712 #define REG_RESOURCE_LIST                  8
   2713 #define REG_FULL_RESOURCE_DESCRIPTOR       9
   2714 #define REG_RESOURCE_REQUIREMENTS_LIST     10
   2715 #define REG_QWORD                          11
   2716 #define REG_QWORD_LITTLE_ENDIAN            11
   2717 
   2718 /* Registry Access Rights */
   2719 #define KEY_QUERY_VALUE         (0x0001)
   2720 #define KEY_SET_VALUE           (0x0002)
   2721 #define KEY_CREATE_SUB_KEY      (0x0004)
   2722 #define KEY_ENUMERATE_SUB_KEYS  (0x0008)
   2723 #define KEY_NOTIFY              (0x0010)
   2724 #define KEY_CREATE_LINK         (0x0020)
   2725 #define KEY_WOW64_32KEY         (0x0200)
   2726 #define KEY_WOW64_64KEY         (0x0100)
   2727 #define KEY_WOW64_RES           (0x0300)
   2728 
   2729 #define KEY_READ                ((STANDARD_RIGHTS_READ       |\
   2730                                   KEY_QUERY_VALUE            |\
   2731                                   KEY_ENUMERATE_SUB_KEYS     |\
   2732                                   KEY_NOTIFY)                 \
   2733                                   &                           \
   2734                                  (~SYNCHRONIZE))
   2735 
   2736 #define KEY_WRITE               ((STANDARD_RIGHTS_WRITE      |\
   2737                                   KEY_SET_VALUE              |\
   2738                                   KEY_CREATE_SUB_KEY)         \
   2739                                   &                           \
   2740                                  (~SYNCHRONIZE))
   2741 
   2742 #define KEY_EXECUTE             ((KEY_READ)                   \
   2743                                   &                           \
   2744                                  (~SYNCHRONIZE))
   2745 
   2746 #define KEY_ALL_ACCESS          ((STANDARD_RIGHTS_ALL        |\
   2747                                   KEY_QUERY_VALUE            |\
   2748                                   KEY_SET_VALUE              |\
   2749                                   KEY_CREATE_SUB_KEY         |\
   2750                                   KEY_ENUMERATE_SUB_KEYS     |\
   2751                                   KEY_NOTIFY                 |\
   2752                                   KEY_CREATE_LINK)            \
   2753                                   &                           \
   2754                                  (~SYNCHRONIZE))
   2755 
   2756 /* Registry Open/Create Options */
   2757 #define REG_OPTION_RESERVED         (0x00000000L)
   2758 #define REG_OPTION_NON_VOLATILE     (0x00000000L)
   2759 #define REG_OPTION_VOLATILE         (0x00000001L)
   2760 #define REG_OPTION_CREATE_LINK      (0x00000002L)
   2761 #define REG_OPTION_BACKUP_RESTORE   (0x00000004L)
   2762 #define REG_OPTION_OPEN_LINK        (0x00000008L)
   2763 
   2764 #define REG_LEGAL_OPTION            \
   2765                 (REG_OPTION_RESERVED            |\
   2766                  REG_OPTION_NON_VOLATILE        |\
   2767                  REG_OPTION_VOLATILE            |\
   2768                  REG_OPTION_CREATE_LINK         |\
   2769                  REG_OPTION_BACKUP_RESTORE      |\
   2770                  REG_OPTION_OPEN_LINK)
   2771 
   2772 #define REG_OPEN_LEGAL_OPTION       \
   2773                 (REG_OPTION_RESERVED            |\
   2774                  REG_OPTION_BACKUP_RESTORE      |\
   2775                  REG_OPTION_OPEN_LINK)
   2776 
   2777 #define REG_STANDARD_FORMAT            1
   2778 #define REG_LATEST_FORMAT              2
   2779 #define REG_NO_COMPRESSION             4
   2780 
   2781 /* Key creation/open disposition */
   2782 #define REG_CREATED_NEW_KEY         (0x00000001L)
   2783 #define REG_OPENED_EXISTING_KEY     (0x00000002L)
   2784 
   2785 /* Key restore & hive load flags */
   2786 #define REG_WHOLE_HIVE_VOLATILE         (0x00000001L)
   2787 #define REG_REFRESH_HIVE                (0x00000002L)
   2788 #define REG_NO_LAZY_FLUSH               (0x00000004L)
   2789 #define REG_FORCE_RESTORE               (0x00000008L)
   2790 #define REG_APP_HIVE                    (0x00000010L)
   2791 #define REG_PROCESS_PRIVATE             (0x00000020L)
   2792 #define REG_START_JOURNAL               (0x00000040L)
   2793 #define REG_HIVE_EXACT_FILE_GROWTH      (0x00000080L)
   2794 #define REG_HIVE_NO_RM                  (0x00000100L)
   2795 #define REG_HIVE_SINGLE_LOG             (0x00000200L)
   2796 #define REG_BOOT_HIVE                   (0x00000400L)
   2797 
   2798 /* Unload Flags */
   2799 #define REG_FORCE_UNLOAD            1
   2800 
   2801 /* Notify Filter Values */
   2802 #define REG_NOTIFY_CHANGE_NAME          (0x00000001L)
   2803 #define REG_NOTIFY_CHANGE_ATTRIBUTES    (0x00000002L)
   2804 #define REG_NOTIFY_CHANGE_LAST_SET      (0x00000004L)
   2805 #define REG_NOTIFY_CHANGE_SECURITY      (0x00000008L)
   2806 
   2807 #define REG_LEGAL_CHANGE_FILTER                 \
   2808                 (REG_NOTIFY_CHANGE_NAME          |\
   2809                  REG_NOTIFY_CHANGE_ATTRIBUTES    |\
   2810                  REG_NOTIFY_CHANGE_LAST_SET      |\
   2811                  REG_NOTIFY_CHANGE_SECURITY)
   2812 
   2813 #include <pshpack4.h>
   2814 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
   2815   UCHAR Type;
   2816   UCHAR ShareDisposition;
   2817   USHORT Flags;
   2818   union {
   2819     struct {
   2820       PHYSICAL_ADDRESS Start;
   2821       ULONG Length;
   2822     } Generic;
   2823     struct {
   2824       PHYSICAL_ADDRESS Start;
   2825       ULONG Length;
   2826     } Port;
   2827     struct {
   2828 #if defined(NT_PROCESSOR_GROUPS)
   2829       USHORT Level;
   2830       USHORT Group;
   2831 #else
   2832       ULONG Level;
   2833 #endif
   2834       ULONG Vector;
   2835       KAFFINITY Affinity;
   2836     } Interrupt;
   2837 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
   2838     struct {
   2839       _ANONYMOUS_UNION union {
   2840         struct {
   2841 #if defined(NT_PROCESSOR_GROUPS)
   2842           USHORT Group;
   2843 #else
   2844           USHORT Reserved;
   2845 #endif
   2846           USHORT MessageCount;
   2847           ULONG Vector;
   2848           KAFFINITY Affinity;
   2849         } Raw;
   2850         struct {
   2851 #if defined(NT_PROCESSOR_GROUPS)
   2852           USHORT Level;
   2853           USHORT Group;
   2854 #else
   2855           ULONG Level;
   2856 #endif
   2857           ULONG Vector;
   2858           KAFFINITY Affinity;
   2859         } Translated;
   2860       } DUMMYUNIONNAME;
   2861     } MessageInterrupt;
   2862 #endif
   2863     struct {
   2864       PHYSICAL_ADDRESS Start;
   2865       ULONG Length;
   2866     } Memory;
   2867     struct {
   2868       ULONG Channel;
   2869       ULONG Port;
   2870       ULONG Reserved1;
   2871     } Dma;
   2872     struct {
   2873       ULONG Data[3];
   2874     } DevicePrivate;
   2875     struct {
   2876       ULONG Start;
   2877       ULONG Length;
   2878       ULONG Reserved;
   2879     } BusNumber;
   2880     struct {
   2881       ULONG DataSize;
   2882       ULONG Reserved1;
   2883       ULONG Reserved2;
   2884     } DeviceSpecificData;
   2885 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
   2886     struct {
   2887       PHYSICAL_ADDRESS Start;
   2888       ULONG Length40;
   2889     } Memory40;
   2890     struct {
   2891       PHYSICAL_ADDRESS Start;
   2892       ULONG Length48;
   2893     } Memory48;
   2894     struct {
   2895       PHYSICAL_ADDRESS Start;
   2896       ULONG Length64;
   2897     } Memory64;
   2898 #endif
   2899   } u;
   2900 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
   2901 #include <poppack.h>
   2902 
   2903 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
   2904 #define CmResourceTypeNull                0
   2905 #define CmResourceTypePort                1
   2906 #define CmResourceTypeInterrupt           2
   2907 #define CmResourceTypeMemory              3
   2908 #define CmResourceTypeDma                 4
   2909 #define CmResourceTypeDeviceSpecific      5
   2910 #define CmResourceTypeBusNumber           6
   2911 #define CmResourceTypeMemoryLarge         7
   2912 #define CmResourceTypeNonArbitrated       128
   2913 #define CmResourceTypeConfigData          128
   2914 #define CmResourceTypeDevicePrivate       129
   2915 #define CmResourceTypePcCardConfig        130
   2916 #define CmResourceTypeMfCardConfig        131
   2917 
   2918 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
   2919 typedef enum _CM_SHARE_DISPOSITION {
   2920   CmResourceShareUndetermined = 0,
   2921   CmResourceShareDeviceExclusive,
   2922   CmResourceShareDriverExclusive,
   2923   CmResourceShareShared
   2924 } CM_SHARE_DISPOSITION;
   2925 
   2926 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
   2927 #define CM_RESOURCE_PORT_MEMORY           0x0000
   2928 #define CM_RESOURCE_PORT_IO               0x0001
   2929 #define CM_RESOURCE_PORT_10_BIT_DECODE    0x0004
   2930 #define CM_RESOURCE_PORT_12_BIT_DECODE    0x0008
   2931 #define CM_RESOURCE_PORT_16_BIT_DECODE    0x0010
   2932 #define CM_RESOURCE_PORT_POSITIVE_DECODE  0x0020
   2933 #define CM_RESOURCE_PORT_PASSIVE_DECODE   0x0040
   2934 #define CM_RESOURCE_PORT_WINDOW_DECODE    0x0080
   2935 #define CM_RESOURCE_PORT_BAR              0x0100
   2936 
   2937 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
   2938 #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
   2939 #define CM_RESOURCE_INTERRUPT_LATCHED         0x0001
   2940 #define CM_RESOURCE_INTERRUPT_MESSAGE         0x0002
   2941 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004
   2942 
   2943 #define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001
   2944 
   2945 #define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN   ((ULONG)-2)
   2946 
   2947 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
   2948 #define CM_RESOURCE_MEMORY_READ_WRITE                    0x0000
   2949 #define CM_RESOURCE_MEMORY_READ_ONLY                     0x0001
   2950 #define CM_RESOURCE_MEMORY_WRITE_ONLY                    0x0002
   2951 #define CM_RESOURCE_MEMORY_WRITEABILITY_MASK             0x0003
   2952 #define CM_RESOURCE_MEMORY_PREFETCHABLE                  0x0004
   2953 #define CM_RESOURCE_MEMORY_COMBINEDWRITE                 0x0008
   2954 #define CM_RESOURCE_MEMORY_24                            0x0010
   2955 #define CM_RESOURCE_MEMORY_CACHEABLE                     0x0020
   2956 #define CM_RESOURCE_MEMORY_WINDOW_DECODE                 0x0040
   2957 #define CM_RESOURCE_MEMORY_BAR                           0x0080
   2958 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100
   2959 
   2960 #define CM_RESOURCE_MEMORY_LARGE                         0x0E00
   2961 #define CM_RESOURCE_MEMORY_LARGE_40                      0x0200
   2962 #define CM_RESOURCE_MEMORY_LARGE_48                      0x0400
   2963 #define CM_RESOURCE_MEMORY_LARGE_64                      0x0800
   2964 
   2965 #define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN               0x000000FFFFFFFF00
   2966 #define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN               0x0000FFFFFFFF0000
   2967 #define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN               0xFFFFFFFF00000000
   2968 
   2969 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
   2970 #define CM_RESOURCE_DMA_8                 0x0000
   2971 #define CM_RESOURCE_DMA_16                0x0001
   2972 #define CM_RESOURCE_DMA_32                0x0002
   2973 #define CM_RESOURCE_DMA_8_AND_16          0x0004
   2974 #define CM_RESOURCE_DMA_BUS_MASTER        0x0008
   2975 #define CM_RESOURCE_DMA_TYPE_A            0x0010
   2976 #define CM_RESOURCE_DMA_TYPE_B            0x0020
   2977 #define CM_RESOURCE_DMA_TYPE_F            0x0040
   2978 
   2979 typedef struct _DEVICE_FLAGS {
   2980   ULONG Failed:1;
   2981   ULONG ReadOnly:1;
   2982   ULONG Removable:1;
   2983   ULONG ConsoleIn:1;
   2984   ULONG ConsoleOut:1;
   2985   ULONG Input:1;
   2986   ULONG Output:1;
   2987 } DEVICE_FLAGS, *PDEVICE_FLAGS;
   2988 
   2989 typedef enum _INTERFACE_TYPE {
   2990   InterfaceTypeUndefined = -1,
   2991   Internal,
   2992   Isa,
   2993   Eisa,
   2994   MicroChannel,
   2995   TurboChannel,
   2996   PCIBus,
   2997   VMEBus,
   2998   NuBus,
   2999   PCMCIABus,
   3000   CBus,
   3001   MPIBus,
   3002   MPSABus,
   3003   ProcessorInternal,
   3004   InternalPowerBus,
   3005   PNPISABus,
   3006   PNPBus,
   3007   Vmcs,
   3008   MaximumInterfaceType
   3009 } INTERFACE_TYPE, *PINTERFACE_TYPE;
   3010 
   3011 typedef struct _CM_COMPONENT_INFORMATION {
   3012   DEVICE_FLAGS Flags;
   3013   ULONG Version;
   3014   ULONG Key;
   3015   KAFFINITY AffinityMask;
   3016 } CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
   3017 
   3018 typedef struct _CM_ROM_BLOCK {
   3019   ULONG Address;
   3020   ULONG Size;
   3021 } CM_ROM_BLOCK, *PCM_ROM_BLOCK;
   3022 
   3023 typedef struct _CM_PARTIAL_RESOURCE_LIST {
   3024   USHORT Version;
   3025   USHORT Revision;
   3026   ULONG Count;
   3027   CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
   3028 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
   3029 
   3030 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
   3031   INTERFACE_TYPE InterfaceType;
   3032   ULONG BusNumber;
   3033   CM_PARTIAL_RESOURCE_LIST PartialResourceList;
   3034 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
   3035 
   3036 typedef struct _CM_RESOURCE_LIST {
   3037   ULONG Count;
   3038   CM_FULL_RESOURCE_DESCRIPTOR List[1];
   3039 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
   3040 
   3041 typedef struct _PNP_BUS_INFORMATION {
   3042   GUID BusTypeGuid;
   3043   INTERFACE_TYPE LegacyBusType;
   3044   ULONG BusNumber;
   3045 } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
   3046 
   3047 #include <pshpack1.h>
   3048 
   3049 typedef struct _CM_INT13_DRIVE_PARAMETER {
   3050   USHORT DriveSelect;
   3051   ULONG MaxCylinders;
   3052   USHORT SectorsPerTrack;
   3053   USHORT MaxHeads;
   3054   USHORT NumberDrives;
   3055 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
   3056 
   3057 typedef struct _CM_MCA_POS_DATA {
   3058   USHORT AdapterId;
   3059   UCHAR PosData1;
   3060   UCHAR PosData2;
   3061   UCHAR PosData3;
   3062   UCHAR PosData4;
   3063 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
   3064 
   3065 typedef struct _CM_PNP_BIOS_DEVICE_NODE {
   3066   USHORT Size;
   3067   UCHAR Node;
   3068   ULONG ProductId;
   3069   UCHAR DeviceType[3];
   3070   USHORT DeviceAttributes;
   3071 } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
   3072 
   3073 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
   3074   UCHAR Signature[4];
   3075   UCHAR Revision;
   3076   UCHAR Length;
   3077   USHORT ControlField;
   3078   UCHAR Checksum;
   3079   ULONG EventFlagAddress;
   3080   USHORT RealModeEntryOffset;
   3081   USHORT RealModeEntrySegment;
   3082   USHORT ProtectedModeEntryOffset;
   3083   ULONG ProtectedModeCodeBaseAddress;
   3084   ULONG OemDeviceId;
   3085   USHORT RealModeDataBaseAddress;
   3086   ULONG ProtectedModeDataBaseAddress;
   3087 } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
   3088 
   3089 #include <poppack.h>
   3090 
   3091 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA {
   3092   ULONG BytesPerSector;
   3093   ULONG NumberOfCylinders;
   3094   ULONG SectorsPerTrack;
   3095   ULONG NumberOfHeads;
   3096 } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
   3097 
   3098 typedef struct _CM_KEYBOARD_DEVICE_DATA {
   3099   USHORT Version;
   3100   USHORT Revision;
   3101   UCHAR Type;
   3102   UCHAR Subtype;
   3103   USHORT KeyboardFlags;
   3104 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
   3105 
   3106 typedef struct _CM_SCSI_DEVICE_DATA {
   3107   USHORT Version;
   3108   USHORT Revision;
   3109   UCHAR HostIdentifier;
   3110 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
   3111 
   3112 typedef struct _CM_VIDEO_DEVICE_DATA {
   3113   USHORT Version;
   3114   USHORT Revision;
   3115   ULONG VideoClock;
   3116 } CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA;
   3117 
   3118 typedef struct _CM_SONIC_DEVICE_DATA {
   3119   USHORT Version;
   3120   USHORT Revision;
   3121   USHORT DataConfigurationRegister;
   3122   UCHAR EthernetAddress[8];
   3123 } CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA;
   3124 
   3125 typedef struct _CM_SERIAL_DEVICE_DATA {
   3126   USHORT Version;
   3127   USHORT Revision;
   3128   ULONG BaudClock;
   3129 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
   3130 
   3131 typedef struct _CM_MONITOR_DEVICE_DATA {
   3132   USHORT Version;
   3133   USHORT Revision;
   3134   USHORT HorizontalScreenSize;
   3135   USHORT VerticalScreenSize;
   3136   USHORT HorizontalResolution;
   3137   USHORT VerticalResolution;
   3138   USHORT HorizontalDisplayTimeLow;
   3139   USHORT HorizontalDisplayTime;
   3140   USHORT HorizontalDisplayTimeHigh;
   3141   USHORT HorizontalBackPorchLow;
   3142   USHORT HorizontalBackPorch;
   3143   USHORT HorizontalBackPorchHigh;
   3144   USHORT HorizontalFrontPorchLow;
   3145   USHORT HorizontalFrontPorch;
   3146   USHORT HorizontalFrontPorchHigh;
   3147   USHORT HorizontalSyncLow;
   3148   USHORT HorizontalSync;
   3149   USHORT HorizontalSyncHigh;
   3150   USHORT VerticalBackPorchLow;
   3151   USHORT VerticalBackPorch;
   3152   USHORT VerticalBackPorchHigh;
   3153   USHORT VerticalFrontPorchLow;
   3154   USHORT VerticalFrontPorch;
   3155   USHORT VerticalFrontPorchHigh;
   3156   USHORT VerticalSyncLow;
   3157   USHORT VerticalSync;
   3158   USHORT VerticalSyncHigh;
   3159 } CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA;
   3160 
   3161 typedef struct _CM_FLOPPY_DEVICE_DATA {
   3162   USHORT Version;
   3163   USHORT Revision;
   3164   CHAR Size[8];
   3165   ULONG MaxDensity;
   3166   ULONG MountDensity;
   3167   UCHAR StepRateHeadUnloadTime;
   3168   UCHAR HeadLoadTime;
   3169   UCHAR MotorOffTime;
   3170   UCHAR SectorLengthCode;
   3171   UCHAR SectorPerTrack;
   3172   UCHAR ReadWriteGapLength;
   3173   UCHAR DataTransferLength;
   3174   UCHAR FormatGapLength;
   3175   UCHAR FormatFillCharacter;
   3176   UCHAR HeadSettleTime;
   3177   UCHAR MotorSettleTime;
   3178   UCHAR MaximumTrackValue;
   3179   UCHAR DataTransferRate;
   3180 } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
   3181 
   3182 typedef enum _KEY_INFORMATION_CLASS {
   3183   KeyBasicInformation,
   3184   KeyNodeInformation,
   3185   KeyFullInformation,
   3186   KeyNameInformation,
   3187   KeyCachedInformation,
   3188   KeyFlagsInformation,
   3189   KeyVirtualizationInformation,
   3190   KeyHandleTagsInformation,
   3191   MaxKeyInfoClass
   3192 } KEY_INFORMATION_CLASS;
   3193 
   3194 typedef struct _KEY_BASIC_INFORMATION {
   3195   LARGE_INTEGER LastWriteTime;
   3196   ULONG TitleIndex;
   3197   ULONG NameLength;
   3198   WCHAR Name[1];
   3199 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
   3200 
   3201 typedef struct _KEY_CONTROL_FLAGS_INFORMATION {
   3202   ULONG ControlFlags;
   3203 } KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION;
   3204 
   3205 typedef struct _KEY_FULL_INFORMATION {
   3206   LARGE_INTEGER LastWriteTime;
   3207   ULONG TitleIndex;
   3208   ULONG ClassOffset;
   3209   ULONG ClassLength;
   3210   ULONG SubKeys;
   3211   ULONG MaxNameLen;
   3212   ULONG MaxClassLen;
   3213   ULONG Values;
   3214   ULONG MaxValueNameLen;
   3215   ULONG MaxValueDataLen;
   3216   WCHAR Class[1];
   3217 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
   3218 
   3219 typedef struct _KEY_HANDLE_TAGS_INFORMATION {
   3220   ULONG HandleTags;
   3221 } KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION;
   3222 
   3223 typedef struct _KEY_NODE_INFORMATION {
   3224   LARGE_INTEGER LastWriteTime;
   3225   ULONG TitleIndex;
   3226   ULONG ClassOffset;
   3227   ULONG ClassLength;
   3228   ULONG NameLength;
   3229   WCHAR Name[1];
   3230 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
   3231 
   3232 typedef enum _KEY_SET_INFORMATION_CLASS {
   3233   KeyWriteTimeInformation,
   3234   KeyWow64FlagsInformation,
   3235   KeyControlFlagsInformation,
   3236   KeySetVirtualizationInformation,
   3237   KeySetDebugInformation,
   3238   KeySetHandleTagsInformation,
   3239   MaxKeySetInfoClass
   3240 } KEY_SET_INFORMATION_CLASS;
   3241 
   3242 typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION {
   3243   ULONG VirtualTarget:1;
   3244   ULONG VirtualStore:1;
   3245   ULONG VirtualSource:1;
   3246   ULONG Reserved:29;
   3247 } KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION;
   3248 
   3249 typedef struct _KEY_VALUE_BASIC_INFORMATION {
   3250   ULONG TitleIndex;
   3251   ULONG Type;
   3252   ULONG NameLength;
   3253   WCHAR Name[1];
   3254 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
   3255 
   3256 typedef struct _KEY_VALUE_FULL_INFORMATION {
   3257   ULONG TitleIndex;
   3258   ULONG Type;
   3259   ULONG DataOffset;
   3260   ULONG DataLength;
   3261   ULONG NameLength;
   3262   WCHAR Name[1];
   3263 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
   3264 
   3265 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
   3266   ULONG TitleIndex;
   3267   ULONG Type;
   3268   ULONG DataLength;
   3269   UCHAR Data[1];
   3270 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
   3271 
   3272 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
   3273   ULONG Type;
   3274   ULONG DataLength;
   3275   UCHAR Data[1];
   3276 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
   3277 
   3278 typedef struct _KEY_VALUE_ENTRY {
   3279   PUNICODE_STRING ValueName;
   3280   ULONG DataLength;
   3281   ULONG DataOffset;
   3282   ULONG Type;
   3283 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
   3284 
   3285 typedef enum _KEY_VALUE_INFORMATION_CLASS {
   3286   KeyValueBasicInformation,
   3287   KeyValueFullInformation,
   3288   KeyValuePartialInformation,
   3289   KeyValueFullInformationAlign64,
   3290   KeyValuePartialInformationAlign64
   3291 } KEY_VALUE_INFORMATION_CLASS;
   3292 
   3293 typedef struct _KEY_WOW64_FLAGS_INFORMATION {
   3294   ULONG UserFlags;
   3295 } KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION;
   3296 
   3297 typedef struct _KEY_WRITE_TIME_INFORMATION {
   3298   LARGE_INTEGER LastWriteTime;
   3299 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
   3300 
   3301 typedef enum _REG_NOTIFY_CLASS {
   3302   RegNtDeleteKey,
   3303   RegNtPreDeleteKey = RegNtDeleteKey,
   3304   RegNtSetValueKey,
   3305   RegNtPreSetValueKey = RegNtSetValueKey,
   3306   RegNtDeleteValueKey,
   3307   RegNtPreDeleteValueKey = RegNtDeleteValueKey,
   3308   RegNtSetInformationKey,
   3309   RegNtPreSetInformationKey = RegNtSetInformationKey,
   3310   RegNtRenameKey,
   3311   RegNtPreRenameKey = RegNtRenameKey,
   3312   RegNtEnumerateKey,
   3313   RegNtPreEnumerateKey = RegNtEnumerateKey,
   3314   RegNtEnumerateValueKey,
   3315   RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
   3316   RegNtQueryKey,
   3317   RegNtPreQueryKey = RegNtQueryKey,
   3318   RegNtQueryValueKey,
   3319   RegNtPreQueryValueKey = RegNtQueryValueKey,
   3320   RegNtQueryMultipleValueKey,
   3321   RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
   3322   RegNtPreCreateKey,
   3323   RegNtPostCreateKey,
   3324   RegNtPreOpenKey,
   3325   RegNtPostOpenKey,
   3326   RegNtKeyHandleClose,
   3327   RegNtPreKeyHandleClose = RegNtKeyHandleClose,
   3328   RegNtPostDeleteKey,
   3329   RegNtPostSetValueKey,
   3330   RegNtPostDeleteValueKey,
   3331   RegNtPostSetInformationKey,
   3332   RegNtPostRenameKey,
   3333   RegNtPostEnumerateKey,
   3334   RegNtPostEnumerateValueKey,
   3335   RegNtPostQueryKey,
   3336   RegNtPostQueryValueKey,
   3337   RegNtPostQueryMultipleValueKey,
   3338   RegNtPostKeyHandleClose,
   3339   RegNtPreCreateKeyEx,
   3340   RegNtPostCreateKeyEx,
   3341   RegNtPreOpenKeyEx,
   3342   RegNtPostOpenKeyEx,
   3343   RegNtPreFlushKey,
   3344   RegNtPostFlushKey,
   3345   RegNtPreLoadKey,
   3346   RegNtPostLoadKey,
   3347   RegNtPreUnLoadKey,
   3348   RegNtPostUnLoadKey,
   3349   RegNtPreQueryKeySecurity,
   3350   RegNtPostQueryKeySecurity,
   3351   RegNtPreSetKeySecurity,
   3352   RegNtPostSetKeySecurity,
   3353   RegNtCallbackObjectContextCleanup,
   3354   RegNtPreRestoreKey,
   3355   RegNtPostRestoreKey,
   3356   RegNtPreSaveKey,
   3357   RegNtPostSaveKey,
   3358   RegNtPreReplaceKey,
   3359   RegNtPostReplaceKey,
   3360   MaxRegNtNotifyClass
   3361 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
   3362 
   3363 typedef NTSTATUS
   3364 (NTAPI EX_CALLBACK_FUNCTION)(
   3365   IN PVOID CallbackContext,
   3366   IN PVOID Argument1,
   3367   IN PVOID Argument2);
   3368 typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION;
   3369 
   3370 typedef struct _REG_DELETE_KEY_INFORMATION {
   3371   PVOID Object;
   3372   PVOID CallContext;
   3373   PVOID ObjectContext;
   3374   PVOID Reserved;
   3375 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION
   3376 #if (NTDDI_VERSION >= NTDDI_VISTA)
   3377 , REG_FLUSH_KEY_INFORMATION, *PREG_FLUSH_KEY_INFORMATION
   3378 #endif
   3379 ;
   3380 
   3381 typedef struct _REG_SET_VALUE_KEY_INFORMATION {
   3382   PVOID Object;
   3383   PUNICODE_STRING ValueName;
   3384   ULONG TitleIndex;
   3385   ULONG Type;
   3386   PVOID Data;
   3387   ULONG DataSize;
   3388   PVOID CallContext;
   3389   PVOID ObjectContext;
   3390   PVOID Reserved;
   3391 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
   3392 
   3393 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION {
   3394   PVOID Object;
   3395   PUNICODE_STRING ValueName;
   3396   PVOID CallContext;
   3397   PVOID ObjectContext;
   3398   PVOID Reserved;
   3399 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
   3400 
   3401 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION {
   3402   PVOID Object;
   3403   KEY_SET_INFORMATION_CLASS KeySetInformationClass;
   3404   PVOID KeySetInformation;
   3405   ULONG KeySetInformationLength;
   3406   PVOID CallContext;
   3407   PVOID ObjectContext;
   3408   PVOID Reserved;
   3409 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
   3410 
   3411 typedef struct _REG_ENUMERATE_KEY_INFORMATION {
   3412   PVOID Object;
   3413   ULONG Index;
   3414   KEY_INFORMATION_CLASS KeyInformationClass;
   3415   PVOID KeyInformation;
   3416   ULONG Length;
   3417   PULONG ResultLength;
   3418   PVOID CallContext;
   3419   PVOID ObjectContext;
   3420   PVOID Reserved;
   3421 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
   3422 
   3423 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION {
   3424   PVOID Object;
   3425   ULONG Index;
   3426   KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
   3427   PVOID KeyValueInformation;
   3428   ULONG Length;
   3429   PULONG ResultLength;
   3430   PVOID CallContext;
   3431   PVOID ObjectContext;
   3432   PVOID Reserved;
   3433 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
   3434 
   3435 typedef struct _REG_QUERY_KEY_INFORMATION {
   3436   PVOID Object;
   3437   KEY_INFORMATION_CLASS KeyInformationClass;
   3438   PVOID KeyInformation;
   3439   ULONG Length;
   3440   PULONG ResultLength;
   3441   PVOID CallContext;
   3442   PVOID ObjectContext;
   3443   PVOID Reserved;
   3444 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
   3445 
   3446 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION {
   3447   PVOID Object;
   3448   PUNICODE_STRING ValueName;
   3449   KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
   3450   PVOID KeyValueInformation;
   3451   ULONG Length;
   3452   PULONG ResultLength;
   3453   PVOID CallContext;
   3454   PVOID ObjectContext;
   3455   PVOID Reserved;
   3456 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
   3457 
   3458 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION {
   3459   PVOID Object;
   3460   PKEY_VALUE_ENTRY ValueEntries;
   3461   ULONG EntryCount;
   3462   PVOID ValueBuffer;
   3463   PULONG BufferLength;
   3464   PULONG RequiredBufferLength;
   3465   PVOID CallContext;
   3466   PVOID ObjectContext;
   3467   PVOID Reserved;
   3468 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
   3469 
   3470 typedef struct _REG_RENAME_KEY_INFORMATION {
   3471   PVOID Object;
   3472   PUNICODE_STRING NewName;
   3473   PVOID CallContext;
   3474   PVOID ObjectContext;
   3475   PVOID Reserved;
   3476 } REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION;
   3477 
   3478 typedef struct _REG_CREATE_KEY_INFORMATION {
   3479   PUNICODE_STRING CompleteName;
   3480   PVOID RootObject;
   3481   PVOID ObjectType;
   3482   ULONG CreateOptions;
   3483   PUNICODE_STRING Class;
   3484   PVOID SecurityDescriptor;
   3485   PVOID SecurityQualityOfService;
   3486   ACCESS_MASK DesiredAccess;
   3487   ACCESS_MASK GrantedAccess;
   3488   PULONG Disposition;
   3489   PVOID *ResultObject;
   3490   PVOID CallContext;
   3491   PVOID RootObjectContext;
   3492   PVOID Transaction;
   3493   PVOID Reserved;
   3494 } REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION;
   3495 
   3496 typedef struct _REG_CREATE_KEY_INFORMATION_V1 {
   3497   PUNICODE_STRING CompleteName;
   3498   PVOID RootObject;
   3499   PVOID ObjectType;
   3500   ULONG Options;
   3501   PUNICODE_STRING Class;
   3502   PVOID SecurityDescriptor;
   3503   PVOID SecurityQualityOfService;
   3504   ACCESS_MASK DesiredAccess;
   3505   ACCESS_MASK GrantedAccess;
   3506   PULONG Disposition;
   3507   PVOID *ResultObject;
   3508   PVOID CallContext;
   3509   PVOID RootObjectContext;
   3510   PVOID Transaction;
   3511   ULONG_PTR Version;
   3512   PUNICODE_STRING RemainingName;
   3513   ULONG Wow64Flags;
   3514   ULONG Attributes;
   3515   KPROCESSOR_MODE CheckAccessMode;
   3516 } REG_CREATE_KEY_INFORMATION_V1, REG_OPEN_KEY_INFORMATION_V1,*PREG_CREATE_KEY_INFORMATION_V1, *PREG_OPEN_KEY_INFORMATION_V1;
   3517 
   3518 typedef struct _REG_PRE_CREATE_KEY_INFORMATION {
   3519   PUNICODE_STRING CompleteName;
   3520 } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;;
   3521 
   3522 typedef struct _REG_POST_CREATE_KEY_INFORMATION {
   3523   PUNICODE_STRING CompleteName;
   3524   PVOID Object;
   3525   NTSTATUS Status;
   3526 } REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
   3527 
   3528 typedef struct _REG_POST_OPERATION_INFORMATION {
   3529   PVOID Object;
   3530   NTSTATUS Status;
   3531   PVOID PreInformation;
   3532   NTSTATUS ReturnStatus;
   3533   PVOID CallContext;
   3534   PVOID ObjectContext;
   3535   PVOID Reserved;
   3536 } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
   3537 
   3538 typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION {
   3539   PVOID Object;
   3540   PVOID CallContext;
   3541   PVOID ObjectContext;
   3542   PVOID Reserved;
   3543 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
   3544 
   3545 #if (NTDDI_VERSION >= NTDDI_VISTA)
   3546 
   3547 typedef struct _REG_LOAD_KEY_INFORMATION {
   3548   PVOID Object;
   3549   PUNICODE_STRING KeyName;
   3550   PUNICODE_STRING SourceFile;
   3551   ULONG Flags;
   3552   PVOID TrustClassObject;
   3553   PVOID UserEvent;
   3554   ACCESS_MASK DesiredAccess;
   3555   PHANDLE RootHandle;
   3556   PVOID CallContext;
   3557   PVOID ObjectContext;
   3558   PVOID Reserved;
   3559 } REG_LOAD_KEY_INFORMATION, *PREG_LOAD_KEY_INFORMATION;
   3560 
   3561 typedef struct _REG_UNLOAD_KEY_INFORMATION {
   3562   PVOID Object;
   3563   PVOID UserEvent;
   3564   PVOID CallContext;
   3565   PVOID ObjectContext;
   3566   PVOID Reserved;
   3567 } REG_UNLOAD_KEY_INFORMATION, *PREG_UNLOAD_KEY_INFORMATION;
   3568 
   3569 typedef struct _REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION {
   3570   PVOID Object;
   3571   PVOID ObjectContext;
   3572   PVOID Reserved;
   3573 } REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION, *PREG_CALLBACK_CONTEXT_CLEANUP_INFORMATION;
   3574 
   3575 typedef struct _REG_QUERY_KEY_SECURITY_INFORMATION {
   3576   PVOID Object;
   3577   PSECURITY_INFORMATION SecurityInformation;
   3578   PSECURITY_DESCRIPTOR SecurityDescriptor;
   3579   PULONG Length;
   3580   PVOID CallContext;
   3581   PVOID ObjectContext;
   3582   PVOID Reserved;
   3583 } REG_QUERY_KEY_SECURITY_INFORMATION, *PREG_QUERY_KEY_SECURITY_INFORMATION;
   3584 
   3585 typedef struct _REG_SET_KEY_SECURITY_INFORMATION {
   3586   PVOID Object;
   3587   PSECURITY_INFORMATION SecurityInformation;
   3588   PSECURITY_DESCRIPTOR SecurityDescriptor;
   3589   PVOID CallContext;
   3590   PVOID ObjectContext;
   3591   PVOID Reserved;
   3592 } REG_SET_KEY_SECURITY_INFORMATION, *PREG_SET_KEY_SECURITY_INFORMATION;
   3593 
   3594 typedef struct _REG_RESTORE_KEY_INFORMATION {
   3595   PVOID Object;
   3596   HANDLE FileHandle;
   3597   ULONG Flags;
   3598   PVOID CallContext;
   3599   PVOID ObjectContext;
   3600   PVOID Reserved;
   3601 } REG_RESTORE_KEY_INFORMATION, *PREG_RESTORE_KEY_INFORMATION;
   3602 
   3603 typedef struct _REG_SAVE_KEY_INFORMATION {
   3604   PVOID Object;
   3605   HANDLE FileHandle;
   3606   ULONG Format;
   3607   PVOID CallContext;
   3608   PVOID ObjectContext;
   3609   PVOID Reserved;
   3610 } REG_SAVE_KEY_INFORMATION, *PREG_SAVE_KEY_INFORMATION;
   3611 
   3612 typedef struct _REG_REPLACE_KEY_INFORMATION {
   3613   PVOID Object;
   3614   PUNICODE_STRING OldFileName;
   3615   PUNICODE_STRING NewFileName;
   3616   PVOID CallContext;
   3617   PVOID ObjectContext;
   3618   PVOID Reserved;
   3619 } REG_REPLACE_KEY_INFORMATION, *PREG_REPLACE_KEY_INFORMATION;
   3620 
   3621 #endif /* NTDDI_VERSION >= NTDDI_VISTA */
   3622 
   3623 #define SERVICE_KERNEL_DRIVER          0x00000001
   3624 #define SERVICE_FILE_SYSTEM_DRIVER     0x00000002
   3625 #define SERVICE_ADAPTER                0x00000004
   3626 #define SERVICE_RECOGNIZER_DRIVER      0x00000008
   3627 
   3628 #define SERVICE_DRIVER                 (SERVICE_KERNEL_DRIVER | \
   3629                                         SERVICE_FILE_SYSTEM_DRIVER | \
   3630                                         SERVICE_RECOGNIZER_DRIVER)
   3631 
   3632 #define SERVICE_WIN32_OWN_PROCESS      0x00000010
   3633 #define SERVICE_WIN32_SHARE_PROCESS    0x00000020
   3634 #define SERVICE_WIN32                  (SERVICE_WIN32_OWN_PROCESS | \
   3635                                         SERVICE_WIN32_SHARE_PROCESS)
   3636 
   3637 #define SERVICE_INTERACTIVE_PROCESS    0x00000100
   3638 
   3639 #define SERVICE_TYPE_ALL               (SERVICE_WIN32  | \
   3640                                         SERVICE_ADAPTER | \
   3641                                         SERVICE_DRIVER  | \
   3642                                         SERVICE_INTERACTIVE_PROCESS)
   3643 
   3644 /* Service Start Types */
   3645 #define SERVICE_BOOT_START             0x00000000
   3646 #define SERVICE_SYSTEM_START           0x00000001
   3647 #define SERVICE_AUTO_START             0x00000002
   3648 #define SERVICE_DEMAND_START           0x00000003
   3649 #define SERVICE_DISABLED               0x00000004
   3650 
   3651 #define SERVICE_ERROR_IGNORE           0x00000000
   3652 #define SERVICE_ERROR_NORMAL           0x00000001
   3653 #define SERVICE_ERROR_SEVERE           0x00000002
   3654 #define SERVICE_ERROR_CRITICAL         0x00000003
   3655 
   3656 typedef enum _CM_SERVICE_NODE_TYPE {
   3657   DriverType = SERVICE_KERNEL_DRIVER,
   3658   FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
   3659   Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
   3660   Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
   3661   AdapterType = SERVICE_ADAPTER,
   3662   RecognizerType = SERVICE_RECOGNIZER_DRIVER
   3663 } SERVICE_NODE_TYPE;
   3664 
   3665 typedef enum _CM_SERVICE_LOAD_TYPE {
   3666   BootLoad = SERVICE_BOOT_START,
   3667   SystemLoad = SERVICE_SYSTEM_START,
   3668   AutoLoad = SERVICE_AUTO_START,
   3669   DemandLoad = SERVICE_DEMAND_START,
   3670   DisableLoad = SERVICE_DISABLED
   3671 } SERVICE_LOAD_TYPE;
   3672 
   3673 typedef enum _CM_ERROR_CONTROL_TYPE {
   3674   IgnoreError = SERVICE_ERROR_IGNORE,
   3675   NormalError = SERVICE_ERROR_NORMAL,
   3676   SevereError = SERVICE_ERROR_SEVERE,
   3677   CriticalError = SERVICE_ERROR_CRITICAL
   3678 } SERVICE_ERROR_TYPE;
   3679 
   3680 #define CM_SERVICE_NETWORK_BOOT_LOAD      0x00000001
   3681 #define CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD 0x00000002
   3682 #define CM_SERVICE_USB_DISK_BOOT_LOAD     0x00000004
   3683 
   3684 #define CM_SERVICE_VALID_PROMOTION_MASK (CM_SERVICE_NETWORK_BOOT_LOAD |       \
   3685                                          CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD |  \
   3686                                          CM_SERVICE_USB_DISK_BOOT_LOAD)
   3687 
   3688 
   3689 /******************************************************************************
   3690  *                         I/O Manager Types                                  *
   3691  ******************************************************************************/
   3692 
   3693 #define STATUS_CONTINUE_COMPLETION      STATUS_SUCCESS
   3694 
   3695 #define CONNECT_FULLY_SPECIFIED         0x1
   3696 #define CONNECT_LINE_BASED              0x2
   3697 #define CONNECT_MESSAGE_BASED           0x3
   3698 #define CONNECT_FULLY_SPECIFIED_GROUP   0x4
   3699 #define CONNECT_CURRENT_VERSION         0x4
   3700 
   3701 #define POOL_COLD_ALLOCATION                256
   3702 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE    8
   3703 #define POOL_RAISE_IF_ALLOCATION_FAILURE    16
   3704 
   3705 #define IO_TYPE_ADAPTER                 1
   3706 #define IO_TYPE_CONTROLLER              2
   3707 #define IO_TYPE_DEVICE                  3
   3708 #define IO_TYPE_DRIVER                  4
   3709 #define IO_TYPE_FILE                    5
   3710 #define IO_TYPE_IRP                     6
   3711 #define IO_TYPE_MASTER_ADAPTER          7
   3712 #define IO_TYPE_OPEN_PACKET             8
   3713 #define IO_TYPE_TIMER                   9
   3714 #define IO_TYPE_VPB                     10
   3715 #define IO_TYPE_ERROR_LOG               11
   3716 #define IO_TYPE_ERROR_MESSAGE           12
   3717 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
   3718 
   3719 #define IO_TYPE_CSQ_IRP_CONTEXT 1
   3720 #define IO_TYPE_CSQ 2
   3721 #define IO_TYPE_CSQ_EX 3
   3722 
   3723 /* IO_RESOURCE_DESCRIPTOR.Option */
   3724 #define IO_RESOURCE_PREFERRED             0x01
   3725 #define IO_RESOURCE_DEFAULT               0x02
   3726 #define IO_RESOURCE_ALTERNATIVE           0x08
   3727 
   3728 #define FILE_DEVICE_BEEP                  0x00000001
   3729 #define FILE_DEVICE_CD_ROM                0x00000002
   3730 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM    0x00000003
   3731 #define FILE_DEVICE_CONTROLLER            0x00000004
   3732 #define FILE_DEVICE_DATALINK              0x00000005
   3733 #define FILE_DEVICE_DFS                   0x00000006
   3734 #define FILE_DEVICE_DISK                  0x00000007
   3735 #define FILE_DEVICE_DISK_FILE_SYSTEM      0x00000008
   3736 #define FILE_DEVICE_FILE_SYSTEM           0x00000009
   3737 #define FILE_DEVICE_INPORT_PORT           0x0000000a
   3738 #define FILE_DEVICE_KEYBOARD              0x0000000b
   3739 #define FILE_DEVICE_MAILSLOT              0x0000000c
   3740 #define FILE_DEVICE_MIDI_IN               0x0000000d
   3741 #define FILE_DEVICE_MIDI_OUT              0x0000000e
   3742 #define FILE_DEVICE_MOUSE                 0x0000000f
   3743 #define FILE_DEVICE_MULTI_UNC_PROVIDER    0x00000010
   3744 #define FILE_DEVICE_NAMED_PIPE            0x00000011
   3745 #define FILE_DEVICE_NETWORK               0x00000012
   3746 #define FILE_DEVICE_NETWORK_BROWSER       0x00000013
   3747 #define FILE_DEVICE_NETWORK_FILE_SYSTEM   0x00000014
   3748 #define FILE_DEVICE_NULL                  0x00000015
   3749 #define FILE_DEVICE_PARALLEL_PORT         0x00000016
   3750 #define FILE_DEVICE_PHYSICAL_NETCARD      0x00000017
   3751 #define FILE_DEVICE_PRINTER               0x00000018
   3752 #define FILE_DEVICE_SCANNER               0x00000019
   3753 #define FILE_DEVICE_SERIAL_MOUSE_PORT     0x0000001a
   3754 #define FILE_DEVICE_SERIAL_PORT           0x0000001b
   3755 #define FILE_DEVICE_SCREEN                0x0000001c
   3756 #define FILE_DEVICE_SOUND                 0x0000001d
   3757 #define FILE_DEVICE_STREAMS               0x0000001e
   3758 #define FILE_DEVICE_TAPE                  0x0000001f
   3759 #define FILE_DEVICE_TAPE_FILE_SYSTEM      0x00000020
   3760 #define FILE_DEVICE_TRANSPORT             0x00000021
   3761 #define FILE_DEVICE_UNKNOWN               0x00000022
   3762 #define FILE_DEVICE_VIDEO                 0x00000023
   3763 #define FILE_DEVICE_VIRTUAL_DISK          0x00000024
   3764 #define FILE_DEVICE_WAVE_IN               0x00000025
   3765 #define FILE_DEVICE_WAVE_OUT              0x00000026
   3766 #define FILE_DEVICE_8042_PORT             0x00000027
   3767 #define FILE_DEVICE_NETWORK_REDIRECTOR    0x00000028
   3768 #define FILE_DEVICE_BATTERY               0x00000029
   3769 #define FILE_DEVICE_BUS_EXTENDER          0x0000002a
   3770 #define FILE_DEVICE_MODEM                 0x0000002b
   3771 #define FILE_DEVICE_VDM                   0x0000002c
   3772 #define FILE_DEVICE_MASS_STORAGE          0x0000002d
   3773 #define FILE_DEVICE_SMB                   0x0000002e
   3774 #define FILE_DEVICE_KS                    0x0000002f
   3775 #define FILE_DEVICE_CHANGER               0x00000030
   3776 #define FILE_DEVICE_SMARTCARD             0x00000031
   3777 #define FILE_DEVICE_ACPI                  0x00000032
   3778 #define FILE_DEVICE_DVD                   0x00000033
   3779 #define FILE_DEVICE_FULLSCREEN_VIDEO      0x00000034
   3780 #define FILE_DEVICE_DFS_FILE_SYSTEM       0x00000035
   3781 #define FILE_DEVICE_DFS_VOLUME            0x00000036
   3782 #define FILE_DEVICE_SERENUM               0x00000037
   3783 #define FILE_DEVICE_TERMSRV               0x00000038
   3784 #define FILE_DEVICE_KSEC                  0x00000039
   3785 #define FILE_DEVICE_FIPS                  0x0000003A
   3786 #define FILE_DEVICE_INFINIBAND            0x0000003B
   3787 #define FILE_DEVICE_VMBUS                 0x0000003E
   3788 #define FILE_DEVICE_CRYPT_PROVIDER        0x0000003F
   3789 #define FILE_DEVICE_WPD                   0x00000040
   3790 #define FILE_DEVICE_BLUETOOTH             0x00000041
   3791 #define FILE_DEVICE_MT_COMPOSITE          0x00000042
   3792 #define FILE_DEVICE_MT_TRANSPORT          0x00000043
   3793 #define FILE_DEVICE_BIOMETRIC             0x00000044
   3794 #define FILE_DEVICE_PMI                   0x00000045
   3795 
   3796 #if defined(NT_PROCESSOR_GROUPS)
   3797 
   3798 typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
   3799 
   3800 typedef enum _IRQ_DEVICE_POLICY_USHORT {
   3801   IrqPolicyMachineDefault = 0,
   3802   IrqPolicyAllCloseProcessors = 1,
   3803   IrqPolicyOneCloseProcessor = 2,
   3804   IrqPolicyAllProcessorsInMachine = 3,
   3805   IrqPolicyAllProcessorsInGroup = 3,
   3806   IrqPolicySpecifiedProcessors = 4,
   3807   IrqPolicySpreadMessagesAcrossAllProcessors = 5};
   3808 
   3809 #else /* defined(NT_PROCESSOR_GROUPS) */
   3810 
   3811 typedef enum _IRQ_DEVICE_POLICY {
   3812   IrqPolicyMachineDefault = 0,
   3813   IrqPolicyAllCloseProcessors,
   3814   IrqPolicyOneCloseProcessor,
   3815   IrqPolicyAllProcessorsInMachine,
   3816   IrqPolicySpecifiedProcessors,
   3817   IrqPolicySpreadMessagesAcrossAllProcessors
   3818 } IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
   3819 
   3820 #endif
   3821 
   3822 typedef enum _IRQ_PRIORITY {
   3823   IrqPriorityUndefined = 0,
   3824   IrqPriorityLow,
   3825   IrqPriorityNormal,
   3826   IrqPriorityHigh
   3827 } IRQ_PRIORITY, *PIRQ_PRIORITY;
   3828 
   3829 typedef enum _IRQ_GROUP_POLICY {
   3830   GroupAffinityAllGroupZero = 0,
   3831   GroupAffinityDontCare
   3832 } IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY;
   3833 
   3834 #define MAXIMUM_VOLUME_LABEL_LENGTH       (32 * sizeof(WCHAR))
   3835 
   3836 typedef struct _OBJECT_HANDLE_INFORMATION {
   3837   ULONG HandleAttributes;
   3838   ACCESS_MASK GrantedAccess;
   3839 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
   3840 
   3841 typedef struct _CLIENT_ID {
   3842   HANDLE UniqueProcess;
   3843   HANDLE UniqueThread;
   3844 } CLIENT_ID, *PCLIENT_ID;
   3845 
   3846 typedef struct _VPB {
   3847   CSHORT Type;
   3848   CSHORT Size;
   3849   USHORT Flags;
   3850   USHORT VolumeLabelLength;
   3851   struct _DEVICE_OBJECT *DeviceObject;
   3852   struct _DEVICE_OBJECT *RealDevice;
   3853   ULONG SerialNumber;
   3854   ULONG ReferenceCount;
   3855   WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
   3856 } VPB, *PVPB;
   3857 
   3858 typedef enum _IO_ALLOCATION_ACTION {
   3859   KeepObject = 1,
   3860   DeallocateObject,
   3861   DeallocateObjectKeepRegisters
   3862 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
   3863 
   3864 typedef IO_ALLOCATION_ACTION
   3865 (NTAPI DRIVER_CONTROL)(
   3866   IN struct _DEVICE_OBJECT *DeviceObject,
   3867   IN struct _IRP *Irp,
   3868   IN PVOID MapRegisterBase,
   3869   IN PVOID Context);
   3870 typedef DRIVER_CONTROL *PDRIVER_CONTROL;
   3871 
   3872 typedef struct _WAIT_CONTEXT_BLOCK {
   3873   KDEVICE_QUEUE_ENTRY WaitQueueEntry;
   3874   PDRIVER_CONTROL DeviceRoutine;
   3875   PVOID DeviceContext;
   3876   ULONG NumberOfMapRegisters;
   3877   PVOID DeviceObject;
   3878   PVOID CurrentIrp;
   3879   PKDPC BufferChainingDpc;
   3880 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
   3881 
   3882 /* DEVICE_OBJECT.Flags */
   3883 #define DO_VERIFY_VOLUME                  0x00000002
   3884 #define DO_BUFFERED_IO                    0x00000004
   3885 #define DO_EXCLUSIVE                      0x00000008
   3886 #define DO_DIRECT_IO                      0x00000010
   3887 #define DO_MAP_IO_BUFFER                  0x00000020
   3888 #define DO_DEVICE_INITIALIZING            0x00000080
   3889 #define DO_SHUTDOWN_REGISTERED            0x00000800
   3890 #define DO_BUS_ENUMERATED_DEVICE          0x00001000
   3891 #define DO_POWER_PAGABLE                  0x00002000
   3892 #define DO_POWER_INRUSH                   0x00004000
   3893 
   3894 /* DEVICE_OBJECT.Characteristics */
   3895 #define FILE_REMOVABLE_MEDIA              0x00000001
   3896 #define FILE_READ_ONLY_DEVICE             0x00000002
   3897 #define FILE_FLOPPY_DISKETTE              0x00000004
   3898 #define FILE_WRITE_ONCE_MEDIA             0x00000008
   3899 #define FILE_REMOTE_DEVICE                0x00000010
   3900 #define FILE_DEVICE_IS_MOUNTED            0x00000020
   3901 #define FILE_VIRTUAL_VOLUME               0x00000040
   3902 #define FILE_AUTOGENERATED_DEVICE_NAME    0x00000080
   3903 #define FILE_DEVICE_SECURE_OPEN           0x00000100
   3904 #define FILE_CHARACTERISTIC_PNP_DEVICE    0x00000800
   3905 #define FILE_CHARACTERISTIC_TS_DEVICE     0x00001000
   3906 #define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000
   3907 
   3908 /* DEVICE_OBJECT.AlignmentRequirement */
   3909 #define FILE_BYTE_ALIGNMENT             0x00000000
   3910 #define FILE_WORD_ALIGNMENT             0x00000001
   3911 #define FILE_LONG_ALIGNMENT             0x00000003
   3912 #define FILE_QUAD_ALIGNMENT             0x00000007
   3913 #define FILE_OCTA_ALIGNMENT             0x0000000f
   3914 #define FILE_32_BYTE_ALIGNMENT          0x0000001f
   3915 #define FILE_64_BYTE_ALIGNMENT          0x0000003f
   3916 #define FILE_128_BYTE_ALIGNMENT         0x0000007f
   3917 #define FILE_256_BYTE_ALIGNMENT         0x000000ff
   3918 #define FILE_512_BYTE_ALIGNMENT         0x000001ff
   3919 
   3920 /* DEVICE_OBJECT.DeviceType */
   3921 #define DEVICE_TYPE ULONG
   3922 
   3923 typedef struct _DEVICE_OBJECT {
   3924   CSHORT Type;
   3925   USHORT Size;
   3926   LONG ReferenceCount;
   3927   struct _DRIVER_OBJECT *DriverObject;
   3928   struct _DEVICE_OBJECT *NextDevice;
   3929   struct _DEVICE_OBJECT *AttachedDevice;
   3930   struct _IRP *CurrentIrp;
   3931   PIO_TIMER Timer;
   3932   ULONG Flags;
   3933   ULONG Characteristics;
   3934   volatile PVPB Vpb;
   3935   PVOID DeviceExtension;
   3936   DEVICE_TYPE DeviceType;
   3937   CCHAR StackSize;
   3938   union {
   3939     LIST_ENTRY ListEntry;
   3940     WAIT_CONTEXT_BLOCK Wcb;
   3941   } Queue;
   3942   ULONG AlignmentRequirement;
   3943   KDEVICE_QUEUE DeviceQueue;
   3944   KDPC Dpc;
   3945   ULONG ActiveThreadCount;
   3946   PSECURITY_DESCRIPTOR SecurityDescriptor;
   3947   KEVENT DeviceLock;
   3948   USHORT SectorSize;
   3949   USHORT Spare1;
   3950   struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
   3951   PVOID Reserved;
   3952 } DEVICE_OBJECT, *PDEVICE_OBJECT;
   3953 
   3954 typedef enum _IO_SESSION_STATE {
   3955   IoSessionStateCreated = 1,
   3956   IoSessionStateInitialized,
   3957   IoSessionStateConnected,
   3958   IoSessionStateDisconnected,
   3959   IoSessionStateDisconnectedLoggedOn,
   3960   IoSessionStateLoggedOn,
   3961   IoSessionStateLoggedOff,
   3962   IoSessionStateTerminated,
   3963   IoSessionStateMax
   3964 } IO_SESSION_STATE, *PIO_SESSION_STATE;
   3965 
   3966 typedef enum _IO_COMPLETION_ROUTINE_RESULT {
   3967   ContinueCompletion = STATUS_CONTINUE_COMPLETION,
   3968   StopCompletion = STATUS_MORE_PROCESSING_REQUIRED
   3969 } IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT;
   3970 
   3971 typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY {
   3972   PHYSICAL_ADDRESS MessageAddress;
   3973   KAFFINITY TargetProcessorSet;
   3974   PKINTERRUPT InterruptObject;
   3975   ULONG MessageData;
   3976   ULONG Vector;
   3977   KIRQL Irql;
   3978   KINTERRUPT_MODE Mode;
   3979   KINTERRUPT_POLARITY Polarity;
   3980 } IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY;
   3981 
   3982 typedef struct _IO_INTERRUPT_MESSAGE_INFO {
   3983   KIRQL UnifiedIrql;
   3984   ULONG MessageCount;
   3985   IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1];
   3986 } IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO;
   3987 
   3988 typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS {
   3989   IN PDEVICE_OBJECT PhysicalDeviceObject;
   3990   OUT PKINTERRUPT *InterruptObject;
   3991   IN PKSERVICE_ROUTINE ServiceRoutine;
   3992   IN PVOID ServiceContext;
   3993   IN PKSPIN_LOCK SpinLock OPTIONAL;
   3994   IN KIRQL SynchronizeIrql;
   3995   IN BOOLEAN FloatingSave;
   3996   IN BOOLEAN ShareVector;
   3997   IN ULONG Vector;
   3998   IN KIRQL Irql;
   3999   IN KINTERRUPT_MODE InterruptMode;
   4000   IN KAFFINITY ProcessorEnableMask;
   4001   IN USHORT Group;
   4002 } IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS;
   4003 
   4004 typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS {
   4005   IN PDEVICE_OBJECT PhysicalDeviceObject;
   4006   OUT PKINTERRUPT *InterruptObject;
   4007   IN PKSERVICE_ROUTINE ServiceRoutine;
   4008   IN PVOID ServiceContext;
   4009   IN PKSPIN_LOCK SpinLock OPTIONAL;
   4010   IN KIRQL SynchronizeIrql OPTIONAL;
   4011   IN BOOLEAN FloatingSave;
   4012 } IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS;
   4013 
   4014 typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS {
   4015   IN PDEVICE_OBJECT PhysicalDeviceObject;
   4016   union {
   4017     OUT PVOID *Generic;
   4018     OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable;
   4019     OUT PKINTERRUPT *InterruptObject;
   4020   } ConnectionContext;
   4021   IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine;
   4022   IN PVOID ServiceContext;
   4023   IN PKSPIN_LOCK SpinLock OPTIONAL;
   4024   IN KIRQL SynchronizeIrql OPTIONAL;
   4025   IN BOOLEAN FloatingSave;
   4026   IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL;
   4027 } IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS;
   4028 
   4029 typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS {
   4030   IN OUT ULONG Version;
   4031   _ANONYMOUS_UNION union {
   4032     IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified;
   4033     IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased;
   4034     IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased;
   4035   } DUMMYUNIONNAME;
   4036 } IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS;
   4037 
   4038 typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS {
   4039   IN ULONG Version;
   4040   union {
   4041     IN PVOID Generic;
   4042     IN PKINTERRUPT InterruptObject;
   4043     IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable;
   4044   } ConnectionContext;
   4045 } IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS;
   4046 
   4047 typedef enum _IO_ACCESS_TYPE {
   4048   ReadAccess,
   4049   WriteAccess,
   4050   ModifyAccess
   4051 } IO_ACCESS_TYPE;
   4052 
   4053 typedef enum _IO_ACCESS_MODE {
   4054   SequentialAccess,
   4055   RandomAccess
   4056 } IO_ACCESS_MODE;
   4057 
   4058 typedef enum _IO_CONTAINER_NOTIFICATION_CLASS {
   4059   IoSessionStateNotification,
   4060   IoMaxContainerNotificationClass
   4061 } IO_CONTAINER_NOTIFICATION_CLASS;
   4062 
   4063 typedef struct _IO_SESSION_STATE_NOTIFICATION {
   4064   ULONG Size;
   4065   ULONG Flags;
   4066   PVOID IoObject;
   4067   ULONG EventMask;
   4068   PVOID Context;
   4069 } IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION;
   4070 
   4071 typedef enum _IO_CONTAINER_INFORMATION_CLASS {
   4072   IoSessionStateInformation,
   4073   IoMaxContainerInformationClass
   4074 } IO_CONTAINER_INFORMATION_CLASS;
   4075 
   4076 typedef struct _IO_SESSION_STATE_INFORMATION {
   4077   ULONG SessionId;
   4078   IO_SESSION_STATE SessionState;
   4079   BOOLEAN LocalSession;
   4080 } IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION;
   4081 
   4082 #if (NTDDI_VERSION >= NTDDI_WIN7)
   4083 
   4084 typedef NTSTATUS
   4085 (NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)(
   4086   VOID);
   4087 
   4088 typedef NTSTATUS
   4089 (NTAPI IO_SESSION_NOTIFICATION_FUNCTION)(
   4090   IN PVOID SessionObject,
   4091   IN PVOID IoObject,
   4092   IN ULONG Event,
   4093   IN PVOID Context,
   4094   IN PVOID NotificationPayload,
   4095   IN ULONG PayloadLength);
   4096 
   4097 typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION;
   4098 
   4099 #endif
   4100 
   4101 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
   4102 
   4103 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
   4104   BOOLEAN Removed;
   4105   BOOLEAN Reserved[3];
   4106   volatile LONG IoCount;
   4107   KEVENT RemoveEvent;
   4108 } IO_REMOVE_LOCK_COMMON_BLOCK;
   4109 
   4110 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
   4111   LONG Signature;
   4112   LONG HighWatermark;
   4113   LONGLONG MaxLockedTicks;
   4114   LONG AllocateTag;
   4115   LIST_ENTRY LockList;
   4116   KSPIN_LOCK Spin;
   4117   volatile LONG LowMemoryCount;
   4118   ULONG Reserved1[4];
   4119   PVOID Reserved2;
   4120   PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
   4121 } IO_REMOVE_LOCK_DBG_BLOCK;
   4122 
   4123 typedef struct _IO_REMOVE_LOCK {
   4124   IO_REMOVE_LOCK_COMMON_BLOCK Common;
   4125 #if DBG
   4126   IO_REMOVE_LOCK_DBG_BLOCK Dbg;
   4127 #endif
   4128 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
   4129 
   4130 typedef struct _IO_WORKITEM *PIO_WORKITEM;
   4131 
   4132 typedef VOID
   4133 (NTAPI IO_WORKITEM_ROUTINE)(
   4134   IN PDEVICE_OBJECT DeviceObject,
   4135   IN PVOID Context);
   4136 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
   4137 
   4138 typedef VOID
   4139 (NTAPI IO_WORKITEM_ROUTINE_EX)(
   4140   IN PVOID IoObject,
   4141   IN PVOID Context OPTIONAL,
   4142   IN PIO_WORKITEM IoWorkItem);
   4143 typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX;
   4144 
   4145 typedef struct _SHARE_ACCESS {
   4146   ULONG OpenCount;
   4147   ULONG Readers;
   4148   ULONG Writers;
   4149   ULONG Deleters;
   4150   ULONG SharedRead;
   4151   ULONG SharedWrite;
   4152   ULONG SharedDelete;
   4153 } SHARE_ACCESS, *PSHARE_ACCESS;
   4154 
   4155 /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as
   4156    inheritance, even from a struct renders the type non-POD. So we use
   4157    this hack */
   4158 #define PCI_COMMON_HEADER_LAYOUT                \
   4159   USHORT VendorID;                              \
   4160   USHORT DeviceID;                              \
   4161   USHORT Command;                               \
   4162   USHORT Status;                                \
   4163   UCHAR RevisionID;                             \
   4164   UCHAR ProgIf;                                 \
   4165   UCHAR SubClass;                               \
   4166   UCHAR BaseClass;                              \
   4167   UCHAR CacheLineSize;                          \
   4168   UCHAR LatencyTimer;                           \
   4169   UCHAR HeaderType;                             \
   4170   UCHAR BIST;                                   \
   4171   union {                                       \
   4172     struct /* _PCI_HEADER_TYPE_0 */ {                 \
   4173       ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \
   4174       ULONG CIS;                                \
   4175       USHORT SubVendorID;                       \
   4176       USHORT SubSystemID;                       \
   4177       ULONG ROMBaseAddress;                     \
   4178       UCHAR CapabilitiesPtr;                    \
   4179       UCHAR Reserved1[3];                       \
   4180       ULONG Reserved2;                          \
   4181       UCHAR InterruptLine;                      \
   4182       UCHAR InterruptPin;                       \
   4183       UCHAR MinimumGrant;                       \
   4184       UCHAR MaximumLatency;                     \
   4185     } type0;                                    \
   4186     struct /* _PCI_HEADER_TYPE_1 */ {                 \
   4187       ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \
   4188       UCHAR PrimaryBus;                         \
   4189       UCHAR SecondaryBus;                       \
   4190       UCHAR SubordinateBus;                     \
   4191       UCHAR SecondaryLatency;                   \
   4192       UCHAR IOBase;                             \
   4193       UCHAR IOLimit;                            \
   4194       USHORT SecondaryStatus;                   \
   4195       USHORT MemoryBase;                        \
   4196       USHORT MemoryLimit;                       \
   4197       USHORT PrefetchBase;                      \
   4198       USHORT PrefetchLimit;                     \
   4199       ULONG PrefetchBaseUpper32;                \
   4200       ULONG PrefetchLimitUpper32;               \
   4201       USHORT IOBaseUpper16;                     \
   4202       USHORT IOLimitUpper16;                    \
   4203       UCHAR CapabilitiesPtr;                    \
   4204       UCHAR Reserved1[3];                       \
   4205       ULONG ROMBaseAddress;                     \
   4206       UCHAR InterruptLine;                      \
   4207       UCHAR InterruptPin;                       \
   4208       USHORT BridgeControl;                     \
   4209     } type1;                                    \
   4210     struct /* _PCI_HEADER_TYPE_2 */ {                 \
   4211       ULONG SocketRegistersBaseAddress;         \
   4212       UCHAR CapabilitiesPtr;                    \
   4213       UCHAR Reserved;                           \
   4214       USHORT SecondaryStatus;                   \
   4215       UCHAR PrimaryBus;                         \
   4216       UCHAR SecondaryBus;                       \
   4217       UCHAR SubordinateBus;                     \
   4218       UCHAR SecondaryLatency;                   \
   4219       struct {                                  \
   4220         ULONG Base;                             \
   4221         ULONG Limit;                            \
   4222       } Range[PCI_TYPE2_ADDRESSES-1];           \
   4223       UCHAR InterruptLine;                      \
   4224       UCHAR InterruptPin;                       \
   4225       USHORT BridgeControl;                     \
   4226     } type2;                                    \
   4227   } u;
   4228 
   4229 typedef enum _CREATE_FILE_TYPE {
   4230   CreateFileTypeNone,
   4231   CreateFileTypeNamedPipe,
   4232   CreateFileTypeMailslot
   4233 } CREATE_FILE_TYPE;
   4234 
   4235 #define IO_FORCE_ACCESS_CHECK               0x001
   4236 #define IO_NO_PARAMETER_CHECKING            0x100
   4237 
   4238 #define IO_REPARSE                      0x0
   4239 #define IO_REMOUNT                      0x1
   4240 
   4241 typedef struct _IO_STATUS_BLOCK {
   4242   _ANONYMOUS_UNION union {
   4243     NTSTATUS Status;
   4244     PVOID Pointer;
   4245   } DUMMYUNIONNAME;
   4246   ULONG_PTR Information;
   4247 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
   4248 
   4249 #if defined(_WIN64)
   4250 typedef struct _IO_STATUS_BLOCK32 {
   4251   NTSTATUS Status;
   4252   ULONG Information;
   4253 } IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32;
   4254 #endif
   4255 
   4256 typedef VOID
   4257 (NTAPI *PIO_APC_ROUTINE)(
   4258   IN PVOID ApcContext,
   4259   IN PIO_STATUS_BLOCK IoStatusBlock,
   4260   IN ULONG Reserved);
   4261 
   4262 #define PIO_APC_ROUTINE_DEFINED
   4263 
   4264 typedef enum _IO_SESSION_EVENT {
   4265   IoSessionEventIgnore = 0,
   4266   IoSessionEventCreated,
   4267   IoSessionEventTerminated,
   4268   IoSessionEventConnected,
   4269   IoSessionEventDisconnected,
   4270   IoSessionEventLogon,
   4271   IoSessionEventLogoff,
   4272   IoSessionEventMax
   4273 } IO_SESSION_EVENT, *PIO_SESSION_EVENT;
   4274 
   4275 #define IO_SESSION_STATE_ALL_EVENTS        0xffffffff
   4276 #define IO_SESSION_STATE_CREATION_EVENT    0x00000001
   4277 #define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002
   4278 #define IO_SESSION_STATE_CONNECT_EVENT     0x00000004
   4279 #define IO_SESSION_STATE_DISCONNECT_EVENT  0x00000008
   4280 #define IO_SESSION_STATE_LOGON_EVENT       0x00000010
   4281 #define IO_SESSION_STATE_LOGOFF_EVENT      0x00000020
   4282 
   4283 #define IO_SESSION_STATE_VALID_EVENT_MASK  0x0000003f
   4284 
   4285 #define IO_SESSION_MAX_PAYLOAD_SIZE        256L
   4286 
   4287 typedef struct _IO_SESSION_CONNECT_INFO {
   4288   ULONG SessionId;
   4289   BOOLEAN LocalSession;
   4290 } IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO;
   4291 
   4292 #define EVENT_INCREMENT                   1
   4293 #define IO_NO_INCREMENT                   0
   4294 #define IO_CD_ROM_INCREMENT               1
   4295 #define IO_DISK_INCREMENT                 1
   4296 #define IO_KEYBOARD_INCREMENT             6
   4297 #define IO_MAILSLOT_INCREMENT             2
   4298 #define IO_MOUSE_INCREMENT                6
   4299 #define IO_NAMED_PIPE_INCREMENT           2
   4300 #define IO_NETWORK_INCREMENT              2
   4301 #define IO_PARALLEL_INCREMENT             1
   4302 #define IO_SERIAL_INCREMENT               2
   4303 #define IO_SOUND_INCREMENT                8
   4304 #define IO_VIDEO_INCREMENT                1
   4305 #define SEMAPHORE_INCREMENT               1
   4306 
   4307 #define MM_MAXIMUM_DISK_IO_SIZE          (0x10000)
   4308 
   4309 typedef struct _BOOTDISK_INFORMATION {
   4310   LONGLONG BootPartitionOffset;
   4311   LONGLONG SystemPartitionOffset;
   4312   ULONG BootDeviceSignature;
   4313   ULONG SystemDeviceSignature;
   4314 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
   4315 
   4316 typedef struct _BOOTDISK_INFORMATION_EX {
   4317   LONGLONG BootPartitionOffset;
   4318   LONGLONG SystemPartitionOffset;
   4319   ULONG BootDeviceSignature;
   4320   ULONG SystemDeviceSignature;
   4321   GUID BootDeviceGuid;
   4322   GUID SystemDeviceGuid;
   4323   BOOLEAN BootDeviceIsGpt;
   4324   BOOLEAN SystemDeviceIsGpt;
   4325 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
   4326 
   4327 #if (NTDDI_VERSION >= NTDDI_WIN7)
   4328 
   4329 typedef struct _LOADER_PARTITION_INFORMATION_EX {
   4330   ULONG PartitionStyle;
   4331   ULONG PartitionNumber;
   4332   _ANONYMOUS_UNION union {
   4333     ULONG Signature;
   4334     GUID DeviceId;
   4335   } DUMMYUNIONNAME;
   4336   ULONG Flags;
   4337 } LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX;
   4338 
   4339 typedef struct _BOOTDISK_INFORMATION_LITE {
   4340   ULONG NumberEntries;
   4341   LOADER_PARTITION_INFORMATION_EX Entries[1];
   4342 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE;
   4343 
   4344 #else
   4345 
   4346 #if (NTDDI_VERSION >= NTDDI_VISTA)
   4347 typedef struct _BOOTDISK_INFORMATION_LITE {
   4348   ULONG BootDeviceSignature;
   4349   ULONG SystemDeviceSignature;
   4350   GUID BootDeviceGuid;
   4351   GUID SystemDeviceGuid;
   4352   BOOLEAN BootDeviceIsGpt;
   4353   BOOLEAN SystemDeviceIsGpt;
   4354 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE;
   4355 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   4356 
   4357 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   4358 
   4359 #include <pshpack1.h>
   4360 
   4361 typedef struct _EISA_MEMORY_TYPE {
   4362   UCHAR ReadWrite:1;
   4363   UCHAR Cached:1;
   4364   UCHAR Reserved0:1;
   4365   UCHAR Type:2;
   4366   UCHAR Shared:1;
   4367   UCHAR Reserved1:1;
   4368   UCHAR MoreEntries:1;
   4369 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
   4370 
   4371 typedef struct _EISA_MEMORY_CONFIGURATION {
   4372   EISA_MEMORY_TYPE ConfigurationByte;
   4373   UCHAR DataSize;
   4374   USHORT AddressLowWord;
   4375   UCHAR AddressHighByte;
   4376   USHORT MemorySize;
   4377 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
   4378 
   4379 typedef struct _EISA_IRQ_DESCRIPTOR {
   4380   UCHAR Interrupt:4;
   4381   UCHAR Reserved:1;
   4382   UCHAR LevelTriggered:1;
   4383   UCHAR Shared:1;
   4384   UCHAR MoreEntries:1;
   4385 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
   4386 
   4387 typedef struct _EISA_IRQ_CONFIGURATION {
   4388   EISA_IRQ_DESCRIPTOR ConfigurationByte;
   4389   UCHAR Reserved;
   4390 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
   4391 
   4392 typedef struct _DMA_CONFIGURATION_BYTE0 {
   4393   UCHAR Channel:3;
   4394   UCHAR Reserved:3;
   4395   UCHAR Shared:1;
   4396   UCHAR MoreEntries:1;
   4397 } DMA_CONFIGURATION_BYTE0;
   4398 
   4399 typedef struct _DMA_CONFIGURATION_BYTE1 {
   4400   UCHAR Reserved0:2;
   4401   UCHAR TransferSize:2;
   4402   UCHAR Timing:2;
   4403   UCHAR Reserved1:2;
   4404 } DMA_CONFIGURATION_BYTE1;
   4405 
   4406 typedef struct _EISA_DMA_CONFIGURATION {
   4407   DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
   4408   DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
   4409 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
   4410 
   4411 typedef struct _EISA_PORT_DESCRIPTOR {
   4412   UCHAR NumberPorts:5;
   4413   UCHAR Reserved:1;
   4414   UCHAR Shared:1;
   4415   UCHAR MoreEntries:1;
   4416 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
   4417 
   4418 typedef struct _EISA_PORT_CONFIGURATION {
   4419   EISA_PORT_DESCRIPTOR Configuration;
   4420   USHORT PortAddress;
   4421 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
   4422 
   4423 typedef struct _CM_EISA_SLOT_INFORMATION {
   4424   UCHAR ReturnCode;
   4425   UCHAR ReturnFlags;
   4426   UCHAR MajorRevision;
   4427   UCHAR MinorRevision;
   4428   USHORT Checksum;
   4429   UCHAR NumberFunctions;
   4430   UCHAR FunctionInformation;
   4431   ULONG CompressedId;
   4432 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
   4433 
   4434 typedef struct _CM_EISA_FUNCTION_INFORMATION {
   4435   ULONG CompressedId;
   4436   UCHAR IdSlotFlags1;
   4437   UCHAR IdSlotFlags2;
   4438   UCHAR MinorRevision;
   4439   UCHAR MajorRevision;
   4440   UCHAR Selections[26];
   4441   UCHAR FunctionFlags;
   4442   UCHAR TypeString[80];
   4443   EISA_MEMORY_CONFIGURATION EisaMemory[9];
   4444   EISA_IRQ_CONFIGURATION EisaIrq[7];
   4445   EISA_DMA_CONFIGURATION EisaDma[4];
   4446   EISA_PORT_CONFIGURATION EisaPort[20];
   4447   UCHAR InitializationData[60];
   4448 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
   4449 
   4450 #include <poppack.h>
   4451 
   4452 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
   4453 
   4454 #define EISA_FUNCTION_ENABLED           0x80
   4455 #define EISA_FREE_FORM_DATA             0x40
   4456 #define EISA_HAS_PORT_INIT_ENTRY        0x20
   4457 #define EISA_HAS_PORT_RANGE             0x10
   4458 #define EISA_HAS_DMA_ENTRY              0x08
   4459 #define EISA_HAS_IRQ_ENTRY              0x04
   4460 #define EISA_HAS_MEMORY_ENTRY           0x02
   4461 #define EISA_HAS_TYPE_ENTRY             0x01
   4462 #define EISA_HAS_INFORMATION \
   4463   (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
   4464   + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
   4465 
   4466 #define EISA_MORE_ENTRIES               0x80
   4467 #define EISA_SYSTEM_MEMORY              0x00
   4468 #define EISA_MEMORY_TYPE_RAM            0x01
   4469 
   4470 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
   4471 
   4472 #define EISA_INVALID_SLOT               0x80
   4473 #define EISA_INVALID_FUNCTION           0x81
   4474 #define EISA_INVALID_CONFIGURATION      0x82
   4475 #define EISA_EMPTY_SLOT                 0x83
   4476 #define EISA_INVALID_BIOS_CALL          0x86
   4477 
   4478 /*
   4479 ** Plug and Play structures
   4480 */
   4481 
   4482 typedef VOID
   4483 (NTAPI *PINTERFACE_REFERENCE)(
   4484   PVOID Context);
   4485 
   4486 typedef VOID
   4487 (NTAPI *PINTERFACE_DEREFERENCE)(
   4488   PVOID Context);
   4489 
   4490 typedef BOOLEAN
   4491 (NTAPI TRANSLATE_BUS_ADDRESS)(
   4492   IN PVOID Context,
   4493   IN PHYSICAL_ADDRESS BusAddress,
   4494   IN ULONG Length,
   4495   IN OUT PULONG AddressSpace,
   4496   OUT PPHYSICAL_ADDRESS  TranslatedAddress);
   4497 typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS;
   4498 
   4499 typedef struct _DMA_ADAPTER*
   4500 (NTAPI GET_DMA_ADAPTER)(
   4501   IN PVOID Context,
   4502   IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
   4503   OUT PULONG NumberOfMapRegisters);
   4504 typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER;
   4505 
   4506 typedef ULONG
   4507 (NTAPI GET_SET_DEVICE_DATA)(
   4508   IN PVOID Context,
   4509   IN ULONG DataType,
   4510   IN PVOID Buffer,
   4511   IN ULONG Offset,
   4512   IN ULONG Length);
   4513 typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA;
   4514 
   4515 typedef enum _DEVICE_INSTALL_STATE {
   4516   InstallStateInstalled,
   4517   InstallStateNeedsReinstall,
   4518   InstallStateFailedInstall,
   4519   InstallStateFinishInstall
   4520 } DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE;
   4521 
   4522 typedef struct _LEGACY_BUS_INFORMATION {
   4523   GUID BusTypeGuid;
   4524   INTERFACE_TYPE LegacyBusType;
   4525   ULONG BusNumber;
   4526 } LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION;
   4527 
   4528 typedef enum _DEVICE_REMOVAL_POLICY {
   4529   RemovalPolicyExpectNoRemoval = 1,
   4530   RemovalPolicyExpectOrderlyRemoval = 2,
   4531   RemovalPolicyExpectSurpriseRemoval = 3
   4532 } DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY;
   4533 
   4534 typedef VOID
   4535 (NTAPI*PREENUMERATE_SELF)(
   4536   IN PVOID Context);
   4537 
   4538 typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD {
   4539   USHORT Size;
   4540   USHORT Version;
   4541   PVOID Context;
   4542   PINTERFACE_REFERENCE InterfaceReference;
   4543   PINTERFACE_DEREFERENCE InterfaceDereference;
   4544   PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf;
   4545 } REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD;
   4546 
   4547 typedef VOID
   4548 (NTAPI *PIO_DEVICE_EJECT_CALLBACK)(
   4549   IN NTSTATUS Status,
   4550   IN OUT PVOID Context OPTIONAL);
   4551 
   4552 #define PCI_DEVICE_PRESENT_INTERFACE_VERSION     1
   4553 
   4554 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
   4555 #define PCI_USE_SUBSYSTEM_IDS   0x00000001
   4556 #define PCI_USE_REVISION        0x00000002
   4557 #define PCI_USE_VENDEV_IDS      0x00000004
   4558 #define PCI_USE_CLASS_SUBCLASS  0x00000008
   4559 #define PCI_USE_PROGIF          0x00000010
   4560 #define PCI_USE_LOCAL_BUS       0x00000020
   4561 #define PCI_USE_LOCAL_DEVICE    0x00000040
   4562 
   4563 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
   4564   ULONG Size;
   4565   ULONG Flags;
   4566   USHORT VendorID;
   4567   USHORT DeviceID;
   4568   UCHAR RevisionID;
   4569   USHORT SubVendorID;
   4570   USHORT SubSystemID;
   4571   UCHAR BaseClass;
   4572   UCHAR SubClass;
   4573   UCHAR ProgIf;
   4574 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
   4575 
   4576 typedef BOOLEAN
   4577 (NTAPI PCI_IS_DEVICE_PRESENT)(
   4578   IN USHORT VendorID,
   4579   IN USHORT DeviceID,
   4580   IN UCHAR RevisionID,
   4581   IN USHORT SubVendorID,
   4582   IN USHORT SubSystemID,
   4583   IN ULONG Flags);
   4584 typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT;
   4585 
   4586 typedef BOOLEAN
   4587 (NTAPI PCI_IS_DEVICE_PRESENT_EX)(
   4588   IN PVOID Context,
   4589   IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
   4590 typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX;
   4591 
   4592 typedef struct _BUS_INTERFACE_STANDARD {
   4593   USHORT Size;
   4594   USHORT Version;
   4595   PVOID Context;
   4596   PINTERFACE_REFERENCE InterfaceReference;
   4597   PINTERFACE_DEREFERENCE InterfaceDereference;
   4598   PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
   4599   PGET_DMA_ADAPTER GetDmaAdapter;
   4600   PGET_SET_DEVICE_DATA SetBusData;
   4601   PGET_SET_DEVICE_DATA GetBusData;
   4602 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
   4603 
   4604 typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
   4605   USHORT Size;
   4606   USHORT Version;
   4607   PVOID Context;
   4608   PINTERFACE_REFERENCE InterfaceReference;
   4609   PINTERFACE_DEREFERENCE InterfaceDereference;
   4610   PPCI_IS_DEVICE_PRESENT IsDevicePresent;
   4611   PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
   4612 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
   4613 
   4614 typedef struct _DEVICE_CAPABILITIES {
   4615   USHORT Size;
   4616   USHORT Version;
   4617   ULONG DeviceD1:1;
   4618   ULONG DeviceD2:1;
   4619   ULONG LockSupported:1;
   4620   ULONG EjectSupported:1;
   4621   ULONG Removable:1;
   4622   ULONG DockDevice:1;
   4623   ULONG UniqueID:1;
   4624   ULONG SilentInstall:1;
   4625   ULONG RawDeviceOK:1;
   4626   ULONG SurpriseRemovalOK:1;
   4627   ULONG WakeFromD0:1;
   4628   ULONG WakeFromD1:1;
   4629   ULONG WakeFromD2:1;
   4630   ULONG WakeFromD3:1;
   4631   ULONG HardwareDisabled:1;
   4632   ULONG NonDynamic:1;
   4633   ULONG WarmEjectSupported:1;
   4634   ULONG NoDisplayInUI:1;
   4635   ULONG Reserved:14;
   4636   ULONG Address;
   4637   ULONG UINumber;
   4638   DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
   4639   SYSTEM_POWER_STATE SystemWake;
   4640   DEVICE_POWER_STATE DeviceWake;
   4641   ULONG D1Latency;
   4642   ULONG D2Latency;
   4643   ULONG D3Latency;
   4644 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
   4645 
   4646 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
   4647   USHORT Version;
   4648   USHORT Size;
   4649   GUID Event;
   4650   GUID InterfaceClassGuid;
   4651   PUNICODE_STRING SymbolicLinkName;
   4652 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
   4653 
   4654 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
   4655   USHORT Version;
   4656   USHORT Size;
   4657   GUID Event;
   4658 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
   4659 
   4660 #undef INTERFACE
   4661 
   4662 typedef struct _INTERFACE {
   4663   USHORT Size;
   4664   USHORT Version;
   4665   PVOID Context;
   4666   PINTERFACE_REFERENCE InterfaceReference;
   4667   PINTERFACE_DEREFERENCE InterfaceDereference;
   4668 } INTERFACE, *PINTERFACE;
   4669 
   4670 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
   4671   USHORT Version;
   4672   USHORT Size;
   4673   GUID Event;
   4674 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
   4675 
   4676 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
   4677 
   4678 /* PNP_DEVICE_STATE */
   4679 
   4680 #define PNP_DEVICE_DISABLED                      0x00000001
   4681 #define PNP_DEVICE_DONT_DISPLAY_IN_UI            0x00000002
   4682 #define PNP_DEVICE_FAILED                        0x00000004
   4683 #define PNP_DEVICE_REMOVED                       0x00000008
   4684 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
   4685 #define PNP_DEVICE_NOT_DISABLEABLE               0x00000020
   4686 
   4687 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
   4688   USHORT Version;
   4689   USHORT Size;
   4690   GUID Event;
   4691   struct _FILE_OBJECT *FileObject;
   4692   LONG NameBufferOffset;
   4693   UCHAR CustomDataBuffer[1];
   4694 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
   4695 
   4696 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
   4697   USHORT Version;
   4698   USHORT Size;
   4699   GUID Event;
   4700   struct _FILE_OBJECT *FileObject;
   4701 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
   4702 
   4703 #if (NTDDI_VERSION >= NTDDI_VISTA)
   4704 #include <devpropdef.h>
   4705 #define PLUGPLAY_PROPERTY_PERSISTENT   0x00000001
   4706 #endif
   4707 
   4708 #define PNP_REPLACE_NO_MAP             MAXLONGLONG
   4709 
   4710 typedef NTSTATUS
   4711 (NTAPI *PREPLACE_MAP_MEMORY)(
   4712   IN PHYSICAL_ADDRESS TargetPhysicalAddress,
   4713   IN PHYSICAL_ADDRESS SparePhysicalAddress,
   4714   IN OUT PLARGE_INTEGER NumberOfBytes,
   4715   OUT PVOID *TargetAddress,
   4716   OUT PVOID *SpareAddress);
   4717 
   4718 typedef struct _PNP_REPLACE_MEMORY_LIST {
   4719   ULONG AllocatedCount;
   4720   ULONG Count;
   4721   ULONGLONG TotalLength;
   4722   struct {
   4723     PHYSICAL_ADDRESS Address;
   4724     ULONGLONG Length;
   4725   } Ranges[ANYSIZE_ARRAY];
   4726 } PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST;
   4727 
   4728 typedef struct _PNP_REPLACE_PROCESSOR_LIST {
   4729   PKAFFINITY Affinity;
   4730   ULONG GroupCount;
   4731   ULONG AllocatedCount;
   4732   ULONG Count;
   4733   ULONG ApicIds[ANYSIZE_ARRAY];
   4734 } PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST;
   4735 
   4736 typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 {
   4737   KAFFINITY AffinityMask;
   4738   ULONG AllocatedCount;
   4739   ULONG Count;
   4740   ULONG ApicIds[ANYSIZE_ARRAY];
   4741 } PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1;
   4742 
   4743 #define PNP_REPLACE_PARAMETERS_VERSION           2
   4744 
   4745 typedef struct _PNP_REPLACE_PARAMETERS {
   4746   ULONG Size;
   4747   ULONG Version;
   4748   ULONG64 Target;
   4749   ULONG64 Spare;
   4750   PPNP_REPLACE_PROCESSOR_LIST TargetProcessors;
   4751   PPNP_REPLACE_PROCESSOR_LIST SpareProcessors;
   4752   PPNP_REPLACE_MEMORY_LIST TargetMemory;
   4753   PPNP_REPLACE_MEMORY_LIST SpareMemory;
   4754   PREPLACE_MAP_MEMORY MapMemory;
   4755 } PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS;
   4756 
   4757 typedef VOID
   4758 (NTAPI *PREPLACE_UNLOAD)(
   4759   VOID);
   4760 
   4761 typedef NTSTATUS
   4762 (NTAPI *PREPLACE_BEGIN)(
   4763   IN PPNP_REPLACE_PARAMETERS Parameters,
   4764   OUT PVOID *Context);
   4765 
   4766 typedef NTSTATUS
   4767 (NTAPI *PREPLACE_END)(
   4768   IN PVOID Context);
   4769 
   4770 typedef NTSTATUS
   4771 (NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)(
   4772   IN PVOID Context,
   4773   IN PHYSICAL_ADDRESS PhysicalAddress,
   4774   IN LARGE_INTEGER ByteCount);
   4775 
   4776 typedef NTSTATUS
   4777 (NTAPI *PREPLACE_SET_PROCESSOR_ID)(
   4778   IN PVOID Context,
   4779   IN ULONG ApicId,
   4780   IN BOOLEAN Target);
   4781 
   4782 typedef NTSTATUS
   4783 (NTAPI *PREPLACE_SWAP)(
   4784   IN PVOID Context);
   4785 
   4786 typedef NTSTATUS
   4787 (NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)(
   4788   IN PVOID Context);
   4789 
   4790 typedef NTSTATUS
   4791 (NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)(
   4792   IN PVOID Context);
   4793 
   4794 typedef NTSTATUS
   4795 (NTAPI *PREPLACE_GET_MEMORY_DESTINATION)(
   4796   IN PVOID Context,
   4797   IN PHYSICAL_ADDRESS SourceAddress,
   4798   OUT PPHYSICAL_ADDRESS DestinationAddress);
   4799 
   4800 typedef NTSTATUS
   4801 (NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)(
   4802   IN PVOID Context,
   4803   IN BOOLEAN Enable);
   4804 
   4805 #define PNP_REPLACE_DRIVER_INTERFACE_VERSION      1
   4806 #define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \
   4807              FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror)
   4808 
   4809 #define PNP_REPLACE_MEMORY_SUPPORTED             0x0001
   4810 #define PNP_REPLACE_PROCESSOR_SUPPORTED          0x0002
   4811 #define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING    0x0004
   4812 #define PNP_REPLACE_HARDWARE_PAGE_COPY           0x0008
   4813 #define PNP_REPLACE_HARDWARE_QUIESCE             0x0010
   4814 
   4815 typedef struct _PNP_REPLACE_DRIVER_INTERFACE {
   4816   ULONG Size;
   4817   ULONG Version;
   4818   ULONG Flags;
   4819   PREPLACE_UNLOAD Unload;
   4820   PREPLACE_BEGIN BeginReplace;
   4821   PREPLACE_END EndReplace;
   4822   PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory;
   4823   PREPLACE_SET_PROCESSOR_ID SetProcessorId;
   4824   PREPLACE_SWAP Swap;
   4825   PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror;
   4826   PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory;
   4827   PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination;
   4828   PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce;
   4829 } PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE;
   4830 
   4831 typedef NTSTATUS
   4832 (NTAPI *PREPLACE_DRIVER_INIT)(
   4833   IN OUT PPNP_REPLACE_DRIVER_INTERFACE Interface,
   4834   IN PVOID Unused);
   4835 
   4836 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
   4837   DeviceUsageTypeUndefined,
   4838   DeviceUsageTypePaging,
   4839   DeviceUsageTypeHibernation,
   4840   DeviceUsageTypeDumpFile
   4841 } DEVICE_USAGE_NOTIFICATION_TYPE;
   4842 
   4843 typedef struct _POWER_SEQUENCE {
   4844   ULONG SequenceD1;
   4845   ULONG SequenceD2;
   4846   ULONG SequenceD3;
   4847 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
   4848 
   4849 typedef enum {
   4850   DevicePropertyDeviceDescription = 0x0,
   4851   DevicePropertyHardwareID = 0x1,
   4852   DevicePropertyCompatibleIDs = 0x2,
   4853   DevicePropertyBootConfiguration = 0x3,
   4854   DevicePropertyBootConfigurationTranslated = 0x4,
   4855   DevicePropertyClassName = 0x5,
   4856   DevicePropertyClassGuid = 0x6,
   4857   DevicePropertyDriverKeyName = 0x7,
   4858   DevicePropertyManufacturer = 0x8,
   4859   DevicePropertyFriendlyName = 0x9,
   4860   DevicePropertyLocationInformation = 0xa,
   4861   DevicePropertyPhysicalDeviceObjectName = 0xb,
   4862   DevicePropertyBusTypeGuid = 0xc,
   4863   DevicePropertyLegacyBusType = 0xd,
   4864   DevicePropertyBusNumber = 0xe,
   4865   DevicePropertyEnumeratorName = 0xf,
   4866   DevicePropertyAddress = 0x10,
   4867   DevicePropertyUINumber = 0x11,
   4868   DevicePropertyInstallState = 0x12,
   4869   DevicePropertyRemovalPolicy = 0x13,
   4870   DevicePropertyResourceRequirements = 0x14,
   4871   DevicePropertyAllocatedResources = 0x15,
   4872   DevicePropertyContainerID = 0x16
   4873 } DEVICE_REGISTRY_PROPERTY;
   4874 
   4875 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
   4876   EventCategoryReserved,
   4877   EventCategoryHardwareProfileChange,
   4878   EventCategoryDeviceInterfaceChange,
   4879   EventCategoryTargetDeviceChange
   4880 } IO_NOTIFICATION_EVENT_CATEGORY;
   4881 
   4882 typedef enum _IO_PRIORITY_HINT {
   4883   IoPriorityVeryLow = 0,
   4884   IoPriorityLow,
   4885   IoPriorityNormal,
   4886   IoPriorityHigh,
   4887   IoPriorityCritical,
   4888   MaxIoPriorityTypes
   4889 } IO_PRIORITY_HINT;
   4890 
   4891 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES    0x00000001
   4892 
   4893 typedef NTSTATUS
   4894 (NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
   4895   IN PVOID NotificationStructure,
   4896   IN PVOID Context);
   4897 typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE;
   4898 
   4899 typedef VOID
   4900 (NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)(
   4901   IN PVOID Context);
   4902 typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK;
   4903 
   4904 typedef enum _FILE_INFORMATION_CLASS {
   4905   FileDirectoryInformation = 1,
   4906   FileFullDirectoryInformation,
   4907   FileBothDirectoryInformation,
   4908   FileBasicInformation,
   4909   FileStandardInformation,
   4910   FileInternalInformation,
   4911   FileEaInformation,
   4912   FileAccessInformation,
   4913   FileNameInformation,
   4914   FileRenameInformation,
   4915   FileLinkInformation,
   4916   FileNamesInformation,
   4917   FileDispositionInformation,
   4918   FilePositionInformation,
   4919   FileFullEaInformation,
   4920   FileModeInformation,
   4921   FileAlignmentInformation,
   4922   FileAllInformation,
   4923   FileAllocationInformation,
   4924   FileEndOfFileInformation,
   4925   FileAlternateNameInformation,
   4926   FileStreamInformation,
   4927   FilePipeInformation,
   4928   FilePipeLocalInformation,
   4929   FilePipeRemoteInformation,
   4930   FileMailslotQueryInformation,
   4931   FileMailslotSetInformation,
   4932   FileCompressionInformation,
   4933   FileObjectIdInformation,
   4934   FileCompletionInformation,
   4935   FileMoveClusterInformation,
   4936   FileQuotaInformation,
   4937   FileReparsePointInformation,
   4938   FileNetworkOpenInformation,
   4939   FileAttributeTagInformation,
   4940   FileTrackingInformation,
   4941   FileIdBothDirectoryInformation,
   4942   FileIdFullDirectoryInformation,
   4943   FileValidDataLengthInformation,
   4944   FileShortNameInformation,
   4945   FileIoCompletionNotificationInformation,
   4946   FileIoStatusBlockRangeInformation,
   4947   FileIoPriorityHintInformation,
   4948   FileSfioReserveInformation,
   4949   FileSfioVolumeInformation,
   4950   FileHardLinkInformation,
   4951   FileProcessIdsUsingFileInformation,
   4952   FileNormalizedNameInformation,
   4953   FileNetworkPhysicalNameInformation,
   4954   FileIdGlobalTxDirectoryInformation,
   4955   FileIsRemoteDeviceInformation,
   4956   FileAttributeCacheInformation,
   4957   FileNumaNodeInformation,
   4958   FileStandardLinkInformation,
   4959   FileRemoteProtocolInformation,
   4960   FileMaximumInformation
   4961 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
   4962 
   4963 typedef struct _FILE_POSITION_INFORMATION {
   4964   LARGE_INTEGER CurrentByteOffset;
   4965 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
   4966 
   4967 typedef struct _FILE_BASIC_INFORMATION {
   4968   LARGE_INTEGER CreationTime;
   4969   LARGE_INTEGER LastAccessTime;
   4970   LARGE_INTEGER LastWriteTime;
   4971   LARGE_INTEGER ChangeTime;
   4972   ULONG FileAttributes;
   4973 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
   4974 
   4975 typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION {
   4976   IO_PRIORITY_HINT PriorityHint;
   4977 } FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION;
   4978 
   4979 typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION {
   4980   ULONG Flags;
   4981 } FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION;
   4982 
   4983 typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION {
   4984   PUCHAR IoStatusBlockRange;
   4985   ULONG Length;
   4986 } FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION;
   4987 
   4988 typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION {
   4989   BOOLEAN IsRemote;
   4990 } FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION;
   4991 
   4992 typedef struct _FILE_NUMA_NODE_INFORMATION {
   4993   USHORT NodeNumber;
   4994 } FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION;
   4995 
   4996 typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION {
   4997   ULONG NumberOfProcessIdsInList;
   4998   ULONG_PTR ProcessIdList[1];
   4999 } FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION;
   5000 
   5001 typedef struct _FILE_STANDARD_INFORMATION {
   5002   LARGE_INTEGER AllocationSize;
   5003   LARGE_INTEGER EndOfFile;
   5004   ULONG NumberOfLinks;
   5005   BOOLEAN DeletePending;
   5006   BOOLEAN Directory;
   5007 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
   5008 
   5009 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
   5010   LARGE_INTEGER CreationTime;
   5011   LARGE_INTEGER LastAccessTime;
   5012   LARGE_INTEGER LastWriteTime;
   5013   LARGE_INTEGER ChangeTime;
   5014   LARGE_INTEGER AllocationSize;
   5015   LARGE_INTEGER EndOfFile;
   5016   ULONG FileAttributes;
   5017 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
   5018 
   5019 typedef enum _FSINFOCLASS {
   5020   FileFsVolumeInformation = 1,
   5021   FileFsLabelInformation,
   5022   FileFsSizeInformation,
   5023   FileFsDeviceInformation,
   5024   FileFsAttributeInformation,
   5025   FileFsControlInformation,
   5026   FileFsFullSizeInformation,
   5027   FileFsObjectIdInformation,
   5028   FileFsDriverPathInformation,
   5029   FileFsVolumeFlagsInformation,
   5030   FileFsMaximumInformation
   5031 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
   5032 
   5033 typedef struct _FILE_FS_DEVICE_INFORMATION {
   5034   DEVICE_TYPE DeviceType;
   5035   ULONG Characteristics;
   5036 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
   5037 
   5038 typedef struct _FILE_FULL_EA_INFORMATION {
   5039   ULONG NextEntryOffset;
   5040   UCHAR Flags;
   5041   UCHAR EaNameLength;
   5042   USHORT EaValueLength;
   5043   CHAR EaName[1];
   5044 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
   5045 
   5046 typedef struct _FILE_SFIO_RESERVE_INFORMATION {
   5047   ULONG RequestsPerPeriod;
   5048   ULONG Period;
   5049   BOOLEAN RetryFailures;
   5050   BOOLEAN Discardable;
   5051   ULONG RequestSize;
   5052   ULONG NumOutstandingRequests;
   5053 } FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION;
   5054 
   5055 typedef struct _FILE_SFIO_VOLUME_INFORMATION {
   5056   ULONG MaximumRequestsPerPeriod;
   5057   ULONG MinimumPeriod;
   5058   ULONG MinimumTransferSize;
   5059 } FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION;
   5060 
   5061 #define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS     0x1
   5062 #define FILE_SKIP_SET_EVENT_ON_HANDLE            0x2
   5063 #define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO      0x4
   5064 
   5065 #define FM_LOCK_BIT             (0x1)
   5066 #define FM_LOCK_BIT_V           (0x0)
   5067 #define FM_LOCK_WAITER_WOKEN    (0x2)
   5068 #define FM_LOCK_WAITER_INC      (0x4)
   5069 
   5070 typedef BOOLEAN
   5071 (NTAPI FAST_IO_CHECK_IF_POSSIBLE)(
   5072   IN struct _FILE_OBJECT *FileObject,
   5073   IN PLARGE_INTEGER FileOffset,
   5074   IN ULONG Length,
   5075   IN BOOLEAN Wait,
   5076   IN ULONG LockKey,
   5077   IN BOOLEAN CheckForReadOperation,
   5078   OUT PIO_STATUS_BLOCK IoStatus,
   5079   IN struct _DEVICE_OBJECT *DeviceObject);
   5080 typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE;
   5081 
   5082 typedef BOOLEAN
   5083 (NTAPI FAST_IO_READ)(
   5084   IN struct _FILE_OBJECT *FileObject,
   5085   IN PLARGE_INTEGER FileOffset,
   5086   IN ULONG Length,
   5087   IN BOOLEAN Wait,
   5088   IN ULONG LockKey,
   5089   OUT PVOID Buffer,
   5090   OUT PIO_STATUS_BLOCK IoStatus,
   5091   IN struct _DEVICE_OBJECT *DeviceObject);
   5092 typedef FAST_IO_READ *PFAST_IO_READ;
   5093 
   5094 typedef BOOLEAN
   5095 (NTAPI FAST_IO_WRITE)(
   5096   IN struct _FILE_OBJECT *FileObject,
   5097   IN PLARGE_INTEGER FileOffset,
   5098   IN ULONG Length,
   5099   IN BOOLEAN Wait,
   5100   IN ULONG LockKey,
   5101   IN PVOID Buffer,
   5102   OUT PIO_STATUS_BLOCK IoStatus,
   5103   IN struct _DEVICE_OBJECT *DeviceObject);
   5104 typedef FAST_IO_WRITE *PFAST_IO_WRITE;
   5105 
   5106 typedef BOOLEAN
   5107 (NTAPI FAST_IO_QUERY_BASIC_INFO)(
   5108   IN struct _FILE_OBJECT *FileObject,
   5109   IN BOOLEAN Wait,
   5110   OUT PFILE_BASIC_INFORMATION Buffer,
   5111   OUT PIO_STATUS_BLOCK IoStatus,
   5112   IN struct _DEVICE_OBJECT *DeviceObject);
   5113 typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO;
   5114 
   5115 typedef BOOLEAN
   5116 (NTAPI FAST_IO_QUERY_STANDARD_INFO)(
   5117   IN struct _FILE_OBJECT *FileObject,
   5118   IN BOOLEAN Wait,
   5119   OUT PFILE_STANDARD_INFORMATION Buffer,
   5120   OUT PIO_STATUS_BLOCK IoStatus,
   5121   IN struct _DEVICE_OBJECT *DeviceObject);
   5122 typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO;
   5123 
   5124 typedef BOOLEAN
   5125 (NTAPI FAST_IO_LOCK)(
   5126   IN struct _FILE_OBJECT *FileObject,
   5127   IN PLARGE_INTEGER FileOffset,
   5128   IN PLARGE_INTEGER Length,
   5129   PEPROCESS ProcessId,
   5130   ULONG Key,
   5131   BOOLEAN FailImmediately,
   5132   BOOLEAN ExclusiveLock,
   5133   OUT PIO_STATUS_BLOCK IoStatus,
   5134   IN struct _DEVICE_OBJECT *DeviceObject);
   5135 typedef FAST_IO_LOCK *PFAST_IO_LOCK;
   5136 
   5137 typedef BOOLEAN
   5138 (NTAPI FAST_IO_UNLOCK_SINGLE)(
   5139   IN struct _FILE_OBJECT *FileObject,
   5140   IN PLARGE_INTEGER FileOffset,
   5141   IN PLARGE_INTEGER Length,
   5142   PEPROCESS ProcessId,
   5143   ULONG Key,
   5144   OUT PIO_STATUS_BLOCK IoStatus,
   5145   IN struct _DEVICE_OBJECT *DeviceObject);
   5146 typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE;
   5147 
   5148 typedef BOOLEAN
   5149 (NTAPI FAST_IO_UNLOCK_ALL)(
   5150   IN struct _FILE_OBJECT *FileObject,
   5151   PEPROCESS ProcessId,
   5152   OUT PIO_STATUS_BLOCK IoStatus,
   5153   IN struct _DEVICE_OBJECT *DeviceObject);
   5154 typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL;
   5155 
   5156 typedef BOOLEAN
   5157 (NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)(
   5158   IN struct _FILE_OBJECT *FileObject,
   5159   PVOID ProcessId,
   5160   ULONG Key,
   5161   OUT PIO_STATUS_BLOCK IoStatus,
   5162   IN struct _DEVICE_OBJECT *DeviceObject);
   5163 typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY;
   5164 
   5165 typedef BOOLEAN
   5166 (NTAPI FAST_IO_DEVICE_CONTROL)(
   5167   IN struct _FILE_OBJECT *FileObject,
   5168   IN BOOLEAN Wait,
   5169   IN PVOID InputBuffer OPTIONAL,
   5170   IN ULONG InputBufferLength,
   5171   OUT PVOID OutputBuffer OPTIONAL,
   5172   IN ULONG OutputBufferLength,
   5173   IN ULONG IoControlCode,
   5174   OUT PIO_STATUS_BLOCK IoStatus,
   5175   IN struct _DEVICE_OBJECT *DeviceObject);
   5176 typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL;
   5177 
   5178 typedef VOID
   5179 (NTAPI FAST_IO_ACQUIRE_FILE)(
   5180   IN struct _FILE_OBJECT *FileObject);
   5181 typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE;
   5182 
   5183 typedef VOID
   5184 (NTAPI FAST_IO_RELEASE_FILE)(
   5185   IN struct _FILE_OBJECT *FileObject);
   5186 typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE;
   5187 
   5188 typedef VOID
   5189 (NTAPI FAST_IO_DETACH_DEVICE)(
   5190   IN struct _DEVICE_OBJECT *SourceDevice,
   5191   IN struct _DEVICE_OBJECT *TargetDevice);
   5192 typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE;
   5193 
   5194 typedef BOOLEAN
   5195 (NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)(
   5196   IN struct _FILE_OBJECT *FileObject,
   5197   IN BOOLEAN Wait,
   5198   OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
   5199   OUT struct _IO_STATUS_BLOCK *IoStatus,
   5200   IN struct _DEVICE_OBJECT *DeviceObject);
   5201 typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO;
   5202 
   5203 typedef NTSTATUS
   5204 (NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)(
   5205   IN struct _FILE_OBJECT *FileObject,
   5206   IN PLARGE_INTEGER EndingOffset,
   5207   OUT struct _ERESOURCE **ResourceToRelease,
   5208   IN struct _DEVICE_OBJECT *DeviceObject);
   5209 typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE;
   5210 
   5211 typedef BOOLEAN
   5212 (NTAPI FAST_IO_MDL_READ)(
   5213   IN struct _FILE_OBJECT *FileObject,
   5214   IN PLARGE_INTEGER FileOffset,
   5215   IN ULONG Length,
   5216   IN ULONG LockKey,
   5217   OUT PMDL *MdlChain,
   5218   OUT PIO_STATUS_BLOCK IoStatus,
   5219   IN struct _DEVICE_OBJECT *DeviceObject);
   5220 typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ;
   5221 
   5222 typedef BOOLEAN
   5223 (NTAPI FAST_IO_MDL_READ_COMPLETE)(
   5224   IN struct _FILE_OBJECT *FileObject,
   5225   IN PMDL MdlChain,
   5226   IN struct _DEVICE_OBJECT *DeviceObject);
   5227 typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE;
   5228 
   5229 typedef BOOLEAN
   5230 (NTAPI FAST_IO_PREPARE_MDL_WRITE)(
   5231   IN struct _FILE_OBJECT *FileObject,
   5232   IN PLARGE_INTEGER FileOffset,
   5233   IN ULONG Length,
   5234   IN ULONG LockKey,
   5235   OUT PMDL *MdlChain,
   5236   OUT PIO_STATUS_BLOCK IoStatus,
   5237   IN struct _DEVICE_OBJECT *DeviceObject);
   5238 typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE;
   5239 
   5240 typedef BOOLEAN
   5241 (NTAPI FAST_IO_MDL_WRITE_COMPLETE)(
   5242   IN struct _FILE_OBJECT *FileObject,
   5243   IN PLARGE_INTEGER FileOffset,
   5244   IN PMDL MdlChain,
   5245   IN struct _DEVICE_OBJECT *DeviceObject);
   5246 typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE;
   5247 
   5248 typedef BOOLEAN
   5249 (NTAPI FAST_IO_READ_COMPRESSED)(
   5250   IN struct _FILE_OBJECT *FileObject,
   5251   IN PLARGE_INTEGER FileOffset,
   5252   IN ULONG Length,
   5253   IN ULONG LockKey,
   5254   OUT PVOID Buffer,
   5255   OUT PMDL *MdlChain,
   5256   OUT PIO_STATUS_BLOCK IoStatus,
   5257   OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
   5258   IN ULONG CompressedDataInfoLength,
   5259   IN struct _DEVICE_OBJECT *DeviceObject);
   5260 typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED;
   5261 
   5262 typedef BOOLEAN
   5263 (NTAPI FAST_IO_WRITE_COMPRESSED)(
   5264   IN struct _FILE_OBJECT *FileObject,
   5265   IN PLARGE_INTEGER FileOffset,
   5266   IN ULONG Length,
   5267   IN ULONG LockKey,
   5268   IN PVOID Buffer,
   5269   OUT PMDL *MdlChain,
   5270   OUT PIO_STATUS_BLOCK IoStatus,
   5271   IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
   5272   IN ULONG CompressedDataInfoLength,
   5273   IN struct _DEVICE_OBJECT *DeviceObject);
   5274 typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED;
   5275 
   5276 typedef BOOLEAN
   5277 (NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
   5278   IN struct _FILE_OBJECT *FileObject,
   5279   IN PMDL MdlChain,
   5280   IN struct _DEVICE_OBJECT *DeviceObject);
   5281 typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED;
   5282 
   5283 typedef BOOLEAN
   5284 (NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
   5285   IN struct _FILE_OBJECT *FileObject,
   5286   IN PLARGE_INTEGER FileOffset,
   5287   IN PMDL MdlChain,
   5288   IN struct _DEVICE_OBJECT *DeviceObject);
   5289 typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED;
   5290 
   5291 typedef BOOLEAN
   5292 (NTAPI FAST_IO_QUERY_OPEN)(
   5293   IN struct _IRP *Irp,
   5294   OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
   5295   IN struct _DEVICE_OBJECT *DeviceObject);
   5296 typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN;
   5297 
   5298 typedef NTSTATUS
   5299 (NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)(
   5300   IN struct _FILE_OBJECT *FileObject,
   5301   IN struct _ERESOURCE *ResourceToRelease,
   5302   IN struct _DEVICE_OBJECT *DeviceObject);
   5303 typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE;
   5304 
   5305 typedef NTSTATUS
   5306 (NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)(
   5307   IN struct _FILE_OBJECT *FileObject,
   5308   IN struct _DEVICE_OBJECT *DeviceObject);
   5309 typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH;
   5310 
   5311 typedef NTSTATUS
   5312 (NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)(
   5313   IN struct _FILE_OBJECT *FileObject,
   5314   IN struct _DEVICE_OBJECT *DeviceObject);
   5315 typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH;
   5316 
   5317 typedef struct _FAST_IO_DISPATCH {
   5318   ULONG SizeOfFastIoDispatch;
   5319   PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
   5320   PFAST_IO_READ FastIoRead;
   5321   PFAST_IO_WRITE FastIoWrite;
   5322   PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
   5323   PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
   5324   PFAST_IO_LOCK FastIoLock;
   5325   PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
   5326   PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
   5327   PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
   5328   PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
   5329   PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
   5330   PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
   5331   PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
   5332   PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
   5333   PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
   5334   PFAST_IO_MDL_READ MdlRead;
   5335   PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
   5336   PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
   5337   PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
   5338   PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
   5339   PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
   5340   PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
   5341   PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
   5342   PFAST_IO_QUERY_OPEN FastIoQueryOpen;
   5343   PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
   5344   PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
   5345   PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
   5346 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
   5347 
   5348 typedef struct _SECTION_OBJECT_POINTERS {
   5349   PVOID DataSectionObject;
   5350   PVOID SharedCacheMap;
   5351   PVOID ImageSectionObject;
   5352 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
   5353 
   5354 typedef struct _IO_COMPLETION_CONTEXT {
   5355   PVOID Port;
   5356   PVOID Key;
   5357 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
   5358 
   5359 /* FILE_OBJECT.Flags */
   5360 #define FO_FILE_OPEN                 0x00000001
   5361 #define FO_SYNCHRONOUS_IO            0x00000002
   5362 #define FO_ALERTABLE_IO              0x00000004
   5363 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
   5364 #define FO_WRITE_THROUGH             0x00000010
   5365 #define FO_SEQUENTIAL_ONLY           0x00000020
   5366 #define FO_CACHE_SUPPORTED           0x00000040
   5367 #define FO_NAMED_PIPE                0x00000080
   5368 #define FO_STREAM_FILE               0x00000100
   5369 #define FO_MAILSLOT                  0x00000200
   5370 #define FO_GENERATE_AUDIT_ON_CLOSE   0x00000400
   5371 #define FO_QUEUE_IRP_TO_THREAD       0x00000400
   5372 #define FO_DIRECT_DEVICE_OPEN        0x00000800
   5373 #define FO_FILE_MODIFIED             0x00001000
   5374 #define FO_FILE_SIZE_CHANGED         0x00002000
   5375 #define FO_CLEANUP_COMPLETE          0x00004000
   5376 #define FO_TEMPORARY_FILE            0x00008000
   5377 #define FO_DELETE_ON_CLOSE           0x00010000
   5378 #define FO_OPENED_CASE_SENSITIVE     0x00020000
   5379 #define FO_HANDLE_CREATED            0x00040000
   5380 #define FO_FILE_FAST_IO_READ         0x00080000
   5381 #define FO_RANDOM_ACCESS             0x00100000
   5382 #define FO_FILE_OPEN_CANCELLED       0x00200000
   5383 #define FO_VOLUME_OPEN               0x00400000
   5384 #define FO_REMOTE_ORIGIN             0x01000000
   5385 #define FO_DISALLOW_EXCLUSIVE        0x02000000
   5386 #define FO_SKIP_COMPLETION_PORT      0x02000000
   5387 #define FO_SKIP_SET_EVENT            0x04000000
   5388 #define FO_SKIP_SET_FAST_IO          0x08000000
   5389 #define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE
   5390 
   5391 /* VPB.Flags */
   5392 #define VPB_MOUNTED                       0x0001
   5393 #define VPB_LOCKED                        0x0002
   5394 #define VPB_PERSISTENT                    0x0004
   5395 #define VPB_REMOVE_PENDING                0x0008
   5396 #define VPB_RAW_MOUNT                     0x0010
   5397 #define VPB_DIRECT_WRITES_ALLOWED         0x0020
   5398 
   5399 /* IRP.Flags */
   5400 
   5401 #define SL_FORCE_ACCESS_CHECK             0x01
   5402 #define SL_OPEN_PAGING_FILE               0x02
   5403 #define SL_OPEN_TARGET_DIRECTORY          0x04
   5404 #define SL_STOP_ON_SYMLINK                0x08
   5405 #define SL_CASE_SENSITIVE                 0x80
   5406 
   5407 #define SL_KEY_SPECIFIED                  0x01
   5408 #define SL_OVERRIDE_VERIFY_VOLUME         0x02
   5409 #define SL_WRITE_THROUGH                  0x04
   5410 #define SL_FT_SEQUENTIAL_WRITE            0x08
   5411 #define SL_FORCE_DIRECT_WRITE             0x10
   5412 #define SL_REALTIME_STREAM                0x20
   5413 
   5414 #define SL_READ_ACCESS_GRANTED            0x01
   5415 #define SL_WRITE_ACCESS_GRANTED           0x04
   5416 
   5417 #define SL_FAIL_IMMEDIATELY               0x01
   5418 #define SL_EXCLUSIVE_LOCK                 0x02
   5419 
   5420 #define SL_RESTART_SCAN                   0x01
   5421 #define SL_RETURN_SINGLE_ENTRY            0x02
   5422 #define SL_INDEX_SPECIFIED                0x04
   5423 
   5424 #define SL_WATCH_TREE                     0x01
   5425 
   5426 #define SL_ALLOW_RAW_MOUNT                0x01
   5427 
   5428 #define CTL_CODE(DeviceType, Function, Method, Access) \
   5429   (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
   5430 
   5431 #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
   5432 
   5433 #define METHOD_FROM_CTL_CODE(ctrlCode)          ((ULONG)(ctrlCode & 3))
   5434 
   5435 #define IRP_NOCACHE                     0x00000001
   5436 #define IRP_PAGING_IO                   0x00000002
   5437 #define IRP_MOUNT_COMPLETION            0x00000002
   5438 #define IRP_SYNCHRONOUS_API             0x00000004
   5439 #define IRP_ASSOCIATED_IRP              0x00000008
   5440 #define IRP_BUFFERED_IO                 0x00000010
   5441 #define IRP_DEALLOCATE_BUFFER           0x00000020
   5442 #define IRP_INPUT_OPERATION             0x00000040
   5443 #define IRP_SYNCHRONOUS_PAGING_IO       0x00000040
   5444 #define IRP_CREATE_OPERATION            0x00000080
   5445 #define IRP_READ_OPERATION              0x00000100
   5446 #define IRP_WRITE_OPERATION             0x00000200
   5447 #define IRP_CLOSE_OPERATION             0x00000400
   5448 #define IRP_DEFER_IO_COMPLETION         0x00000800
   5449 #define IRP_OB_QUERY_NAME               0x00001000
   5450 #define IRP_HOLD_DEVICE_QUEUE           0x00002000
   5451 #define IRP_RETRY_IO_COMPLETION         0x00004000
   5452 #define IRP_CLASS_CACHE_OPERATION       0x00008000
   5453 
   5454 #define IRP_QUOTA_CHARGED                 0x01
   5455 #define IRP_ALLOCATED_MUST_SUCCEED        0x02
   5456 #define IRP_ALLOCATED_FIXED_SIZE          0x04
   5457 #define IRP_LOOKASIDE_ALLOCATION          0x08
   5458 
   5459 /*
   5460 ** IRP function codes
   5461 */
   5462 
   5463 #define IRP_MJ_CREATE                     0x00
   5464 #define IRP_MJ_CREATE_NAMED_PIPE          0x01
   5465 #define IRP_MJ_CLOSE                      0x02
   5466 #define IRP_MJ_READ                       0x03
   5467 #define IRP_MJ_WRITE                      0x04
   5468 #define IRP_MJ_QUERY_INFORMATION          0x05
   5469 #define IRP_MJ_SET_INFORMATION            0x06
   5470 #define IRP_MJ_QUERY_EA                   0x07
   5471 #define IRP_MJ_SET_EA                     0x08
   5472 #define IRP_MJ_FLUSH_BUFFERS              0x09
   5473 #define IRP_MJ_QUERY_VOLUME_INFORMATION   0x0a
   5474 #define IRP_MJ_SET_VOLUME_INFORMATION     0x0b
   5475 #define IRP_MJ_DIRECTORY_CONTROL          0x0c
   5476 #define IRP_MJ_FILE_SYSTEM_CONTROL        0x0d
   5477 #define IRP_MJ_DEVICE_CONTROL             0x0e
   5478 #define IRP_MJ_INTERNAL_DEVICE_CONTROL    0x0f
   5479 #define IRP_MJ_SCSI                       0x0f
   5480 #define IRP_MJ_SHUTDOWN                   0x10
   5481 #define IRP_MJ_LOCK_CONTROL               0x11
   5482 #define IRP_MJ_CLEANUP                    0x12
   5483 #define IRP_MJ_CREATE_MAILSLOT            0x13
   5484 #define IRP_MJ_QUERY_SECURITY             0x14
   5485 #define IRP_MJ_SET_SECURITY               0x15
   5486 #define IRP_MJ_POWER                      0x16
   5487 #define IRP_MJ_SYSTEM_CONTROL             0x17
   5488 #define IRP_MJ_DEVICE_CHANGE              0x18
   5489 #define IRP_MJ_QUERY_QUOTA                0x19
   5490 #define IRP_MJ_SET_QUOTA                  0x1a
   5491 #define IRP_MJ_PNP                        0x1b
   5492 #define IRP_MJ_PNP_POWER                  0x1b
   5493 #define IRP_MJ_MAXIMUM_FUNCTION           0x1b
   5494 
   5495 #define IRP_MN_SCSI_CLASS                 0x01
   5496 
   5497 #define IRP_MN_START_DEVICE               0x00
   5498 #define IRP_MN_QUERY_REMOVE_DEVICE        0x01
   5499 #define IRP_MN_REMOVE_DEVICE              0x02
   5500 #define IRP_MN_CANCEL_REMOVE_DEVICE       0x03
   5501 #define IRP_MN_STOP_DEVICE                0x04
   5502 #define IRP_MN_QUERY_STOP_DEVICE          0x05
   5503 #define IRP_MN_CANCEL_STOP_DEVICE         0x06
   5504 
   5505 #define IRP_MN_QUERY_DEVICE_RELATIONS       0x07
   5506 #define IRP_MN_QUERY_INTERFACE              0x08
   5507 #define IRP_MN_QUERY_CAPABILITIES           0x09
   5508 #define IRP_MN_QUERY_RESOURCES              0x0A
   5509 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS  0x0B
   5510 #define IRP_MN_QUERY_DEVICE_TEXT            0x0C
   5511 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
   5512 
   5513 #define IRP_MN_READ_CONFIG                  0x0F
   5514 #define IRP_MN_WRITE_CONFIG                 0x10
   5515 #define IRP_MN_EJECT                        0x11
   5516 #define IRP_MN_SET_LOCK                     0x12
   5517 #define IRP_MN_QUERY_ID                     0x13
   5518 #define IRP_MN_QUERY_PNP_DEVICE_STATE       0x14
   5519 #define IRP_MN_QUERY_BUS_INFORMATION        0x15
   5520 #define IRP_MN_DEVICE_USAGE_NOTIFICATION    0x16
   5521 #define IRP_MN_SURPRISE_REMOVAL             0x17
   5522 #if (NTDDI_VERSION >= NTDDI_WIN7)
   5523 #define IRP_MN_DEVICE_ENUMERATED            0x19
   5524 #endif
   5525 
   5526 #define IRP_MN_WAIT_WAKE                  0x00
   5527 #define IRP_MN_POWER_SEQUENCE             0x01
   5528 #define IRP_MN_SET_POWER                  0x02
   5529 #define IRP_MN_QUERY_POWER                0x03
   5530 
   5531 #define IRP_MN_QUERY_ALL_DATA             0x00
   5532 #define IRP_MN_QUERY_SINGLE_INSTANCE      0x01
   5533 #define IRP_MN_CHANGE_SINGLE_INSTANCE     0x02
   5534 #define IRP_MN_CHANGE_SINGLE_ITEM         0x03
   5535 #define IRP_MN_ENABLE_EVENTS              0x04
   5536 #define IRP_MN_DISABLE_EVENTS             0x05
   5537 #define IRP_MN_ENABLE_COLLECTION          0x06
   5538 #define IRP_MN_DISABLE_COLLECTION         0x07
   5539 #define IRP_MN_REGINFO                    0x08
   5540 #define IRP_MN_EXECUTE_METHOD             0x09
   5541 
   5542 #define IRP_MN_REGINFO_EX                 0x0b
   5543 
   5544 typedef struct _FILE_OBJECT {
   5545   CSHORT Type;
   5546   CSHORT Size;
   5547   PDEVICE_OBJECT DeviceObject;
   5548   PVPB Vpb;
   5549   PVOID FsContext;
   5550   PVOID FsContext2;
   5551   PSECTION_OBJECT_POINTERS SectionObjectPointer;
   5552   PVOID PrivateCacheMap;
   5553   NTSTATUS FinalStatus;
   5554   struct _FILE_OBJECT *RelatedFileObject;
   5555   BOOLEAN LockOperation;
   5556   BOOLEAN DeletePending;
   5557   BOOLEAN ReadAccess;
   5558   BOOLEAN WriteAccess;
   5559   BOOLEAN DeleteAccess;
   5560   BOOLEAN SharedRead;
   5561   BOOLEAN SharedWrite;
   5562   BOOLEAN SharedDelete;
   5563   ULONG Flags;
   5564   UNICODE_STRING FileName;
   5565   LARGE_INTEGER CurrentByteOffset;
   5566   volatile ULONG Waiters;
   5567   volatile ULONG Busy;
   5568   PVOID LastLock;
   5569   KEVENT Lock;
   5570   KEVENT Event;
   5571   volatile PIO_COMPLETION_CONTEXT CompletionContext;
   5572   KSPIN_LOCK IrpListLock;
   5573   LIST_ENTRY IrpList;
   5574   volatile PVOID FileObjectExtension;
   5575 } FILE_OBJECT, *PFILE_OBJECT;
   5576 
   5577 typedef struct _IO_ERROR_LOG_PACKET {
   5578   UCHAR MajorFunctionCode;
   5579   UCHAR RetryCount;
   5580   USHORT DumpDataSize;
   5581   USHORT NumberOfStrings;
   5582   USHORT StringOffset;
   5583   USHORT EventCategory;
   5584   NTSTATUS ErrorCode;
   5585   ULONG UniqueErrorValue;
   5586   NTSTATUS FinalStatus;
   5587   ULONG SequenceNumber;
   5588   ULONG IoControlCode;
   5589   LARGE_INTEGER DeviceOffset;
   5590   ULONG DumpData[1];
   5591 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
   5592 
   5593 typedef struct _IO_ERROR_LOG_MESSAGE {
   5594   USHORT Type;
   5595   USHORT Size;
   5596   USHORT DriverNameLength;
   5597   LARGE_INTEGER TimeStamp;
   5598   ULONG DriverNameOffset;
   5599   IO_ERROR_LOG_PACKET EntryData;
   5600 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
   5601 
   5602 #define ERROR_LOG_LIMIT_SIZE               240
   5603 
   5604 #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
   5605                                             sizeof(IO_ERROR_LOG_PACKET) +  \
   5606                                             (sizeof(WCHAR) * 40))
   5607 
   5608 #define ERROR_LOG_MESSAGE_LIMIT_SIZE                                       \
   5609     (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
   5610 
   5611 #define IO_ERROR_LOG_MESSAGE_LENGTH                                        \
   5612     ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ?        \
   5613         ERROR_LOG_MESSAGE_LIMIT_SIZE :                                     \
   5614         PORT_MAXIMUM_MESSAGE_LENGTH)
   5615 
   5616 #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH -              \
   5617                                 IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
   5618 
   5619 #ifdef _WIN64
   5620 #define PORT_MAXIMUM_MESSAGE_LENGTH    512
   5621 #else
   5622 #define PORT_MAXIMUM_MESSAGE_LENGTH    256
   5623 #endif
   5624 
   5625 typedef enum _DMA_WIDTH {
   5626   Width8Bits,
   5627   Width16Bits,
   5628   Width32Bits,
   5629   MaximumDmaWidth
   5630 } DMA_WIDTH, *PDMA_WIDTH;
   5631 
   5632 typedef enum _DMA_SPEED {
   5633   Compatible,
   5634   TypeA,
   5635   TypeB,
   5636   TypeC,
   5637   TypeF,
   5638   MaximumDmaSpeed
   5639 } DMA_SPEED, *PDMA_SPEED;
   5640 
   5641 /* DEVICE_DESCRIPTION.Version */
   5642 
   5643 #define DEVICE_DESCRIPTION_VERSION        0x0000
   5644 #define DEVICE_DESCRIPTION_VERSION1       0x0001
   5645 #define DEVICE_DESCRIPTION_VERSION2       0x0002
   5646 
   5647 typedef struct _DEVICE_DESCRIPTION {
   5648   ULONG Version;
   5649   BOOLEAN Master;
   5650   BOOLEAN ScatterGather;
   5651   BOOLEAN DemandMode;
   5652   BOOLEAN AutoInitialize;
   5653   BOOLEAN Dma32BitAddresses;
   5654   BOOLEAN IgnoreCount;
   5655   BOOLEAN Reserved1;
   5656   BOOLEAN Dma64BitAddresses;
   5657   ULONG BusNumber;
   5658   ULONG DmaChannel;
   5659   INTERFACE_TYPE InterfaceType;
   5660   DMA_WIDTH DmaWidth;
   5661   DMA_SPEED DmaSpeed;
   5662   ULONG MaximumLength;
   5663   ULONG DmaPort;
   5664 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
   5665 
   5666 typedef enum _DEVICE_RELATION_TYPE {
   5667   BusRelations,
   5668   EjectionRelations,
   5669   PowerRelations,
   5670   RemovalRelations,
   5671   TargetDeviceRelation,
   5672   SingleBusRelations,
   5673   TransportRelations
   5674 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
   5675 
   5676 typedef struct _DEVICE_RELATIONS {
   5677   ULONG Count;
   5678   PDEVICE_OBJECT Objects[1];
   5679 } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
   5680 
   5681 typedef struct _DEVOBJ_EXTENSION {
   5682   CSHORT Type;
   5683   USHORT Size;
   5684   PDEVICE_OBJECT DeviceObject;
   5685 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
   5686 
   5687 typedef struct _SCATTER_GATHER_ELEMENT {
   5688   PHYSICAL_ADDRESS Address;
   5689   ULONG Length;
   5690   ULONG_PTR Reserved;
   5691 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
   5692 
   5693 #if defined(_MSC_EXTENSIONS) || defined(__GNUC__)
   5694 
   5695 #if defined(_MSC_VER)
   5696 #if _MSC_VER >= 1200
   5697 #pragma warning(push)
   5698 #endif
   5699 #pragma warning(disable:4200)
   5700 #endif /* _MSC_VER */
   5701 
   5702 typedef struct _SCATTER_GATHER_LIST {
   5703   ULONG NumberOfElements;
   5704   ULONG_PTR Reserved;
   5705   SCATTER_GATHER_ELEMENT Elements[1];
   5706 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
   5707 
   5708 #if defined(_MSC_VER)
   5709 #if _MSC_VER >= 1200
   5710 #pragma warning(pop)
   5711 #else
   5712 #pragma warning(default:4200)
   5713 #endif
   5714 #endif /* _MSC_VER */
   5715 
   5716 #else /* defined(_MSC_EXTENSIONS) || defined(__GNUC__) */
   5717 
   5718 struct _SCATTER_GATHER_LIST;
   5719 typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
   5720 
   5721 #endif /* defined(_MSC_EXTENSIONS) || defined(__GNUC__) */
   5722 
   5723 typedef NTSTATUS
   5724 (NTAPI DRIVER_ADD_DEVICE)(
   5725   IN struct _DRIVER_OBJECT *DriverObject,
   5726   IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
   5727 typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
   5728 
   5729 typedef struct _DRIVER_EXTENSION {
   5730   struct _DRIVER_OBJECT *DriverObject;
   5731   PDRIVER_ADD_DEVICE AddDevice;
   5732   ULONG Count;
   5733   UNICODE_STRING ServiceKeyName;
   5734 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
   5735 
   5736 #define DRVO_UNLOAD_INVOKED               0x00000001
   5737 #define DRVO_LEGACY_DRIVER                0x00000002
   5738 #define DRVO_BUILTIN_DRIVER               0x00000004
   5739 
   5740 typedef NTSTATUS
   5741 (NTAPI DRIVER_INITIALIZE)(
   5742   IN struct _DRIVER_OBJECT *DriverObject,
   5743   IN PUNICODE_STRING RegistryPath);
   5744 typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE;
   5745 
   5746 typedef VOID
   5747 (NTAPI DRIVER_STARTIO)(
   5748   IN struct _DEVICE_OBJECT *DeviceObject,
   5749   IN struct _IRP *Irp);
   5750 typedef DRIVER_STARTIO *PDRIVER_STARTIO;
   5751 
   5752 typedef VOID
   5753 (NTAPI DRIVER_UNLOAD)(
   5754   IN struct _DRIVER_OBJECT *DriverObject);
   5755 typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
   5756 
   5757 typedef NTSTATUS
   5758 (NTAPI DRIVER_DISPATCH)(
   5759   IN struct _DEVICE_OBJECT *DeviceObject,
   5760   IN struct _IRP *Irp);
   5761 typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
   5762 
   5763 typedef struct _DRIVER_OBJECT {
   5764   CSHORT Type;
   5765   CSHORT Size;
   5766   PDEVICE_OBJECT DeviceObject;
   5767   ULONG Flags;
   5768   PVOID DriverStart;
   5769   ULONG DriverSize;
   5770   PVOID DriverSection;
   5771   PDRIVER_EXTENSION DriverExtension;
   5772   UNICODE_STRING DriverName;
   5773   PUNICODE_STRING HardwareDatabase;
   5774   struct _FAST_IO_DISPATCH *FastIoDispatch;
   5775   PDRIVER_INITIALIZE DriverInit;
   5776   PDRIVER_STARTIO DriverStartIo;
   5777   PDRIVER_UNLOAD DriverUnload;
   5778   PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
   5779 } DRIVER_OBJECT, *PDRIVER_OBJECT;
   5780 
   5781 typedef struct _DMA_ADAPTER {
   5782   USHORT Version;
   5783   USHORT Size;
   5784   struct _DMA_OPERATIONS* DmaOperations;
   5785 } DMA_ADAPTER, *PDMA_ADAPTER;
   5786 
   5787 typedef VOID
   5788 (NTAPI *PPUT_DMA_ADAPTER)(
   5789   IN PDMA_ADAPTER DmaAdapter);
   5790 
   5791 typedef PVOID
   5792 (NTAPI *PALLOCATE_COMMON_BUFFER)(
   5793   IN PDMA_ADAPTER DmaAdapter,
   5794   IN ULONG Length,
   5795   OUT PPHYSICAL_ADDRESS LogicalAddress,
   5796   IN BOOLEAN CacheEnabled);
   5797 
   5798 typedef VOID
   5799 (NTAPI *PFREE_COMMON_BUFFER)(
   5800   IN PDMA_ADAPTER DmaAdapter,
   5801   IN ULONG Length,
   5802   IN PHYSICAL_ADDRESS LogicalAddress,
   5803   IN PVOID VirtualAddress,
   5804   IN BOOLEAN CacheEnabled);
   5805 
   5806 typedef NTSTATUS
   5807 (NTAPI *PALLOCATE_ADAPTER_CHANNEL)(
   5808   IN PDMA_ADAPTER DmaAdapter,
   5809   IN PDEVICE_OBJECT DeviceObject,
   5810   IN ULONG NumberOfMapRegisters,
   5811   IN PDRIVER_CONTROL ExecutionRoutine,
   5812   IN PVOID Context);
   5813 
   5814 typedef BOOLEAN
   5815 (NTAPI *PFLUSH_ADAPTER_BUFFERS)(
   5816   IN PDMA_ADAPTER DmaAdapter,
   5817   IN PMDL Mdl,
   5818   IN PVOID MapRegisterBase,
   5819   IN PVOID CurrentVa,
   5820   IN ULONG Length,
   5821   IN BOOLEAN WriteToDevice);
   5822 
   5823 typedef VOID
   5824 (NTAPI *PFREE_ADAPTER_CHANNEL)(
   5825   IN PDMA_ADAPTER DmaAdapter);
   5826 
   5827 typedef VOID
   5828 (NTAPI *PFREE_MAP_REGISTERS)(
   5829   IN PDMA_ADAPTER DmaAdapter,
   5830   PVOID MapRegisterBase,
   5831   ULONG NumberOfMapRegisters);
   5832 
   5833 typedef PHYSICAL_ADDRESS
   5834 (NTAPI *PMAP_TRANSFER)(
   5835   IN PDMA_ADAPTER DmaAdapter,
   5836   IN PMDL Mdl,
   5837   IN PVOID MapRegisterBase,
   5838   IN PVOID CurrentVa,
   5839   IN OUT PULONG Length,
   5840   IN BOOLEAN WriteToDevice);
   5841 
   5842 typedef ULONG
   5843 (NTAPI *PGET_DMA_ALIGNMENT)(
   5844   IN PDMA_ADAPTER DmaAdapter);
   5845 
   5846 typedef ULONG
   5847 (NTAPI *PREAD_DMA_COUNTER)(
   5848   IN PDMA_ADAPTER DmaAdapter);
   5849 
   5850 typedef VOID
   5851 (NTAPI DRIVER_LIST_CONTROL)(
   5852   IN struct _DEVICE_OBJECT *DeviceObject,
   5853   IN struct _IRP *Irp,
   5854   IN struct _SCATTER_GATHER_LIST *ScatterGather,
   5855   IN PVOID Context);
   5856 typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL;
   5857 
   5858 typedef NTSTATUS
   5859 (NTAPI *PGET_SCATTER_GATHER_LIST)(
   5860   IN PDMA_ADAPTER DmaAdapter,
   5861   IN PDEVICE_OBJECT DeviceObject,
   5862   IN PMDL Mdl,
   5863   IN PVOID CurrentVa,
   5864   IN ULONG Length,
   5865   IN PDRIVER_LIST_CONTROL ExecutionRoutine,
   5866   IN PVOID Context,
   5867   IN BOOLEAN WriteToDevice);
   5868 
   5869 typedef VOID
   5870 (NTAPI *PPUT_SCATTER_GATHER_LIST)(
   5871   IN PDMA_ADAPTER DmaAdapter,
   5872   IN PSCATTER_GATHER_LIST ScatterGather,
   5873   IN BOOLEAN WriteToDevice);
   5874 
   5875 typedef NTSTATUS
   5876 (NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
   5877   IN PDMA_ADAPTER DmaAdapter,
   5878   IN PMDL Mdl OPTIONAL,
   5879   IN PVOID CurrentVa,
   5880   IN ULONG Length,
   5881   OUT PULONG ScatterGatherListSize,
   5882   OUT PULONG pNumberOfMapRegisters OPTIONAL);
   5883 
   5884 typedef NTSTATUS
   5885 (NTAPI *PBUILD_SCATTER_GATHER_LIST)(
   5886   IN PDMA_ADAPTER DmaAdapter,
   5887   IN PDEVICE_OBJECT DeviceObject,
   5888   IN PMDL Mdl,
   5889   IN PVOID CurrentVa,
   5890   IN ULONG Length,
   5891   IN PDRIVER_LIST_CONTROL ExecutionRoutine,
   5892   IN PVOID Context,
   5893   IN BOOLEAN WriteToDevice,
   5894   IN PVOID ScatterGatherBuffer,
   5895   IN ULONG ScatterGatherLength);
   5896 
   5897 typedef NTSTATUS
   5898 (NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
   5899   IN PDMA_ADAPTER DmaAdapter,
   5900   IN PSCATTER_GATHER_LIST ScatterGather,
   5901   IN PMDL OriginalMdl,
   5902   OUT PMDL *TargetMdl);
   5903 
   5904 typedef struct _DMA_OPERATIONS {
   5905   ULONG Size;
   5906   PPUT_DMA_ADAPTER PutDmaAdapter;
   5907   PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
   5908   PFREE_COMMON_BUFFER FreeCommonBuffer;
   5909   PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
   5910   PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
   5911   PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
   5912   PFREE_MAP_REGISTERS FreeMapRegisters;
   5913   PMAP_TRANSFER MapTransfer;
   5914   PGET_DMA_ALIGNMENT GetDmaAlignment;
   5915   PREAD_DMA_COUNTER ReadDmaCounter;
   5916   PGET_SCATTER_GATHER_LIST GetScatterGatherList;
   5917   PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
   5918   PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
   5919   PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
   5920   PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
   5921 } DMA_OPERATIONS, *PDMA_OPERATIONS;
   5922 
   5923 typedef struct _IO_RESOURCE_DESCRIPTOR {
   5924   UCHAR Option;
   5925   UCHAR Type;
   5926   UCHAR ShareDisposition;
   5927   UCHAR Spare1;
   5928   USHORT Flags;
   5929   USHORT Spare2;
   5930   union {
   5931     struct {
   5932       ULONG Length;
   5933       ULONG Alignment;
   5934       PHYSICAL_ADDRESS MinimumAddress;
   5935       PHYSICAL_ADDRESS MaximumAddress;
   5936     } Port;
   5937     struct {
   5938       ULONG Length;
   5939       ULONG Alignment;
   5940       PHYSICAL_ADDRESS MinimumAddress;
   5941       PHYSICAL_ADDRESS MaximumAddress;
   5942     } Memory;
   5943     struct {
   5944       ULONG MinimumVector;
   5945       ULONG MaximumVector;
   5946     } Interrupt;
   5947     struct {
   5948       ULONG MinimumChannel;
   5949       ULONG MaximumChannel;
   5950     } Dma;
   5951     struct {
   5952       ULONG Length;
   5953       ULONG Alignment;
   5954       PHYSICAL_ADDRESS MinimumAddress;
   5955       PHYSICAL_ADDRESS MaximumAddress;
   5956     } Generic;
   5957     struct {
   5958       ULONG Data[3];
   5959     } DevicePrivate;
   5960     struct {
   5961       ULONG Length;
   5962       ULONG MinBusNumber;
   5963       ULONG MaxBusNumber;
   5964       ULONG Reserved;
   5965     } BusNumber;
   5966     struct {
   5967       ULONG Priority;
   5968       ULONG Reserved1;
   5969       ULONG Reserved2;
   5970     } ConfigData;
   5971   } u;
   5972 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
   5973 
   5974 typedef struct _IO_RESOURCE_LIST {
   5975   USHORT Version;
   5976   USHORT Revision;
   5977   ULONG Count;
   5978   IO_RESOURCE_DESCRIPTOR Descriptors[1];
   5979 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
   5980 
   5981 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
   5982   ULONG ListSize;
   5983   INTERFACE_TYPE InterfaceType;
   5984   ULONG BusNumber;
   5985   ULONG SlotNumber;
   5986   ULONG Reserved[3];
   5987   ULONG AlternativeLists;
   5988   IO_RESOURCE_LIST List[1];
   5989 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
   5990 
   5991 typedef VOID
   5992 (NTAPI DRIVER_CANCEL)(
   5993   IN struct _DEVICE_OBJECT *DeviceObject,
   5994   IN struct _IRP *Irp);
   5995 typedef DRIVER_CANCEL *PDRIVER_CANCEL;
   5996 
   5997 typedef struct _IRP {
   5998   CSHORT Type;
   5999   USHORT Size;
   6000   struct _MDL *MdlAddress;
   6001   ULONG Flags;
   6002   union {
   6003     struct _IRP *MasterIrp;
   6004     volatile LONG IrpCount;
   6005     PVOID SystemBuffer;
   6006   } AssociatedIrp;
   6007   LIST_ENTRY ThreadListEntry;
   6008   IO_STATUS_BLOCK IoStatus;
   6009   KPROCESSOR_MODE RequestorMode;
   6010   BOOLEAN PendingReturned;
   6011   CHAR StackCount;
   6012   CHAR CurrentLocation;
   6013   BOOLEAN Cancel;
   6014   KIRQL CancelIrql;
   6015   CCHAR ApcEnvironment;
   6016   UCHAR AllocationFlags;
   6017   PIO_STATUS_BLOCK UserIosb;
   6018   PKEVENT UserEvent;
   6019   union {
   6020     struct {
   6021       _ANONYMOUS_UNION union {
   6022         PIO_APC_ROUTINE UserApcRoutine;
   6023         PVOID IssuingProcess;
   6024       } DUMMYUNIONNAME;
   6025       PVOID UserApcContext;
   6026     } AsynchronousParameters;
   6027     LARGE_INTEGER AllocationSize;
   6028   } Overlay;
   6029   volatile PDRIVER_CANCEL CancelRoutine;
   6030   PVOID UserBuffer;
   6031   union {
   6032     struct {
   6033       _ANONYMOUS_UNION union {
   6034         KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
   6035         _ANONYMOUS_STRUCT struct {
   6036           PVOID DriverContext[4];
   6037         } DUMMYSTRUCTNAME;
   6038       } DUMMYUNIONNAME;
   6039       PETHREAD Thread;
   6040       PCHAR AuxiliaryBuffer;
   6041       _ANONYMOUS_STRUCT struct {
   6042         LIST_ENTRY ListEntry;
   6043         _ANONYMOUS_UNION union {
   6044           struct _IO_STACK_LOCATION *CurrentStackLocation;
   6045           ULONG PacketType;
   6046         } DUMMYUNIONNAME;
   6047       } DUMMYSTRUCTNAME;
   6048       struct _FILE_OBJECT *OriginalFileObject;
   6049     } Overlay;
   6050     KAPC Apc;
   6051     PVOID CompletionKey;
   6052   } Tail;
   6053 } IRP, *PIRP;
   6054 
   6055 typedef enum _IO_PAGING_PRIORITY {
   6056   IoPagingPriorityInvalid,
   6057   IoPagingPriorityNormal,
   6058   IoPagingPriorityHigh,
   6059   IoPagingPriorityReserved1,
   6060   IoPagingPriorityReserved2
   6061 } IO_PAGING_PRIORITY;
   6062 
   6063 typedef NTSTATUS
   6064 (NTAPI IO_COMPLETION_ROUTINE)(
   6065   IN struct _DEVICE_OBJECT *DeviceObject,
   6066   IN struct _IRP *Irp,
   6067   IN PVOID Context);
   6068 typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE;
   6069 
   6070 typedef VOID
   6071 (NTAPI IO_DPC_ROUTINE)(
   6072   IN struct _KDPC *Dpc,
   6073   IN struct _DEVICE_OBJECT *DeviceObject,
   6074   IN struct _IRP *Irp,
   6075   IN PVOID Context);
   6076 typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE;
   6077 
   6078 typedef NTSTATUS
   6079 (NTAPI *PMM_DLL_INITIALIZE)(
   6080   IN PUNICODE_STRING RegistryPath);
   6081 
   6082 typedef NTSTATUS
   6083 (NTAPI *PMM_DLL_UNLOAD)(
   6084   VOID);
   6085 
   6086 typedef VOID
   6087 (NTAPI IO_TIMER_ROUTINE)(
   6088   IN struct _DEVICE_OBJECT *DeviceObject,
   6089   IN PVOID Context);
   6090 typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE;
   6091 
   6092 typedef struct _IO_SECURITY_CONTEXT {
   6093   PSECURITY_QUALITY_OF_SERVICE SecurityQos;
   6094   PACCESS_STATE AccessState;
   6095   ACCESS_MASK DesiredAccess;
   6096   ULONG FullCreateOptions;
   6097 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
   6098 
   6099 struct _IO_CSQ;
   6100 
   6101 typedef struct _IO_CSQ_IRP_CONTEXT {
   6102   ULONG Type;
   6103   struct _IRP *Irp;
   6104   struct _IO_CSQ *Csq;
   6105 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
   6106 
   6107 typedef VOID
   6108 (NTAPI *PIO_CSQ_INSERT_IRP)(
   6109   IN struct _IO_CSQ *Csq,
   6110   IN PIRP Irp);
   6111 
   6112 typedef NTSTATUS
   6113 (NTAPI IO_CSQ_INSERT_IRP_EX)(
   6114   IN struct _IO_CSQ *Csq,
   6115   IN PIRP Irp,
   6116   IN PVOID InsertContext);
   6117 typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX;
   6118 
   6119 typedef VOID
   6120 (NTAPI *PIO_CSQ_REMOVE_IRP)(
   6121   IN struct _IO_CSQ *Csq,
   6122   IN PIRP Irp);
   6123 
   6124 typedef PIRP
   6125 (NTAPI *PIO_CSQ_PEEK_NEXT_IRP)(
   6126   IN struct _IO_CSQ *Csq,
   6127   IN PIRP Irp,
   6128   IN PVOID PeekContext);
   6129 
   6130 typedef VOID
   6131 (NTAPI *PIO_CSQ_ACQUIRE_LOCK)(
   6132   IN struct _IO_CSQ *Csq,
   6133   OUT PKIRQL Irql);
   6134 
   6135 typedef VOID
   6136 (NTAPI *PIO_CSQ_RELEASE_LOCK)(
   6137   IN struct _IO_CSQ *Csq,
   6138   IN KIRQL Irql);
   6139 
   6140 typedef VOID
   6141 (NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
   6142   IN struct _IO_CSQ *Csq,
   6143   IN PIRP Irp);
   6144 
   6145 typedef struct _IO_CSQ {
   6146   ULONG Type;
   6147   PIO_CSQ_INSERT_IRP CsqInsertIrp;
   6148   PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
   6149   PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
   6150   PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
   6151   PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
   6152   PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
   6153   PVOID ReservePointer;
   6154 } IO_CSQ, *PIO_CSQ;
   6155 
   6156 typedef enum _BUS_QUERY_ID_TYPE {
   6157   BusQueryDeviceID,
   6158   BusQueryHardwareIDs,
   6159   BusQueryCompatibleIDs,
   6160   BusQueryInstanceID,
   6161   BusQueryDeviceSerialNumber
   6162 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
   6163 
   6164 typedef enum _DEVICE_TEXT_TYPE {
   6165   DeviceTextDescription,
   6166   DeviceTextLocationInformation
   6167 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
   6168 
   6169 typedef BOOLEAN
   6170 (NTAPI *PGPE_SERVICE_ROUTINE)(
   6171   PVOID,
   6172   PVOID);
   6173 
   6174 typedef NTSTATUS
   6175 (NTAPI *PGPE_CONNECT_VECTOR)(
   6176   PDEVICE_OBJECT,
   6177   ULONG,
   6178   KINTERRUPT_MODE,
   6179   BOOLEAN,
   6180   PGPE_SERVICE_ROUTINE,
   6181   PVOID,
   6182   PVOID);
   6183 
   6184 typedef NTSTATUS
   6185 (NTAPI *PGPE_DISCONNECT_VECTOR)(
   6186   PVOID);
   6187 
   6188 typedef NTSTATUS
   6189 (NTAPI *PGPE_ENABLE_EVENT)(
   6190   PDEVICE_OBJECT,
   6191   PVOID);
   6192 
   6193 typedef NTSTATUS
   6194 (NTAPI *PGPE_DISABLE_EVENT)(
   6195   PDEVICE_OBJECT,
   6196   PVOID);
   6197 
   6198 typedef NTSTATUS
   6199 (NTAPI *PGPE_CLEAR_STATUS)(
   6200   PDEVICE_OBJECT,
   6201   PVOID);
   6202 
   6203 typedef VOID
   6204 (NTAPI *PDEVICE_NOTIFY_CALLBACK)(
   6205   PVOID,
   6206   ULONG);
   6207 
   6208 typedef NTSTATUS
   6209 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)(
   6210   PDEVICE_OBJECT,
   6211   PDEVICE_NOTIFY_CALLBACK,
   6212   PVOID);
   6213 
   6214 typedef VOID
   6215 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)(
   6216   PDEVICE_OBJECT,
   6217   PDEVICE_NOTIFY_CALLBACK);
   6218 
   6219 typedef struct _ACPI_INTERFACE_STANDARD {
   6220   USHORT Size;
   6221   USHORT Version;
   6222   PVOID Context;
   6223   PINTERFACE_REFERENCE InterfaceReference;
   6224   PINTERFACE_DEREFERENCE InterfaceDereference;
   6225   PGPE_CONNECT_VECTOR GpeConnectVector;
   6226   PGPE_DISCONNECT_VECTOR GpeDisconnectVector;
   6227   PGPE_ENABLE_EVENT GpeEnableEvent;
   6228   PGPE_DISABLE_EVENT GpeDisableEvent;
   6229   PGPE_CLEAR_STATUS GpeClearStatus;
   6230   PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications;
   6231   PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications;
   6232 } ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
   6233 
   6234 typedef BOOLEAN
   6235 (NTAPI *PGPE_SERVICE_ROUTINE2)(
   6236   PVOID ObjectContext,
   6237   PVOID ServiceContext);
   6238 
   6239 typedef NTSTATUS
   6240 (NTAPI *PGPE_CONNECT_VECTOR2)(
   6241   PVOID Context,
   6242   ULONG GpeNumber,
   6243   KINTERRUPT_MODE Mode,
   6244   BOOLEAN Shareable,
   6245   PGPE_SERVICE_ROUTINE ServiceRoutine,
   6246   PVOID ServiceContext,
   6247   PVOID *ObjectContext);
   6248 
   6249 typedef NTSTATUS
   6250 (NTAPI *PGPE_DISCONNECT_VECTOR2)(
   6251   PVOID Context,
   6252   PVOID ObjectContext);
   6253 
   6254 typedef NTSTATUS
   6255 (NTAPI *PGPE_ENABLE_EVENT2)(
   6256   PVOID Context,
   6257   PVOID ObjectContext);
   6258 
   6259 typedef NTSTATUS
   6260 (NTAPI *PGPE_DISABLE_EVENT2)(
   6261   PVOID Context,
   6262   PVOID ObjectContext);
   6263 
   6264 typedef NTSTATUS
   6265 (NTAPI *PGPE_CLEAR_STATUS2)(
   6266   PVOID Context,
   6267   PVOID ObjectContext);
   6268 
   6269 typedef VOID
   6270 (NTAPI *PDEVICE_NOTIFY_CALLBACK2)(
   6271   PVOID NotificationContext,
   6272   ULONG NotifyCode);
   6273 
   6274 typedef NTSTATUS
   6275 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
   6276   PVOID Context,
   6277   PDEVICE_NOTIFY_CALLBACK2 NotificationHandler,
   6278   PVOID NotificationContext);
   6279 
   6280 typedef VOID
   6281 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
   6282   PVOID Context);
   6283 
   6284 typedef struct _ACPI_INTERFACE_STANDARD2 {
   6285   USHORT Size;
   6286   USHORT Version;
   6287   PVOID Context;
   6288   PINTERFACE_REFERENCE InterfaceReference;
   6289   PINTERFACE_DEREFERENCE InterfaceDereference;
   6290   PGPE_CONNECT_VECTOR2 GpeConnectVector;
   6291   PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector;
   6292   PGPE_ENABLE_EVENT2 GpeEnableEvent;
   6293   PGPE_DISABLE_EVENT2 GpeDisableEvent;
   6294   PGPE_CLEAR_STATUS2 GpeClearStatus;
   6295   PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications;
   6296   PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications;
   6297 } ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2;
   6298 
   6299 #if !defined(_AMD64_) && !defined(_IA64_)
   6300 #include <pshpack4.h>
   6301 #endif
   6302 typedef struct _IO_STACK_LOCATION {
   6303   UCHAR MajorFunction;
   6304   UCHAR MinorFunction;
   6305   UCHAR Flags;
   6306   UCHAR Control;
   6307   union {
   6308     struct {
   6309       PIO_SECURITY_CONTEXT SecurityContext;
   6310       ULONG Options;
   6311       USHORT POINTER_ALIGNMENT FileAttributes;
   6312       USHORT ShareAccess;
   6313       ULONG POINTER_ALIGNMENT EaLength;
   6314     } Create;
   6315     struct {
   6316       ULONG Length;
   6317       ULONG POINTER_ALIGNMENT Key;
   6318       LARGE_INTEGER ByteOffset;
   6319     } Read;
   6320     struct {
   6321       ULONG Length;
   6322       ULONG POINTER_ALIGNMENT Key;
   6323       LARGE_INTEGER ByteOffset;
   6324     } Write;
   6325     struct {
   6326       ULONG Length;
   6327       PUNICODE_STRING FileName;
   6328       FILE_INFORMATION_CLASS FileInformationClass;
   6329       ULONG FileIndex;
   6330     } QueryDirectory;
   6331     struct {
   6332       ULONG Length;
   6333       ULONG CompletionFilter;
   6334     } NotifyDirectory;
   6335     struct {
   6336       ULONG Length;
   6337       FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
   6338     } QueryFile;
   6339     struct {
   6340       ULONG Length;
   6341       FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
   6342       PFILE_OBJECT FileObject;
   6343       _ANONYMOUS_UNION union {
   6344         _ANONYMOUS_STRUCT struct {
   6345           BOOLEAN ReplaceIfExists;
   6346           BOOLEAN AdvanceOnly;
   6347         } DUMMYSTRUCTNAME;
   6348         ULONG ClusterCount;
   6349         HANDLE DeleteHandle;
   6350       } DUMMYUNIONNAME;
   6351     } SetFile;
   6352     struct {
   6353       ULONG Length;
   6354       PVOID EaList;
   6355       ULONG EaListLength;
   6356       ULONG EaIndex;
   6357     } QueryEa;
   6358     struct {
   6359       ULONG Length;
   6360     } SetEa;
   6361     struct {
   6362       ULONG Length;
   6363       FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
   6364     } QueryVolume;
   6365     struct {
   6366       ULONG Length;
   6367       FS_INFORMATION_CLASS FsInformationClass;
   6368     } SetVolume;
   6369     struct {
   6370       ULONG OutputBufferLength;
   6371       ULONG InputBufferLength;
   6372       ULONG FsControlCode;
   6373       PVOID Type3InputBuffer;
   6374     } FileSystemControl;
   6375     struct {
   6376       PLARGE_INTEGER Length;
   6377       ULONG Key;
   6378       LARGE_INTEGER ByteOffset;
   6379     } LockControl;
   6380     struct {
   6381       ULONG OutputBufferLength;
   6382       ULONG POINTER_ALIGNMENT InputBufferLength;
   6383       ULONG POINTER_ALIGNMENT IoControlCode;
   6384       PVOID Type3InputBuffer;
   6385     } DeviceIoControl;
   6386     struct {
   6387       SECURITY_INFORMATION SecurityInformation;
   6388       ULONG POINTER_ALIGNMENT Length;
   6389     } QuerySecurity;
   6390     struct {
   6391       SECURITY_INFORMATION SecurityInformation;
   6392       PSECURITY_DESCRIPTOR SecurityDescriptor;
   6393     } SetSecurity;
   6394     struct {
   6395       PVPB Vpb;
   6396       PDEVICE_OBJECT DeviceObject;
   6397     } MountVolume;
   6398     struct {
   6399       PVPB Vpb;
   6400       PDEVICE_OBJECT DeviceObject;
   6401     } VerifyVolume;
   6402     struct {
   6403       struct _SCSI_REQUEST_BLOCK *Srb;
   6404     } Scsi;
   6405     struct {
   6406       ULONG Length;
   6407       PSID StartSid;
   6408       struct _FILE_GET_QUOTA_INFORMATION *SidList;
   6409       ULONG SidListLength;
   6410     } QueryQuota;
   6411     struct {
   6412       ULONG Length;
   6413     } SetQuota;
   6414     struct {
   6415       DEVICE_RELATION_TYPE Type;
   6416     } QueryDeviceRelations;
   6417     struct {
   6418       CONST GUID *InterfaceType;
   6419       USHORT Size;
   6420       USHORT Version;
   6421       PINTERFACE Interface;
   6422       PVOID InterfaceSpecificData;
   6423     } QueryInterface;
   6424     struct {
   6425       PDEVICE_CAPABILITIES Capabilities;
   6426     } DeviceCapabilities;
   6427     struct {
   6428       PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
   6429     } FilterResourceRequirements;
   6430     struct {
   6431       ULONG WhichSpace;
   6432       PVOID Buffer;
   6433       ULONG Offset;
   6434       ULONG POINTER_ALIGNMENT Length;
   6435     } ReadWriteConfig;
   6436     struct {
   6437       BOOLEAN Lock;
   6438     } SetLock;
   6439     struct {
   6440       BUS_QUERY_ID_TYPE IdType;
   6441     } QueryId;
   6442     struct {
   6443       DEVICE_TEXT_TYPE DeviceTextType;
   6444       LCID POINTER_ALIGNMENT LocaleId;
   6445     } QueryDeviceText;
   6446     struct {
   6447       BOOLEAN InPath;
   6448       BOOLEAN Reserved[3];
   6449       DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
   6450     } UsageNotification;
   6451     struct {
   6452       SYSTEM_POWER_STATE PowerState;
   6453     } WaitWake;
   6454     struct {
   6455       PPOWER_SEQUENCE PowerSequence;
   6456     } PowerSequence;
   6457     struct {
   6458       ULONG SystemContext;
   6459       POWER_STATE_TYPE POINTER_ALIGNMENT Type;
   6460       POWER_STATE POINTER_ALIGNMENT State;
   6461       POWER_ACTION POINTER_ALIGNMENT ShutdownType;
   6462     } Power;
   6463     struct {
   6464       PCM_RESOURCE_LIST AllocatedResources;
   6465       PCM_RESOURCE_LIST AllocatedResourcesTranslated;
   6466     } StartDevice;
   6467     struct {
   6468       ULONG_PTR ProviderId;
   6469       PVOID DataPath;
   6470       ULONG BufferSize;
   6471       PVOID Buffer;
   6472     } WMI;
   6473     struct {
   6474       PVOID Argument1;
   6475       PVOID Argument2;
   6476       PVOID Argument3;
   6477       PVOID Argument4;
   6478     } Others;
   6479   } Parameters;
   6480   PDEVICE_OBJECT DeviceObject;
   6481   PFILE_OBJECT FileObject;
   6482   PIO_COMPLETION_ROUTINE CompletionRoutine;
   6483   PVOID Context;
   6484 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
   6485 #if !defined(_AMD64_) && !defined(_IA64_)
   6486 #include <poppack.h>
   6487 #endif
   6488 
   6489 /* IO_STACK_LOCATION.Control */
   6490 
   6491 #define SL_PENDING_RETURNED               0x01
   6492 #define SL_ERROR_RETURNED                 0x02
   6493 #define SL_INVOKE_ON_CANCEL               0x20
   6494 #define SL_INVOKE_ON_SUCCESS              0x40
   6495 #define SL_INVOKE_ON_ERROR                0x80
   6496 
   6497 #define METHOD_BUFFERED                   0
   6498 #define METHOD_IN_DIRECT                  1
   6499 #define METHOD_OUT_DIRECT                 2
   6500 #define METHOD_NEITHER                    3
   6501 
   6502 #define METHOD_DIRECT_TO_HARDWARE       METHOD_IN_DIRECT
   6503 #define METHOD_DIRECT_FROM_HARDWARE     METHOD_OUT_DIRECT
   6504 
   6505 #define FILE_SUPERSEDED                   0x00000000
   6506 #define FILE_OPENED                       0x00000001
   6507 #define FILE_CREATED                      0x00000002
   6508 #define FILE_OVERWRITTEN                  0x00000003
   6509 #define FILE_EXISTS                       0x00000004
   6510 #define FILE_DOES_NOT_EXIST               0x00000005
   6511 
   6512 #define FILE_USE_FILE_POINTER_POSITION    0xfffffffe
   6513 #define FILE_WRITE_TO_END_OF_FILE         0xffffffff
   6514 
   6515 /* also in winnt.h */
   6516 #define FILE_LIST_DIRECTORY               0x00000001
   6517 #define FILE_READ_DATA                    0x00000001
   6518 #define FILE_ADD_FILE                     0x00000002
   6519 #define FILE_WRITE_DATA                   0x00000002
   6520 #define FILE_ADD_SUBDIRECTORY             0x00000004
   6521 #define FILE_APPEND_DATA                  0x00000004
   6522 #define FILE_CREATE_PIPE_INSTANCE         0x00000004
   6523 #define FILE_READ_EA                      0x00000008
   6524 #define FILE_WRITE_EA                     0x00000010
   6525 #define FILE_EXECUTE                      0x00000020
   6526 #define FILE_TRAVERSE                     0x00000020
   6527 #define FILE_DELETE_CHILD                 0x00000040
   6528 #define FILE_READ_ATTRIBUTES              0x00000080
   6529 #define FILE_WRITE_ATTRIBUTES             0x00000100
   6530 
   6531 #define FILE_SHARE_READ                   0x00000001
   6532 #define FILE_SHARE_WRITE                  0x00000002
   6533 #define FILE_SHARE_DELETE                 0x00000004
   6534 #define FILE_SHARE_VALID_FLAGS            0x00000007
   6535 
   6536 #define FILE_ATTRIBUTE_READONLY           0x00000001
   6537 #define FILE_ATTRIBUTE_HIDDEN             0x00000002
   6538 #define FILE_ATTRIBUTE_SYSTEM             0x00000004
   6539 #define FILE_ATTRIBUTE_DIRECTORY          0x00000010
   6540 #define FILE_ATTRIBUTE_ARCHIVE            0x00000020
   6541 #define FILE_ATTRIBUTE_DEVICE             0x00000040
   6542 #define FILE_ATTRIBUTE_NORMAL             0x00000080
   6543 #define FILE_ATTRIBUTE_TEMPORARY          0x00000100
   6544 #define FILE_ATTRIBUTE_SPARSE_FILE        0x00000200
   6545 #define FILE_ATTRIBUTE_REPARSE_POINT      0x00000400
   6546 #define FILE_ATTRIBUTE_COMPRESSED         0x00000800
   6547 #define FILE_ATTRIBUTE_OFFLINE            0x00001000
   6548 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
   6549 #define FILE_ATTRIBUTE_ENCRYPTED          0x00004000
   6550 #define FILE_ATTRIBUTE_VIRTUAL            0x00010000
   6551 
   6552 #define FILE_ATTRIBUTE_VALID_FLAGS        0x00007fb7
   6553 #define FILE_ATTRIBUTE_VALID_SET_FLAGS    0x000031a7
   6554 
   6555 #define FILE_VALID_OPTION_FLAGS           0x00ffffff
   6556 #define FILE_VALID_PIPE_OPTION_FLAGS      0x00000032
   6557 #define FILE_VALID_MAILSLOT_OPTION_FLAGS  0x00000032
   6558 #define FILE_VALID_SET_FLAGS              0x00000036
   6559 
   6560 #define FILE_SUPERSEDE                    0x00000000
   6561 #define FILE_OPEN                         0x00000001
   6562 #define FILE_CREATE                       0x00000002
   6563 #define FILE_OPEN_IF                      0x00000003
   6564 #define FILE_OVERWRITE                    0x00000004
   6565 #define FILE_OVERWRITE_IF                 0x00000005
   6566 #define FILE_MAXIMUM_DISPOSITION          0x00000005
   6567 
   6568 #define FILE_DIRECTORY_FILE               0x00000001
   6569 #define FILE_WRITE_THROUGH                0x00000002
   6570 #define FILE_SEQUENTIAL_ONLY              0x00000004
   6571 #define FILE_NO_INTERMEDIATE_BUFFERING    0x00000008
   6572 #define FILE_SYNCHRONOUS_IO_ALERT         0x00000010
   6573 #define FILE_SYNCHRONOUS_IO_NONALERT      0x00000020
   6574 #define FILE_NON_DIRECTORY_FILE           0x00000040
   6575 #define FILE_CREATE_TREE_CONNECTION       0x00000080
   6576 #define FILE_COMPLETE_IF_OPLOCKED         0x00000100
   6577 #define FILE_NO_EA_KNOWLEDGE              0x00000200
   6578 #define FILE_OPEN_REMOTE_INSTANCE         0x00000400
   6579 #define FILE_RANDOM_ACCESS                0x00000800
   6580 #define FILE_DELETE_ON_CLOSE              0x00001000
   6581 #define FILE_OPEN_BY_FILE_ID              0x00002000
   6582 #define FILE_OPEN_FOR_BACKUP_INTENT       0x00004000
   6583 #define FILE_NO_COMPRESSION               0x00008000
   6584 #if (NTDDI_VERSION >= NTDDI_WIN7)
   6585 #define FILE_OPEN_REQUIRING_OPLOCK        0x00010000
   6586 #define FILE_DISALLOW_EXCLUSIVE           0x00020000
   6587 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   6588 #define FILE_RESERVE_OPFILTER             0x00100000
   6589 #define FILE_OPEN_REPARSE_POINT           0x00200000
   6590 #define FILE_OPEN_NO_RECALL               0x00400000
   6591 #define FILE_OPEN_FOR_FREE_SPACE_QUERY    0x00800000
   6592 
   6593 #define FILE_ANY_ACCESS                   0x00000000
   6594 #define FILE_SPECIAL_ACCESS               FILE_ANY_ACCESS
   6595 #define FILE_READ_ACCESS                  0x00000001
   6596 #define FILE_WRITE_ACCESS                 0x00000002
   6597 
   6598 #define FILE_ALL_ACCESS \
   6599   (STANDARD_RIGHTS_REQUIRED | \
   6600    SYNCHRONIZE | \
   6601    0x1FF)
   6602 
   6603 #define FILE_GENERIC_EXECUTE \
   6604   (STANDARD_RIGHTS_EXECUTE | \
   6605    FILE_READ_ATTRIBUTES | \
   6606    FILE_EXECUTE | \
   6607    SYNCHRONIZE)
   6608 
   6609 #define FILE_GENERIC_READ \
   6610   (STANDARD_RIGHTS_READ | \
   6611    FILE_READ_DATA | \
   6612    FILE_READ_ATTRIBUTES | \
   6613    FILE_READ_EA | \
   6614    SYNCHRONIZE)
   6615 
   6616 #define FILE_GENERIC_WRITE \
   6617   (STANDARD_RIGHTS_WRITE | \
   6618    FILE_WRITE_DATA | \
   6619    FILE_WRITE_ATTRIBUTES | \
   6620    FILE_WRITE_EA | \
   6621    FILE_APPEND_DATA | \
   6622    SYNCHRONIZE)
   6623 
   6624 /* end winnt.h */
   6625 
   6626 #define WMIREG_ACTION_REGISTER      1
   6627 #define WMIREG_ACTION_DEREGISTER    2
   6628 #define WMIREG_ACTION_REREGISTER    3
   6629 #define WMIREG_ACTION_UPDATE_GUIDS  4
   6630 #define WMIREG_ACTION_BLOCK_IRPS    5
   6631 
   6632 #define WMIREGISTER                 0
   6633 #define WMIUPDATE                   1
   6634 
   6635 typedef VOID
   6636 (NTAPI FWMI_NOTIFICATION_CALLBACK)(
   6637   PVOID Wnode,
   6638   PVOID Context);
   6639 typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK;
   6640 
   6641 #ifndef _PCI_X_
   6642 #define _PCI_X_
   6643 
   6644 typedef struct _PCI_SLOT_NUMBER {
   6645   union {
   6646     struct {
   6647       ULONG DeviceNumber:5;
   6648       ULONG FunctionNumber:3;
   6649       ULONG Reserved:24;
   6650     } bits;
   6651     ULONG AsULONG;
   6652   } u;
   6653 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
   6654 
   6655 #define PCI_TYPE0_ADDRESSES               6
   6656 #define PCI_TYPE1_ADDRESSES               2
   6657 #define PCI_TYPE2_ADDRESSES               5
   6658 
   6659 typedef struct _PCI_COMMON_HEADER {
   6660   PCI_COMMON_HEADER_LAYOUT
   6661 } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
   6662 
   6663 #ifdef __cplusplus
   6664 typedef struct _PCI_COMMON_CONFIG {
   6665   PCI_COMMON_HEADER_LAYOUT
   6666   UCHAR DeviceSpecific[192];
   6667 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
   6668 #else
   6669 typedef struct _PCI_COMMON_CONFIG {
   6670   __extension__ struct {
   6671     PCI_COMMON_HEADER_LAYOUT
   6672   };
   6673   UCHAR DeviceSpecific[192];
   6674 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
   6675 #endif
   6676 
   6677 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
   6678 
   6679 #define PCI_EXTENDED_CONFIG_LENGTH               0x1000
   6680 
   6681 #define PCI_MAX_DEVICES        32
   6682 #define PCI_MAX_FUNCTION       8
   6683 #define PCI_MAX_BRIDGE_NUMBER  0xFF
   6684 #define PCI_INVALID_VENDORID   0xFFFF
   6685 
   6686 /* PCI_COMMON_CONFIG.HeaderType */
   6687 #define PCI_MULTIFUNCTION                 0x80
   6688 #define PCI_DEVICE_TYPE                   0x00
   6689 #define PCI_BRIDGE_TYPE                   0x01
   6690 #define PCI_CARDBUS_BRIDGE_TYPE           0x02
   6691 
   6692 #define PCI_CONFIGURATION_TYPE(PciData) \
   6693   (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
   6694 
   6695 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
   6696   ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
   6697 
   6698 /* PCI_COMMON_CONFIG.Command */
   6699 #define PCI_ENABLE_IO_SPACE               0x0001
   6700 #define PCI_ENABLE_MEMORY_SPACE           0x0002
   6701 #define PCI_ENABLE_BUS_MASTER             0x0004
   6702 #define PCI_ENABLE_SPECIAL_CYCLES         0x0008
   6703 #define PCI_ENABLE_WRITE_AND_INVALIDATE   0x0010
   6704 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
   6705 #define PCI_ENABLE_PARITY                 0x0040
   6706 #define PCI_ENABLE_WAIT_CYCLE             0x0080
   6707 #define PCI_ENABLE_SERR                   0x0100
   6708 #define PCI_ENABLE_FAST_BACK_TO_BACK      0x0200
   6709 #define PCI_DISABLE_LEVEL_INTERRUPT       0x0400
   6710 
   6711 /* PCI_COMMON_CONFIG.Status */
   6712 #define PCI_STATUS_INTERRUPT_PENDING      0x0008
   6713 #define PCI_STATUS_CAPABILITIES_LIST      0x0010
   6714 #define PCI_STATUS_66MHZ_CAPABLE          0x0020
   6715 #define PCI_STATUS_UDF_SUPPORTED          0x0040
   6716 #define PCI_STATUS_FAST_BACK_TO_BACK      0x0080
   6717 #define PCI_STATUS_DATA_PARITY_DETECTED   0x0100
   6718 #define PCI_STATUS_DEVSEL                 0x0600
   6719 #define PCI_STATUS_SIGNALED_TARGET_ABORT  0x0800
   6720 #define PCI_STATUS_RECEIVED_TARGET_ABORT  0x1000
   6721 #define PCI_STATUS_RECEIVED_MASTER_ABORT  0x2000
   6722 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR  0x4000
   6723 #define PCI_STATUS_DETECTED_PARITY_ERROR  0x8000
   6724 
   6725 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
   6726 
   6727 #define PCI_WHICHSPACE_CONFIG             0x0
   6728 #define PCI_WHICHSPACE_ROM                0x52696350 /* 'PciR' */
   6729 
   6730 #define PCI_CAPABILITY_ID_POWER_MANAGEMENT  0x01
   6731 #define PCI_CAPABILITY_ID_AGP               0x02
   6732 #define PCI_CAPABILITY_ID_VPD               0x03
   6733 #define PCI_CAPABILITY_ID_SLOT_ID           0x04
   6734 #define PCI_CAPABILITY_ID_MSI               0x05
   6735 #define PCI_CAPABILITY_ID_CPCI_HOTSWAP      0x06
   6736 #define PCI_CAPABILITY_ID_PCIX              0x07
   6737 #define PCI_CAPABILITY_ID_HYPERTRANSPORT    0x08
   6738 #define PCI_CAPABILITY_ID_VENDOR_SPECIFIC   0x09
   6739 #define PCI_CAPABILITY_ID_DEBUG_PORT        0x0A
   6740 #define PCI_CAPABILITY_ID_CPCI_RES_CTRL     0x0B
   6741 #define PCI_CAPABILITY_ID_SHPC              0x0C
   6742 #define PCI_CAPABILITY_ID_P2P_SSID          0x0D
   6743 #define PCI_CAPABILITY_ID_AGP_TARGET        0x0E
   6744 #define PCI_CAPABILITY_ID_SECURE            0x0F
   6745 #define PCI_CAPABILITY_ID_PCI_EXPRESS       0x10
   6746 #define PCI_CAPABILITY_ID_MSIX              0x11
   6747 
   6748 typedef struct _PCI_CAPABILITIES_HEADER {
   6749   UCHAR CapabilityID;
   6750   UCHAR Next;
   6751 } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
   6752 
   6753 typedef struct _PCI_PMC {
   6754   UCHAR Version:3;
   6755   UCHAR PMEClock:1;
   6756   UCHAR Rsvd1:1;
   6757   UCHAR DeviceSpecificInitialization:1;
   6758   UCHAR Rsvd2:2;
   6759   struct _PM_SUPPORT {
   6760     UCHAR Rsvd2:1;
   6761     UCHAR D1:1;
   6762     UCHAR D2:1;
   6763     UCHAR PMED0:1;
   6764     UCHAR PMED1:1;
   6765     UCHAR PMED2:1;
   6766     UCHAR PMED3Hot:1;
   6767     UCHAR PMED3Cold:1;
   6768   } Support;
   6769 } PCI_PMC, *PPCI_PMC;
   6770 
   6771 typedef struct _PCI_PMCSR {
   6772   USHORT PowerState:2;
   6773   USHORT Rsvd1:6;
   6774   USHORT PMEEnable:1;
   6775   USHORT DataSelect:4;
   6776   USHORT DataScale:2;
   6777   USHORT PMEStatus:1;
   6778 } PCI_PMCSR, *PPCI_PMCSR;
   6779 
   6780 typedef struct _PCI_PMCSR_BSE {
   6781   UCHAR Rsvd1:6;
   6782   UCHAR D3HotSupportsStopClock:1;
   6783   UCHAR BusPowerClockControlEnabled:1;
   6784 } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
   6785 
   6786 typedef struct _PCI_PM_CAPABILITY {
   6787   PCI_CAPABILITIES_HEADER Header;
   6788   union {
   6789     PCI_PMC Capabilities;
   6790     USHORT AsUSHORT;
   6791   } PMC;
   6792     union {
   6793       PCI_PMCSR ControlStatus;
   6794       USHORT AsUSHORT;
   6795     } PMCSR;
   6796     union {
   6797       PCI_PMCSR_BSE BridgeSupport;
   6798       UCHAR AsUCHAR;
   6799     } PMCSR_BSE;
   6800   UCHAR Data;
   6801 } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
   6802 
   6803 typedef struct {
   6804   PCI_CAPABILITIES_HEADER Header;
   6805   union {
   6806     struct {
   6807       USHORT DataParityErrorRecoveryEnable:1;
   6808       USHORT EnableRelaxedOrdering:1;
   6809       USHORT MaxMemoryReadByteCount:2;
   6810       USHORT MaxOutstandingSplitTransactions:3;
   6811       USHORT Reserved:9;
   6812     } bits;
   6813     USHORT AsUSHORT;
   6814   } Command;
   6815   union {
   6816     struct {
   6817       ULONG FunctionNumber:3;
   6818       ULONG DeviceNumber:5;
   6819       ULONG BusNumber:8;
   6820       ULONG Device64Bit:1;
   6821       ULONG Capable133MHz:1;
   6822       ULONG SplitCompletionDiscarded:1;
   6823       ULONG UnexpectedSplitCompletion:1;
   6824       ULONG DeviceComplexity:1;
   6825       ULONG DesignedMaxMemoryReadByteCount:2;
   6826       ULONG DesignedMaxOutstandingSplitTransactions:3;
   6827       ULONG DesignedMaxCumulativeReadSize:3;
   6828       ULONG ReceivedSplitCompletionErrorMessage:1;
   6829       ULONG CapablePCIX266:1;
   6830       ULONG CapablePCIX533:1;
   6831       } bits;
   6832     ULONG AsULONG;
   6833   } Status;
   6834 } PCI_X_CAPABILITY, *PPCI_X_CAPABILITY;
   6835 
   6836 #define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID                     0x0001
   6837 #define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID                              0x0002
   6838 #define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID                         0x0003
   6839 #define PCI_EXPRESS_POWER_BUDGETING_CAP_ID                              0x0004
   6840 #define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID                          0x0005
   6841 #define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID                     0x0006
   6842 #define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID      0x0007
   6843 #define PCI_EXPRESS_MFVC_CAP_ID                                         0x0008
   6844 #define PCI_EXPRESS_VC_AND_MFVC_CAP_ID                                  0x0009
   6845 #define PCI_EXPRESS_RCRB_HEADER_CAP_ID                                  0x000A
   6846 #define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID                0x0010
   6847 
   6848 typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER {
   6849   USHORT CapabilityID;
   6850   USHORT Version:4;
   6851   USHORT Next:12;
   6852 } PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER;
   6853 
   6854 typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY {
   6855   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
   6856   ULONG LowSerialNumber;
   6857   ULONG HighSerialNumber;
   6858 } PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY;
   6859 
   6860 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS {
   6861   _ANONYMOUS_STRUCT struct {
   6862     ULONG Undefined:1;
   6863     ULONG Reserved1:3;
   6864     ULONG DataLinkProtocolError:1;
   6865     ULONG SurpriseDownError:1;
   6866     ULONG Reserved2:6;
   6867     ULONG PoisonedTLP:1;
   6868     ULONG FlowControlProtocolError:1;
   6869     ULONG CompletionTimeout:1;
   6870     ULONG CompleterAbort:1;
   6871     ULONG UnexpectedCompletion:1;
   6872     ULONG ReceiverOverflow:1;
   6873     ULONG MalformedTLP:1;
   6874     ULONG ECRCError:1;
   6875     ULONG UnsupportedRequestError:1;
   6876     ULONG Reserved3:11;
   6877   } DUMMYSTRUCTNAME;
   6878   ULONG AsULONG;
   6879 } PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS;
   6880 
   6881 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK {
   6882   _ANONYMOUS_STRUCT struct {
   6883     ULONG Undefined:1;
   6884     ULONG Reserved1:3;
   6885     ULONG DataLinkProtocolError:1;
   6886     ULONG SurpriseDownError:1;
   6887     ULONG Reserved2:6;
   6888     ULONG PoisonedTLP:1;
   6889     ULONG FlowControlProtocolError:1;
   6890     ULONG CompletionTimeout:1;
   6891     ULONG CompleterAbort:1;
   6892     ULONG UnexpectedCompletion:1;
   6893     ULONG ReceiverOverflow:1;
   6894     ULONG MalformedTLP:1;
   6895     ULONG ECRCError:1;
   6896     ULONG UnsupportedRequestError:1;
   6897     ULONG Reserved3:11;
   6898   } DUMMYSTRUCTNAME;
   6899   ULONG AsULONG;
   6900 } PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK;
   6901 
   6902 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY {
   6903   _ANONYMOUS_STRUCT struct {
   6904     ULONG Undefined:1;
   6905     ULONG Reserved1:3;
   6906     ULONG DataLinkProtocolError:1;
   6907     ULONG SurpriseDownError:1;
   6908     ULONG Reserved2:6;
   6909     ULONG PoisonedTLP:1;
   6910     ULONG FlowControlProtocolError:1;
   6911     ULONG CompletionTimeout:1;
   6912     ULONG CompleterAbort:1;
   6913     ULONG UnexpectedCompletion:1;
   6914     ULONG ReceiverOverflow:1;
   6915     ULONG MalformedTLP:1;
   6916     ULONG ECRCError:1;
   6917     ULONG UnsupportedRequestError:1;
   6918     ULONG Reserved3:11;
   6919   } DUMMYSTRUCTNAME;
   6920   ULONG AsULONG;
   6921 } PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY;
   6922 
   6923 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS {
   6924   _ANONYMOUS_STRUCT struct {
   6925     ULONG ReceiverError:1;
   6926     ULONG Reserved1:5;
   6927     ULONG BadTLP:1;
   6928     ULONG BadDLLP:1;
   6929     ULONG ReplayNumRollover:1;
   6930     ULONG Reserved2:3;
   6931     ULONG ReplayTimerTimeout:1;
   6932     ULONG AdvisoryNonFatalError:1;
   6933     ULONG Reserved3:18;
   6934   } DUMMYSTRUCTNAME;
   6935   ULONG AsULONG;
   6936 } PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS;
   6937 
   6938 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK {
   6939   _ANONYMOUS_STRUCT struct {
   6940     ULONG ReceiverError:1;
   6941     ULONG Reserved1:5;
   6942     ULONG BadTLP:1;
   6943     ULONG BadDLLP:1;
   6944     ULONG ReplayNumRollover:1;
   6945     ULONG Reserved2:3;
   6946     ULONG ReplayTimerTimeout:1;
   6947     ULONG AdvisoryNonFatalError:1;
   6948     ULONG Reserved3:18;
   6949   } DUMMYSTRUCTNAME;
   6950   ULONG AsULONG;
   6951 } PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK;
   6952 
   6953 typedef union _PCI_EXPRESS_AER_CAPABILITIES {
   6954   _ANONYMOUS_STRUCT struct {
   6955     ULONG FirstErrorPointer:5;
   6956     ULONG ECRCGenerationCapable:1;
   6957     ULONG ECRCGenerationEnable:1;
   6958     ULONG ECRCCheckCapable:1;
   6959     ULONG ECRCCheckEnable:1;
   6960     ULONG Reserved:23;
   6961   } DUMMYSTRUCTNAME;
   6962   ULONG AsULONG;
   6963 } PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES;
   6964 
   6965 typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND {
   6966   _ANONYMOUS_STRUCT struct {
   6967     ULONG CorrectableErrorReportingEnable:1;
   6968     ULONG NonFatalErrorReportingEnable:1;
   6969     ULONG FatalErrorReportingEnable:1;
   6970     ULONG Reserved:29;
   6971   } DUMMYSTRUCTNAME;
   6972   ULONG AsULONG;
   6973 } PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND;
   6974 
   6975 typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS {
   6976   _ANONYMOUS_STRUCT struct {
   6977     ULONG CorrectableErrorReceived:1;
   6978     ULONG MultipleCorrectableErrorsReceived:1;
   6979     ULONG UncorrectableErrorReceived:1;
   6980     ULONG MultipleUncorrectableErrorsReceived:1;
   6981     ULONG FirstUncorrectableFatal:1;
   6982     ULONG NonFatalErrorMessagesReceived:1;
   6983     ULONG FatalErrorMessagesReceived:1;
   6984     ULONG Reserved:20;
   6985     ULONG AdvancedErrorInterruptMessageNumber:5;
   6986   } DUMMYSTRUCTNAME;
   6987   ULONG AsULONG;
   6988 } PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS;
   6989 
   6990 typedef union _PCI_EXPRESS_ERROR_SOURCE_ID {
   6991   _ANONYMOUS_STRUCT struct {
   6992     USHORT CorrectableSourceIdFun:3;
   6993     USHORT CorrectableSourceIdDev:5;
   6994     USHORT CorrectableSourceIdBus:8;
   6995     USHORT UncorrectableSourceIdFun:3;
   6996     USHORT UncorrectableSourceIdDev:5;
   6997     USHORT UncorrectableSourceIdBus:8;
   6998   } DUMMYSTRUCTNAME;
   6999   ULONG AsULONG;
   7000 } PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID;
   7001 
   7002 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS {
   7003   _ANONYMOUS_STRUCT struct {
   7004     ULONG TargetAbortOnSplitCompletion:1;
   7005     ULONG MasterAbortOnSplitCompletion:1;
   7006     ULONG ReceivedTargetAbort:1;
   7007     ULONG ReceivedMasterAbort:1;
   7008     ULONG RsvdZ:1;
   7009     ULONG UnexpectedSplitCompletionError:1;
   7010     ULONG UncorrectableSplitCompletion:1;
   7011     ULONG UncorrectableDataError:1;
   7012     ULONG UncorrectableAttributeError:1;
   7013     ULONG UncorrectableAddressError:1;
   7014     ULONG DelayedTransactionDiscardTimerExpired:1;
   7015     ULONG PERRAsserted:1;
   7016     ULONG SERRAsserted:1;
   7017     ULONG InternalBridgeError:1;
   7018     ULONG Reserved:18;
   7019   } DUMMYSTRUCTNAME;
   7020   ULONG AsULONG;
   7021 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS;
   7022 
   7023 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK {
   7024   _ANONYMOUS_STRUCT struct {
   7025     ULONG TargetAbortOnSplitCompletion:1;
   7026     ULONG MasterAbortOnSplitCompletion:1;
   7027     ULONG ReceivedTargetAbort:1;
   7028     ULONG ReceivedMasterAbort:1;
   7029     ULONG RsvdZ:1;
   7030     ULONG UnexpectedSplitCompletionError:1;
   7031     ULONG UncorrectableSplitCompletion:1;
   7032     ULONG UncorrectableDataError:1;
   7033     ULONG UncorrectableAttributeError:1;
   7034     ULONG UncorrectableAddressError:1;
   7035     ULONG DelayedTransactionDiscardTimerExpired:1;
   7036     ULONG PERRAsserted:1;
   7037     ULONG SERRAsserted:1;
   7038     ULONG InternalBridgeError:1;
   7039     ULONG Reserved:18;
   7040   } DUMMYSTRUCTNAME;
   7041   ULONG AsULONG;
   7042 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK;
   7043 
   7044 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY {
   7045   _ANONYMOUS_STRUCT struct {
   7046     ULONG TargetAbortOnSplitCompletion:1;
   7047     ULONG MasterAbortOnSplitCompletion:1;
   7048     ULONG ReceivedTargetAbort:1;
   7049     ULONG ReceivedMasterAbort:1;
   7050     ULONG RsvdZ:1;
   7051     ULONG UnexpectedSplitCompletionError:1;
   7052     ULONG UncorrectableSplitCompletion:1;
   7053     ULONG UncorrectableDataError:1;
   7054     ULONG UncorrectableAttributeError:1;
   7055     ULONG UncorrectableAddressError:1;
   7056     ULONG DelayedTransactionDiscardTimerExpired:1;
   7057     ULONG PERRAsserted:1;
   7058     ULONG SERRAsserted:1;
   7059     ULONG InternalBridgeError:1;
   7060     ULONG Reserved:18;
   7061   } DUMMYSTRUCTNAME;
   7062   ULONG AsULONG;
   7063 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY;
   7064 
   7065 typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES {
   7066   _ANONYMOUS_STRUCT struct {
   7067     ULONG SecondaryUncorrectableFirstErrorPtr:5;
   7068     ULONG Reserved:27;
   7069   } DUMMYSTRUCTNAME;
   7070   ULONG AsULONG;
   7071 } PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES;
   7072 
   7073 #define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING  0x00000001
   7074 #define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING     0x00000002
   7075 #define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING        0x00000004
   7076 
   7077 #define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \
   7078     (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \
   7079      ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \
   7080      ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING)
   7081 
   7082 typedef struct _PCI_EXPRESS_AER_CAPABILITY {
   7083   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
   7084   PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
   7085   PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
   7086   PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
   7087   PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
   7088   PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
   7089   PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
   7090   ULONG HeaderLog[4];
   7091   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
   7092   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
   7093   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
   7094   PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
   7095   ULONG SecHeaderLog[4];
   7096 } PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY;
   7097 
   7098 typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY {
   7099   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
   7100   PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
   7101   PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
   7102   PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
   7103   PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
   7104   PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
   7105   PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
   7106   ULONG HeaderLog[4];
   7107   PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand;
   7108   PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus;
   7109   PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId;
   7110 } PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY;
   7111 
   7112 typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY {
   7113   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
   7114   PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
   7115   PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
   7116   PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
   7117   PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
   7118   PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
   7119   PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
   7120   ULONG HeaderLog[4];
   7121   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
   7122   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
   7123   PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
   7124   PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
   7125   ULONG SecHeaderLog[4];
   7126 } PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY;
   7127 
   7128 typedef union _PCI_EXPRESS_SRIOV_CAPS {
   7129   _ANONYMOUS_STRUCT struct {
   7130     ULONG VFMigrationCapable:1;
   7131     ULONG Reserved1:20;
   7132     ULONG VFMigrationInterruptNumber:11;
   7133   } DUMMYSTRUCTNAME;
   7134   ULONG AsULONG;
   7135 } PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS;
   7136 
   7137 typedef union _PCI_EXPRESS_SRIOV_CONTROL {
   7138   _ANONYMOUS_STRUCT struct {
   7139     USHORT VFEnable:1;
   7140     USHORT VFMigrationEnable:1;
   7141     USHORT VFMigrationInterruptEnable:1;
   7142     USHORT VFMemorySpaceEnable:1;
   7143     USHORT ARICapableHierarchy:1;
   7144     USHORT Reserved1:11;
   7145   } DUMMYSTRUCTNAME;
   7146   USHORT AsUSHORT;
   7147 } PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL;
   7148 
   7149 typedef union _PCI_EXPRESS_SRIOV_STATUS {
   7150   _ANONYMOUS_STRUCT struct {
   7151     USHORT VFMigrationStatus:1;
   7152     USHORT Reserved1:15;
   7153   } DUMMYSTRUCTNAME;
   7154   USHORT AsUSHORT;
   7155 } PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS;
   7156 
   7157 typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY {
   7158   _ANONYMOUS_STRUCT struct {
   7159     ULONG VFMigrationStateBIR:3;
   7160     ULONG VFMigrationStateOffset:29;
   7161   } DUMMYSTRUCTNAME;
   7162   ULONG AsULONG;
   7163 } PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY;
   7164 
   7165 typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY {
   7166   PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
   7167   PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities;
   7168   PCI_EXPRESS_SRIOV_CONTROL SRIOVControl;
   7169   PCI_EXPRESS_SRIOV_STATUS SRIOVStatus;
   7170   USHORT InitialVFs;
   7171   USHORT TotalVFs;
   7172   USHORT NumVFs;
   7173   UCHAR FunctionDependencyLink;
   7174   UCHAR RsvdP1;
   7175   USHORT FirstVFOffset;
   7176   USHORT VFStride;
   7177   USHORT RsvdP2;
   7178   USHORT VFDeviceId;
   7179   ULONG SupportedPageSizes;
   7180   ULONG SystemPageSize;
   7181   ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
   7182   PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset;
   7183 } PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY;
   7184 
   7185 /* PCI device classes */
   7186 #define PCI_CLASS_PRE_20                    0x00
   7187 #define PCI_CLASS_MASS_STORAGE_CTLR         0x01
   7188 #define PCI_CLASS_NETWORK_CTLR              0x02
   7189 #define PCI_CLASS_DISPLAY_CTLR              0x03
   7190 #define PCI_CLASS_MULTIMEDIA_DEV            0x04
   7191 #define PCI_CLASS_MEMORY_CTLR               0x05
   7192 #define PCI_CLASS_BRIDGE_DEV                0x06
   7193 #define PCI_CLASS_SIMPLE_COMMS_CTLR         0x07
   7194 #define PCI_CLASS_BASE_SYSTEM_DEV           0x08
   7195 #define PCI_CLASS_INPUT_DEV                 0x09
   7196 #define PCI_CLASS_DOCKING_STATION           0x0a
   7197 #define PCI_CLASS_PROCESSOR                 0x0b
   7198 #define PCI_CLASS_SERIAL_BUS_CTLR           0x0c
   7199 #define PCI_CLASS_WIRELESS_CTLR             0x0d
   7200 #define PCI_CLASS_INTELLIGENT_IO_CTLR       0x0e
   7201 #define PCI_CLASS_SATELLITE_COMMS_CTLR      0x0f
   7202 #define PCI_CLASS_ENCRYPTION_DECRYPTION     0x10
   7203 #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC      0x11
   7204 #define PCI_CLASS_NOT_DEFINED               0xff
   7205 
   7206 /* PCI device subclasses for class 0 */
   7207 #define PCI_SUBCLASS_PRE_20_NON_VGA         0x00
   7208 #define PCI_SUBCLASS_PRE_20_VGA             0x01
   7209 
   7210 /* PCI device subclasses for class 1 (mass storage controllers)*/
   7211 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR      0x00
   7212 #define PCI_SUBCLASS_MSC_IDE_CTLR           0x01
   7213 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR        0x02
   7214 #define PCI_SUBCLASS_MSC_IPI_CTLR           0x03
   7215 #define PCI_SUBCLASS_MSC_RAID_CTLR          0x04
   7216 #define PCI_SUBCLASS_MSC_OTHER              0x80
   7217 
   7218 /* PCI device subclasses for class 2 (network controllers)*/
   7219 #define PCI_SUBCLASS_NET_ETHERNET_CTLR      0x00
   7220 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR    0x01
   7221 #define PCI_SUBCLASS_NET_FDDI_CTLR          0x02
   7222 #define PCI_SUBCLASS_NET_ATM_CTLR           0x03
   7223 #define PCI_SUBCLASS_NET_ISDN_CTLR          0x04
   7224 #define PCI_SUBCLASS_NET_OTHER              0x80
   7225 
   7226 /* PCI device subclasses for class 3 (display controllers)*/
   7227 #define PCI_SUBCLASS_VID_VGA_CTLR           0x00
   7228 #define PCI_SUBCLASS_VID_XGA_CTLR           0x01
   7229 #define PCI_SUBCLASS_VID_3D_CTLR            0x02
   7230 #define PCI_SUBCLASS_VID_OTHER              0x80
   7231 
   7232 /* PCI device subclasses for class 4 (multimedia device)*/
   7233 #define PCI_SUBCLASS_MM_VIDEO_DEV           0x00
   7234 #define PCI_SUBCLASS_MM_AUDIO_DEV           0x01
   7235 #define PCI_SUBCLASS_MM_TELEPHONY_DEV       0x02
   7236 #define PCI_SUBCLASS_MM_OTHER               0x80
   7237 
   7238 /* PCI device subclasses for class 5 (memory controller)*/
   7239 #define PCI_SUBCLASS_MEM_RAM                0x00
   7240 #define PCI_SUBCLASS_MEM_FLASH              0x01
   7241 #define PCI_SUBCLASS_MEM_OTHER              0x80
   7242 
   7243 /* PCI device subclasses for class 6 (bridge device)*/
   7244 #define PCI_SUBCLASS_BR_HOST                0x00
   7245 #define PCI_SUBCLASS_BR_ISA                 0x01
   7246 #define PCI_SUBCLASS_BR_EISA                0x02
   7247 #define PCI_SUBCLASS_BR_MCA                 0x03
   7248 #define PCI_SUBCLASS_BR_PCI_TO_PCI          0x04
   7249 #define PCI_SUBCLASS_BR_PCMCIA              0x05
   7250 #define PCI_SUBCLASS_BR_NUBUS               0x06
   7251 #define PCI_SUBCLASS_BR_CARDBUS             0x07
   7252 #define PCI_SUBCLASS_BR_RACEWAY             0x08
   7253 #define PCI_SUBCLASS_BR_OTHER               0x80
   7254 
   7255 #define PCI_SUBCLASS_COM_SERIAL             0x00
   7256 #define PCI_SUBCLASS_COM_PARALLEL           0x01
   7257 #define PCI_SUBCLASS_COM_MULTIPORT          0x02
   7258 #define PCI_SUBCLASS_COM_MODEM              0x03
   7259 #define PCI_SUBCLASS_COM_OTHER              0x80
   7260 
   7261 #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR     0x00
   7262 #define PCI_SUBCLASS_SYS_DMA_CTLR           0x01
   7263 #define PCI_SUBCLASS_SYS_SYSTEM_TIMER       0x02
   7264 #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK    0x03
   7265 #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR   0x04
   7266 #define PCI_SUBCLASS_SYS_SDIO_CTRL          0x05
   7267 #define PCI_SUBCLASS_SYS_OTHER              0x80
   7268 
   7269 #define PCI_SUBCLASS_INP_KEYBOARD           0x00
   7270 #define PCI_SUBCLASS_INP_DIGITIZER          0x01
   7271 #define PCI_SUBCLASS_INP_MOUSE              0x02
   7272 #define PCI_SUBCLASS_INP_SCANNER            0x03
   7273 #define PCI_SUBCLASS_INP_GAMEPORT           0x04
   7274 #define PCI_SUBCLASS_INP_OTHER              0x80
   7275 
   7276 #define PCI_SUBCLASS_DOC_GENERIC            0x00
   7277 #define PCI_SUBCLASS_DOC_OTHER              0x80
   7278 
   7279 #define PCI_SUBCLASS_PROC_386               0x00
   7280 #define PCI_SUBCLASS_PROC_486               0x01
   7281 #define PCI_SUBCLASS_PROC_PENTIUM           0x02
   7282 #define PCI_SUBCLASS_PROC_ALPHA             0x10
   7283 #define PCI_SUBCLASS_PROC_POWERPC           0x20
   7284 #define PCI_SUBCLASS_PROC_COPROCESSOR       0x40
   7285 
   7286 /* PCI device subclasses for class C (serial bus controller)*/
   7287 #define PCI_SUBCLASS_SB_IEEE1394            0x00
   7288 #define PCI_SUBCLASS_SB_ACCESS              0x01
   7289 #define PCI_SUBCLASS_SB_SSA                 0x02
   7290 #define PCI_SUBCLASS_SB_USB                 0x03
   7291 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL       0x04
   7292 #define PCI_SUBCLASS_SB_SMBUS               0x05
   7293 
   7294 #define PCI_SUBCLASS_WIRELESS_IRDA          0x00
   7295 #define PCI_SUBCLASS_WIRELESS_CON_IR        0x01
   7296 #define PCI_SUBCLASS_WIRELESS_RF            0x10
   7297 #define PCI_SUBCLASS_WIRELESS_OTHER         0x80
   7298 
   7299 #define PCI_SUBCLASS_INTIO_I2O              0x00
   7300 
   7301 #define PCI_SUBCLASS_SAT_TV                 0x01
   7302 #define PCI_SUBCLASS_SAT_AUDIO              0x02
   7303 #define PCI_SUBCLASS_SAT_VOICE              0x03
   7304 #define PCI_SUBCLASS_SAT_DATA               0x04
   7305 
   7306 #define PCI_SUBCLASS_CRYPTO_NET_COMP        0x00
   7307 #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT   0x10
   7308 #define PCI_SUBCLASS_CRYPTO_OTHER           0x80
   7309 
   7310 #define PCI_SUBCLASS_DASP_DPIO              0x00
   7311 #define PCI_SUBCLASS_DASP_OTHER             0x80
   7312 
   7313 #define PCI_ADDRESS_IO_SPACE                0x00000001
   7314 #define PCI_ADDRESS_MEMORY_TYPE_MASK        0x00000006
   7315 #define PCI_ADDRESS_MEMORY_PREFETCHABLE     0x00000008
   7316 #define PCI_ADDRESS_IO_ADDRESS_MASK         0xfffffffc
   7317 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK     0xfffffff0
   7318 #define PCI_ADDRESS_ROM_ADDRESS_MASK        0xfffff800
   7319 
   7320 #define PCI_TYPE_32BIT                      0
   7321 #define PCI_TYPE_20BIT                      2
   7322 #define PCI_TYPE_64BIT                      4
   7323 
   7324 #define PCI_ROMADDRESS_ENABLED              0x00000001
   7325 
   7326 #endif /* _PCI_X_ */
   7327 
   7328 #define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION       1
   7329 
   7330 typedef NTSTATUS
   7331 (NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)(
   7332   IN OUT PVOID Context);
   7333 typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE;
   7334 
   7335 typedef NTSTATUS
   7336 (NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)(
   7337   IN OUT PVOID Context);
   7338 typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE;
   7339 
   7340 typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE {
   7341   USHORT Size;
   7342   USHORT Version;
   7343   PVOID Context;
   7344   PINTERFACE_REFERENCE InterfaceReference;
   7345   PINTERFACE_DEREFERENCE InterfaceDereference;
   7346   PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode;
   7347   PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode;
   7348 } PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE;
   7349 
   7350 #define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION            1
   7351 
   7352 typedef ULONG
   7353 (NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)(
   7354   IN PVOID Context,
   7355   OUT PVOID Buffer,
   7356   IN ULONG Offset,
   7357   IN ULONG Length);
   7358 
   7359 typedef ULONG
   7360 (NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)(
   7361   IN PVOID Context,
   7362   IN PVOID Buffer,
   7363   IN ULONG Offset,
   7364   IN ULONG Length);
   7365 
   7366 typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE {
   7367   USHORT Size;
   7368   USHORT Version;
   7369   PVOID Context;
   7370   PINTERFACE_REFERENCE InterfaceReference;
   7371   PINTERFACE_DEREFERENCE InterfaceDereference;
   7372   PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace;
   7373   PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace;
   7374 } PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE;
   7375 
   7376 #define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION            1
   7377 
   7378 typedef NTSTATUS
   7379 (NTAPI PCI_MSIX_SET_ENTRY)(
   7380   IN PVOID Context,
   7381   IN ULONG TableEntry,
   7382   IN ULONG MessageNumber);
   7383 typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY;
   7384 
   7385 typedef NTSTATUS
   7386 (NTAPI PCI_MSIX_MASKUNMASK_ENTRY)(
   7387   IN PVOID Context,
   7388   IN ULONG TableEntry);
   7389 typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY;
   7390 
   7391 typedef NTSTATUS
   7392 (NTAPI PCI_MSIX_GET_ENTRY)(
   7393   IN PVOID Context,
   7394   IN ULONG TableEntry,
   7395   OUT PULONG MessageNumber,
   7396   OUT PBOOLEAN Masked);
   7397 typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY;
   7398 
   7399 typedef NTSTATUS
   7400 (NTAPI PCI_MSIX_GET_TABLE_SIZE)(
   7401   IN PVOID Context,
   7402   OUT PULONG TableSize);
   7403 typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE;
   7404 
   7405 typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE {
   7406   USHORT Size;
   7407   USHORT Version;
   7408   PVOID Context;
   7409   PINTERFACE_REFERENCE InterfaceReference;
   7410   PINTERFACE_DEREFERENCE InterfaceDereference;
   7411   PPCI_MSIX_SET_ENTRY SetTableEntry;
   7412   PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry;
   7413   PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry;
   7414   PPCI_MSIX_GET_ENTRY GetTableEntry;
   7415   PPCI_MSIX_GET_TABLE_SIZE GetTableSize;
   7416 } PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE;
   7417 
   7418 #define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \
   7419         RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry)
   7420 
   7421 /******************************************************************************
   7422  *                            Object Manager Types                            *
   7423  ******************************************************************************/
   7424 
   7425 #define MAXIMUM_FILENAME_LENGTH           256
   7426 #define OBJ_NAME_PATH_SEPARATOR           ((WCHAR)L'\\')
   7427 
   7428 #define OBJECT_TYPE_CREATE                0x0001
   7429 #define OBJECT_TYPE_ALL_ACCESS            (STANDARD_RIGHTS_REQUIRED | 0x1)
   7430 
   7431 #define DIRECTORY_QUERY                   0x0001
   7432 #define DIRECTORY_TRAVERSE                0x0002
   7433 #define DIRECTORY_CREATE_OBJECT           0x0004
   7434 #define DIRECTORY_CREATE_SUBDIRECTORY     0x0008
   7435 #define DIRECTORY_ALL_ACCESS              (STANDARD_RIGHTS_REQUIRED | 0xF)
   7436 
   7437 #define SYMBOLIC_LINK_QUERY               0x0001
   7438 #define SYMBOLIC_LINK_ALL_ACCESS          (STANDARD_RIGHTS_REQUIRED | 0x1)
   7439 
   7440 #define DUPLICATE_CLOSE_SOURCE            0x00000001
   7441 #define DUPLICATE_SAME_ACCESS             0x00000002
   7442 #define DUPLICATE_SAME_ATTRIBUTES         0x00000004
   7443 
   7444 #define OB_FLT_REGISTRATION_VERSION_0100  0x0100
   7445 #define OB_FLT_REGISTRATION_VERSION       OB_FLT_REGISTRATION_VERSION_0100
   7446 
   7447 typedef ULONG OB_OPERATION;
   7448 
   7449 #define OB_OPERATION_HANDLE_CREATE        0x00000001
   7450 #define OB_OPERATION_HANDLE_DUPLICATE     0x00000002
   7451 
   7452 typedef struct _OB_PRE_CREATE_HANDLE_INFORMATION {
   7453   IN OUT ACCESS_MASK DesiredAccess;
   7454   IN ACCESS_MASK OriginalDesiredAccess;
   7455 } OB_PRE_CREATE_HANDLE_INFORMATION, *POB_PRE_CREATE_HANDLE_INFORMATION;
   7456 
   7457 typedef struct _OB_PRE_DUPLICATE_HANDLE_INFORMATION {
   7458   IN OUT ACCESS_MASK DesiredAccess;
   7459   IN ACCESS_MASK OriginalDesiredAccess;
   7460   IN PVOID SourceProcess;
   7461   IN PVOID TargetProcess;
   7462 } OB_PRE_DUPLICATE_HANDLE_INFORMATION, *POB_PRE_DUPLICATE_HANDLE_INFORMATION;
   7463 
   7464 typedef union _OB_PRE_OPERATION_PARAMETERS {
   7465   IN OUT OB_PRE_CREATE_HANDLE_INFORMATION CreateHandleInformation;
   7466   IN OUT OB_PRE_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation;
   7467 } OB_PRE_OPERATION_PARAMETERS, *POB_PRE_OPERATION_PARAMETERS;
   7468 
   7469 typedef struct _OB_PRE_OPERATION_INFORMATION {
   7470   IN OB_OPERATION Operation;
   7471   _ANONYMOUS_UNION union {
   7472     IN ULONG Flags;
   7473     _ANONYMOUS_STRUCT struct {
   7474       IN ULONG KernelHandle:1;
   7475       IN ULONG Reserved:31;
   7476     } DUMMYSTRUCTNAME;
   7477   } DUMMYUNIONNAME;
   7478   IN PVOID Object;
   7479   IN POBJECT_TYPE ObjectType;
   7480   OUT PVOID CallContext;
   7481   IN POB_PRE_OPERATION_PARAMETERS Parameters;
   7482 } OB_PRE_OPERATION_INFORMATION, *POB_PRE_OPERATION_INFORMATION;
   7483 
   7484 typedef struct _OB_POST_CREATE_HANDLE_INFORMATION {
   7485   IN ACCESS_MASK GrantedAccess;
   7486 } OB_POST_CREATE_HANDLE_INFORMATION, *POB_POST_CREATE_HANDLE_INFORMATION;
   7487 
   7488 typedef struct _OB_POST_DUPLICATE_HANDLE_INFORMATION {
   7489   IN ACCESS_MASK GrantedAccess;
   7490 } OB_POST_DUPLICATE_HANDLE_INFORMATION, *POB_POST_DUPLICATE_HANDLE_INFORMATION;
   7491 
   7492 typedef union _OB_POST_OPERATION_PARAMETERS {
   7493   IN OB_POST_CREATE_HANDLE_INFORMATION CreateHandleInformation;
   7494   IN OB_POST_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation;
   7495 } OB_POST_OPERATION_PARAMETERS, *POB_POST_OPERATION_PARAMETERS;
   7496 
   7497 typedef struct _OB_POST_OPERATION_INFORMATION {
   7498   IN OB_OPERATION Operation;
   7499   _ANONYMOUS_UNION union {
   7500     IN ULONG Flags;
   7501     _ANONYMOUS_STRUCT struct {
   7502       IN ULONG KernelHandle:1;
   7503       IN ULONG Reserved:31;
   7504     } DUMMYSTRUCTNAME;
   7505   } DUMMYUNIONNAME;
   7506   IN PVOID Object;
   7507   IN POBJECT_TYPE ObjectType;
   7508   IN PVOID CallContext;
   7509   IN NTSTATUS ReturnStatus;
   7510   IN POB_POST_OPERATION_PARAMETERS Parameters;
   7511 } OB_POST_OPERATION_INFORMATION,*POB_POST_OPERATION_INFORMATION;
   7512 
   7513 typedef enum _OB_PREOP_CALLBACK_STATUS {
   7514   OB_PREOP_SUCCESS
   7515 } OB_PREOP_CALLBACK_STATUS, *POB_PREOP_CALLBACK_STATUS;
   7516 
   7517 typedef OB_PREOP_CALLBACK_STATUS
   7518 (NTAPI *POB_PRE_OPERATION_CALLBACK)(
   7519   IN PVOID RegistrationContext,
   7520   IN OUT POB_PRE_OPERATION_INFORMATION OperationInformation);
   7521 
   7522 typedef VOID
   7523 (NTAPI *POB_POST_OPERATION_CALLBACK)(
   7524   IN PVOID RegistrationContext,
   7525   IN POB_POST_OPERATION_INFORMATION OperationInformation);
   7526 
   7527 typedef struct _OB_OPERATION_REGISTRATION {
   7528   IN POBJECT_TYPE *ObjectType;
   7529   IN OB_OPERATION Operations;
   7530   IN POB_PRE_OPERATION_CALLBACK PreOperation;
   7531   IN POB_POST_OPERATION_CALLBACK PostOperation;
   7532 } OB_OPERATION_REGISTRATION, *POB_OPERATION_REGISTRATION;
   7533 
   7534 typedef struct _OB_CALLBACK_REGISTRATION {
   7535   IN USHORT Version;
   7536   IN USHORT OperationRegistrationCount;
   7537   IN UNICODE_STRING Altitude;
   7538   IN PVOID RegistrationContext;
   7539   IN OB_OPERATION_REGISTRATION *OperationRegistration;
   7540 } OB_CALLBACK_REGISTRATION, *POB_CALLBACK_REGISTRATION;
   7541 
   7542 typedef struct _OBJECT_NAME_INFORMATION {
   7543   UNICODE_STRING Name;
   7544 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
   7545 
   7546 /* Exported object types */
   7547 extern POBJECT_TYPE NTSYSAPI CmKeyObjectType;
   7548 extern POBJECT_TYPE NTSYSAPI ExEventObjectType;
   7549 extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType;
   7550 extern POBJECT_TYPE NTSYSAPI IoFileObjectType;
   7551 extern POBJECT_TYPE NTSYSAPI PsThreadType;
   7552 extern POBJECT_TYPE NTSYSAPI SeTokenObjectType;
   7553 extern POBJECT_TYPE NTSYSAPI PsProcessType;
   7554 
   7555 /******************************************************************************
   7556  *                           Process Manager Types                            *
   7557  ******************************************************************************/
   7558 
   7559 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE  0x00000001
   7560 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
   7561 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE  0x00000004
   7562 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
   7563 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
   7564 
   7565 /* Thread Access Rights */
   7566 #define THREAD_TERMINATE                 0x0001
   7567 #define THREAD_SUSPEND_RESUME            0x0002
   7568 #define THREAD_ALERT                     0x0004
   7569 #define THREAD_GET_CONTEXT               0x0008
   7570 #define THREAD_SET_CONTEXT               0x0010
   7571 #define THREAD_SET_INFORMATION           0x0020
   7572 #define THREAD_SET_LIMITED_INFORMATION   0x0400
   7573 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
   7574 
   7575 #define PROCESS_DUP_HANDLE               (0x0040)
   7576 
   7577 #if (NTDDI_VERSION >= NTDDI_VISTA)
   7578 #define PROCESS_ALL_ACCESS  (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
   7579 #else
   7580 #define PROCESS_ALL_ACCESS  (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF)
   7581 #endif
   7582 
   7583 #if (NTDDI_VERSION >= NTDDI_VISTA)
   7584 #define THREAD_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
   7585 #else
   7586 #define THREAD_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF)
   7587 #endif
   7588 
   7589 #define LOW_PRIORITY                      0
   7590 #define LOW_REALTIME_PRIORITY             16
   7591 #define HIGH_PRIORITY                     31
   7592 #define MAXIMUM_PRIORITY                  32
   7593 
   7594 
   7595 /******************************************************************************
   7596  *                          WMI Library Support Types                         *
   7597  ******************************************************************************/
   7598 
   7599 #ifdef RUN_WPP
   7600 #include <evntrace.h>
   7601 #include <stdarg.h>
   7602 #endif
   7603 
   7604 #ifndef _TRACEHANDLE_DEFINED
   7605 #define _TRACEHANDLE_DEFINED
   7606 typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE;
   7607 #endif
   7608 
   7609 #ifndef TRACE_INFORMATION_CLASS_DEFINE
   7610 
   7611 typedef struct _ETW_TRACE_SESSION_SETTINGS {
   7612   ULONG Version;
   7613   ULONG BufferSize;
   7614   ULONG MinimumBuffers;
   7615   ULONG MaximumBuffers;
   7616   ULONG LoggerMode;
   7617   ULONG FlushTimer;
   7618   ULONG FlushThreshold;
   7619   ULONG ClockType;
   7620 } ETW_TRACE_SESSION_SETTINGS, *PETW_TRACE_SESSION_SETTINGS;
   7621 
   7622 typedef enum _TRACE_INFORMATION_CLASS {
   7623   TraceIdClass,
   7624   TraceHandleClass,
   7625   TraceEnableFlagsClass,
   7626   TraceEnableLevelClass,
   7627   GlobalLoggerHandleClass,
   7628   EventLoggerHandleClass,
   7629   AllLoggerHandlesClass,
   7630   TraceHandleByNameClass,
   7631   LoggerEventsLostClass,
   7632   TraceSessionSettingsClass,
   7633   LoggerEventsLoggedClass,
   7634   MaxTraceInformationClass
   7635 } TRACE_INFORMATION_CLASS;
   7636 
   7637 #endif /* TRACE_INFORMATION_CLASS_DEFINE */
   7638 
   7639 #ifndef _ETW_KM_
   7640 #define _ETW_KM_
   7641 #endif
   7642 
   7643 #include <evntprov.h>
   7644 
   7645 typedef VOID
   7646 (NTAPI *PETWENABLECALLBACK)(
   7647   IN LPCGUID SourceId,
   7648   IN ULONG ControlCode,
   7649   IN UCHAR Level,
   7650   IN ULONGLONG MatchAnyKeyword,
   7651   IN ULONGLONG MatchAllKeyword,
   7652   IN PEVENT_FILTER_DESCRIPTOR FilterData OPTIONAL,
   7653   IN OUT PVOID CallbackContext OPTIONAL);
   7654 
   7655 #define EVENT_WRITE_FLAG_NO_FAULTING             0x00000001
   7656 
   7657 
   7658 #if defined(_M_IX86)
   7659 /** Kernel definitions for x86 **/
   7660 
   7661 /* Interrupt request levels */
   7662 #define PASSIVE_LEVEL           0
   7663 #define LOW_LEVEL               0
   7664 #define APC_LEVEL               1
   7665 #define DISPATCH_LEVEL          2
   7666 #define CMCI_LEVEL              5
   7667 #define PROFILE_LEVEL           27
   7668 #define CLOCK1_LEVEL            28
   7669 #define CLOCK2_LEVEL            28
   7670 #define IPI_LEVEL               29
   7671 #define POWER_LEVEL             30
   7672 #define HIGH_LEVEL              31
   7673 #define CLOCK_LEVEL             CLOCK2_LEVEL
   7674 
   7675 #define KIP0PCRADDRESS          0xffdff000
   7676 #define KI_USER_SHARED_DATA     0xffdf0000
   7677 #define SharedUserData          ((KUSER_SHARED_DATA * CONST)KI_USER_SHARED_DATA)
   7678 
   7679 #define PAGE_SIZE               0x1000
   7680 #define PAGE_SHIFT              12L
   7681 #define KeGetDcacheFillSize()   1L
   7682 
   7683 #define EFLAG_SIGN              0x8000
   7684 #define EFLAG_ZERO              0x4000
   7685 #define EFLAG_SELECT            (EFLAG_SIGN | EFLAG_ZERO)
   7686 
   7687 #define RESULT_NEGATIVE         ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
   7688 #define RESULT_ZERO             ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
   7689 #define RESULT_POSITIVE         ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
   7690 
   7691 
   7692 typedef struct _KFLOATING_SAVE {
   7693   ULONG ControlWord;
   7694   ULONG StatusWord;
   7695   ULONG ErrorOffset;
   7696   ULONG ErrorSelector;
   7697   ULONG DataOffset;
   7698   ULONG DataSelector;
   7699   ULONG Cr0NpxState;
   7700   ULONG Spare1;
   7701 } KFLOATING_SAVE, *PKFLOATING_SAVE;
   7702 
   7703 extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount;
   7704 
   7705 #define YieldProcessor _mm_pause
   7706 
   7707 FORCEINLINE
   7708 VOID
   7709 KeMemoryBarrier(VOID)
   7710 {
   7711   volatile LONG Barrier;
   7712 #if defined(__GNUC__)
   7713   __asm__ __volatile__ ("xchg %%eax, %0" : : "m" (Barrier) : "%eax");
   7714 #elif defined(_MSC_VER)
   7715   __asm xchg [Barrier], eax
   7716 #endif
   7717 }
   7718 
   7719 NTHALAPI
   7720 KIRQL
   7721 NTAPI
   7722 KeGetCurrentIrql(VOID);
   7723 
   7724 NTHALAPI
   7725 VOID
   7726 FASTCALL
   7727 KfLowerIrql(
   7728   IN KIRQL NewIrql);
   7729 #define KeLowerIrql(a) KfLowerIrql(a)
   7730 
   7731 NTHALAPI
   7732 KIRQL
   7733 FASTCALL
   7734 KfRaiseIrql(
   7735   IN KIRQL NewIrql);
   7736 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
   7737 
   7738 NTHALAPI
   7739 KIRQL
   7740 NTAPI
   7741 KeRaiseIrqlToDpcLevel(VOID);
   7742 
   7743 NTHALAPI
   7744 KIRQL
   7745 NTAPI
   7746 KeRaiseIrqlToSynchLevel(VOID);
   7747 
   7748 NTHALAPI
   7749 KIRQL
   7750 FASTCALL
   7751 KfAcquireSpinLock(
   7752   IN OUT PKSPIN_LOCK SpinLock);
   7753 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
   7754 
   7755 NTHALAPI
   7756 VOID
   7757 FASTCALL
   7758 KfReleaseSpinLock(
   7759   IN OUT PKSPIN_LOCK SpinLock,
   7760   IN KIRQL NewIrql);
   7761 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
   7762 
   7763 NTKERNELAPI
   7764 VOID
   7765 FASTCALL
   7766 KefAcquireSpinLockAtDpcLevel(
   7767   IN OUT PKSPIN_LOCK SpinLock);
   7768 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
   7769 
   7770 NTKERNELAPI
   7771 VOID
   7772 FASTCALL
   7773 KefReleaseSpinLockFromDpcLevel(
   7774   IN OUT PKSPIN_LOCK SpinLock);
   7775 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
   7776 
   7777 NTSYSAPI
   7778 PKTHREAD
   7779 NTAPI
   7780 KeGetCurrentThread(VOID);
   7781 
   7782 NTKERNELAPI
   7783 NTSTATUS
   7784 NTAPI
   7785 KeSaveFloatingPointState(
   7786   OUT PKFLOATING_SAVE FloatSave);
   7787 
   7788 NTKERNELAPI
   7789 NTSTATUS
   7790 NTAPI
   7791 KeRestoreFloatingPointState(
   7792   IN PKFLOATING_SAVE FloatSave);
   7793 
   7794 /* VOID
   7795  * KeFlushIoBuffers(
   7796  *   IN PMDL Mdl,
   7797  *   IN BOOLEAN ReadOperation,
   7798  *   IN BOOLEAN DmaOperation)
   7799  */
   7800 #define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
   7801 
   7802 /* x86 and x64 performs a 0x2C interrupt */
   7803 #define DbgRaiseAssertionFailure __int2c
   7804 
   7805 FORCEINLINE
   7806 VOID
   7807 _KeQueryTickCount(
   7808   OUT PLARGE_INTEGER CurrentCount)
   7809 {
   7810   for (;;) {
   7811 #ifdef NONAMELESSUNION
   7812     CurrentCount->s.HighPart = KeTickCount.High1Time;
   7813     CurrentCount->s.LowPart = KeTickCount.LowPart;
   7814     if (CurrentCount->s.HighPart == KeTickCount.High2Time) break;
   7815 #else
   7816     CurrentCount->HighPart = KeTickCount.High1Time;
   7817     CurrentCount->LowPart = KeTickCount.LowPart;
   7818     if (CurrentCount->HighPart == KeTickCount.High2Time) break;
   7819 #endif
   7820     YieldProcessor();
   7821   }
   7822 }
   7823 #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount)
   7824 
   7825 
   7826 #elif defined(_M_AMD64)
   7827 /** Kernel definitions for AMD64 **/
   7828 
   7829 /* Interrupt request levels */
   7830 #define PASSIVE_LEVEL           0
   7831 #define LOW_LEVEL               0
   7832 #define APC_LEVEL               1
   7833 #define DISPATCH_LEVEL          2
   7834 #define CMCI_LEVEL              5
   7835 #define CLOCK_LEVEL             13
   7836 #define IPI_LEVEL               14
   7837 #define DRS_LEVEL               14
   7838 #define POWER_LEVEL             14
   7839 #define PROFILE_LEVEL           15
   7840 #define HIGH_LEVEL              15
   7841 
   7842 #define KI_USER_SHARED_DATA     0xFFFFF78000000000ULL
   7843 #define SharedUserData          ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA)
   7844 #define SharedInterruptTime     (KI_USER_SHARED_DATA + 0x8)
   7845 #define SharedSystemTime        (KI_USER_SHARED_DATA + 0x14)
   7846 #define SharedTickCount         (KI_USER_SHARED_DATA + 0x320)
   7847 
   7848 #define PAGE_SIZE               0x1000
   7849 #define PAGE_SHIFT              12L
   7850 
   7851 #define EFLAG_SIGN              0x8000
   7852 #define EFLAG_ZERO              0x4000
   7853 #define EFLAG_SELECT            (EFLAG_SIGN | EFLAG_ZERO)
   7854 
   7855 typedef struct _KFLOATING_SAVE {
   7856   ULONG Dummy;
   7857 } KFLOATING_SAVE, *PKFLOATING_SAVE;
   7858 
   7859 typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
   7860 
   7861 #define KeQueryInterruptTime() \
   7862     (*(volatile ULONG64*)SharedInterruptTime)
   7863 
   7864 #define KeQuerySystemTime(CurrentCount) \
   7865     *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime
   7866 
   7867 #define KeQueryTickCount(CurrentCount) \
   7868     *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount
   7869 
   7870 #define KeGetDcacheFillSize() 1L
   7871 
   7872 #define YieldProcessor _mm_pause
   7873 
   7874 FORCEINLINE
   7875 KIRQL
   7876 KeGetCurrentIrql(VOID)
   7877 {
   7878   return (KIRQL)__readcr8();
   7879 }
   7880 
   7881 FORCEINLINE
   7882 VOID
   7883 KeLowerIrql(IN KIRQL NewIrql)
   7884 {
   7885   //ASSERT(KeGetCurrentIrql() >= NewIrql);
   7886   __writecr8(NewIrql);
   7887 }
   7888 
   7889 FORCEINLINE
   7890 KIRQL
   7891 KfRaiseIrql(IN KIRQL NewIrql)
   7892 {
   7893   KIRQL OldIrql;
   7894 
   7895   OldIrql = (KIRQL)__readcr8();
   7896   //ASSERT(OldIrql <= NewIrql);
   7897   __writecr8(NewIrql);
   7898   return OldIrql;
   7899 }
   7900 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
   7901 
   7902 FORCEINLINE
   7903 KIRQL
   7904 KeRaiseIrqlToDpcLevel(VOID)
   7905 {
   7906   return KfRaiseIrql(DISPATCH_LEVEL);
   7907 }
   7908 
   7909 FORCEINLINE
   7910 KIRQL
   7911 KeRaiseIrqlToSynchLevel(VOID)
   7912 {
   7913   return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2
   7914 }
   7915 
   7916 FORCEINLINE
   7917 PKTHREAD
   7918 KeGetCurrentThread(VOID)
   7919 {
   7920   return (struct _KTHREAD *)__readgsqword(0x188);
   7921 }
   7922 
   7923 /* VOID
   7924  * KeFlushIoBuffers(
   7925  *   IN PMDL Mdl,
   7926  *   IN BOOLEAN ReadOperation,
   7927  *   IN BOOLEAN DmaOperation)
   7928  */
   7929 #define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
   7930 
   7931 /* x86 and x64 performs a 0x2C interrupt */
   7932 #define DbgRaiseAssertionFailure __int2c
   7933 
   7934 #elif defined(_M_IA64)
   7935 /** Kernel definitions for IA64 **/
   7936 
   7937 /* Interrupt request levels */
   7938 #define PASSIVE_LEVEL           0
   7939 #define LOW_LEVEL               0
   7940 #define APC_LEVEL               1
   7941 #define DISPATCH_LEVEL          2
   7942 #define CMC_LEVEL               3
   7943 #define DEVICE_LEVEL_BASE       4
   7944 #define PC_LEVEL                12
   7945 #define IPI_LEVEL               14
   7946 #define DRS_LEVEL               14
   7947 #define CLOCK_LEVEL             13
   7948 #define POWER_LEVEL             15
   7949 #define PROFILE_LEVEL           15
   7950 #define HIGH_LEVEL              15
   7951 
   7952 #define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000))
   7953 extern volatile LARGE_INTEGER KeTickCount;
   7954 
   7955 #define PAUSE_PROCESSOR __yield();
   7956 
   7957 FORCEINLINE
   7958 VOID
   7959 KeFlushWriteBuffer(VOID)
   7960 {
   7961   __mf ();
   7962   return;
   7963 }
   7964 
   7965 NTSYSAPI
   7966 PKTHREAD
   7967 NTAPI
   7968 KeGetCurrentThread(VOID);
   7969 
   7970 
   7971 #elif defined(_M_PPC)
   7972 
   7973 /* Interrupt request levels */
   7974 #define PASSIVE_LEVEL                      0
   7975 #define LOW_LEVEL                          0
   7976 #define APC_LEVEL                          1
   7977 #define DISPATCH_LEVEL                     2
   7978 #define PROFILE_LEVEL                     27
   7979 #define CLOCK1_LEVEL                      28
   7980 #define CLOCK2_LEVEL                      28
   7981 #define IPI_LEVEL                         29
   7982 #define POWER_LEVEL                       30
   7983 #define HIGH_LEVEL                        31
   7984 
   7985 //
   7986 // Used to contain PFNs and PFN counts
   7987 //
   7988 typedef ULONG PFN_COUNT;
   7989 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
   7990 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
   7991 
   7992 
   7993 typedef struct _KFLOATING_SAVE {
   7994   ULONG Dummy;
   7995 } KFLOATING_SAVE, *PKFLOATING_SAVE;
   7996 
   7997 typedef struct _KPCR_TIB {
   7998   PVOID ExceptionList;         /* 00 */
   7999   PVOID StackBase;             /* 04 */
   8000   PVOID StackLimit;            /* 08 */
   8001   PVOID SubSystemTib;          /* 0C */
   8002   _ANONYMOUS_UNION union {
   8003     PVOID FiberData;           /* 10 */
   8004     ULONG Version;             /* 10 */
   8005   } DUMMYUNIONNAME;
   8006   PVOID ArbitraryUserPointer;  /* 14 */
   8007   struct _KPCR_TIB *Self;       /* 18 */
   8008 } KPCR_TIB, *PKPCR_TIB;         /* 1C */
   8009 
   8010 #define PCR_MINOR_VERSION 1
   8011 #define PCR_MAJOR_VERSION 1
   8012 
   8013 typedef struct _KPCR {
   8014   KPCR_TIB Tib;                /* 00 */
   8015   struct _KPCR *Self;          /* 1C */
   8016   struct _KPRCB *Prcb;         /* 20 */
   8017   KIRQL Irql;                  /* 24 */
   8018   ULONG IRR;                   /* 28 */
   8019   ULONG IrrActive;             /* 2C */
   8020   ULONG IDR;                   /* 30 */
   8021   PVOID KdVersionBlock;        /* 34 */
   8022   PUSHORT IDT;                 /* 38 */
   8023   PUSHORT GDT;                 /* 3C */
   8024   struct _KTSS *TSS;           /* 40 */
   8025   USHORT MajorVersion;         /* 44 */
   8026   USHORT MinorVersion;         /* 46 */
   8027   KAFFINITY SetMember;         /* 48 */
   8028   ULONG StallScaleFactor;      /* 4C */
   8029   UCHAR SpareUnused;           /* 50 */
   8030   UCHAR Number;                /* 51 */
   8031 } KPCR, *PKPCR;                /* 54 */
   8032 
   8033 #define KeGetPcr()                      PCR
   8034 
   8035 #define YieldProcessor() __asm__ __volatile__("nop");
   8036 
   8037 FORCEINLINE
   8038 ULONG
   8039 NTAPI
   8040 KeGetCurrentProcessorNumber(VOID)
   8041 {
   8042   ULONG Number;
   8043   __asm__ __volatile__ (
   8044     "lwz %0, %c1(12)\n"
   8045     : "=r" (Number)
   8046     : "i" (FIELD_OFFSET(KPCR, Number))
   8047   );
   8048   return Number;
   8049 }
   8050 
   8051 NTHALAPI
   8052 VOID
   8053 FASTCALL
   8054 KfLowerIrql(
   8055   IN KIRQL NewIrql);
   8056 #define KeLowerIrql(a) KfLowerIrql(a)
   8057 
   8058 NTHALAPI
   8059 KIRQL
   8060 FASTCALL
   8061 KfRaiseIrql(
   8062   IN KIRQL NewIrql);
   8063 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
   8064 
   8065 NTHALAPI
   8066 KIRQL
   8067 NTAPI
   8068 KeRaiseIrqlToDpcLevel(VOID);
   8069 
   8070 NTHALAPI
   8071 KIRQL
   8072 NTAPI
   8073 KeRaiseIrqlToSynchLevel(VOID);
   8074 
   8075 
   8076 
   8077 #elif defined(_M_MIPS)
   8078 #error MIPS Headers are totally incorrect
   8079 
   8080 //
   8081 // Used to contain PFNs and PFN counts
   8082 //
   8083 typedef ULONG PFN_COUNT;
   8084 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
   8085 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
   8086 
   8087 #define PASSIVE_LEVEL                      0
   8088 #define APC_LEVEL                          1
   8089 #define DISPATCH_LEVEL                     2
   8090 #define PROFILE_LEVEL                     27
   8091 #define IPI_LEVEL                         29
   8092 #define HIGH_LEVEL                        31
   8093 
   8094 typedef struct _KPCR {
   8095   struct _KPRCB *Prcb;         /* 20 */
   8096   KIRQL Irql;                  /* 24 */
   8097   ULONG IRR;                   /* 28 */
   8098   ULONG IDR;                   /* 30 */
   8099 } KPCR, *PKPCR;
   8100 
   8101 #define KeGetPcr()                      PCR
   8102 
   8103 typedef struct _KFLOATING_SAVE {
   8104 } KFLOATING_SAVE, *PKFLOATING_SAVE;
   8105 
   8106 static __inline
   8107 ULONG
   8108 NTAPI
   8109 KeGetCurrentProcessorNumber(VOID)
   8110 {
   8111   return 0;
   8112 }
   8113 
   8114 #define YieldProcessor() __asm__ __volatile__("nop");
   8115 
   8116 #define KeLowerIrql(a) KfLowerIrql(a)
   8117 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
   8118 
   8119 NTKERNELAPI
   8120 VOID
   8121 NTAPI
   8122 KfLowerIrql(
   8123   IN KIRQL NewIrql);
   8124 
   8125 NTKERNELAPI
   8126 KIRQL
   8127 NTAPI
   8128 KfRaiseIrql(
   8129   IN KIRQL NewIrql);
   8130 
   8131 NTKERNELAPI
   8132 KIRQL
   8133 NTAPI
   8134 KeRaiseIrqlToDpcLevel(VOID);
   8135 
   8136 NTKERNELAPI
   8137 KIRQL
   8138 NTAPI
   8139 KeRaiseIrqlToSynchLevel(VOID);
   8140 
   8141 
   8142 #elif defined(_M_ARM)
   8143 #include <armddk.h>
   8144 #else
   8145 #error Unknown Architecture
   8146 #endif
   8147 
   8148 
   8149 /******************************************************************************
   8150  *                         Runtime Library Functions                          *
   8151  ******************************************************************************/
   8152 
   8153 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
   8154 
   8155 #define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x }
   8156 
   8157 FORCEINLINE
   8158 VOID
   8159 InitializeListHead(
   8160   OUT PLIST_ENTRY ListHead)
   8161 {
   8162   ListHead->Flink = ListHead->Blink = ListHead;
   8163 }
   8164 
   8165 FORCEINLINE
   8166 BOOLEAN
   8167 IsListEmpty(
   8168   IN CONST LIST_ENTRY * ListHead)
   8169 {
   8170   return (BOOLEAN)(ListHead->Flink == ListHead);
   8171 }
   8172 
   8173 FORCEINLINE
   8174 BOOLEAN
   8175 RemoveEntryList(
   8176   IN PLIST_ENTRY Entry)
   8177 {
   8178   PLIST_ENTRY OldFlink;
   8179   PLIST_ENTRY OldBlink;
   8180 
   8181   OldFlink = Entry->Flink;
   8182   OldBlink = Entry->Blink;
   8183   OldFlink->Blink = OldBlink;
   8184   OldBlink->Flink = OldFlink;
   8185   return (BOOLEAN)(OldFlink == OldBlink);
   8186 }
   8187 
   8188 FORCEINLINE
   8189 PLIST_ENTRY
   8190 RemoveHeadList(
   8191   IN OUT PLIST_ENTRY ListHead)
   8192 {
   8193   PLIST_ENTRY Flink;
   8194   PLIST_ENTRY Entry;
   8195 
   8196   Entry = ListHead->Flink;
   8197   Flink = Entry->Flink;
   8198   ListHead->Flink = Flink;
   8199   Flink->Blink = ListHead;
   8200   return Entry;
   8201 }
   8202 
   8203 FORCEINLINE
   8204 PLIST_ENTRY
   8205 RemoveTailList(
   8206   IN OUT PLIST_ENTRY ListHead)
   8207 {
   8208   PLIST_ENTRY Blink;
   8209   PLIST_ENTRY Entry;
   8210 
   8211   Entry = ListHead->Blink;
   8212   Blink = Entry->Blink;
   8213   ListHead->Blink = Blink;
   8214   Blink->Flink = ListHead;
   8215   return Entry;
   8216 }
   8217 
   8218 FORCEINLINE
   8219 VOID
   8220 InsertTailList(
   8221   IN OUT PLIST_ENTRY ListHead,
   8222   IN OUT PLIST_ENTRY Entry)
   8223 {
   8224   PLIST_ENTRY OldBlink;
   8225   OldBlink = ListHead->Blink;
   8226   Entry->Flink = ListHead;
   8227   Entry->Blink = OldBlink;
   8228   OldBlink->Flink = Entry;
   8229   ListHead->Blink = Entry;
   8230 }
   8231 
   8232 FORCEINLINE
   8233 VOID
   8234 InsertHeadList(
   8235   IN OUT PLIST_ENTRY ListHead,
   8236   IN OUT PLIST_ENTRY Entry)
   8237 {
   8238   PLIST_ENTRY OldFlink;
   8239   OldFlink = ListHead->Flink;
   8240   Entry->Flink = OldFlink;
   8241   Entry->Blink = ListHead;
   8242   OldFlink->Blink = Entry;
   8243   ListHead->Flink = Entry;
   8244 }
   8245 
   8246 FORCEINLINE
   8247 VOID
   8248 AppendTailList(
   8249   IN OUT PLIST_ENTRY ListHead,
   8250   IN OUT PLIST_ENTRY ListToAppend)
   8251 {
   8252   PLIST_ENTRY ListEnd = ListHead->Blink;
   8253 
   8254   ListHead->Blink->Flink = ListToAppend;
   8255   ListHead->Blink = ListToAppend->Blink;
   8256   ListToAppend->Blink->Flink = ListHead;
   8257   ListToAppend->Blink = ListEnd;
   8258 }
   8259 
   8260 FORCEINLINE
   8261 PSINGLE_LIST_ENTRY
   8262 PopEntryList(
   8263   IN OUT PSINGLE_LIST_ENTRY ListHead)
   8264 {
   8265   PSINGLE_LIST_ENTRY FirstEntry;
   8266   FirstEntry = ListHead->Next;
   8267   if (FirstEntry != NULL) {
   8268     ListHead->Next = FirstEntry->Next;
   8269   }
   8270   return FirstEntry;
   8271 }
   8272 
   8273 FORCEINLINE
   8274 VOID
   8275 PushEntryList(
   8276   IN OUT PSINGLE_LIST_ENTRY ListHead,
   8277   IN OUT PSINGLE_LIST_ENTRY Entry)
   8278 {
   8279   Entry->Next = ListHead->Next;
   8280   ListHead->Next = Entry;
   8281 }
   8282 
   8283 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
   8284 
   8285 NTSYSAPI
   8286 VOID
   8287 NTAPI
   8288 RtlAssert(
   8289   IN PVOID FailedAssertion,
   8290   IN PVOID FileName,
   8291   IN ULONG LineNumber,
   8292   IN PSTR Message);
   8293 
   8294 /* VOID
   8295  * RtlCopyMemory(
   8296  *     IN VOID UNALIGNED *Destination,
   8297  *     IN CONST VOID UNALIGNED *Source,
   8298  *     IN SIZE_T Length)
   8299  */
   8300 #define RtlCopyMemory(Destination, Source, Length) \
   8301     memcpy(Destination, Source, Length)
   8302 
   8303 #define RtlCopyBytes RtlCopyMemory
   8304 
   8305 #if defined(_M_AMD64)
   8306 NTSYSAPI
   8307 VOID
   8308 NTAPI
   8309 RtlCopyMemoryNonTemporal(
   8310   VOID UNALIGNED *Destination,
   8311   CONST VOID UNALIGNED *Source,
   8312   SIZE_T Length);
   8313 #else
   8314 #define RtlCopyMemoryNonTemporal RtlCopyMemory
   8315 #endif
   8316 
   8317 /* BOOLEAN
   8318  * RtlEqualLuid(
   8319  *     IN PLUID Luid1,
   8320  *     IN PLUID Luid2)
   8321  */
   8322 #define RtlEqualLuid(Luid1, Luid2) \
   8323     (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart))
   8324 
   8325 /* ULONG
   8326  * RtlEqualMemory(
   8327  *     IN VOID UNALIGNED *Destination,
   8328  *     IN CONST VOID UNALIGNED *Source,
   8329  *     IN SIZE_T Length)
   8330  */
   8331 #define RtlEqualMemory(Destination, Source, Length) \
   8332     (!memcmp(Destination, Source, Length))
   8333 
   8334 /* VOID
   8335  * RtlFillMemory(
   8336  *     IN VOID UNALIGNED *Destination,
   8337  *     IN SIZE_T Length,
   8338  *     IN UCHAR Fill)
   8339  */
   8340 #define RtlFillMemory(Destination, Length, Fill) \
   8341     memset(Destination, Fill, Length)
   8342 
   8343 #define RtlFillBytes RtlFillMemory
   8344 
   8345 NTSYSAPI
   8346 VOID
   8347 NTAPI
   8348 RtlFreeUnicodeString(
   8349   IN OUT PUNICODE_STRING UnicodeString);
   8350 
   8351 NTSYSAPI
   8352 NTSTATUS
   8353 NTAPI
   8354 RtlGUIDFromString(
   8355   IN PUNICODE_STRING GuidString,
   8356   OUT GUID *Guid);
   8357 
   8358 NTSYSAPI
   8359 VOID
   8360 NTAPI
   8361 RtlInitUnicodeString(
   8362   IN OUT PUNICODE_STRING DestinationString,
   8363   IN PCWSTR SourceString OPTIONAL);
   8364 
   8365 /* VOID
   8366  * RtlMoveMemory(
   8367  *    IN VOID UNALIGNED *Destination,
   8368  *    IN CONST VOID UNALIGNED *Source,
   8369  *    IN SIZE_T Length)
   8370  */
   8371 #define RtlMoveMemory(Destination, Source, Length) \
   8372     memmove(Destination, Source, Length)
   8373 
   8374 NTSYSAPI
   8375 NTSTATUS
   8376 NTAPI
   8377 RtlStringFromGUID(
   8378   IN REFGUID Guid,
   8379   OUT PUNICODE_STRING GuidString);
   8380 
   8381 /* VOID
   8382  * RtlZeroMemory(
   8383  *     IN VOID UNALIGNED *Destination,
   8384  *     IN SIZE_T Length)
   8385  */
   8386 #define RtlZeroMemory(Destination, Length) \
   8387     memset(Destination, 0, Length)
   8388 
   8389 #define RtlZeroBytes RtlZeroMemory
   8390 
   8391 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   8392 
   8393 NTSYSAPI
   8394 BOOLEAN
   8395 NTAPI
   8396 RtlAreBitsClear(
   8397   IN PRTL_BITMAP BitMapHeader,
   8398   IN ULONG StartingIndex,
   8399   IN ULONG Length);
   8400 
   8401 NTSYSAPI
   8402 BOOLEAN
   8403 NTAPI
   8404 RtlAreBitsSet(
   8405   IN PRTL_BITMAP BitMapHeader,
   8406   IN ULONG StartingIndex,
   8407   IN ULONG Length);
   8408 
   8409 NTSYSAPI
   8410 NTSTATUS
   8411 NTAPI
   8412 RtlAnsiStringToUnicodeString(
   8413   IN OUT PUNICODE_STRING DestinationString,
   8414   IN PANSI_STRING SourceString,
   8415   IN BOOLEAN AllocateDestinationString);
   8416 
   8417 NTSYSAPI
   8418 ULONG
   8419 NTAPI
   8420 RtlxAnsiStringToUnicodeSize(
   8421   IN PCANSI_STRING AnsiString);
   8422 
   8423 #define RtlAnsiStringToUnicodeSize(String) (               \
   8424   NLS_MB_CODE_PAGE_TAG ?                                   \
   8425   RtlxAnsiStringToUnicodeSize(String) :                    \
   8426   ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR)   \
   8427 )
   8428 
   8429 NTSYSAPI
   8430 NTSTATUS
   8431 NTAPI
   8432 RtlAppendUnicodeStringToString(
   8433   IN OUT PUNICODE_STRING Destination,
   8434   IN PCUNICODE_STRING Source);
   8435 
   8436 NTSYSAPI
   8437 NTSTATUS
   8438 NTAPI
   8439 RtlAppendUnicodeToString(
   8440   IN OUT PUNICODE_STRING Destination,
   8441   IN PCWSTR Source);
   8442 
   8443 NTSYSAPI
   8444 NTSTATUS
   8445 NTAPI
   8446 RtlCheckRegistryKey(
   8447   IN ULONG RelativeTo,
   8448   IN PWSTR Path);
   8449 
   8450 NTSYSAPI
   8451 VOID
   8452 NTAPI
   8453 RtlClearAllBits(
   8454   IN PRTL_BITMAP BitMapHeader);
   8455 
   8456 NTSYSAPI
   8457 VOID
   8458 NTAPI
   8459 RtlClearBits(
   8460   IN PRTL_BITMAP BitMapHeader,
   8461   IN ULONG StartingIndex,
   8462   IN ULONG NumberToClear);
   8463 
   8464 NTSYSAPI
   8465 SIZE_T
   8466 NTAPI
   8467 RtlCompareMemory(
   8468   IN CONST VOID *Source1,
   8469   IN CONST VOID *Source2,
   8470   IN SIZE_T Length);
   8471 
   8472 NTSYSAPI
   8473 LONG
   8474 NTAPI
   8475 RtlCompareUnicodeString(
   8476   IN PCUNICODE_STRING String1,
   8477   IN PCUNICODE_STRING String2,
   8478   IN BOOLEAN CaseInSensitive);
   8479 
   8480 NTSYSAPI
   8481 LONG
   8482 NTAPI
   8483 RtlCompareUnicodeStrings(
   8484   IN PCWCH String1,
   8485   IN SIZE_T String1Length,
   8486   IN PCWCH String2,
   8487   IN SIZE_T String2Length,
   8488   IN BOOLEAN CaseInSensitive);
   8489 
   8490 NTSYSAPI
   8491 VOID
   8492 NTAPI
   8493 RtlCopyUnicodeString(
   8494   IN OUT PUNICODE_STRING DestinationString,
   8495   IN PCUNICODE_STRING SourceString OPTIONAL);
   8496 
   8497 NTSYSAPI
   8498 NTSTATUS
   8499 NTAPI
   8500 RtlCreateRegistryKey(
   8501   IN ULONG RelativeTo,
   8502   IN PWSTR Path);
   8503 
   8504 NTSYSAPI
   8505 NTSTATUS
   8506 NTAPI
   8507 RtlCreateSecurityDescriptor(
   8508   IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
   8509   IN ULONG Revision);
   8510 
   8511 NTSYSAPI
   8512 NTSTATUS
   8513 NTAPI
   8514 RtlDeleteRegistryValue(
   8515   IN ULONG RelativeTo,
   8516   IN PCWSTR Path,
   8517   IN PCWSTR ValueName);
   8518 
   8519 NTSYSAPI
   8520 BOOLEAN
   8521 NTAPI
   8522 RtlEqualUnicodeString(
   8523   IN CONST UNICODE_STRING *String1,
   8524   IN CONST UNICODE_STRING *String2,
   8525   IN BOOLEAN CaseInSensitive);
   8526 
   8527 #if !defined(_AMD64_) && !defined(_IA64_)
   8528 NTSYSAPI
   8529 LARGE_INTEGER
   8530 NTAPI
   8531 RtlExtendedIntegerMultiply(
   8532   IN LARGE_INTEGER Multiplicand,
   8533   IN LONG Multiplier);
   8534 
   8535 NTSYSAPI
   8536 LARGE_INTEGER
   8537 NTAPI
   8538 RtlExtendedLargeIntegerDivide(
   8539   IN LARGE_INTEGER Dividend,
   8540   IN ULONG Divisor,
   8541   OUT PULONG Remainder OPTIONAL);
   8542 #endif
   8543 
   8544 #if defined(_X86_) || defined(_IA64_)
   8545 NTSYSAPI
   8546 LARGE_INTEGER
   8547 NTAPI
   8548 RtlExtendedMagicDivide(
   8549     IN LARGE_INTEGER Dividend,
   8550     IN LARGE_INTEGER MagicDivisor,
   8551     IN CCHAR  ShiftCount);
   8552 #endif
   8553 
   8554 NTSYSAPI
   8555 VOID
   8556 NTAPI
   8557 RtlFreeAnsiString(
   8558   IN PANSI_STRING AnsiString);
   8559 
   8560 NTSYSAPI
   8561 ULONG
   8562 NTAPI
   8563 RtlFindClearBits(
   8564   IN PRTL_BITMAP BitMapHeader,
   8565   IN ULONG NumberToFind,
   8566   IN ULONG HintIndex);
   8567 
   8568 NTSYSAPI
   8569 ULONG
   8570 NTAPI
   8571 RtlFindClearBitsAndSet(
   8572   IN PRTL_BITMAP BitMapHeader,
   8573   IN ULONG NumberToFind,
   8574   IN ULONG HintIndex);
   8575 
   8576 NTSYSAPI
   8577 ULONG
   8578 NTAPI
   8579 RtlFindFirstRunClear(
   8580   IN PRTL_BITMAP BitMapHeader,
   8581   OUT PULONG StartingIndex);
   8582 
   8583 NTSYSAPI
   8584 ULONG
   8585 NTAPI
   8586 RtlFindClearRuns(
   8587   IN PRTL_BITMAP BitMapHeader,
   8588   OUT PRTL_BITMAP_RUN RunArray,
   8589   IN ULONG SizeOfRunArray,
   8590   IN BOOLEAN LocateLongestRuns);
   8591 
   8592 NTSYSAPI
   8593 ULONG
   8594 NTAPI
   8595 RtlFindLastBackwardRunClear(
   8596   IN PRTL_BITMAP BitMapHeader,
   8597   IN ULONG FromIndex,
   8598   OUT PULONG StartingRunIndex);
   8599 
   8600 NTSYSAPI
   8601 CCHAR
   8602 NTAPI
   8603 RtlFindLeastSignificantBit(
   8604   IN ULONGLONG Set);
   8605 
   8606 NTSYSAPI
   8607 ULONG
   8608 NTAPI
   8609 RtlFindLongestRunClear(
   8610   IN PRTL_BITMAP BitMapHeader,
   8611   OUT PULONG StartingIndex);
   8612 
   8613 NTSYSAPI
   8614 CCHAR
   8615 NTAPI
   8616 RtlFindMostSignificantBit(
   8617   IN ULONGLONG Set);
   8618 
   8619 NTSYSAPI
   8620 ULONG
   8621 NTAPI
   8622 RtlFindNextForwardRunClear(
   8623   IN PRTL_BITMAP BitMapHeader,
   8624   IN ULONG FromIndex,
   8625   OUT PULONG StartingRunIndex);
   8626 
   8627 NTSYSAPI
   8628 ULONG
   8629 NTAPI
   8630 RtlFindSetBits(
   8631   IN PRTL_BITMAP BitMapHeader,
   8632   IN ULONG NumberToFind,
   8633   IN ULONG HintIndex);
   8634 
   8635 NTSYSAPI
   8636 ULONG
   8637 NTAPI
   8638 RtlFindSetBitsAndClear(
   8639   IN PRTL_BITMAP BitMapHeader,
   8640   IN ULONG NumberToFind,
   8641   IN ULONG HintIndex);
   8642 
   8643 NTSYSAPI
   8644 VOID
   8645 NTAPI
   8646 RtlInitAnsiString(
   8647   IN OUT PANSI_STRING DestinationString,
   8648   IN PCSZ SourceString);
   8649 
   8650 NTSYSAPI
   8651 VOID
   8652 NTAPI
   8653 RtlInitializeBitMap(
   8654   IN PRTL_BITMAP BitMapHeader,
   8655   IN PULONG BitMapBuffer,
   8656   IN ULONG SizeOfBitMap);
   8657 
   8658 NTSYSAPI
   8659 VOID
   8660 NTAPI
   8661 RtlInitString(
   8662   IN OUT PSTRING DestinationString,
   8663   IN PCSZ SourceString);
   8664 
   8665 NTSYSAPI
   8666 NTSTATUS
   8667 NTAPI
   8668 RtlIntegerToUnicodeString(
   8669   IN ULONG Value,
   8670   IN ULONG Base OPTIONAL,
   8671   IN OUT PUNICODE_STRING String);
   8672 
   8673 NTSYSAPI
   8674 NTSTATUS
   8675 NTAPI
   8676 RtlInt64ToUnicodeString(
   8677   IN ULONGLONG Value,
   8678   IN ULONG Base OPTIONAL,
   8679   IN OUT PUNICODE_STRING String);
   8680 
   8681 #ifdef _WIN64
   8682 #define RtlIntPtrToUnicodeString(Value, Base, String) \
   8683     RtlInt64ToUnicodeString(Value, Base, String)
   8684 #else
   8685 #define RtlIntPtrToUnicodeString(Value, Base, String) \
   8686     RtlIntegerToUnicodeString(Value, Base, String)
   8687 #endif
   8688 
   8689 /* BOOLEAN
   8690  * RtlIsZeroLuid(
   8691  *     IN PLUID L1);
   8692  */
   8693 #define RtlIsZeroLuid(_L1) \
   8694     ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
   8695 
   8696 NTSYSAPI
   8697 ULONG
   8698 NTAPI
   8699 RtlLengthSecurityDescriptor(
   8700   IN PSECURITY_DESCRIPTOR SecurityDescriptor);
   8701 
   8702 NTSYSAPI
   8703 ULONG
   8704 NTAPI
   8705 RtlNumberOfClearBits(
   8706   IN PRTL_BITMAP BitMapHeader);
   8707 
   8708 NTSYSAPI
   8709 ULONG
   8710 NTAPI
   8711 RtlNumberOfSetBits(
   8712   IN PRTL_BITMAP BitMapHeader);
   8713 
   8714 NTSYSAPI
   8715 NTSTATUS
   8716 NTAPI
   8717 RtlQueryRegistryValues(
   8718   IN ULONG RelativeTo,
   8719   IN PCWSTR Path,
   8720   IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable,
   8721   IN PVOID Context OPTIONAL,
   8722   IN PVOID Environment OPTIONAL);
   8723 
   8724 #define SHORT_SIZE  (sizeof(USHORT))
   8725 #define SHORT_MASK  (SHORT_SIZE - 1)
   8726 #define LONG_SIZE (sizeof(LONG))
   8727 #define LONGLONG_SIZE   (sizeof(LONGLONG))
   8728 #define LONG_MASK (LONG_SIZE - 1)
   8729 #define LONGLONG_MASK   (LONGLONG_SIZE - 1)
   8730 #define LOWBYTE_MASK 0x00FF
   8731 
   8732 #define FIRSTBYTE(VALUE)  ((VALUE) & LOWBYTE_MASK)
   8733 #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK)
   8734 #define THIRDBYTE(VALUE)  (((VALUE) >> 16) & LOWBYTE_MASK)
   8735 #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK)
   8736 
   8737 NTSYSAPI
   8738 VOID
   8739 NTAPI
   8740 RtlSetAllBits(
   8741   IN PRTL_BITMAP BitMapHeader);
   8742 
   8743 NTSYSAPI
   8744 VOID
   8745 NTAPI
   8746 RtlSetBits(
   8747   IN PRTL_BITMAP BitMapHeader,
   8748   IN ULONG StartingIndex,
   8749   IN ULONG NumberToSet);
   8750 
   8751 NTSYSAPI
   8752 NTSTATUS
   8753 NTAPI
   8754 RtlSetDaclSecurityDescriptor(
   8755   IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
   8756   IN BOOLEAN DaclPresent,
   8757   IN PACL Dacl OPTIONAL,
   8758   IN BOOLEAN DaclDefaulted OPTIONAL);
   8759 
   8760 #if defined(_AMD64_)
   8761 
   8762 /* VOID
   8763  * RtlStoreUlong(
   8764  *     IN PULONG Address,
   8765  *     IN ULONG Value);
   8766  */
   8767 #define RtlStoreUlong(Address,Value) \
   8768     *(ULONG UNALIGNED *)(Address) = (Value)
   8769 
   8770 /* VOID
   8771  * RtlStoreUlonglong(
   8772  *     IN OUT PULONGLONG Address,
   8773  *     ULONGLONG Value);
   8774  */
   8775 #define RtlStoreUlonglong(Address,Value) \
   8776     *(ULONGLONG UNALIGNED *)(Address) = (Value)
   8777 
   8778 /* VOID
   8779  * RtlStoreUshort(
   8780  *     IN PUSHORT Address,
   8781  *     IN USHORT Value);
   8782  */
   8783 #define RtlStoreUshort(Address,Value) \
   8784     *(USHORT UNALIGNED *)(Address) = (Value)
   8785 
   8786 /* VOID
   8787  * RtlRetrieveUshort(
   8788  *     PUSHORT DestinationAddress,
   8789  *    PUSHORT SourceAddress);
   8790  */
   8791 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
   8792     *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
   8793 
   8794 /* VOID
   8795  * RtlRetrieveUlong(
   8796  *    PULONG DestinationAddress,
   8797  *    PULONG SourceAddress);
   8798  */
   8799 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
   8800     *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
   8801 
   8802 #else
   8803 
   8804 #define RtlStoreUlong(Address,Value)                      \
   8805     if ((ULONG_PTR)(Address) & LONG_MASK) { \
   8806         ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT]    = (UCHAR)(FIRSTBYTE(Value)); \
   8807         ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \
   8808         ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \
   8809         ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT]     = (UCHAR)(FOURTHBYTE(Value)); \
   8810     } \
   8811     else { \
   8812         *((PULONG)(Address)) = (ULONG) (Value); \
   8813     }
   8814 
   8815 #define RtlStoreUlonglong(Address,Value) \
   8816     if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \
   8817         RtlStoreUlong((ULONG_PTR)(Address), \
   8818                       (ULONGLONG)(Value) & 0xFFFFFFFF); \
   8819         RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \
   8820                       (ULONGLONG)(Value) >> 32); \
   8821     } else { \
   8822         *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
   8823     }
   8824 
   8825 #define RtlStoreUshort(Address,Value) \
   8826     if ((ULONG_PTR)(Address) & SHORT_MASK) { \
   8827         ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
   8828         ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \
   8829     } \
   8830     else { \
   8831         *((PUSHORT) (Address)) = (USHORT)Value; \
   8832     }
   8833 
   8834 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
   8835     if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
   8836     { \
   8837         ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
   8838         ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
   8839     } \
   8840     else \
   8841     { \
   8842         *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
   8843     }
   8844 
   8845 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
   8846     if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
   8847     { \
   8848         ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
   8849         ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
   8850         ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
   8851         ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
   8852     } \
   8853     else \
   8854     { \
   8855         *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
   8856     }
   8857 
   8858 #endif /* defined(_AMD64_) */
   8859 
   8860 #ifdef _WIN64
   8861 /* VOID
   8862  * RtlStoreUlongPtr(
   8863  *     IN OUT PULONG_PTR Address,
   8864  *     IN ULONG_PTR Value);
   8865  */
   8866 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value)
   8867 #else
   8868 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value)
   8869 #endif /* _WIN64 */
   8870 
   8871 NTSYSAPI
   8872 BOOLEAN
   8873 NTAPI
   8874 RtlTimeFieldsToTime(
   8875   IN PTIME_FIELDS TimeFields,
   8876   IN PLARGE_INTEGER Time);
   8877 
   8878 NTSYSAPI
   8879 VOID
   8880 NTAPI
   8881 RtlTimeToTimeFields(
   8882   IN PLARGE_INTEGER Time,
   8883   IN PTIME_FIELDS TimeFields);
   8884 
   8885 NTSYSAPI
   8886 ULONG
   8887 FASTCALL
   8888 RtlUlongByteSwap(
   8889   IN ULONG Source);
   8890 
   8891 NTSYSAPI
   8892 ULONGLONG
   8893 FASTCALL
   8894 RtlUlonglongByteSwap(
   8895   IN ULONGLONG Source);
   8896 
   8897 NTSYSAPI
   8898 NTSTATUS
   8899 NTAPI
   8900 RtlUnicodeStringToAnsiString(
   8901   IN OUT PANSI_STRING DestinationString,
   8902   IN PCUNICODE_STRING SourceString,
   8903   IN BOOLEAN AllocateDestinationString);
   8904 
   8905 NTSYSAPI
   8906 ULONG
   8907 NTAPI
   8908 RtlxUnicodeStringToAnsiSize(
   8909   IN PCUNICODE_STRING UnicodeString);
   8910 
   8911 #define RtlUnicodeStringToAnsiSize(String) (                  \
   8912     NLS_MB_CODE_PAGE_TAG ?                                    \
   8913     RtlxUnicodeStringToAnsiSize(String) :                     \
   8914     ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
   8915 )
   8916 
   8917 NTSYSAPI
   8918 NTSTATUS
   8919 NTAPI
   8920 RtlUnicodeStringToInteger(
   8921   IN PCUNICODE_STRING String,
   8922   IN ULONG Base OPTIONAL,
   8923   OUT PULONG Value);
   8924 
   8925 NTSYSAPI
   8926 WCHAR
   8927 NTAPI
   8928 RtlUpcaseUnicodeChar(
   8929   IN WCHAR SourceCharacter);
   8930 
   8931 NTSYSAPI
   8932 USHORT
   8933 FASTCALL
   8934 RtlUshortByteSwap(
   8935   IN USHORT Source);
   8936 
   8937 NTSYSAPI
   8938 BOOLEAN
   8939 NTAPI
   8940 RtlValidRelativeSecurityDescriptor(
   8941   IN PSECURITY_DESCRIPTOR SecurityDescriptorInput,
   8942   IN ULONG SecurityDescriptorLength,
   8943   IN SECURITY_INFORMATION RequiredInformation);
   8944 
   8945 NTSYSAPI
   8946 BOOLEAN
   8947 NTAPI
   8948 RtlValidSecurityDescriptor(
   8949   IN PSECURITY_DESCRIPTOR SecurityDescriptor);
   8950 
   8951 NTSYSAPI
   8952 NTSTATUS
   8953 NTAPI
   8954 RtlWriteRegistryValue(
   8955   IN ULONG RelativeTo,
   8956   IN PCWSTR Path,
   8957   IN PCWSTR ValueName,
   8958   IN ULONG ValueType,
   8959   IN PVOID ValueData,
   8960   IN ULONG ValueLength);
   8961 
   8962 
   8963 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   8964 
   8965 
   8966 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
   8967 NTSYSAPI
   8968 VOID
   8969 FASTCALL
   8970 RtlPrefetchMemoryNonTemporal(
   8971   IN PVOID Source,
   8972   IN SIZE_T Length);
   8973 #endif
   8974 
   8975 
   8976 #if (NTDDI_VERSION >= NTDDI_WINXP)
   8977 
   8978 
   8979 NTSYSAPI
   8980 VOID
   8981 NTAPI
   8982 RtlClearBit(
   8983   PRTL_BITMAP BitMapHeader,
   8984   ULONG BitNumber);
   8985 
   8986 NTSYSAPI
   8987 WCHAR
   8988 NTAPI
   8989 RtlDowncaseUnicodeChar(
   8990   IN WCHAR SourceCharacter);
   8991 
   8992 NTSYSAPI
   8993 VOID
   8994 NTAPI
   8995 RtlSetBit(
   8996   PRTL_BITMAP BitMapHeader,
   8997   ULONG BitNumber);
   8998 
   8999 NTSYSAPI
   9000 BOOLEAN
   9001 NTAPI
   9002 RtlTestBit(
   9003   IN PRTL_BITMAP BitMapHeader,
   9004   IN ULONG BitNumber);
   9005 
   9006 NTSYSAPI
   9007 NTSTATUS
   9008 NTAPI
   9009 RtlHashUnicodeString(
   9010   IN CONST UNICODE_STRING *String,
   9011   IN BOOLEAN CaseInSensitive,
   9012   IN ULONG HashAlgorithm,
   9013   OUT PULONG HashValue);
   9014 
   9015 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
   9016 
   9017 
   9018 #if (NTDDI_VERSION >= NTDDI_VISTA)
   9019 
   9020 NTSYSAPI
   9021 ULONG
   9022 NTAPI
   9023 RtlNumberOfSetBitsUlongPtr(
   9024   IN ULONG_PTR Target);
   9025 
   9026 NTSYSAPI
   9027 ULONGLONG
   9028 NTAPI
   9029 RtlIoDecodeMemIoResource(
   9030   IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
   9031   OUT PULONGLONG Alignment OPTIONAL,
   9032   OUT PULONGLONG MinimumAddress OPTIONAL,
   9033   OUT PULONGLONG MaximumAddress OPTIONAL);
   9034 
   9035 NTSYSAPI
   9036 NTSTATUS
   9037 NTAPI
   9038 RtlIoEncodeMemIoResource(
   9039   IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
   9040   IN UCHAR Type,
   9041   IN ULONGLONG Length,
   9042   IN ULONGLONG Alignment,
   9043   IN ULONGLONG MinimumAddress,
   9044   IN ULONGLONG MaximumAddress);
   9045 
   9046 NTSYSAPI
   9047 ULONGLONG
   9048 NTAPI
   9049 RtlCmDecodeMemIoResource(
   9050   IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor,
   9051   OUT PULONGLONG Start OPTIONAL);
   9052 
   9053 NTSYSAPI
   9054 NTSTATUS
   9055 NTAPI
   9056 RtlFindClosestEncodableLength(
   9057   IN ULONGLONG SourceLength,
   9058   OUT PULONGLONG TargetLength);
   9059 
   9060 NTSYSAPI
   9061 NTSTATUS
   9062 NTAPI
   9063 RtlCmEncodeMemIoResource(
   9064   IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
   9065   IN UCHAR Type,
   9066   IN ULONGLONG Length,
   9067   IN ULONGLONG Start);
   9068 
   9069 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   9070 
   9071 #if (NTDDI_VERSION >= NTDDI_WIN7)
   9072 
   9073 NTSYSAPI
   9074 NTSTATUS
   9075 NTAPI
   9076 RtlUnicodeToUTF8N(
   9077   OUT PCHAR UTF8StringDestination,
   9078   IN ULONG UTF8StringMaxByteCount,
   9079   OUT PULONG UTF8StringActualByteCount,
   9080   IN PCWCH UnicodeStringSource,
   9081   IN ULONG UnicodeStringByteCount);
   9082 
   9083 NTSYSAPI
   9084 NTSTATUS
   9085 NTAPI
   9086 RtlUTF8ToUnicodeN(
   9087   OUT PWSTR UnicodeStringDestination,
   9088   IN ULONG UnicodeStringMaxByteCount,
   9089   OUT PULONG UnicodeStringActualByteCount,
   9090   IN PCCH UTF8StringSource,
   9091   IN ULONG UTF8StringByteCount);
   9092 
   9093 NTSYSAPI
   9094 ULONG64
   9095 NTAPI
   9096 RtlGetEnabledExtendedFeatures(
   9097   IN ULONG64 FeatureMask);
   9098 
   9099 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   9100 
   9101 
   9102 #if !defined(MIDL_PASS)
   9103 /* inline funftions */
   9104 //DECLSPEC_DEPRECATED_DDK_WINXP
   9105 static __inline
   9106 LARGE_INTEGER
   9107 NTAPI_INLINE
   9108 RtlConvertLongToLargeInteger(
   9109   IN LONG SignedInteger)
   9110 {
   9111   LARGE_INTEGER ret;
   9112   ret.QuadPart = SignedInteger;
   9113   return ret;
   9114 }
   9115 
   9116 //DECLSPEC_DEPRECATED_DDK_WINXP
   9117 static __inline
   9118 LARGE_INTEGER
   9119 NTAPI_INLINE
   9120 RtlConvertUlongToLargeInteger(
   9121   IN ULONG UnsignedInteger)
   9122 {
   9123   LARGE_INTEGER ret;
   9124   ret.QuadPart = UnsignedInteger;
   9125   return ret;
   9126 }
   9127 
   9128 //DECLSPEC_DEPRECATED_DDK_WINXP
   9129 static __inline
   9130 LARGE_INTEGER
   9131 NTAPI_INLINE
   9132 RtlLargeIntegerShiftLeft(
   9133   IN LARGE_INTEGER LargeInteger,
   9134   IN CCHAR ShiftCount)
   9135 {
   9136   LARGE_INTEGER Result;
   9137 
   9138   Result.QuadPart = LargeInteger.QuadPart << ShiftCount;
   9139   return Result;
   9140 }
   9141 
   9142 //DECLSPEC_DEPRECATED_DDK_WINXP
   9143 static __inline
   9144 LARGE_INTEGER
   9145 NTAPI_INLINE
   9146 RtlLargeIntegerShiftRight(
   9147   IN LARGE_INTEGER LargeInteger,
   9148   IN CCHAR ShiftCount)
   9149 {
   9150   LARGE_INTEGER Result;
   9151 
   9152   Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount;
   9153   return Result;
   9154 }
   9155 
   9156 //DECLSPEC_DEPRECATED_DDK
   9157 static __inline
   9158 ULONG
   9159 NTAPI_INLINE
   9160 RtlEnlargedUnsignedDivide(
   9161   IN ULARGE_INTEGER Dividend,
   9162   IN ULONG Divisor,
   9163   IN OUT PULONG Remainder)
   9164 {
   9165   if (Remainder)
   9166     *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
   9167   return (ULONG)(Dividend.QuadPart / Divisor);
   9168 }
   9169 
   9170 //DECLSPEC_DEPRECATED_DDK
   9171 static __inline
   9172 LARGE_INTEGER
   9173 NTAPI_INLINE
   9174 RtlLargeIntegerNegate(
   9175   IN LARGE_INTEGER Subtrahend)
   9176 {
   9177   LARGE_INTEGER Difference;
   9178 
   9179   Difference.QuadPart = -Subtrahend.QuadPart;
   9180   return Difference;
   9181 }
   9182 
   9183 //DECLSPEC_DEPRECATED_DDK
   9184 static __inline
   9185 LARGE_INTEGER
   9186 NTAPI_INLINE
   9187 RtlLargeIntegerSubtract(
   9188   IN LARGE_INTEGER Minuend,
   9189   IN LARGE_INTEGER Subtrahend)
   9190 {
   9191   LARGE_INTEGER Difference;
   9192 
   9193   Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart;
   9194   return Difference;
   9195 }
   9196 
   9197 //DECLSPEC_DEPRECATED_DDK
   9198 static __inline
   9199 LARGE_INTEGER
   9200 NTAPI_INLINE
   9201 RtlEnlargedUnsignedMultiply(
   9202   IN ULONG Multiplicand,
   9203   IN ULONG Multiplier)
   9204 {
   9205   LARGE_INTEGER ret;
   9206   ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
   9207   return ret;
   9208 }
   9209 
   9210 //DECLSPEC_DEPRECATED_DDK
   9211 static __inline
   9212 LARGE_INTEGER
   9213 NTAPI_INLINE
   9214 RtlEnlargedIntegerMultiply(
   9215   IN LONG Multiplicand,
   9216   IN LONG Multiplier)
   9217 {
   9218   LARGE_INTEGER ret;
   9219   ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
   9220   return ret;
   9221 }
   9222 
   9223 FORCEINLINE
   9224 VOID
   9225 RtlInitEmptyAnsiString(
   9226   OUT PANSI_STRING AnsiString,
   9227   IN PCHAR Buffer,
   9228   IN USHORT BufferSize)
   9229 {
   9230   AnsiString->Length = 0;
   9231   AnsiString->MaximumLength = BufferSize;
   9232   AnsiString->Buffer = Buffer;
   9233 }
   9234 
   9235 FORCEINLINE
   9236 VOID
   9237 RtlInitEmptyUnicodeString(
   9238   OUT PUNICODE_STRING UnicodeString,
   9239   IN PWSTR Buffer,
   9240   IN USHORT BufferSize)
   9241 {
   9242   UnicodeString->Length = 0;
   9243   UnicodeString->MaximumLength = BufferSize;
   9244   UnicodeString->Buffer = Buffer;
   9245 }
   9246 
   9247 #if defined(_AMD64_) || defined(_IA64_)
   9248 
   9249 static __inline
   9250 LARGE_INTEGER
   9251 NTAPI_INLINE
   9252 RtlExtendedIntegerMultiply(
   9253   IN LARGE_INTEGER Multiplicand,
   9254   IN LONG Multiplier)
   9255 {
   9256   LARGE_INTEGER ret;
   9257   ret.QuadPart = Multiplicand.QuadPart * Multiplier;
   9258   return ret;
   9259 }
   9260 
   9261 static __inline
   9262 LARGE_INTEGER
   9263 NTAPI_INLINE
   9264 RtlExtendedLargeIntegerDivide(
   9265   IN LARGE_INTEGER Dividend,
   9266   IN ULONG Divisor,
   9267   OUT PULONG Remainder OPTIONAL)
   9268 {
   9269   LARGE_INTEGER ret;
   9270   ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor;
   9271   if (Remainder)
   9272     *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
   9273   return ret;
   9274 }
   9275 
   9276 #endif /* defined(_AMD64_) || defined(_IA64_) */
   9277 
   9278 
   9279 #if defined(_AMD64_)
   9280 
   9281 #define MultiplyHigh __mulh
   9282 #define UnsignedMultiplyHigh __umulh
   9283 
   9284 //DECLSPEC_DEPRECATED_DDK
   9285 static __inline
   9286 LARGE_INTEGER
   9287 NTAPI_INLINE
   9288 RtlExtendedMagicDivide(
   9289   IN LARGE_INTEGER Dividend,
   9290   IN LARGE_INTEGER MagicDivisor,
   9291   IN CCHAR ShiftCount)
   9292 {
   9293   LARGE_INTEGER ret;
   9294   ULONG64 ret64;
   9295   BOOLEAN Pos;
   9296   Pos = (Dividend.QuadPart >= 0);
   9297   ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart,
   9298                                MagicDivisor.QuadPart);
   9299   ret64 >>= ShiftCount;
   9300   ret.QuadPart = Pos ? ret64 : -(LONG64)ret64;
   9301   return ret;
   9302 }
   9303 #endif
   9304 
   9305 //DECLSPEC_DEPRECATED_DDK
   9306 static __inline
   9307 LARGE_INTEGER
   9308 NTAPI_INLINE
   9309 RtlLargeIntegerAdd(
   9310   IN LARGE_INTEGER Addend1,
   9311   IN LARGE_INTEGER Addend2)
   9312 {
   9313   LARGE_INTEGER ret;
   9314   ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart;
   9315   return ret;
   9316 }
   9317 
   9318 /* VOID
   9319  * RtlLargeIntegerAnd(
   9320  *     IN OUT LARGE_INTEGER Result,
   9321  *     IN LARGE_INTEGER Source,
   9322  *     IN LARGE_INTEGER Mask);
   9323  */
   9324 #define RtlLargeIntegerAnd(Result, Source, Mask) \
   9325     Result.QuadPart = Source.QuadPart & Mask.QuadPart
   9326 
   9327 //DECLSPEC_DEPRECATED_DDK
   9328 static __inline
   9329 LARGE_INTEGER
   9330 NTAPI_INLINE
   9331 RtlLargeIntegerArithmeticShift(
   9332   IN LARGE_INTEGER LargeInteger,
   9333   IN CCHAR ShiftCount)
   9334 {
   9335   LARGE_INTEGER ret;
   9336   ret.QuadPart = LargeInteger.QuadPart >> ShiftCount;
   9337   return ret;
   9338 }
   9339 
   9340 /* BOOLEAN
   9341  * RtlLargeIntegerEqualTo(
   9342  *     IN LARGE_INTEGER  Operand1,
   9343  *     IN LARGE_INTEGER  Operand2);
   9344  */
   9345 #define RtlLargeIntegerEqualTo(X,Y) \
   9346     (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
   9347 
   9348 FORCEINLINE
   9349 PVOID
   9350 RtlSecureZeroMemory(
   9351   OUT PVOID Pointer,
   9352   IN SIZE_T Size)
   9353 {
   9354   volatile char* vptr = (volatile char*)Pointer;
   9355 #if defined(_M_AMD64)
   9356   __stosb((PUCHAR)vptr, 0, Size);
   9357 #else
   9358   char * endptr = (char *)vptr + Size;
   9359   while (vptr < endptr) {
   9360     *vptr = 0; vptr++;
   9361   }
   9362 #endif
   9363    return Pointer;
   9364 }
   9365 
   9366 #if defined(_M_AMD64)
   9367 FORCEINLINE
   9368 BOOLEAN
   9369 RtlCheckBit(
   9370   IN PRTL_BITMAP BitMapHeader,
   9371   IN ULONG BitPosition)
   9372 {
   9373   return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition);
   9374 }
   9375 #else
   9376 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
   9377 #endif /* defined(_M_AMD64) */
   9378 
   9379 #define RtlLargeIntegerGreaterThan(X,Y) (                              \
   9380     (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
   9381     ((X).HighPart > (Y).HighPart)                                      \
   9382 )
   9383 
   9384 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) (                      \
   9385     (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
   9386     ((X).HighPart > (Y).HighPart)                                       \
   9387 )
   9388 
   9389 #define RtlLargeIntegerNotEqualTo(X,Y) (                          \
   9390     (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
   9391 )
   9392 
   9393 #define RtlLargeIntegerLessThan(X,Y) (                                 \
   9394     (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
   9395     ((X).HighPart < (Y).HighPart)                                      \
   9396 )
   9397 
   9398 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) (                         \
   9399     (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
   9400     ((X).HighPart < (Y).HighPart)                                       \
   9401 )
   9402 
   9403 #define RtlLargeIntegerGreaterThanZero(X) (       \
   9404     (((X).HighPart == 0) && ((X).LowPart > 0)) || \
   9405     ((X).HighPart > 0 )                           \
   9406 )
   9407 
   9408 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
   9409 
   9410 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
   9411 
   9412 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
   9413 
   9414 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
   9415 
   9416 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
   9417 
   9418 #endif /* !defined(MIDL_PASS) */
   9419 
   9420 /* Byte Swap Functions */
   9421 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \
   9422     ((defined(_M_AMD64) || defined(_M_IA64)) \
   9423         && (_MSC_FULL_VER > 13009175 || defined(__GNUC__)))
   9424 
   9425 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
   9426 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
   9427 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
   9428 
   9429 #endif
   9430 
   9431 #if DBG
   9432 
   9433 #define ASSERT(exp) \
   9434   (VOID)((!(exp)) ? \
   9435     RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
   9436 
   9437 #define ASSERTMSG(msg, exp) \
   9438   (VOID)((!(exp)) ? \
   9439     RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE)
   9440 
   9441 #define RTL_SOFT_ASSERT(exp) \
   9442   (VOID)((!(exp)) ? \
   9443     DbgPrint("%s(%d): Soft assertion failed\n   Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
   9444 
   9445 #define RTL_SOFT_ASSERTMSG(msg, exp) \
   9446   (VOID)((!(exp)) ? \
   9447     DbgPrint("%s(%d): Soft assertion failed\n   Expression: %s\n   Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
   9448 
   9449 #define RTL_VERIFY(exp) ASSERT(exp)
   9450 #define RTL_VERIFYMSG(msg, exp) ASSERTMSG(msg, exp)
   9451 
   9452 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
   9453 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
   9454 
   9455 #if defined(_MSC_VER)
   9456 
   9457 #define NT_ASSERT(exp) \
   9458    ((!(exp)) ? \
   9459       (__annotation(L"Debug", L"AssertFail", L#exp), \
   9460        DbgRaiseAssertionFailure(), FALSE) : TRUE)
   9461 
   9462 #define NT_ASSERTMSG(msg, exp) \
   9463    ((!(exp)) ? \
   9464       (__annotation(L"Debug", L"AssertFail", L##msg), \
   9465       DbgRaiseAssertionFailure(), FALSE) : TRUE)
   9466 
   9467 #define NT_ASSERTMSGW(msg, exp) \
   9468     ((!(exp)) ? \
   9469         (__annotation(L"Debug", L"AssertFail", msg), \
   9470          DbgRaiseAssertionFailure(), FALSE) : TRUE)
   9471 
   9472 #define NT_VERIFY     NT_ASSERT
   9473 #define NT_VERIFYMSG  NT_ASSERTMSG
   9474 #define NT_VERIFYMSGW NT_ASSERTMSGW
   9475 
   9476 #else
   9477 
   9478 /* GCC doesn't support __annotation (nor PDB) */
   9479 #define NT_ASSERT(exp) \
   9480    (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
   9481 
   9482 #define NT_ASSERTMSG NT_ASSERT
   9483 #define NT_ASSERTMSGW NT_ASSERT
   9484 
   9485 #endif
   9486 
   9487 #else /* !DBG */
   9488 
   9489 #define ASSERT(exp) ((VOID) 0)
   9490 #define ASSERTMSG(msg, exp) ((VOID) 0)
   9491 
   9492 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
   9493 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
   9494 
   9495 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
   9496 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
   9497 
   9498 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
   9499 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
   9500 
   9501 #define NT_ASSERT(exp)          ((VOID)0)
   9502 #define NT_ASSERTMSG(msg, exp)  ((VOID)0)
   9503 #define NT_ASSERTMSGW(msg, exp) ((VOID)0)
   9504 
   9505 #define NT_VERIFY(_exp)           ((_exp) ? TRUE : FALSE)
   9506 #define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
   9507 #define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
   9508 
   9509 #endif /* DBG */
   9510 
   9511 #define InitializeListHead32(ListHead) (\
   9512     (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
   9513 
   9514 #if !defined(_WINBASE_)
   9515 
   9516 #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
   9517 
   9518 NTKERNELAPI
   9519 VOID
   9520 InitializeSListHead(
   9521   OUT PSLIST_HEADER SListHead);
   9522 
   9523 #else
   9524 
   9525 FORCEINLINE
   9526 VOID
   9527 InitializeSListHead(
   9528   OUT PSLIST_HEADER SListHead)
   9529 {
   9530 #if defined(_IA64_)
   9531   ULONG64 FeatureBits;
   9532 #endif
   9533 
   9534 #if defined(_WIN64)
   9535   if (((ULONG_PTR)SListHead & 0xf) != 0) {
   9536     RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
   9537   }
   9538 #endif
   9539   RtlZeroMemory(SListHead, sizeof(SLIST_HEADER));
   9540 #if defined(_IA64_)
   9541   FeatureBits = __getReg(CV_IA64_CPUID4);
   9542   if ((FeatureBits & KF_16BYTE_INSTR) != 0) {
   9543     SListHead->Header16.HeaderType = 1;
   9544     SListHead->Header16.Init = 1;
   9545   }
   9546 #endif
   9547 }
   9548 
   9549 #endif
   9550 
   9551 #if defined(_WIN64)
   9552 
   9553 #define InterlockedPopEntrySList(Head) \
   9554     ExpInterlockedPopEntrySList(Head)
   9555 
   9556 #define InterlockedPushEntrySList(Head, Entry) \
   9557     ExpInterlockedPushEntrySList(Head, Entry)
   9558 
   9559 #define InterlockedFlushSList(Head) \
   9560     ExpInterlockedFlushSList(Head)
   9561 
   9562 #define QueryDepthSList(Head) \
   9563     ExQueryDepthSList(Head)
   9564 
   9565 #else /* !defined(_WIN64) */
   9566 
   9567 NTKERNELAPI
   9568 PSLIST_ENTRY
   9569 FASTCALL
   9570 InterlockedPopEntrySList(
   9571   IN PSLIST_HEADER ListHead);
   9572 
   9573 NTKERNELAPI
   9574 PSLIST_ENTRY
   9575 FASTCALL
   9576 InterlockedPushEntrySList(
   9577   IN PSLIST_HEADER ListHead,
   9578   IN PSLIST_ENTRY ListEntry);
   9579 
   9580 #define InterlockedFlushSList(ListHead) \
   9581     ExInterlockedFlushSList(ListHead)
   9582 
   9583 #define QueryDepthSList(Head) \
   9584     ExQueryDepthSList(Head)
   9585 
   9586 #endif /* !defined(_WIN64) */
   9587 
   9588 #endif /* !defined(_WINBASE_) */
   9589 
   9590 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
   9591 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
   9592 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk)       \
   9593     ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
   9594 #define RTL_CONTEXT_OFFSET(Context, Chunk)              \
   9595     RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
   9596 #define RTL_CONTEXT_LENGTH(Context, Chunk)              \
   9597     RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
   9598 #define RTL_CONTEXT_CHUNK(Context, Chunk)               \
   9599     RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1),    \
   9600                          (PCONTEXT_EX)(Context + 1),    \
   9601                          Chunk)
   9602 
   9603 BOOLEAN
   9604 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)(
   9605   IN ULONG Version);
   9606 
   9607 BOOLEAN
   9608 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)(
   9609   IN ULONG Version);
   9610 
   9611 #ifndef RtlIsNtDdiVersionAvailable
   9612 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
   9613 #endif
   9614 
   9615 #ifndef RtlIsServicePackVersionInstalled
   9616 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
   9617 #endif
   9618 
   9619 #define RtlInterlockedSetBits(Flags, Flag) \
   9620     InterlockedOr((PLONG)(Flags), Flag)
   9621 
   9622 #define RtlInterlockedAndBits(Flags, Flag) \
   9623     InterlockedAnd((PLONG)(Flags), Flag)
   9624 
   9625 #define RtlInterlockedClearBits(Flags, Flag) \
   9626     RtlInterlockedAndBits(Flags, ~(Flag))
   9627 
   9628 #define RtlInterlockedXorBits(Flags, Flag) \
   9629     InterlockedXor(Flags, Flag)
   9630 
   9631 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
   9632     (VOID) RtlInterlockedSetBits(Flags, Flag)
   9633 
   9634 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
   9635     (VOID) RtlInterlockedAndBits(Flags, Flag)
   9636 
   9637 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
   9638     RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
   9639 
   9640 
   9641 /******************************************************************************
   9642  *                              Kernel Functions                              *
   9643  ******************************************************************************/
   9644 NTKERNELAPI
   9645 VOID
   9646 NTAPI
   9647 KeInitializeEvent(
   9648   OUT PRKEVENT Event,
   9649   IN EVENT_TYPE Type,
   9650   IN BOOLEAN State);
   9651 
   9652 NTKERNELAPI
   9653 VOID
   9654 NTAPI
   9655 KeClearEvent(
   9656   IN OUT PRKEVENT Event);
   9657 
   9658 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   9659 
   9660 #if defined(_NTDDK_) || defined(_NTIFS_)
   9661 NTKERNELAPI
   9662 VOID
   9663 NTAPI
   9664 ProbeForRead(
   9665   IN CONST VOID *Address, /* CONST is added */
   9666   IN SIZE_T Length,
   9667   IN ULONG Alignment);
   9668 #endif /* defined(_NTDDK_) || defined(_NTIFS_) */
   9669 
   9670 NTKERNELAPI
   9671 VOID
   9672 NTAPI
   9673 ProbeForWrite(
   9674   IN PVOID Address,
   9675   IN SIZE_T Length,
   9676   IN ULONG Alignment);
   9677 
   9678 #if defined(SINGLE_GROUP_LEGACY_API)
   9679 
   9680 NTKERNELAPI
   9681 VOID
   9682 NTAPI
   9683 KeRevertToUserAffinityThread(VOID);
   9684 
   9685 NTKERNELAPI
   9686 VOID
   9687 NTAPI
   9688 KeSetSystemAffinityThread(
   9689   IN KAFFINITY Affinity);
   9690 
   9691 NTKERNELAPI
   9692 VOID
   9693 NTAPI
   9694 KeSetTargetProcessorDpc(
   9695   IN OUT PRKDPC Dpc,
   9696   IN CCHAR Number);
   9697 
   9698 NTKERNELAPI
   9699 KAFFINITY
   9700 NTAPI
   9701 KeQueryActiveProcessors(VOID);
   9702 #endif /* defined(SINGLE_GROUP_LEGACY_API) */
   9703 
   9704 #if !defined(_M_AMD64)
   9705 NTKERNELAPI
   9706 ULONGLONG
   9707 NTAPI
   9708 KeQueryInterruptTime(VOID);
   9709 
   9710 NTKERNELAPI
   9711 VOID
   9712 NTAPI
   9713 KeQuerySystemTime(
   9714   OUT PLARGE_INTEGER CurrentTime);
   9715 #endif /* !_M_AMD64 */
   9716 
   9717 #if !defined(_X86_) && !defined(_M_ARM)
   9718 NTKERNELAPI
   9719 KIRQL
   9720 NTAPI
   9721 KeAcquireSpinLockRaiseToDpc(
   9722   IN OUT PKSPIN_LOCK SpinLock);
   9723 
   9724 #define KeAcquireSpinLock(SpinLock, OldIrql) \
   9725     *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
   9726 
   9727 NTKERNELAPI
   9728 VOID
   9729 NTAPI
   9730 KeAcquireSpinLockAtDpcLevel(
   9731   IN OUT PKSPIN_LOCK SpinLock);
   9732 
   9733 NTKERNELAPI
   9734 VOID
   9735 NTAPI
   9736 KeReleaseSpinLock(
   9737   IN OUT PKSPIN_LOCK SpinLock,
   9738   IN KIRQL NewIrql);
   9739 
   9740 NTKERNELAPI
   9741 VOID
   9742 NTAPI
   9743 KeReleaseSpinLockFromDpcLevel(
   9744   IN OUT PKSPIN_LOCK SpinLock);
   9745 #endif /* !_X86_ */
   9746 
   9747 #if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK))
   9748 NTKERNELAPI
   9749 VOID
   9750 NTAPI
   9751 KeInitializeSpinLock(
   9752   IN PKSPIN_LOCK SpinLock);
   9753 #else
   9754 FORCEINLINE
   9755 VOID
   9756 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
   9757 {
   9758   /* Clear the lock */
   9759   *SpinLock = 0;
   9760 }
   9761 #endif
   9762 
   9763 NTKERNELAPI
   9764 DECLSPEC_NORETURN
   9765 VOID
   9766 NTAPI
   9767 KeBugCheckEx(
   9768   IN ULONG BugCheckCode,
   9769   IN ULONG_PTR BugCheckParameter1,
   9770   IN ULONG_PTR BugCheckParameter2,
   9771   IN ULONG_PTR BugCheckParameter3,
   9772   IN ULONG_PTR BugCheckParameter4);
   9773 
   9774 NTKERNELAPI
   9775 BOOLEAN
   9776 NTAPI
   9777 KeCancelTimer(
   9778   IN OUT PKTIMER);
   9779 
   9780 NTKERNELAPI
   9781 NTSTATUS
   9782 NTAPI
   9783 KeDelayExecutionThread(
   9784   IN KPROCESSOR_MODE WaitMode,
   9785   IN BOOLEAN Alertable,
   9786   IN PLARGE_INTEGER Interval);
   9787 
   9788 NTKERNELAPI
   9789 BOOLEAN
   9790 NTAPI
   9791 KeDeregisterBugCheckCallback(
   9792   IN OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
   9793 
   9794 NTKERNELAPI
   9795 VOID
   9796 NTAPI
   9797 KeEnterCriticalRegion(VOID);
   9798 
   9799 NTKERNELAPI
   9800 VOID
   9801 NTAPI
   9802 KeInitializeDeviceQueue(
   9803   OUT PKDEVICE_QUEUE DeviceQueue);
   9804 
   9805 NTKERNELAPI
   9806 VOID
   9807 NTAPI
   9808 KeInitializeDpc(
   9809   OUT PRKDPC Dpc,
   9810   IN PKDEFERRED_ROUTINE DeferredRoutine,
   9811   IN PVOID DeferredContext OPTIONAL);
   9812 
   9813 NTKERNELAPI
   9814 VOID
   9815 NTAPI
   9816 KeInitializeMutex(
   9817   OUT PRKMUTEX Mutex,
   9818   IN ULONG Level);
   9819 
   9820 NTKERNELAPI
   9821 VOID
   9822 NTAPI
   9823 KeInitializeSemaphore(
   9824   OUT PRKSEMAPHORE Semaphore,
   9825   IN LONG Count,
   9826   IN LONG Limit);
   9827 
   9828 NTKERNELAPI
   9829 VOID
   9830 NTAPI
   9831 KeInitializeTimer(
   9832   OUT PKTIMER Timer);
   9833 
   9834 NTKERNELAPI
   9835 VOID
   9836 NTAPI
   9837 KeInitializeTimerEx(
   9838   OUT PKTIMER Timer,
   9839   IN TIMER_TYPE Type);
   9840 
   9841 NTKERNELAPI
   9842 BOOLEAN
   9843 NTAPI
   9844 KeInsertByKeyDeviceQueue(
   9845   IN OUT PKDEVICE_QUEUE DeviceQueue,
   9846   IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry,
   9847   IN ULONG SortKey);
   9848 
   9849 NTKERNELAPI
   9850 BOOLEAN
   9851 NTAPI
   9852 KeInsertDeviceQueue(
   9853   IN OUT PKDEVICE_QUEUE DeviceQueue,
   9854   IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
   9855 
   9856 NTKERNELAPI
   9857 BOOLEAN
   9858 NTAPI
   9859 KeInsertQueueDpc(
   9860   IN OUT PRKDPC Dpc,
   9861   IN PVOID SystemArgument1 OPTIONAL,
   9862   IN PVOID SystemArgument2 OPTIONAL);
   9863 
   9864 NTKERNELAPI
   9865 VOID
   9866 NTAPI
   9867 KeLeaveCriticalRegion(VOID);
   9868 
   9869 NTHALAPI
   9870 LARGE_INTEGER
   9871 NTAPI
   9872 KeQueryPerformanceCounter(
   9873   OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL);
   9874 
   9875 NTKERNELAPI
   9876 KPRIORITY
   9877 NTAPI
   9878 KeQueryPriorityThread(
   9879   IN PRKTHREAD Thread);
   9880 
   9881 NTKERNELAPI
   9882 ULONG
   9883 NTAPI
   9884 KeQueryTimeIncrement(VOID);
   9885 
   9886 NTKERNELAPI
   9887 LONG
   9888 NTAPI
   9889 KeReadStateEvent(
   9890   IN PRKEVENT Event);
   9891 
   9892 NTKERNELAPI
   9893 LONG
   9894 NTAPI
   9895 KeReadStateMutex(
   9896   IN PRKMUTEX Mutex);
   9897 
   9898 NTKERNELAPI
   9899 LONG
   9900 NTAPI
   9901 KeReadStateSemaphore(
   9902   IN PRKSEMAPHORE Semaphore);
   9903 
   9904 NTKERNELAPI
   9905 BOOLEAN
   9906 NTAPI
   9907 KeReadStateTimer(
   9908   IN PKTIMER Timer);
   9909 
   9910 NTKERNELAPI
   9911 BOOLEAN
   9912 NTAPI
   9913 KeRegisterBugCheckCallback(
   9914   OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
   9915   IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
   9916   IN PVOID Buffer,
   9917   IN ULONG Length,
   9918   IN PUCHAR Component);
   9919 
   9920 NTKERNELAPI
   9921 LONG
   9922 NTAPI
   9923 KeReleaseMutex(
   9924   IN OUT PRKMUTEX Mutex,
   9925   IN BOOLEAN Wait);
   9926 
   9927 NTKERNELAPI
   9928 LONG
   9929 NTAPI
   9930 KeReleaseSemaphore(
   9931   IN OUT PRKSEMAPHORE Semaphore,
   9932   IN KPRIORITY Increment,
   9933   IN LONG Adjustment,
   9934   IN BOOLEAN Wait);
   9935 
   9936 NTKERNELAPI
   9937 PKDEVICE_QUEUE_ENTRY
   9938 NTAPI
   9939 KeRemoveByKeyDeviceQueue(
   9940   IN OUT PKDEVICE_QUEUE DeviceQueue,
   9941   IN ULONG SortKey);
   9942 
   9943 NTKERNELAPI
   9944 PKDEVICE_QUEUE_ENTRY
   9945 NTAPI
   9946 KeRemoveDeviceQueue(
   9947   IN OUT PKDEVICE_QUEUE DeviceQueue);
   9948 
   9949 NTKERNELAPI
   9950 BOOLEAN
   9951 NTAPI
   9952 KeRemoveEntryDeviceQueue(
   9953   IN OUT PKDEVICE_QUEUE DeviceQueue,
   9954   IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
   9955 
   9956 NTKERNELAPI
   9957 BOOLEAN
   9958 NTAPI
   9959 KeRemoveQueueDpc(
   9960   IN OUT PRKDPC Dpc);
   9961 
   9962 NTKERNELAPI
   9963 LONG
   9964 NTAPI
   9965 KeResetEvent(
   9966   IN OUT PRKEVENT Event);
   9967 
   9968 NTKERNELAPI
   9969 LONG
   9970 NTAPI
   9971 KeSetEvent(
   9972   IN OUT PRKEVENT Event,
   9973   IN KPRIORITY Increment,
   9974   IN BOOLEAN Wait);
   9975 
   9976 NTKERNELAPI
   9977 VOID
   9978 NTAPI
   9979 KeSetImportanceDpc(
   9980   IN OUT PRKDPC Dpc,
   9981   IN KDPC_IMPORTANCE Importance);
   9982 
   9983 NTKERNELAPI
   9984 KPRIORITY
   9985 NTAPI
   9986 KeSetPriorityThread(
   9987   IN OUT PKTHREAD Thread,
   9988   IN KPRIORITY Priority);
   9989 
   9990 NTKERNELAPI
   9991 BOOLEAN
   9992 NTAPI
   9993 KeSetTimer(
   9994   IN OUT PKTIMER Timer,
   9995   IN LARGE_INTEGER DueTime,
   9996   IN PKDPC Dpc OPTIONAL);
   9997 
   9998 NTKERNELAPI
   9999 BOOLEAN
   10000 NTAPI
   10001 KeSetTimerEx(
   10002   IN OUT PKTIMER Timer,
   10003   IN LARGE_INTEGER DueTime,
   10004   IN LONG Period OPTIONAL,
   10005   IN PKDPC Dpc OPTIONAL);
   10006 
   10007 NTHALAPI
   10008 VOID
   10009 NTAPI
   10010 KeStallExecutionProcessor(
   10011   IN ULONG MicroSeconds);
   10012 
   10013 NTKERNELAPI
   10014 BOOLEAN
   10015 NTAPI
   10016 KeSynchronizeExecution(
   10017   IN OUT PKINTERRUPT Interrupt,
   10018   IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
   10019   IN PVOID SynchronizeContext OPTIONAL);
   10020 
   10021 NTKERNELAPI
   10022 NTSTATUS
   10023 NTAPI
   10024 KeWaitForMultipleObjects(
   10025   IN ULONG Count,
   10026   IN PVOID Object[],
   10027   IN WAIT_TYPE WaitType,
   10028   IN KWAIT_REASON WaitReason,
   10029   IN KPROCESSOR_MODE WaitMode,
   10030   IN BOOLEAN Alertable,
   10031   IN PLARGE_INTEGER Timeout OPTIONAL,
   10032   OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL);
   10033 
   10034 #define KeWaitForMutexObject KeWaitForSingleObject
   10035 
   10036 NTKERNELAPI
   10037 NTSTATUS
   10038 NTAPI
   10039 KeWaitForSingleObject(
   10040   IN PVOID Object,
   10041   IN KWAIT_REASON WaitReason,
   10042   IN KPROCESSOR_MODE WaitMode,
   10043   IN BOOLEAN Alertable,
   10044   IN PLARGE_INTEGER Timeout OPTIONAL);
   10045 
   10046 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   10047 
   10048 #if (NTDDI_VERSION >= NTDDI_WINXP)
   10049 
   10050 _DECL_HAL_KE_IMPORT
   10051 VOID
   10052 FASTCALL
   10053 KeAcquireInStackQueuedSpinLock(
   10054   IN OUT PKSPIN_LOCK SpinLock,
   10055   OUT PKLOCK_QUEUE_HANDLE LockHandle);
   10056 
   10057 NTKERNELAPI
   10058 VOID
   10059 FASTCALL
   10060 KeAcquireInStackQueuedSpinLockAtDpcLevel(
   10061   IN OUT PKSPIN_LOCK SpinLock,
   10062   OUT PKLOCK_QUEUE_HANDLE LockHandle);
   10063 
   10064 NTKERNELAPI
   10065 KIRQL
   10066 NTAPI
   10067 KeAcquireInterruptSpinLock(
   10068   IN OUT PKINTERRUPT Interrupt);
   10069 
   10070 NTKERNELAPI
   10071 BOOLEAN
   10072 NTAPI
   10073 KeAreApcsDisabled(VOID);
   10074 
   10075 NTKERNELAPI
   10076 ULONG
   10077 NTAPI
   10078 KeGetRecommendedSharedDataAlignment(VOID);
   10079 
   10080 NTKERNELAPI
   10081 ULONG
   10082 NTAPI
   10083 KeQueryRuntimeThread(
   10084   IN PKTHREAD Thread,
   10085   OUT PULONG UserTime);
   10086 
   10087 NTKERNELAPI
   10088 VOID
   10089 FASTCALL
   10090 KeReleaseInStackQueuedSpinLockFromDpcLevel(
   10091   IN PKLOCK_QUEUE_HANDLE LockHandle);
   10092 
   10093 NTKERNELAPI
   10094 VOID
   10095 NTAPI
   10096 KeReleaseInterruptSpinLock(
   10097   IN OUT PKINTERRUPT Interrupt,
   10098   IN KIRQL OldIrql);
   10099 
   10100 NTKERNELAPI
   10101 PKDEVICE_QUEUE_ENTRY
   10102 NTAPI
   10103 KeRemoveByKeyDeviceQueueIfBusy(
   10104   IN OUT PKDEVICE_QUEUE DeviceQueue,
   10105   IN ULONG SortKey);
   10106 
   10107 _DECL_HAL_KE_IMPORT
   10108 VOID
   10109 FASTCALL
   10110 KeReleaseInStackQueuedSpinLock(
   10111   IN PKLOCK_QUEUE_HANDLE LockHandle);
   10112 
   10113 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
   10114 
   10115 #if (NTDDI_VERSION >= NTDDI_WINXPSP1)
   10116 
   10117 NTKERNELAPI
   10118 BOOLEAN
   10119 NTAPI
   10120 KeDeregisterBugCheckReasonCallback(
   10121   IN OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord);
   10122 
   10123 NTKERNELAPI
   10124 BOOLEAN
   10125 NTAPI
   10126 KeRegisterBugCheckReasonCallback(
   10127   OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord,
   10128   IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine,
   10129   IN KBUGCHECK_CALLBACK_REASON Reason,
   10130   IN PUCHAR Component);
   10131 
   10132 #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */
   10133 
   10134 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
   10135 NTKERNELAPI
   10136 VOID
   10137 NTAPI
   10138 KeFlushQueuedDpcs(VOID);
   10139 #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
   10140 #if (NTDDI_VERSION >= NTDDI_WS03)
   10141 
   10142 NTKERNELAPI
   10143 PVOID
   10144 NTAPI
   10145 KeRegisterNmiCallback(
   10146   IN PNMI_CALLBACK CallbackRoutine,
   10147   IN PVOID Context OPTIONAL);
   10148 
   10149 NTKERNELAPI
   10150 NTSTATUS
   10151 NTAPI
   10152 KeDeregisterNmiCallback(
   10153   IN PVOID Handle);
   10154 
   10155 NTKERNELAPI
   10156 VOID
   10157 NTAPI
   10158 KeInitializeThreadedDpc(
   10159   OUT PRKDPC Dpc,
   10160   IN PKDEFERRED_ROUTINE DeferredRoutine,
   10161   IN PVOID DeferredContext OPTIONAL);
   10162 
   10163 NTKERNELAPI
   10164 ULONG_PTR
   10165 NTAPI
   10166 KeIpiGenericCall(
   10167   IN PKIPI_BROADCAST_WORKER BroadcastFunction,
   10168   IN ULONG_PTR Context);
   10169 
   10170 NTKERNELAPI
   10171 KIRQL
   10172 FASTCALL
   10173 KeAcquireSpinLockForDpc(
   10174   IN OUT PKSPIN_LOCK SpinLock);
   10175 
   10176 NTKERNELAPI
   10177 VOID
   10178 FASTCALL
   10179 KeReleaseSpinLockForDpc(
   10180   IN OUT PKSPIN_LOCK SpinLock,
   10181   IN KIRQL OldIrql);
   10182 
   10183 NTKERNELAPI
   10184 BOOLEAN
   10185 FASTCALL
   10186 KeTestSpinLock(
   10187   IN PKSPIN_LOCK SpinLock);
   10188 
   10189 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */
   10190 
   10191 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
   10192 
   10193 NTKERNELAPI
   10194 BOOLEAN
   10195 FASTCALL
   10196 KeTryToAcquireSpinLockAtDpcLevel(
   10197   IN OUT PKSPIN_LOCK SpinLock);
   10198 
   10199 NTKERNELAPI
   10200 BOOLEAN
   10201 NTAPI
   10202 KeAreAllApcsDisabled(VOID);
   10203 
   10204 NTKERNELAPI
   10205 VOID
   10206 FASTCALL
   10207 KeAcquireGuardedMutex(
   10208   IN OUT PKGUARDED_MUTEX GuardedMutex);
   10209 
   10210 NTKERNELAPI
   10211 VOID
   10212 FASTCALL
   10213 KeAcquireGuardedMutexUnsafe(
   10214   IN OUT PKGUARDED_MUTEX GuardedMutex);
   10215 
   10216 NTKERNELAPI
   10217 VOID
   10218 NTAPI
   10219 KeEnterGuardedRegion(VOID);
   10220 
   10221 NTKERNELAPI
   10222 VOID
   10223 NTAPI
   10224 KeLeaveGuardedRegion(VOID);
   10225 
   10226 NTKERNELAPI
   10227 VOID
   10228 FASTCALL
   10229 KeInitializeGuardedMutex(
   10230   OUT PKGUARDED_MUTEX GuardedMutex);
   10231 
   10232 NTKERNELAPI
   10233 VOID
   10234 FASTCALL
   10235 KeReleaseGuardedMutexUnsafe(
   10236   IN OUT PKGUARDED_MUTEX GuardedMutex);
   10237 
   10238 NTKERNELAPI
   10239 VOID
   10240 FASTCALL
   10241 KeReleaseGuardedMutex(
   10242   IN OUT PKGUARDED_MUTEX GuardedMutex);
   10243 
   10244 NTKERNELAPI
   10245 BOOLEAN
   10246 FASTCALL
   10247 KeTryToAcquireGuardedMutex(
   10248   IN OUT PKGUARDED_MUTEX GuardedMutex);
   10249 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
   10250 
   10251 #if (NTDDI_VERSION >= NTDDI_VISTA)
   10252 NTKERNELAPI
   10253 VOID
   10254 FASTCALL
   10255 KeAcquireInStackQueuedSpinLockForDpc(
   10256   IN OUT PKSPIN_LOCK SpinLock,
   10257   OUT PKLOCK_QUEUE_HANDLE LockHandle);
   10258 
   10259 NTKERNELAPI
   10260 VOID
   10261 FASTCALL
   10262 KeReleaseInStackQueuedSpinLockForDpc(
   10263   IN PKLOCK_QUEUE_HANDLE LockHandle);
   10264 
   10265 NTKERNELAPI
   10266 NTSTATUS
   10267 NTAPI
   10268 KeQueryDpcWatchdogInformation(
   10269   OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation);
   10270 #if defined(SINGLE_GROUP_LEGACY_API)
   10271 
   10272 NTKERNELAPI
   10273 KAFFINITY
   10274 NTAPI
   10275 KeSetSystemAffinityThreadEx(
   10276   IN KAFFINITY Affinity);
   10277 
   10278 NTKERNELAPI
   10279 VOID
   10280 NTAPI
   10281 KeRevertToUserAffinityThreadEx(
   10282   IN KAFFINITY Affinity);
   10283 
   10284 NTKERNELAPI
   10285 ULONG
   10286 NTAPI
   10287 KeQueryActiveProcessorCount(
   10288   OUT PKAFFINITY ActiveProcessors OPTIONAL);
   10289 
   10290 NTKERNELAPI
   10291 ULONG
   10292 NTAPI
   10293 KeQueryMaximumProcessorCount(VOID);
   10294 #endif /* SINGLE_GROUP_LEGACY_API */
   10295 
   10296 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   10297 
   10298 #if (NTDDI_VERSION >= NTDDI_WS08)
   10299 
   10300 PVOID
   10301 KeRegisterProcessorChangeCallback(
   10302   IN PPROCESSOR_CALLBACK_FUNCTION CallbackFunction,
   10303   IN PVOID CallbackContext OPTIONAL,
   10304   IN ULONG Flags);
   10305 
   10306 VOID
   10307 KeDeregisterProcessorChangeCallback(
   10308   IN PVOID CallbackHandle);
   10309 
   10310 #endif /* (NTDDI_VERSION >= NTDDI_WS08) */
   10311 #if (NTDDI_VERSION >= NTDDI_WIN7)
   10312 
   10313 ULONG64
   10314 NTAPI
   10315 KeQueryTotalCycleTimeProcess(
   10316   IN OUT PKPROCESS Process,
   10317   OUT PULONG64 CycleTimeStamp);
   10318 
   10319 ULONG64
   10320 NTAPI
   10321 KeQueryTotalCycleTimeThread(
   10322   IN OUT PKTHREAD Thread,
   10323   OUT PULONG64 CycleTimeStamp);
   10324 
   10325 NTKERNELAPI
   10326 NTSTATUS
   10327 NTAPI
   10328 KeSetTargetProcessorDpcEx(
   10329   IN OUT PKDPC Dpc,
   10330   IN PPROCESSOR_NUMBER ProcNumber);
   10331 
   10332 NTKERNELAPI
   10333 VOID
   10334 NTAPI
   10335 KeSetSystemGroupAffinityThread(
   10336   IN PGROUP_AFFINITY Affinity,
   10337   OUT PGROUP_AFFINITY PreviousAffinity OPTIONAL);
   10338 
   10339 NTKERNELAPI
   10340 VOID
   10341 NTAPI
   10342 KeRevertToUserGroupAffinityThread(
   10343   IN PGROUP_AFFINITY PreviousAffinity);
   10344 
   10345 NTKERNELAPI
   10346 BOOLEAN
   10347 NTAPI
   10348 KeSetCoalescableTimer(
   10349   IN OUT PKTIMER Timer,
   10350   IN LARGE_INTEGER DueTime,
   10351   IN ULONG Period,
   10352   IN ULONG TolerableDelay,
   10353   IN PKDPC Dpc OPTIONAL);
   10354 
   10355 NTKERNELAPI
   10356 ULONGLONG
   10357 NTAPI
   10358 KeQueryUnbiasedInterruptTime(VOID);
   10359 
   10360 NTKERNELAPI
   10361 ULONG
   10362 NTAPI
   10363 KeQueryActiveProcessorCountEx(
   10364   IN USHORT GroupNumber);
   10365 
   10366 NTKERNELAPI
   10367 ULONG
   10368 NTAPI
   10369 KeQueryMaximumProcessorCountEx(
   10370   IN USHORT GroupNumber);
   10371 
   10372 NTKERNELAPI
   10373 USHORT
   10374 NTAPI
   10375 KeQueryActiveGroupCount(VOID);
   10376 
   10377 NTKERNELAPI
   10378 USHORT
   10379 NTAPI
   10380 KeQueryMaximumGroupCount(VOID);
   10381 
   10382 NTKERNELAPI
   10383 KAFFINITY
   10384 NTAPI
   10385 KeQueryGroupAffinity(
   10386   IN USHORT GroupNumber);
   10387 
   10388 NTKERNELAPI
   10389 ULONG
   10390 NTAPI
   10391 KeGetCurrentProcessorNumberEx(
   10392   OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL);
   10393 
   10394 NTKERNELAPI
   10395 VOID
   10396 NTAPI
   10397 KeQueryNodeActiveAffinity(
   10398   IN USHORT NodeNumber,
   10399   OUT PGROUP_AFFINITY Affinity OPTIONAL,
   10400   OUT PUSHORT Count OPTIONAL);
   10401 
   10402 NTKERNELAPI
   10403 USHORT
   10404 NTAPI
   10405 KeQueryNodeMaximumProcessorCount(
   10406   IN USHORT NodeNumber);
   10407 
   10408 NTKERNELAPI
   10409 USHORT
   10410 NTAPI
   10411 KeQueryHighestNodeNumber(VOID);
   10412 
   10413 NTKERNELAPI
   10414 USHORT
   10415 NTAPI
   10416 KeGetCurrentNodeNumber(VOID);
   10417 
   10418 NTKERNELAPI
   10419 NTSTATUS
   10420 NTAPI
   10421 KeQueryLogicalProcessorRelationship(
   10422   IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL,
   10423   IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType,
   10424   OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL,
   10425   IN OUT PULONG Length);
   10426 
   10427 NTKERNELAPI
   10428 NTSTATUS
   10429 NTAPI
   10430 KeSaveExtendedProcessorState(
   10431   IN ULONG64 Mask,
   10432   OUT PXSTATE_SAVE XStateSave);
   10433 
   10434 NTKERNELAPI
   10435 VOID
   10436 NTAPI
   10437 KeRestoreExtendedProcessorState(
   10438   IN PXSTATE_SAVE XStateSave);
   10439 
   10440 NTSTATUS
   10441 NTAPI
   10442 KeGetProcessorNumberFromIndex(
   10443   IN ULONG ProcIndex,
   10444   OUT PPROCESSOR_NUMBER ProcNumber);
   10445 
   10446 ULONG
   10447 NTAPI
   10448 KeGetProcessorIndexFromNumber(
   10449   IN PPROCESSOR_NUMBER ProcNumber);
   10450 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   10451 #if !defined(_IA64_)
   10452 NTHALAPI
   10453 VOID
   10454 NTAPI
   10455 KeFlushWriteBuffer(VOID);
   10456 #endif
   10457 
   10458 /* VOID
   10459  * KeInitializeCallbackRecord(
   10460  *   IN PKBUGCHECK_CALLBACK_RECORD  CallbackRecord)
   10461  */
   10462 #define KeInitializeCallbackRecord(CallbackRecord) \
   10463   CallbackRecord->State = BufferEmpty;
   10464 
   10465 #if DBG
   10466 
   10467 #if (NTDDI_VERSION >= NTDDI_VISTA)
   10468 #define PAGED_ASSERT( exp ) NT_ASSERT( exp )
   10469 #else
   10470 #define PAGED_ASSERT( exp ) ASSERT( exp )
   10471 #endif
   10472 
   10473 #define PAGED_CODE() { \
   10474   if (KeGetCurrentIrql() > APC_LEVEL) { \
   10475     KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \
   10476     PAGED_ASSERT(FALSE); \
   10477   } \
   10478 }
   10479 
   10480 #else
   10481 
   10482 #define PAGED_CODE()
   10483 
   10484 #endif /* DBG */
   10485 
   10486 #define PAGED_CODE_LOCKED() NOP_FUNCTION;
   10487 
   10488 /******************************************************************************
   10489  *                       Memory manager Functions                             *
   10490  ******************************************************************************/
   10491 /* Alignment Macros */
   10492 #define ALIGN_DOWN_BY(size, align) \
   10493     ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
   10494 
   10495 #define ALIGN_UP_BY(size, align) \
   10496     (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
   10497 
   10498 #define ALIGN_DOWN_POINTER_BY(ptr, align) \
   10499     ((PVOID)ALIGN_DOWN_BY(ptr, align))
   10500 
   10501 #define ALIGN_UP_POINTER_BY(ptr, align) \
   10502     ((PVOID)ALIGN_UP_BY(ptr, align))
   10503 
   10504 #define ALIGN_DOWN(size, type) \
   10505     ALIGN_DOWN_BY(size, sizeof(type))
   10506 
   10507 #define ALIGN_UP(size, type) \
   10508     ALIGN_UP_BY(size, sizeof(type))
   10509 
   10510 #define ALIGN_DOWN_POINTER(ptr, type) \
   10511     ALIGN_DOWN_POINTER_BY(ptr, sizeof(type))
   10512 
   10513 #define ALIGN_UP_POINTER(ptr, type) \
   10514     ALIGN_UP_POINTER_BY(ptr, sizeof(type))
   10515 
   10516 #ifndef FIELD_OFFSET
   10517 #define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field))
   10518 #endif
   10519 
   10520 #ifndef FIELD_SIZE
   10521 #define FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
   10522 #endif
   10523 
   10524 #define POOL_TAGGING                             1
   10525 
   10526 #if DBG
   10527 #define IF_DEBUG if (TRUE)
   10528 #else
   10529 #define IF_DEBUG if (FALSE)
   10530 #endif /* DBG */
   10531 
   10532 /* ULONG
   10533  * BYTE_OFFSET(
   10534  *   IN PVOID Va)
   10535  */
   10536 #define BYTE_OFFSET(Va) \
   10537   ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
   10538 
   10539 /* ULONG
   10540  * BYTES_TO_PAGES(
   10541  *   IN ULONG Size)
   10542  */
   10543 #define BYTES_TO_PAGES(Size) \
   10544   (((Size) + PAGE_SIZE - 1) >> PAGE_SHIFT)
   10545 
   10546 /* PVOID
   10547  * PAGE_ALIGN(
   10548  *   IN PVOID Va)
   10549  */
   10550 #define PAGE_ALIGN(Va) \
   10551   ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
   10552 
   10553 /* ULONG_PTR
   10554  * ROUND_TO_PAGES(
   10555  *   IN ULONG_PTR Size)
   10556  */
   10557 #define ROUND_TO_PAGES(Size) \
   10558   (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
   10559 
   10560 /* ULONG
   10561  * ADDRESS_AND_SIZE_TO_SPAN_PAGES(
   10562  *   IN PVOID Va,
   10563  *   IN ULONG Size)
   10564  */
   10565 #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size) \
   10566   ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \
   10567     + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
   10568 
   10569 #define COMPUTE_PAGES_SPANNED(Va, Size) \
   10570     ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size)
   10571 
   10572 /*
   10573  * ULONG
   10574  * MmGetMdlByteCount(
   10575  *   IN PMDL  Mdl)
   10576  */
   10577 #define MmGetMdlByteCount(_Mdl) \
   10578   ((_Mdl)->ByteCount)
   10579 
   10580 /*
   10581  * ULONG
   10582  * MmGetMdlByteOffset(
   10583  *   IN PMDL  Mdl)
   10584  */
   10585 #define MmGetMdlByteOffset(_Mdl) \
   10586   ((_Mdl)->ByteOffset)
   10587 
   10588 #define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa)
   10589 
   10590 /*
   10591  * PPFN_NUMBER
   10592  * MmGetMdlPfnArray(
   10593  *   IN PMDL  Mdl)
   10594  */
   10595 #define MmGetMdlPfnArray(_Mdl) \
   10596   ((PPFN_NUMBER) ((_Mdl) + 1))
   10597 
   10598 /*
   10599  * PVOID
   10600  * MmGetMdlVirtualAddress(
   10601  *   IN PMDL  Mdl)
   10602  */
   10603 #define MmGetMdlVirtualAddress(_Mdl) \
   10604   ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))
   10605 
   10606 #define MmGetProcedureAddress(Address) (Address)
   10607 #define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address)
   10608 
   10609 /* PVOID MmGetSystemAddressForMdl(
   10610  *     IN PMDL Mdl);
   10611  */
   10612 #define MmGetSystemAddressForMdl(Mdl) \
   10613   (((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
   10614     MDL_SOURCE_IS_NONPAGED_POOL)) ? \
   10615       ((Mdl)->MappedSystemVa) : \
   10616       (MmMapLockedPages((Mdl), KernelMode)))
   10617 
   10618 /* PVOID
   10619  * MmGetSystemAddressForMdlSafe(
   10620  *     IN PMDL Mdl,
   10621  *     IN MM_PAGE_PRIORITY Priority)
   10622  */
   10623 #define MmGetSystemAddressForMdlSafe(_Mdl, _Priority) \
   10624   (((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \
   10625     | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
   10626     (_Mdl)->MappedSystemVa : \
   10627     (PVOID) MmMapLockedPagesSpecifyCache((_Mdl), \
   10628       KernelMode, MmCached, NULL, FALSE, (_Priority)))
   10629 
   10630 /*
   10631  * VOID
   10632  * MmInitializeMdl(
   10633  *   IN PMDL  MemoryDescriptorList,
   10634  *   IN PVOID  BaseVa,
   10635  *   IN SIZE_T  Length)
   10636  */
   10637 #define MmInitializeMdl(_MemoryDescriptorList, \
   10638                         _BaseVa, \
   10639                         _Length) \
   10640 { \
   10641   (_MemoryDescriptorList)->Next = (PMDL) NULL; \
   10642   (_MemoryDescriptorList)->Size = (CSHORT) (sizeof(MDL) + \
   10643     (sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(_BaseVa, _Length))); \
   10644   (_MemoryDescriptorList)->MdlFlags = 0; \
   10645   (_MemoryDescriptorList)->StartVa = (PVOID) PAGE_ALIGN(_BaseVa); \
   10646   (_MemoryDescriptorList)->ByteOffset = BYTE_OFFSET(_BaseVa); \
   10647   (_MemoryDescriptorList)->ByteCount = (ULONG) _Length; \
   10648 }
   10649 
   10650 /*
   10651  * VOID
   10652  * MmPrepareMdlForReuse(
   10653  *   IN PMDL  Mdl)
   10654  */
   10655 #define MmPrepareMdlForReuse(_Mdl) \
   10656 { \
   10657   if (((_Mdl)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) { \
   10658     ASSERT(((_Mdl)->MdlFlags & MDL_PARTIAL) != 0); \
   10659     MmUnmapLockedPages((_Mdl)->MappedSystemVa, (_Mdl)); \
   10660   } else if (((_Mdl)->MdlFlags & MDL_PARTIAL) == 0) { \
   10661     ASSERT(((_Mdl)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \
   10662   } \
   10663 }
   10664 
   10665 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   10666 NTKERNELAPI
   10667 PVOID
   10668 NTAPI
   10669 MmAllocateContiguousMemory(
   10670   IN SIZE_T NumberOfBytes,
   10671   IN PHYSICAL_ADDRESS HighestAcceptableAddress);
   10672 
   10673 NTKERNELAPI
   10674 PVOID
   10675 NTAPI
   10676 MmAllocateContiguousMemorySpecifyCache(
   10677   IN SIZE_T NumberOfBytes,
   10678   IN PHYSICAL_ADDRESS LowestAcceptableAddress,
   10679   IN PHYSICAL_ADDRESS HighestAcceptableAddress,
   10680   IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL,
   10681   IN MEMORY_CACHING_TYPE CacheType);
   10682 
   10683 NTKERNELAPI
   10684 PMDL
   10685 NTAPI
   10686 MmAllocatePagesForMdl(
   10687   IN PHYSICAL_ADDRESS LowAddress,
   10688   IN PHYSICAL_ADDRESS HighAddress,
   10689   IN PHYSICAL_ADDRESS SkipBytes,
   10690   IN SIZE_T TotalBytes);
   10691 
   10692 NTKERNELAPI
   10693 VOID
   10694 NTAPI
   10695 MmBuildMdlForNonPagedPool(
   10696   IN OUT PMDLX MemoryDescriptorList);
   10697 
   10698 //DECLSPEC_DEPRECATED_DDK
   10699 NTKERNELAPI
   10700 PMDL
   10701 NTAPI
   10702 MmCreateMdl(
   10703   IN PMDL MemoryDescriptorList OPTIONAL,
   10704   IN PVOID Base,
   10705   IN SIZE_T Length);
   10706 
   10707 NTKERNELAPI
   10708 VOID
   10709 NTAPI
   10710 MmFreeContiguousMemory(
   10711   IN PVOID BaseAddress);
   10712 
   10713 NTKERNELAPI
   10714 VOID
   10715 NTAPI
   10716 MmFreeContiguousMemorySpecifyCache(
   10717   IN PVOID BaseAddress,
   10718   IN SIZE_T NumberOfBytes,
   10719   IN MEMORY_CACHING_TYPE CacheType);
   10720 
   10721 NTKERNELAPI
   10722 VOID
   10723 NTAPI
   10724 MmFreePagesFromMdl(
   10725   IN PMDLX MemoryDescriptorList);
   10726 
   10727 NTKERNELAPI
   10728 PVOID
   10729 NTAPI
   10730 MmGetSystemRoutineAddress(
   10731   IN PUNICODE_STRING SystemRoutineName);
   10732 
   10733 NTKERNELAPI
   10734 LOGICAL
   10735 NTAPI
   10736 MmIsDriverVerifying(
   10737   IN struct _DRIVER_OBJECT *DriverObject);
   10738 
   10739 NTKERNELAPI
   10740 PVOID
   10741 NTAPI
   10742 MmLockPagableDataSection(
   10743   IN PVOID AddressWithinSection);
   10744 
   10745 NTKERNELAPI
   10746 PVOID
   10747 NTAPI
   10748 MmMapIoSpace(
   10749   IN PHYSICAL_ADDRESS PhysicalAddress,
   10750   IN SIZE_T NumberOfBytes,
   10751   IN MEMORY_CACHING_TYPE CacheEnable);
   10752 
   10753 NTKERNELAPI
   10754 PVOID
   10755 NTAPI
   10756 MmMapLockedPages(
   10757   IN PMDL MemoryDescriptorList,
   10758   IN KPROCESSOR_MODE AccessMode);
   10759 
   10760 NTKERNELAPI
   10761 PVOID
   10762 NTAPI
   10763 MmMapLockedPagesSpecifyCache(
   10764   IN PMDLX MemoryDescriptorList,
   10765   IN KPROCESSOR_MODE AccessMode,
   10766   IN MEMORY_CACHING_TYPE CacheType,
   10767   IN PVOID BaseAddress OPTIONAL,
   10768   IN ULONG BugCheckOnFailure,
   10769   IN MM_PAGE_PRIORITY Priority);
   10770 
   10771 NTKERNELAPI
   10772 PVOID
   10773 NTAPI
   10774 MmPageEntireDriver(
   10775   IN PVOID AddressWithinSection);
   10776 
   10777 NTKERNELAPI
   10778 VOID
   10779 NTAPI
   10780 MmProbeAndLockPages(
   10781   IN OUT PMDL MemoryDescriptorList,
   10782   IN KPROCESSOR_MODE AccessMode,
   10783   IN LOCK_OPERATION Operation);
   10784 
   10785 NTKERNELAPI
   10786 MM_SYSTEMSIZE
   10787 NTAPI
   10788 MmQuerySystemSize(VOID);
   10789 
   10790 NTKERNELAPI
   10791 VOID
   10792 NTAPI
   10793 MmResetDriverPaging(
   10794   IN PVOID AddressWithinSection);
   10795 
   10796 NTKERNELAPI
   10797 SIZE_T
   10798 NTAPI
   10799 MmSizeOfMdl(
   10800   IN PVOID Base,
   10801   IN SIZE_T Length);
   10802 
   10803 NTKERNELAPI
   10804 VOID
   10805 NTAPI
   10806 MmUnlockPagableImageSection(
   10807   IN PVOID ImageSectionHandle);
   10808 
   10809 NTKERNELAPI
   10810 VOID
   10811 NTAPI
   10812 MmUnlockPages(
   10813   IN OUT PMDL MemoryDescriptorList);
   10814 
   10815 NTKERNELAPI
   10816 VOID
   10817 NTAPI
   10818 MmUnmapIoSpace(
   10819   IN PVOID BaseAddress,
   10820   IN SIZE_T NumberOfBytes);
   10821 
   10822 NTKERNELAPI
   10823 VOID
   10824 NTAPI
   10825 MmProbeAndLockProcessPages(
   10826   IN OUT PMDL MemoryDescriptorList,
   10827   IN PEPROCESS Process,
   10828   IN KPROCESSOR_MODE AccessMode,
   10829   IN LOCK_OPERATION Operation);
   10830 
   10831 NTKERNELAPI
   10832 VOID
   10833 NTAPI
   10834 MmUnmapLockedPages(
   10835   IN PVOID BaseAddress,
   10836   IN PMDL MemoryDescriptorList);
   10837 
   10838 NTKERNELAPI
   10839 PVOID
   10840 NTAPI
   10841 MmAllocateContiguousMemorySpecifyCacheNode(
   10842   IN SIZE_T NumberOfBytes,
   10843   IN PHYSICAL_ADDRESS LowestAcceptableAddress,
   10844   IN PHYSICAL_ADDRESS HighestAcceptableAddress,
   10845   IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL,
   10846   IN MEMORY_CACHING_TYPE CacheType,
   10847   IN NODE_REQUIREMENT PreferredNode);
   10848 
   10849 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   10850 
   10851 #if (NTDDI_VERSION >= NTDDI_WINXP)
   10852 
   10853 NTKERNELAPI
   10854 NTSTATUS
   10855 NTAPI
   10856 MmAdvanceMdl(
   10857   IN OUT PMDL Mdl,
   10858   IN ULONG NumberOfBytes);
   10859 
   10860 NTKERNELAPI
   10861 PVOID
   10862 NTAPI
   10863 MmAllocateMappingAddress(
   10864   IN SIZE_T NumberOfBytes,
   10865   IN ULONG PoolTag);
   10866 
   10867 NTKERNELAPI
   10868 VOID
   10869 NTAPI
   10870 MmFreeMappingAddress(
   10871   IN PVOID BaseAddress,
   10872   IN ULONG PoolTag);
   10873 
   10874 NTKERNELAPI
   10875 NTSTATUS
   10876 NTAPI
   10877 MmIsVerifierEnabled(
   10878   OUT PULONG VerifierFlags);
   10879 
   10880 NTKERNELAPI
   10881 PVOID
   10882 NTAPI
   10883 MmMapLockedPagesWithReservedMapping(
   10884   IN PVOID MappingAddress,
   10885   IN ULONG PoolTag,
   10886   IN PMDL MemoryDescriptorList,
   10887   IN MEMORY_CACHING_TYPE CacheType);
   10888 
   10889 NTKERNELAPI
   10890 NTSTATUS
   10891 NTAPI
   10892 MmProtectMdlSystemAddress(
   10893   IN PMDL MemoryDescriptorList,
   10894   IN ULONG NewProtect);
   10895 
   10896 NTKERNELAPI
   10897 VOID
   10898 NTAPI
   10899 MmUnmapReservedMapping(
   10900   IN PVOID BaseAddress,
   10901   IN ULONG PoolTag,
   10902   IN PMDL MemoryDescriptorList);
   10903 
   10904 NTKERNELAPI
   10905 NTSTATUS
   10906 NTAPI
   10907 MmAddVerifierThunks(
   10908   IN PVOID ThunkBuffer,
   10909   IN ULONG ThunkBufferSize);
   10910 
   10911 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
   10912 
   10913 #if (NTDDI_VERSION >= NTDDI_WS03)
   10914 NTKERNELAPI
   10915 LOGICAL
   10916 NTAPI
   10917 MmIsIoSpaceActive(
   10918   IN PHYSICAL_ADDRESS StartAddress,
   10919   IN SIZE_T NumberOfBytes);
   10920 
   10921 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */
   10922 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
   10923 NTKERNELAPI
   10924 PMDL
   10925 NTAPI
   10926 MmAllocatePagesForMdlEx(
   10927   IN PHYSICAL_ADDRESS LowAddress,
   10928   IN PHYSICAL_ADDRESS HighAddress,
   10929   IN PHYSICAL_ADDRESS SkipBytes,
   10930   IN SIZE_T TotalBytes,
   10931   IN MEMORY_CACHING_TYPE CacheType,
   10932   IN ULONG Flags);
   10933 #endif
   10934 
   10935 #if (NTDDI_VERSION >= NTDDI_VISTA)
   10936 NTKERNELAPI
   10937 LOGICAL
   10938 NTAPI
   10939 MmIsDriverVerifyingByAddress(
   10940   IN PVOID AddressWithinSection);
   10941 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   10942 
   10943 /******************************************************************************
   10944  *                            Security Manager Functions                      *
   10945  ******************************************************************************/
   10946 
   10947 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   10948 NTKERNELAPI
   10949 BOOLEAN
   10950 NTAPI
   10951 SeAccessCheck(
   10952   IN PSECURITY_DESCRIPTOR SecurityDescriptor,
   10953   IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
   10954   IN BOOLEAN SubjectContextLocked,
   10955   IN ACCESS_MASK DesiredAccess,
   10956   IN ACCESS_MASK PreviouslyGrantedAccess,
   10957   OUT PPRIVILEGE_SET *Privileges OPTIONAL,
   10958   IN PGENERIC_MAPPING GenericMapping,
   10959   IN KPROCESSOR_MODE AccessMode,
   10960   OUT PACCESS_MASK GrantedAccess,
   10961   OUT PNTSTATUS AccessStatus);
   10962 
   10963 NTKERNELAPI
   10964 NTSTATUS
   10965 NTAPI
   10966 SeAssignSecurity(
   10967   IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
   10968   IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL,
   10969   OUT PSECURITY_DESCRIPTOR *NewDescriptor,
   10970   IN BOOLEAN IsDirectoryObject,
   10971   IN PSECURITY_SUBJECT_CONTEXT SubjectContext,
   10972   IN PGENERIC_MAPPING GenericMapping,
   10973   IN POOL_TYPE PoolType);
   10974 
   10975 NTKERNELAPI
   10976 NTSTATUS
   10977 NTAPI
   10978 SeAssignSecurityEx(
   10979   IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
   10980   IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL,
   10981   OUT PSECURITY_DESCRIPTOR *NewDescriptor,
   10982   IN GUID *ObjectType OPTIONAL,
   10983   IN BOOLEAN IsDirectoryObject,
   10984   IN ULONG AutoInheritFlags,
   10985   IN PSECURITY_SUBJECT_CONTEXT SubjectContext,
   10986   IN PGENERIC_MAPPING GenericMapping,
   10987   IN POOL_TYPE PoolType);
   10988 
   10989 NTKERNELAPI
   10990 NTSTATUS
   10991 NTAPI
   10992 SeDeassignSecurity(
   10993   IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor);
   10994 
   10995 NTKERNELAPI
   10996 BOOLEAN
   10997 NTAPI
   10998 SeValidSecurityDescriptor(
   10999   IN ULONG Length,
   11000   IN PSECURITY_DESCRIPTOR SecurityDescriptor);
   11001 
   11002 NTKERNELAPI
   11003 ULONG
   11004 NTAPI
   11005 SeObjectCreateSaclAccessBits(
   11006   IN PSECURITY_DESCRIPTOR SecurityDescriptor);
   11007 
   11008 NTKERNELAPI
   11009 VOID
   11010 NTAPI
   11011 SeReleaseSubjectContext(
   11012   IN OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
   11013 
   11014 NTKERNELAPI
   11015 VOID
   11016 NTAPI
   11017 SeUnlockSubjectContext(
   11018   IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
   11019 
   11020 NTKERNELAPI
   11021 VOID
   11022 NTAPI
   11023 SeCaptureSubjectContext(
   11024   OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
   11025 
   11026 NTKERNELAPI
   11027 VOID
   11028 NTAPI
   11029 SeLockSubjectContext(
   11030   IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
   11031 
   11032 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   11033 
   11034 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
   11035 
   11036 NTSTATUS
   11037 NTAPI
   11038 SeSetAuditParameter(
   11039   IN OUT PSE_ADT_PARAMETER_ARRAY AuditParameters,
   11040   IN SE_ADT_PARAMETER_TYPE Type,
   11041   IN ULONG Index,
   11042   IN PVOID Data);
   11043 
   11044 NTSTATUS
   11045 NTAPI
   11046 SeReportSecurityEvent(
   11047   IN ULONG Flags,
   11048   IN PUNICODE_STRING SourceName,
   11049   IN PSID UserSid OPTIONAL,
   11050   IN PSE_ADT_PARAMETER_ARRAY AuditParameters);
   11051 
   11052 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
   11053 
   11054 #if (NTDDI_VERSION >= NTDDI_VISTA)
   11055 NTKERNELAPI
   11056 ULONG
   11057 NTAPI
   11058 SeComputeAutoInheritByObjectType(
   11059   IN PVOID ObjectType,
   11060   IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
   11061   IN PSECURITY_DESCRIPTOR ParentSecurityDescriptor OPTIONAL);
   11062 
   11063 #ifdef SE_NTFS_WORLD_CACHE
   11064 VOID
   11065 NTAPI
   11066 SeGetWorldRights(
   11067   IN PSECURITY_DESCRIPTOR SecurityDescriptor,
   11068   IN PGENERIC_MAPPING GenericMapping,
   11069   OUT PACCESS_MASK GrantedAccess);
   11070 #endif /* SE_NTFS_WORLD_CACHE */
   11071 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   11072 
   11073 /******************************************************************************
   11074  *                         Configuration Manager Functions                    *
   11075  ******************************************************************************/
   11076 
   11077 #if (NTDDI_VERSION >= NTDDI_WINXP)
   11078 NTKERNELAPI
   11079 NTSTATUS
   11080 NTAPI
   11081 CmRegisterCallback(
   11082   IN PEX_CALLBACK_FUNCTION Function,
   11083   IN PVOID Context OPTIONAL,
   11084   OUT PLARGE_INTEGER Cookie);
   11085 
   11086 NTKERNELAPI
   11087 NTSTATUS
   11088 NTAPI
   11089 CmUnRegisterCallback(
   11090   IN LARGE_INTEGER Cookie);
   11091 #endif
   11092 
   11093 #if (NTDDI_VERSION >= NTDDI_VISTA)
   11094 
   11095 NTKERNELAPI
   11096 NTSTATUS
   11097 NTAPI
   11098 CmRegisterCallbackEx(
   11099   PEX_CALLBACK_FUNCTION Function,
   11100   PCUNICODE_STRING Altitude,
   11101   PVOID Driver,
   11102   PVOID Context,
   11103   PLARGE_INTEGER Cookie,
   11104   PVOID Reserved);
   11105 
   11106 NTKERNELAPI
   11107 VOID
   11108 NTAPI
   11109 CmGetCallbackVersion(
   11110   OUT PULONG Major OPTIONAL,
   11111   OUT PULONG Minor OPTIONAL);
   11112 
   11113 NTKERNELAPI
   11114 NTSTATUS
   11115 NTAPI
   11116 CmSetCallbackObjectContext(
   11117   IN OUT PVOID Object,
   11118   IN PLARGE_INTEGER Cookie,
   11119   IN PVOID NewContext,
   11120   OUT PVOID *OldContext OPTIONAL);
   11121 
   11122 NTKERNELAPI
   11123 NTSTATUS
   11124 NTAPI
   11125 CmCallbackGetKeyObjectID(
   11126   IN PLARGE_INTEGER Cookie,
   11127   IN PVOID Object,
   11128   OUT PULONG_PTR ObjectID OPTIONAL,
   11129   OUT PCUNICODE_STRING *ObjectName OPTIONAL);
   11130 
   11131 NTKERNELAPI
   11132 PVOID
   11133 NTAPI
   11134 CmGetBoundTransaction(
   11135   IN PLARGE_INTEGER Cookie,
   11136   IN PVOID Object);
   11137 
   11138 #endif // NTDDI_VERSION >= NTDDI_VISTA
   11139 
   11140 
   11141 /******************************************************************************
   11142  *                         I/O Manager Functions                              *
   11143  ******************************************************************************/
   11144 
   11145 /*
   11146  * NTSTATUS
   11147  * IoAcquireRemoveLock(
   11148  *   IN PIO_REMOVE_LOCK  RemoveLock,
   11149  *   IN OPTIONAL PVOID  Tag)
   11150  */
   11151 #if DBG
   11152 #define IoAcquireRemoveLock(RemoveLock, Tag) \
   11153   IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK))
   11154 #else
   11155 #define IoAcquireRemoveLock(RemoveLock, Tag) \
   11156   IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK))
   11157 #endif
   11158 
   11159 /*
   11160  * VOID
   11161  * IoAdjustPagingPathCount(
   11162  *   IN PLONG  Count,
   11163  *   IN BOOLEAN  Increment)
   11164  */
   11165 #define IoAdjustPagingPathCount(_Count, \
   11166                                 _Increment) \
   11167 { \
   11168   if (_Increment) \
   11169     { \
   11170       InterlockedIncrement(_Count); \
   11171     } \
   11172   else \
   11173     { \
   11174       InterlockedDecrement(_Count); \
   11175     } \
   11176 }
   11177 
   11178 #if !defined(_M_AMD64)
   11179 NTHALAPI
   11180 VOID
   11181 NTAPI
   11182 READ_PORT_BUFFER_UCHAR(
   11183   IN PUCHAR Port,
   11184   IN PUCHAR Buffer,
   11185   IN ULONG Count);
   11186 
   11187 NTHALAPI
   11188 VOID
   11189 NTAPI
   11190 READ_PORT_BUFFER_ULONG(
   11191   IN PULONG Port,
   11192   IN PULONG Buffer,
   11193   IN ULONG Count);
   11194 
   11195 NTHALAPI
   11196 VOID
   11197 NTAPI
   11198 READ_PORT_BUFFER_USHORT(
   11199   IN PUSHORT Port,
   11200   IN PUSHORT Buffer,
   11201   IN ULONG Count);
   11202 
   11203 NTHALAPI
   11204 UCHAR
   11205 NTAPI
   11206 READ_PORT_UCHAR(
   11207   IN PUCHAR Port);
   11208 
   11209 NTHALAPI
   11210 ULONG
   11211 NTAPI
   11212 READ_PORT_ULONG(
   11213   IN PULONG Port);
   11214 
   11215 NTHALAPI
   11216 USHORT
   11217 NTAPI
   11218 READ_PORT_USHORT(
   11219   IN PUSHORT Port);
   11220 
   11221 NTKERNELAPI
   11222 VOID
   11223 NTAPI
   11224 READ_REGISTER_BUFFER_UCHAR(
   11225   IN PUCHAR Register,
   11226   IN PUCHAR Buffer,
   11227   IN ULONG Count);
   11228 
   11229 NTKERNELAPI
   11230 VOID
   11231 NTAPI
   11232 READ_REGISTER_BUFFER_ULONG(
   11233   IN PULONG Register,
   11234   IN PULONG Buffer,
   11235   IN ULONG Count);
   11236 
   11237 NTKERNELAPI
   11238 VOID
   11239 NTAPI
   11240 READ_REGISTER_BUFFER_USHORT(
   11241   IN PUSHORT Register,
   11242   IN PUSHORT Buffer,
   11243   IN ULONG Count);
   11244 
   11245 NTKERNELAPI
   11246 UCHAR
   11247 NTAPI
   11248 READ_REGISTER_UCHAR(
   11249   IN PUCHAR Register);
   11250 
   11251 NTKERNELAPI
   11252 ULONG
   11253 NTAPI
   11254 READ_REGISTER_ULONG(
   11255   IN PULONG Register);
   11256 
   11257 NTKERNELAPI
   11258 USHORT
   11259 NTAPI
   11260 READ_REGISTER_USHORT(
   11261   IN PUSHORT Register);
   11262 
   11263 NTHALAPI
   11264 VOID
   11265 NTAPI
   11266 WRITE_PORT_BUFFER_UCHAR(
   11267   IN PUCHAR Port,
   11268   IN PUCHAR Buffer,
   11269   IN ULONG Count);
   11270 
   11271 NTHALAPI
   11272 VOID
   11273 NTAPI
   11274 WRITE_PORT_BUFFER_ULONG(
   11275   IN PULONG Port,
   11276   IN PULONG Buffer,
   11277   IN ULONG Count);
   11278 
   11279 NTHALAPI
   11280 VOID
   11281 NTAPI
   11282 WRITE_PORT_BUFFER_USHORT(
   11283   IN PUSHORT Port,
   11284   IN PUSHORT Buffer,
   11285   IN ULONG Count);
   11286 
   11287 NTHALAPI
   11288 VOID
   11289 NTAPI
   11290 WRITE_PORT_UCHAR(
   11291   IN PUCHAR Port,
   11292   IN UCHAR Value);
   11293 
   11294 NTHALAPI
   11295 VOID
   11296 NTAPI
   11297 WRITE_PORT_ULONG(
   11298   IN PULONG Port,
   11299   IN ULONG Value);
   11300 
   11301 NTHALAPI
   11302 VOID
   11303 NTAPI
   11304 WRITE_PORT_USHORT(
   11305   IN PUSHORT Port,
   11306   IN USHORT Value);
   11307 
   11308 NTKERNELAPI
   11309 VOID
   11310 NTAPI
   11311 WRITE_REGISTER_BUFFER_UCHAR(
   11312   IN PUCHAR Register,
   11313   IN PUCHAR Buffer,
   11314   IN ULONG Count);
   11315 
   11316 NTKERNELAPI
   11317 VOID
   11318 NTAPI
   11319 WRITE_REGISTER_BUFFER_ULONG(
   11320   IN PULONG Register,
   11321   IN PULONG Buffer,
   11322   IN ULONG Count);
   11323 
   11324 NTKERNELAPI
   11325 VOID
   11326 NTAPI
   11327 WRITE_REGISTER_BUFFER_USHORT(
   11328   IN PUSHORT Register,
   11329   IN PUSHORT Buffer,
   11330   IN ULONG Count);
   11331 
   11332 NTKERNELAPI
   11333 VOID
   11334 NTAPI
   11335 WRITE_REGISTER_UCHAR(
   11336   IN PUCHAR Register,
   11337   IN UCHAR Value);
   11338 
   11339 NTKERNELAPI
   11340 VOID
   11341 NTAPI
   11342 WRITE_REGISTER_ULONG(
   11343   IN PULONG Register,
   11344   IN ULONG Value);
   11345 
   11346 NTKERNELAPI
   11347 VOID
   11348 NTAPI
   11349 WRITE_REGISTER_USHORT(
   11350   IN PUSHORT Register,
   11351   IN USHORT Value);
   11352 
   11353 #else
   11354 
   11355 FORCEINLINE
   11356 VOID
   11357 READ_PORT_BUFFER_UCHAR(
   11358   IN PUCHAR Port,
   11359   IN PUCHAR Buffer,
   11360   IN ULONG Count)
   11361 {
   11362   __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
   11363 }
   11364 
   11365 FORCEINLINE
   11366 VOID
   11367 READ_PORT_BUFFER_ULONG(
   11368   IN PULONG Port,
   11369   IN PULONG Buffer,
   11370   IN ULONG Count)
   11371 {
   11372   __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
   11373 }
   11374 
   11375 FORCEINLINE
   11376 VOID
   11377 READ_PORT_BUFFER_USHORT(
   11378   IN PUSHORT Port,
   11379   IN PUSHORT Buffer,
   11380   IN ULONG Count)
   11381 {
   11382   __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
   11383 }
   11384 
   11385 FORCEINLINE
   11386 UCHAR
   11387 READ_PORT_UCHAR(
   11388   IN PUCHAR Port)
   11389 {
   11390   return __inbyte((USHORT)(ULONG_PTR)Port);
   11391 }
   11392 
   11393 FORCEINLINE
   11394 ULONG
   11395 READ_PORT_ULONG(
   11396   IN PULONG Port)
   11397 {
   11398   return __indword((USHORT)(ULONG_PTR)Port);
   11399 }
   11400 
   11401 FORCEINLINE
   11402 USHORT
   11403 READ_PORT_USHORT(
   11404   IN PUSHORT Port)
   11405 {
   11406   return __inword((USHORT)(ULONG_PTR)Port);
   11407 }
   11408 
   11409 FORCEINLINE
   11410 VOID
   11411 READ_REGISTER_BUFFER_UCHAR(
   11412   IN PUCHAR Register,
   11413   IN PUCHAR Buffer,
   11414   IN ULONG Count)
   11415 {
   11416   __movsb(Register, Buffer, Count);
   11417 }
   11418 
   11419 FORCEINLINE
   11420 VOID
   11421 READ_REGISTER_BUFFER_ULONG(
   11422   IN PULONG Register,
   11423   IN PULONG Buffer,
   11424   IN ULONG Count)
   11425 {
   11426   __movsd(Register, Buffer, Count);
   11427 }
   11428 
   11429 FORCEINLINE
   11430 VOID
   11431 READ_REGISTER_BUFFER_USHORT(
   11432   IN PUSHORT Register,
   11433   IN PUSHORT Buffer,
   11434   IN ULONG Count)
   11435 {
   11436   __movsw(Register, Buffer, Count);
   11437 }
   11438 
   11439 FORCEINLINE
   11440 UCHAR
   11441 READ_REGISTER_UCHAR(
   11442   IN volatile UCHAR *Register)
   11443 {
   11444   return *Register;
   11445 }
   11446 
   11447 FORCEINLINE
   11448 ULONG
   11449 READ_REGISTER_ULONG(
   11450   IN volatile ULONG *Register)
   11451 {
   11452   return *Register;
   11453 }
   11454 
   11455 FORCEINLINE
   11456 USHORT
   11457 READ_REGISTER_USHORT(
   11458   IN volatile USHORT *Register)
   11459 {
   11460   return *Register;
   11461 }
   11462 
   11463 FORCEINLINE
   11464 VOID
   11465 WRITE_PORT_BUFFER_UCHAR(
   11466   IN PUCHAR Port,
   11467   IN PUCHAR Buffer,
   11468   IN ULONG Count)
   11469 {
   11470   __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
   11471 }
   11472 
   11473 FORCEINLINE
   11474 VOID
   11475 WRITE_PORT_BUFFER_ULONG(
   11476   IN PULONG Port,
   11477   IN PULONG Buffer,
   11478   IN ULONG Count)
   11479 {
   11480   __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
   11481 }
   11482 
   11483 FORCEINLINE
   11484 VOID
   11485 WRITE_PORT_BUFFER_USHORT(
   11486   IN PUSHORT Port,
   11487   IN PUSHORT Buffer,
   11488   IN ULONG Count)
   11489 {
   11490   __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
   11491 }
   11492 
   11493 FORCEINLINE
   11494 VOID
   11495 WRITE_PORT_UCHAR(
   11496   IN PUCHAR Port,
   11497   IN UCHAR Value)
   11498 {
   11499   __outbyte((USHORT)(ULONG_PTR)Port, Value);
   11500 }
   11501 
   11502 FORCEINLINE
   11503 VOID
   11504 WRITE_PORT_ULONG(
   11505   IN PULONG Port,
   11506   IN ULONG Value)
   11507 {
   11508   __outdword((USHORT)(ULONG_PTR)Port, Value);
   11509 }
   11510 
   11511 FORCEINLINE
   11512 VOID
   11513 WRITE_PORT_USHORT(
   11514   IN PUSHORT Port,
   11515   IN USHORT Value)
   11516 {
   11517   __outword((USHORT)(ULONG_PTR)Port, Value);
   11518 }
   11519 
   11520 FORCEINLINE
   11521 VOID
   11522 WRITE_REGISTER_BUFFER_UCHAR(
   11523   IN PUCHAR Register,
   11524   IN PUCHAR Buffer,
   11525   IN ULONG Count)
   11526 {
   11527   LONG Synch;
   11528   __movsb(Register, Buffer, Count);
   11529   InterlockedOr(&Synch, 1);
   11530 }
   11531 
   11532 FORCEINLINE
   11533 VOID
   11534 WRITE_REGISTER_BUFFER_ULONG(
   11535   IN PULONG Register,
   11536   IN PULONG Buffer,
   11537   IN ULONG Count)
   11538 {
   11539   LONG Synch;
   11540   __movsd(Register, Buffer, Count);
   11541   InterlockedOr(&Synch, 1);
   11542 }
   11543 
   11544 FORCEINLINE
   11545 VOID
   11546 WRITE_REGISTER_BUFFER_USHORT(
   11547   IN PUSHORT Register,
   11548   IN PUSHORT Buffer,
   11549   IN ULONG Count)
   11550 {
   11551   LONG Synch;
   11552   __movsw(Register, Buffer, Count);
   11553   InterlockedOr(&Synch, 1);
   11554 }
   11555 
   11556 FORCEINLINE
   11557 VOID
   11558 WRITE_REGISTER_UCHAR(
   11559   IN volatile UCHAR *Register,
   11560   IN UCHAR Value)
   11561 {
   11562   LONG Synch;
   11563   *Register = Value;
   11564   InterlockedOr(&Synch, 1);
   11565 }
   11566 
   11567 FORCEINLINE
   11568 VOID
   11569 WRITE_REGISTER_ULONG(
   11570   IN volatile ULONG *Register,
   11571   IN ULONG Value)
   11572 {
   11573   LONG Synch;
   11574   *Register = Value;
   11575   InterlockedOr(&Synch, 1);
   11576 }
   11577 
   11578 FORCEINLINE
   11579 VOID
   11580 WRITE_REGISTER_USHORT(
   11581   IN volatile USHORT *Register,
   11582   IN USHORT Value)
   11583 {
   11584   LONG Sync;
   11585   *Register = Value;
   11586   InterlockedOr(&Sync, 1);
   11587 }
   11588 #endif
   11589 
   11590 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && \
   11591    (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
   11592 
   11593 #define DMA_MACROS_DEFINED
   11594 
   11595 FORCEINLINE
   11596 NTSTATUS
   11597 IoAllocateAdapterChannel(
   11598   IN PDMA_ADAPTER DmaAdapter,
   11599   IN PDEVICE_OBJECT DeviceObject,
   11600   IN ULONG NumberOfMapRegisters,
   11601   IN PDRIVER_CONTROL ExecutionRoutine,
   11602   IN PVOID Context)
   11603 {
   11604   PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
   11605   AllocateAdapterChannel =
   11606       *(DmaAdapter)->DmaOperations->AllocateAdapterChannel;
   11607   ASSERT(AllocateAdapterChannel);
   11608   return AllocateAdapterChannel(DmaAdapter,
   11609                                 DeviceObject,
   11610                                 NumberOfMapRegisters,
   11611                                 ExecutionRoutine,
   11612                                 Context );
   11613 }
   11614 
   11615 FORCEINLINE
   11616 BOOLEAN
   11617 NTAPI
   11618 IoFlushAdapterBuffers(
   11619   IN PDMA_ADAPTER DmaAdapter,
   11620   IN PMDL Mdl,
   11621   IN PVOID MapRegisterBase,
   11622   IN PVOID CurrentVa,
   11623   IN ULONG Length,
   11624   IN BOOLEAN WriteToDevice)
   11625 {
   11626   PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
   11627   FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers;
   11628   ASSERT(FlushAdapterBuffers);
   11629   return FlushAdapterBuffers(DmaAdapter,
   11630                              Mdl,
   11631                              MapRegisterBase,
   11632                              CurrentVa,
   11633                              Length,
   11634                              WriteToDevice);
   11635 }
   11636 
   11637 FORCEINLINE
   11638 VOID
   11639 NTAPI
   11640 IoFreeAdapterChannel(
   11641   IN PDMA_ADAPTER DmaAdapter)
   11642 {
   11643   PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
   11644   FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel;
   11645   ASSERT(FreeAdapterChannel);
   11646   FreeAdapterChannel(DmaAdapter);
   11647 }
   11648 
   11649 FORCEINLINE
   11650 VOID
   11651 NTAPI
   11652 IoFreeMapRegisters(
   11653   IN PDMA_ADAPTER DmaAdapter,
   11654   IN PVOID MapRegisterBase,
   11655   IN ULONG NumberOfMapRegisters)
   11656 {
   11657   PFREE_MAP_REGISTERS FreeMapRegisters;
   11658   FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters;
   11659   ASSERT(FreeMapRegisters);
   11660   FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters);
   11661 }
   11662 
   11663 FORCEINLINE
   11664 PHYSICAL_ADDRESS
   11665 NTAPI
   11666 IoMapTransfer(
   11667   IN PDMA_ADAPTER DmaAdapter,
   11668   IN PMDL Mdl,
   11669   IN PVOID MapRegisterBase,
   11670   IN PVOID CurrentVa,
   11671   IN OUT PULONG Length,
   11672   IN BOOLEAN WriteToDevice)
   11673 {
   11674   PMAP_TRANSFER MapTransfer;
   11675 
   11676   MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer;
   11677   ASSERT(MapTransfer);
   11678   return MapTransfer(DmaAdapter,
   11679                      Mdl,
   11680                      MapRegisterBase,
   11681                      CurrentVa,
   11682                      Length,
   11683                      WriteToDevice);
   11684 }
   11685 #endif
   11686 
   11687 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   11688 
   11689 NTKERNELAPI
   11690 VOID
   11691 NTAPI
   11692 IoAcquireCancelSpinLock(
   11693   OUT PKIRQL Irql);
   11694 
   11695 NTKERNELAPI
   11696 NTSTATUS
   11697 NTAPI
   11698 IoAcquireRemoveLockEx(
   11699   IN PIO_REMOVE_LOCK RemoveLock,
   11700   IN PVOID Tag OPTIONAL,
   11701   IN PCSTR File,
   11702   IN ULONG Line,
   11703   IN ULONG RemlockSize);
   11704 NTKERNELAPI
   11705 NTSTATUS
   11706 NTAPI
   11707 IoAllocateDriverObjectExtension(
   11708   IN PDRIVER_OBJECT DriverObject,
   11709   IN PVOID ClientIdentificationAddress,
   11710   IN ULONG DriverObjectExtensionSize,
   11711   OUT PVOID *DriverObjectExtension);
   11712 
   11713 NTKERNELAPI
   11714 PVOID
   11715 NTAPI
   11716 IoAllocateErrorLogEntry(
   11717   IN PVOID IoObject,
   11718   IN UCHAR EntrySize);
   11719 
   11720 NTKERNELAPI
   11721 PIRP
   11722 NTAPI
   11723 IoAllocateIrp(
   11724   IN CCHAR StackSize,
   11725   IN BOOLEAN ChargeQuota);
   11726 
   11727 NTKERNELAPI
   11728 PMDL
   11729 NTAPI
   11730 IoAllocateMdl(
   11731   IN PVOID VirtualAddress OPTIONAL,
   11732   IN ULONG Length,
   11733   IN BOOLEAN SecondaryBuffer,
   11734   IN BOOLEAN ChargeQuota,
   11735   IN OUT PIRP Irp OPTIONAL);
   11736 
   11737 NTKERNELAPI
   11738 PIO_WORKITEM
   11739 NTAPI
   11740 IoAllocateWorkItem(
   11741   IN PDEVICE_OBJECT DeviceObject);
   11742 
   11743 NTKERNELAPI
   11744 NTSTATUS
   11745 NTAPI
   11746 IoAttachDevice(
   11747   IN PDEVICE_OBJECT SourceDevice,
   11748   IN PUNICODE_STRING TargetDevice,
   11749   OUT PDEVICE_OBJECT *AttachedDevice);
   11750 
   11751 NTKERNELAPI
   11752 PDEVICE_OBJECT
   11753 NTAPI
   11754 IoAttachDeviceToDeviceStack(
   11755   IN PDEVICE_OBJECT SourceDevice,
   11756   IN PDEVICE_OBJECT TargetDevice);
   11757 
   11758 NTKERNELAPI
   11759 PIRP
   11760 NTAPI
   11761 IoBuildAsynchronousFsdRequest(
   11762   IN ULONG MajorFunction,
   11763   IN PDEVICE_OBJECT DeviceObject,
   11764   IN OUT PVOID Buffer OPTIONAL,
   11765   IN ULONG Length OPTIONAL,
   11766   IN PLARGE_INTEGER StartingOffset OPTIONAL,
   11767   IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL);
   11768 
   11769 NTKERNELAPI
   11770 PIRP
   11771 NTAPI
   11772 IoBuildDeviceIoControlRequest(
   11773   IN ULONG IoControlCode,
   11774   IN PDEVICE_OBJECT DeviceObject,
   11775   IN PVOID InputBuffer OPTIONAL,
   11776   IN ULONG InputBufferLength,
   11777   OUT PVOID OutputBuffer OPTIONAL,
   11778   IN ULONG OutputBufferLength,
   11779   IN BOOLEAN InternalDeviceIoControl,
   11780   IN PKEVENT Event,
   11781   OUT PIO_STATUS_BLOCK IoStatusBlock);
   11782 
   11783 NTKERNELAPI
   11784 VOID
   11785 NTAPI
   11786 IoBuildPartialMdl(
   11787   IN PMDL SourceMdl,
   11788   IN OUT PMDL TargetMdl,
   11789   IN PVOID VirtualAddress,
   11790   IN ULONG Length);
   11791 
   11792 NTKERNELAPI
   11793 PIRP
   11794 NTAPI
   11795 IoBuildSynchronousFsdRequest(
   11796   IN ULONG MajorFunction,
   11797   IN PDEVICE_OBJECT DeviceObject,
   11798   IN OUT PVOID Buffer OPTIONAL,
   11799   IN ULONG Length OPTIONAL,
   11800   IN PLARGE_INTEGER StartingOffset OPTIONAL,
   11801   IN PKEVENT Event,
   11802   OUT PIO_STATUS_BLOCK IoStatusBlock);
   11803 
   11804 NTKERNELAPI
   11805 NTSTATUS
   11806 FASTCALL
   11807 IofCallDriver(
   11808   IN PDEVICE_OBJECT DeviceObject,
   11809   IN OUT PIRP Irp);
   11810 #define IoCallDriver IofCallDriver
   11811 
   11812 NTKERNELAPI
   11813 VOID
   11814 FASTCALL
   11815 IofCompleteRequest(
   11816   IN PIRP Irp,
   11817   IN CCHAR PriorityBoost);
   11818 #define IoCompleteRequest IofCompleteRequest
   11819 
   11820 NTKERNELAPI
   11821 BOOLEAN
   11822 NTAPI
   11823 IoCancelIrp(
   11824   IN PIRP Irp);
   11825 
   11826 NTKERNELAPI
   11827 NTSTATUS
   11828 NTAPI
   11829 IoCheckShareAccess(
   11830   IN ACCESS_MASK DesiredAccess,
   11831   IN ULONG DesiredShareAccess,
   11832   IN OUT PFILE_OBJECT FileObject,
   11833   IN OUT PSHARE_ACCESS ShareAccess,
   11834   IN BOOLEAN Update);
   11835 
   11836 NTKERNELAPI
   11837 VOID
   11838 FASTCALL
   11839 IofCompleteRequest(
   11840   IN PIRP Irp,
   11841   IN CCHAR PriorityBoost);
   11842 
   11843 NTKERNELAPI
   11844 NTSTATUS
   11845 NTAPI
   11846 IoConnectInterrupt(
   11847   OUT PKINTERRUPT *InterruptObject,
   11848   IN PKSERVICE_ROUTINE ServiceRoutine,
   11849   IN PVOID ServiceContext OPTIONAL,
   11850   IN PKSPIN_LOCK SpinLock OPTIONAL,
   11851   IN ULONG Vector,
   11852   IN KIRQL Irql,
   11853   IN KIRQL SynchronizeIrql,
   11854   IN KINTERRUPT_MODE InterruptMode,
   11855   IN BOOLEAN ShareVector,
   11856   IN KAFFINITY ProcessorEnableMask,
   11857   IN BOOLEAN FloatingSave);
   11858 
   11859 NTKERNELAPI
   11860 NTSTATUS
   11861 NTAPI
   11862 IoCreateDevice(
   11863   IN PDRIVER_OBJECT DriverObject,
   11864   IN ULONG DeviceExtensionSize,
   11865   IN PUNICODE_STRING DeviceName OPTIONAL,
   11866   IN DEVICE_TYPE DeviceType,
   11867   IN ULONG DeviceCharacteristics,
   11868   IN BOOLEAN Exclusive,
   11869   OUT PDEVICE_OBJECT *DeviceObject);
   11870 
   11871 NTKERNELAPI
   11872 NTSTATUS
   11873 NTAPI
   11874 IoCreateFile(
   11875   OUT PHANDLE FileHandle,
   11876   IN ACCESS_MASK DesiredAccess,
   11877   IN POBJECT_ATTRIBUTES ObjectAttributes,
   11878   OUT PIO_STATUS_BLOCK IoStatusBlock,
   11879   IN PLARGE_INTEGER AllocationSize OPTIONAL,
   11880   IN ULONG FileAttributes,
   11881   IN ULONG ShareAccess,
   11882   IN ULONG Disposition,
   11883   IN ULONG CreateOptions,
   11884   IN PVOID EaBuffer OPTIONAL,
   11885   IN ULONG EaLength,
   11886   IN CREATE_FILE_TYPE CreateFileType,
   11887   IN PVOID InternalParameters OPTIONAL,
   11888   IN ULONG Options);
   11889 
   11890 NTKERNELAPI
   11891 PKEVENT
   11892 NTAPI
   11893 IoCreateNotificationEvent(
   11894   IN PUNICODE_STRING EventName,
   11895   OUT PHANDLE EventHandle);
   11896 
   11897 NTKERNELAPI
   11898 NTSTATUS
   11899 NTAPI
   11900 IoCreateSymbolicLink(
   11901   IN PUNICODE_STRING SymbolicLinkName,
   11902   IN PUNICODE_STRING DeviceName);
   11903 
   11904 NTKERNELAPI
   11905 PKEVENT
   11906 NTAPI
   11907 IoCreateSynchronizationEvent(
   11908   IN PUNICODE_STRING EventName,
   11909   OUT PHANDLE EventHandle);
   11910 
   11911 NTKERNELAPI
   11912 NTSTATUS
   11913 NTAPI
   11914 IoCreateUnprotectedSymbolicLink(
   11915   IN PUNICODE_STRING SymbolicLinkName,
   11916   IN PUNICODE_STRING DeviceName);
   11917 
   11918 NTKERNELAPI
   11919 VOID
   11920 NTAPI
   11921 IoDeleteDevice(
   11922   IN PDEVICE_OBJECT DeviceObject);
   11923 
   11924 NTKERNELAPI
   11925 NTSTATUS
   11926 NTAPI
   11927 IoDeleteSymbolicLink(
   11928   IN PUNICODE_STRING SymbolicLinkName);
   11929 
   11930 NTKERNELAPI
   11931 VOID
   11932 NTAPI
   11933 IoDetachDevice(
   11934   IN OUT PDEVICE_OBJECT TargetDevice);
   11935 
   11936 NTKERNELAPI
   11937 VOID
   11938 NTAPI
   11939 IoDisconnectInterrupt(
   11940   IN PKINTERRUPT InterruptObject);
   11941 
   11942 NTKERNELAPI
   11943 VOID
   11944 NTAPI
   11945 IoFreeIrp(
   11946   IN PIRP Irp);
   11947 
   11948 NTKERNELAPI
   11949 VOID
   11950 NTAPI
   11951 IoFreeMdl(
   11952   IN PMDL Mdl);
   11953 
   11954 NTKERNELAPI
   11955 VOID
   11956 NTAPI
   11957 IoFreeWorkItem(
   11958   IN PIO_WORKITEM IoWorkItem);
   11959 
   11960 NTKERNELAPI
   11961 PDEVICE_OBJECT
   11962 NTAPI
   11963 IoGetAttachedDevice(
   11964   IN PDEVICE_OBJECT DeviceObject);
   11965 
   11966 NTKERNELAPI
   11967 PDEVICE_OBJECT
   11968 NTAPI
   11969 IoGetAttachedDeviceReference(
   11970   IN PDEVICE_OBJECT DeviceObject);
   11971 
   11972 NTKERNELAPI
   11973 NTSTATUS
   11974 NTAPI
   11975 IoGetBootDiskInformation(
   11976   IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
   11977   IN ULONG Size);
   11978 
   11979 NTKERNELAPI
   11980 NTSTATUS
   11981 NTAPI
   11982 IoGetDeviceInterfaceAlias(
   11983   IN PUNICODE_STRING SymbolicLinkName,
   11984   IN CONST GUID *AliasInterfaceClassGuid,
   11985   OUT PUNICODE_STRING AliasSymbolicLinkName);
   11986 
   11987 NTKERNELAPI
   11988 PEPROCESS
   11989 NTAPI
   11990 IoGetCurrentProcess(VOID);
   11991 
   11992 NTKERNELAPI
   11993 NTSTATUS
   11994 NTAPI
   11995 IoGetDeviceInterfaces(
   11996   IN CONST GUID *InterfaceClassGuid,
   11997   IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
   11998   IN ULONG Flags,
   11999   OUT PWSTR *SymbolicLinkList);
   12000 
   12001 NTKERNELAPI
   12002 NTSTATUS
   12003 NTAPI
   12004 IoGetDeviceObjectPointer(
   12005   IN PUNICODE_STRING ObjectName,
   12006   IN ACCESS_MASK DesiredAccess,
   12007   OUT PFILE_OBJECT *FileObject,
   12008   OUT PDEVICE_OBJECT *DeviceObject);
   12009 
   12010 NTKERNELAPI
   12011 NTSTATUS
   12012 NTAPI
   12013 IoGetDeviceProperty(
   12014   IN PDEVICE_OBJECT DeviceObject,
   12015   IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
   12016   IN ULONG BufferLength,
   12017   OUT PVOID PropertyBuffer,
   12018   OUT PULONG ResultLength);
   12019 
   12020 NTKERNELAPI
   12021 PDMA_ADAPTER
   12022 NTAPI
   12023 IoGetDmaAdapter(
   12024   IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
   12025   IN PDEVICE_DESCRIPTION DeviceDescription,
   12026   IN OUT PULONG NumberOfMapRegisters);
   12027 
   12028 NTKERNELAPI
   12029 PVOID
   12030 NTAPI
   12031 IoGetDriverObjectExtension(
   12032   IN PDRIVER_OBJECT DriverObject,
   12033   IN PVOID ClientIdentificationAddress);
   12034 
   12035 NTKERNELAPI
   12036 PVOID
   12037 NTAPI
   12038 IoGetInitialStack(VOID);
   12039 
   12040 NTKERNELAPI
   12041 PDEVICE_OBJECT
   12042 NTAPI
   12043 IoGetRelatedDeviceObject(
   12044   IN PFILE_OBJECT FileObject);
   12045 
   12046 NTKERNELAPI
   12047 VOID
   12048 NTAPI
   12049 IoQueueWorkItem(
   12050   IN PIO_WORKITEM IoWorkItem,
   12051   IN PIO_WORKITEM_ROUTINE WorkerRoutine,
   12052   IN WORK_QUEUE_TYPE QueueType,
   12053   IN PVOID Context OPTIONAL);
   12054 
   12055 NTKERNELAPI
   12056 VOID
   12057 NTAPI
   12058 IoInitializeIrp(
   12059   IN OUT PIRP Irp,
   12060   IN USHORT PacketSize,
   12061   IN CCHAR StackSize);
   12062 
   12063 NTKERNELAPI
   12064 VOID
   12065 NTAPI
   12066 IoInitializeRemoveLockEx(
   12067   IN PIO_REMOVE_LOCK Lock,
   12068   IN ULONG AllocateTag,
   12069   IN ULONG MaxLockedMinutes,
   12070   IN ULONG HighWatermark,
   12071   IN ULONG RemlockSize);
   12072 
   12073 NTKERNELAPI
   12074 NTSTATUS
   12075 NTAPI
   12076 IoInitializeTimer(
   12077   IN PDEVICE_OBJECT DeviceObject,
   12078   IN PIO_TIMER_ROUTINE TimerRoutine,
   12079   IN PVOID Context OPTIONAL);
   12080 
   12081 NTKERNELAPI
   12082 VOID
   12083 NTAPI
   12084 IoInvalidateDeviceRelations(
   12085   IN PDEVICE_OBJECT DeviceObject,
   12086   IN DEVICE_RELATION_TYPE Type);
   12087 
   12088 NTKERNELAPI
   12089 VOID
   12090 NTAPI
   12091 IoInvalidateDeviceState(
   12092   IN PDEVICE_OBJECT PhysicalDeviceObject);
   12093 
   12094 NTKERNELAPI
   12095 BOOLEAN
   12096 NTAPI
   12097 IoIsWdmVersionAvailable(
   12098   IN UCHAR MajorVersion,
   12099   IN UCHAR MinorVersion);
   12100 
   12101 NTKERNELAPI
   12102 NTSTATUS
   12103 NTAPI
   12104 IoOpenDeviceInterfaceRegistryKey(
   12105   IN PUNICODE_STRING SymbolicLinkName,
   12106   IN ACCESS_MASK DesiredAccess,
   12107   OUT PHANDLE DeviceInterfaceKey);
   12108 
   12109 NTKERNELAPI
   12110 NTSTATUS
   12111 NTAPI
   12112 IoOpenDeviceRegistryKey(
   12113   IN PDEVICE_OBJECT DeviceObject,
   12114   IN ULONG DevInstKeyType,
   12115   IN ACCESS_MASK DesiredAccess,
   12116   OUT PHANDLE DevInstRegKey);
   12117 
   12118 NTKERNELAPI
   12119 NTSTATUS
   12120 NTAPI
   12121 IoRegisterDeviceInterface(
   12122   IN PDEVICE_OBJECT PhysicalDeviceObject,
   12123   IN CONST GUID *InterfaceClassGuid,
   12124   IN PUNICODE_STRING ReferenceString OPTIONAL,
   12125   OUT PUNICODE_STRING SymbolicLinkName);
   12126 
   12127 NTKERNELAPI
   12128 NTSTATUS
   12129 NTAPI
   12130 IoRegisterPlugPlayNotification(
   12131   IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
   12132   IN ULONG EventCategoryFlags,
   12133   IN PVOID EventCategoryData OPTIONAL,
   12134   IN PDRIVER_OBJECT DriverObject,
   12135   IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine,
   12136   IN OUT PVOID Context OPTIONAL,
   12137   OUT PVOID *NotificationEntry);
   12138 
   12139 NTKERNELAPI
   12140 NTSTATUS
   12141 NTAPI
   12142 IoRegisterShutdownNotification(
   12143   IN PDEVICE_OBJECT DeviceObject);
   12144 
   12145 NTKERNELAPI
   12146 VOID
   12147 NTAPI
   12148 IoReleaseCancelSpinLock(
   12149   IN KIRQL Irql);
   12150 
   12151 NTKERNELAPI
   12152 VOID
   12153 NTAPI
   12154 IoReleaseRemoveLockAndWaitEx(
   12155   IN PIO_REMOVE_LOCK RemoveLock,
   12156   IN PVOID Tag OPTIONAL,
   12157   IN ULONG RemlockSize);
   12158 
   12159 NTKERNELAPI
   12160 VOID
   12161 NTAPI
   12162 IoReleaseRemoveLockEx(
   12163   IN PIO_REMOVE_LOCK RemoveLock,
   12164   IN PVOID Tag OPTIONAL,
   12165   IN ULONG RemlockSize);
   12166 
   12167 NTKERNELAPI
   12168 VOID
   12169 NTAPI
   12170 IoRemoveShareAccess(
   12171   IN PFILE_OBJECT FileObject,
   12172   IN OUT PSHARE_ACCESS ShareAccess);
   12173 
   12174 NTKERNELAPI
   12175 NTSTATUS
   12176 NTAPI
   12177 IoReportTargetDeviceChange(
   12178   IN PDEVICE_OBJECT PhysicalDeviceObject,
   12179   IN PVOID NotificationStructure);
   12180 
   12181 NTKERNELAPI
   12182 NTSTATUS
   12183 NTAPI
   12184 IoReportTargetDeviceChangeAsynchronous(
   12185   IN PDEVICE_OBJECT PhysicalDeviceObject,
   12186   IN PVOID NotificationStructure,
   12187   IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL,
   12188   IN PVOID Context OPTIONAL);
   12189 
   12190 NTKERNELAPI
   12191 VOID
   12192 NTAPI
   12193 IoRequestDeviceEject(
   12194   IN PDEVICE_OBJECT PhysicalDeviceObject);
   12195 
   12196 NTKERNELAPI
   12197 VOID
   12198 NTAPI
   12199 IoReuseIrp(
   12200   IN OUT PIRP Irp,
   12201   IN NTSTATUS Status);
   12202 
   12203 NTKERNELAPI
   12204 NTSTATUS
   12205 NTAPI
   12206 IoSetDeviceInterfaceState(
   12207   IN PUNICODE_STRING SymbolicLinkName,
   12208   IN BOOLEAN Enable);
   12209 
   12210 NTKERNELAPI
   12211 VOID
   12212 NTAPI
   12213 IoSetShareAccess(
   12214   IN ACCESS_MASK DesiredAccess,
   12215   IN ULONG DesiredShareAccess,
   12216   IN OUT PFILE_OBJECT FileObject,
   12217   OUT PSHARE_ACCESS ShareAccess);
   12218 
   12219 NTKERNELAPI
   12220 VOID
   12221 NTAPI
   12222 IoStartNextPacket(
   12223   IN PDEVICE_OBJECT DeviceObject,
   12224   IN BOOLEAN Cancelable);
   12225 
   12226 NTKERNELAPI
   12227 VOID
   12228 NTAPI
   12229 IoStartNextPacketByKey(
   12230   IN PDEVICE_OBJECT DeviceObject,
   12231   IN BOOLEAN Cancelable,
   12232   IN ULONG Key);
   12233 
   12234 NTKERNELAPI
   12235 VOID
   12236 NTAPI
   12237 IoStartPacket(
   12238   IN PDEVICE_OBJECT DeviceObject,
   12239   IN PIRP Irp,
   12240   IN PULONG Key OPTIONAL,
   12241   IN PDRIVER_CANCEL CancelFunction OPTIONAL);
   12242 
   12243 NTKERNELAPI
   12244 VOID
   12245 NTAPI
   12246 IoStartTimer(
   12247   IN PDEVICE_OBJECT DeviceObject);
   12248 
   12249 NTKERNELAPI
   12250 VOID
   12251 NTAPI
   12252 IoStopTimer(
   12253   IN PDEVICE_OBJECT DeviceObject);
   12254 
   12255 NTKERNELAPI
   12256 NTSTATUS
   12257 NTAPI
   12258 IoUnregisterPlugPlayNotification(
   12259   IN PVOID NotificationEntry);
   12260 
   12261 NTKERNELAPI
   12262 VOID
   12263 NTAPI
   12264 IoUnregisterShutdownNotification(
   12265   IN PDEVICE_OBJECT DeviceObject);
   12266 
   12267 NTKERNELAPI
   12268 VOID
   12269 NTAPI
   12270 IoUpdateShareAccess(
   12271   IN PFILE_OBJECT FileObject,
   12272   IN OUT PSHARE_ACCESS ShareAccess);
   12273 
   12274 NTKERNELAPI
   12275 NTSTATUS
   12276 NTAPI
   12277 IoWMIAllocateInstanceIds(
   12278   IN GUID *Guid,
   12279   IN ULONG InstanceCount,
   12280   OUT ULONG *FirstInstanceId);
   12281 
   12282 NTKERNELAPI
   12283 NTSTATUS
   12284 NTAPI
   12285 IoWMIQuerySingleInstanceMultiple(
   12286   IN PVOID *DataBlockObjectList,
   12287   IN PUNICODE_STRING InstanceNames,
   12288   IN ULONG ObjectCount,
   12289   IN OUT ULONG *InOutBufferSize,
   12290   OUT PVOID OutBuffer);
   12291 
   12292 NTKERNELAPI
   12293 NTSTATUS
   12294 NTAPI
   12295 IoWMIRegistrationControl(
   12296   IN PDEVICE_OBJECT DeviceObject,
   12297   IN ULONG Action);
   12298 
   12299 NTKERNELAPI
   12300 NTSTATUS
   12301 NTAPI
   12302 IoWMISuggestInstanceName(
   12303   IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
   12304   IN PUNICODE_STRING SymbolicLinkName OPTIONAL,
   12305   IN BOOLEAN CombineNames,
   12306   OUT PUNICODE_STRING SuggestedInstanceName);
   12307 
   12308 NTKERNELAPI
   12309 NTSTATUS
   12310 NTAPI
   12311 IoWMIWriteEvent(
   12312   IN OUT PVOID WnodeEventItem);
   12313 
   12314 NTKERNELAPI
   12315 VOID
   12316 NTAPI
   12317 IoWriteErrorLogEntry(
   12318   IN PVOID ElEntry);
   12319 
   12320 NTKERNELAPI
   12321 PIRP
   12322 NTAPI
   12323 IoGetTopLevelIrp(VOID);
   12324 
   12325 NTKERNELAPI
   12326 NTSTATUS
   12327 NTAPI
   12328 IoRegisterLastChanceShutdownNotification(
   12329   IN PDEVICE_OBJECT DeviceObject);
   12330 
   12331 NTKERNELAPI
   12332 VOID
   12333 NTAPI
   12334 IoSetTopLevelIrp(
   12335   IN PIRP Irp OPTIONAL);
   12336 
   12337 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   12338 
   12339 
   12340 #if (NTDDI_VERSION >= NTDDI_WINXP)
   12341 
   12342 NTKERNELAPI
   12343 NTSTATUS
   12344 NTAPI
   12345 IoCsqInitialize(
   12346   IN PIO_CSQ Csq,
   12347   IN PIO_CSQ_INSERT_IRP CsqInsertIrp,
   12348   IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
   12349   IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
   12350   IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
   12351   IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
   12352   IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
   12353 
   12354 NTKERNELAPI
   12355 VOID
   12356 NTAPI
   12357 IoCsqInsertIrp(
   12358   IN PIO_CSQ Csq,
   12359   IN PIRP Irp,
   12360   IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL);
   12361 
   12362 NTKERNELAPI
   12363 PIRP
   12364 NTAPI
   12365 IoCsqRemoveIrp(
   12366   IN PIO_CSQ Csq,
   12367   IN PIO_CSQ_IRP_CONTEXT Context);
   12368 
   12369 NTKERNELAPI
   12370 PIRP
   12371 NTAPI
   12372 IoCsqRemoveNextIrp(
   12373   IN PIO_CSQ Csq,
   12374   IN PVOID PeekContext OPTIONAL);
   12375 
   12376 NTKERNELAPI
   12377 BOOLEAN
   12378 NTAPI
   12379 IoForwardIrpSynchronously(
   12380   IN PDEVICE_OBJECT DeviceObject,
   12381   IN PIRP Irp);
   12382 
   12383 #define IoForwardAndCatchIrp IoForwardIrpSynchronously
   12384 
   12385 NTKERNELAPI
   12386 VOID
   12387 NTAPI
   12388 IoFreeErrorLogEntry(
   12389   PVOID ElEntry);
   12390 
   12391 NTKERNELAPI
   12392 NTSTATUS
   12393 NTAPI
   12394 IoSetCompletionRoutineEx(
   12395   IN PDEVICE_OBJECT DeviceObject,
   12396   IN PIRP Irp,
   12397   IN PIO_COMPLETION_ROUTINE CompletionRoutine,
   12398   IN PVOID Context,
   12399   IN BOOLEAN InvokeOnSuccess,
   12400   IN BOOLEAN InvokeOnError,
   12401   IN BOOLEAN InvokeOnCancel);
   12402 
   12403 VOID
   12404 NTAPI
   12405 IoSetStartIoAttributes(
   12406   IN PDEVICE_OBJECT DeviceObject,
   12407   IN BOOLEAN DeferredStartIo,
   12408   IN BOOLEAN NonCancelable);
   12409 
   12410 NTKERNELAPI
   12411 NTSTATUS
   12412 NTAPI
   12413 IoWMIDeviceObjectToInstanceName(
   12414   IN PVOID DataBlockObject,
   12415   IN PDEVICE_OBJECT DeviceObject,
   12416   OUT PUNICODE_STRING InstanceName);
   12417 
   12418 NTKERNELAPI
   12419 NTSTATUS
   12420 NTAPI
   12421 IoWMIExecuteMethod(
   12422   IN PVOID DataBlockObject,
   12423   IN PUNICODE_STRING InstanceName,
   12424   IN ULONG MethodId,
   12425   IN ULONG InBufferSize,
   12426   IN OUT PULONG OutBufferSize,
   12427   IN OUT  PUCHAR InOutBuffer);
   12428 
   12429 NTKERNELAPI
   12430 NTSTATUS
   12431 NTAPI
   12432 IoWMIHandleToInstanceName(
   12433   IN PVOID DataBlockObject,
   12434   IN HANDLE FileHandle,
   12435   OUT PUNICODE_STRING InstanceName);
   12436 
   12437 NTKERNELAPI
   12438 NTSTATUS
   12439 NTAPI
   12440 IoWMIOpenBlock(
   12441   IN GUID *DataBlockGuid,
   12442   IN ULONG DesiredAccess,
   12443   OUT PVOID *DataBlockObject);
   12444 
   12445 NTKERNELAPI
   12446 NTSTATUS
   12447 NTAPI
   12448 IoWMIQueryAllData(
   12449   IN PVOID DataBlockObject,
   12450   IN OUT ULONG *InOutBufferSize,
   12451   OUT PVOID OutBuffer);
   12452 
   12453 NTKERNELAPI
   12454 NTSTATUS
   12455 NTAPI
   12456 IoWMIQueryAllDataMultiple(
   12457   IN PVOID *DataBlockObjectList,
   12458   IN ULONG ObjectCount,
   12459   IN OUT ULONG *InOutBufferSize,
   12460   OUT PVOID OutBuffer);
   12461 
   12462 NTKERNELAPI
   12463 NTSTATUS
   12464 NTAPI
   12465 IoWMIQuerySingleInstance(
   12466   IN PVOID DataBlockObject,
   12467   IN PUNICODE_STRING InstanceName,
   12468   IN OUT ULONG *InOutBufferSize,
   12469   OUT PVOID OutBuffer);
   12470 
   12471 NTKERNELAPI
   12472 NTSTATUS
   12473 NTAPI
   12474 IoWMISetNotificationCallback(
   12475   IN OUT PVOID Object,
   12476   IN WMI_NOTIFICATION_CALLBACK Callback,
   12477   IN PVOID Context OPTIONAL);
   12478 
   12479 NTKERNELAPI
   12480 NTSTATUS
   12481 NTAPI
   12482 IoWMISetSingleInstance(
   12483   IN PVOID DataBlockObject,
   12484   IN PUNICODE_STRING InstanceName,
   12485   IN ULONG Version,
   12486   IN ULONG ValueBufferSize,
   12487   IN PVOID ValueBuffer);
   12488 
   12489 NTKERNELAPI
   12490 NTSTATUS
   12491 NTAPI
   12492 IoWMISetSingleItem(
   12493   IN PVOID DataBlockObject,
   12494   IN PUNICODE_STRING InstanceName,
   12495   IN ULONG DataItemId,
   12496   IN ULONG Version,
   12497   IN ULONG ValueBufferSize,
   12498   IN PVOID ValueBuffer);
   12499 
   12500 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
   12501 
   12502 #if (NTDDI_VERSION >= NTDDI_WINXPSP1)
   12503 NTKERNELAPI
   12504 NTSTATUS
   12505 NTAPI
   12506 IoValidateDeviceIoControlAccess(
   12507   IN PIRP Irp,
   12508   IN ULONG RequiredAccess);
   12509 #endif
   12510 
   12511 #if (NTDDI_VERSION >= NTDDI_WS03)
   12512 NTKERNELAPI
   12513 NTSTATUS
   12514 NTAPI
   12515 IoCsqInitializeEx(
   12516   IN PIO_CSQ Csq,
   12517   IN PIO_CSQ_INSERT_IRP_EX CsqInsertIrp,
   12518   IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
   12519   IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
   12520   IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
   12521   IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
   12522   IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
   12523 
   12524 NTKERNELAPI
   12525 NTSTATUS
   12526 NTAPI
   12527 IoCsqInsertIrpEx(
   12528   IN PIO_CSQ Csq,
   12529   IN PIRP Irp,
   12530   IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL,
   12531   IN PVOID InsertContext OPTIONAL);
   12532 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */
   12533 
   12534 
   12535 #if (NTDDI_VERSION >= NTDDI_VISTA)
   12536 NTKERNELAPI
   12537 NTSTATUS
   12538 NTAPI
   12539 IoGetBootDiskInformationLite(
   12540   OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation);
   12541 
   12542 NTKERNELAPI
   12543 NTSTATUS
   12544 NTAPI
   12545 IoCheckShareAccessEx(
   12546   IN ACCESS_MASK DesiredAccess,
   12547   IN ULONG DesiredShareAccess,
   12548   IN OUT PFILE_OBJECT FileObject,
   12549   IN OUT PSHARE_ACCESS ShareAccess,
   12550   IN BOOLEAN Update,
   12551   IN PBOOLEAN WritePermission);
   12552 
   12553 NTKERNELAPI
   12554 NTSTATUS
   12555 NTAPI
   12556 IoConnectInterruptEx(
   12557   IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters);
   12558 
   12559 NTKERNELAPI
   12560 VOID
   12561 NTAPI
   12562 IoDisconnectInterruptEx(
   12563   IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters);
   12564 
   12565 LOGICAL
   12566 NTAPI
   12567 IoWithinStackLimits(
   12568   IN ULONG_PTR RegionStart,
   12569   IN SIZE_T RegionSize);
   12570 
   12571 NTKERNELAPI
   12572 VOID
   12573 NTAPI
   12574 IoSetShareAccessEx(
   12575   IN ACCESS_MASK DesiredAccess,
   12576   IN ULONG DesiredShareAccess,
   12577   IN OUT PFILE_OBJECT FileObject,
   12578   OUT PSHARE_ACCESS ShareAccess,
   12579   IN PBOOLEAN WritePermission);
   12580 
   12581 ULONG
   12582 NTAPI
   12583 IoSizeofWorkItem(VOID);
   12584 
   12585 VOID
   12586 NTAPI
   12587 IoInitializeWorkItem(
   12588   IN PVOID IoObject,
   12589   IN PIO_WORKITEM IoWorkItem);
   12590 
   12591 VOID
   12592 NTAPI
   12593 IoUninitializeWorkItem(
   12594   IN PIO_WORKITEM IoWorkItem);
   12595 
   12596 VOID
   12597 NTAPI
   12598 IoQueueWorkItemEx(
   12599   IN PIO_WORKITEM IoWorkItem,
   12600   IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine,
   12601   IN WORK_QUEUE_TYPE QueueType,
   12602   IN PVOID Context OPTIONAL);
   12603 
   12604 IO_PRIORITY_HINT
   12605 NTAPI
   12606 IoGetIoPriorityHint(
   12607   IN PIRP Irp);
   12608 
   12609 NTSTATUS
   12610 NTAPI
   12611 IoSetIoPriorityHint(
   12612   IN PIRP Irp,
   12613   IN IO_PRIORITY_HINT PriorityHint);
   12614 
   12615 NTSTATUS
   12616 NTAPI
   12617 IoAllocateSfioStreamIdentifier(
   12618   IN PFILE_OBJECT FileObject,
   12619   IN ULONG Length,
   12620   IN PVOID Signature,
   12621   OUT PVOID *StreamIdentifier);
   12622 
   12623 PVOID
   12624 NTAPI
   12625 IoGetSfioStreamIdentifier(
   12626   IN PFILE_OBJECT FileObject,
   12627   IN PVOID Signature);
   12628 
   12629 NTSTATUS
   12630 NTAPI
   12631 IoFreeSfioStreamIdentifier(
   12632   IN PFILE_OBJECT FileObject,
   12633   IN PVOID Signature);
   12634 
   12635 NTKERNELAPI
   12636 NTSTATUS
   12637 NTAPI
   12638 IoRequestDeviceEjectEx(
   12639   IN PDEVICE_OBJECT PhysicalDeviceObject,
   12640   IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL,
   12641   IN PVOID Context OPTIONAL,
   12642   IN PDRIVER_OBJECT DriverObject OPTIONAL);
   12643 
   12644 NTKERNELAPI
   12645 NTSTATUS
   12646 NTAPI
   12647 IoSetDevicePropertyData(
   12648   IN PDEVICE_OBJECT     Pdo,
   12649   IN CONST DEVPROPKEY   *PropertyKey,
   12650   IN LCID               Lcid,
   12651   IN ULONG              Flags,
   12652   IN DEVPROPTYPE        Type,
   12653   IN ULONG              Size,
   12654   IN PVOID          Data OPTIONAL);
   12655 
   12656 NTKERNELAPI
   12657 NTSTATUS
   12658 NTAPI
   12659 IoGetDevicePropertyData(
   12660   PDEVICE_OBJECT Pdo,
   12661   CONST DEVPROPKEY *PropertyKey,
   12662   LCID Lcid,
   12663   ULONG Flags,
   12664   ULONG Size,
   12665   PVOID Data,
   12666   PULONG RequiredSize,
   12667   PDEVPROPTYPE Type);
   12668 
   12669 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   12670 
   12671 #define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b)
   12672 
   12673 #if (NTDDI_VERSION >= NTDDI_WS08)
   12674 NTKERNELAPI
   12675 NTSTATUS
   12676 NTAPI
   12677 IoReplacePartitionUnit(
   12678   IN PDEVICE_OBJECT TargetPdo,
   12679   IN PDEVICE_OBJECT SparePdo,
   12680   IN ULONG Flags);
   12681 #endif
   12682 
   12683 #if (NTDDI_VERSION >= NTDDI_WIN7)
   12684 
   12685 NTKERNELAPI
   12686 NTSTATUS
   12687 NTAPI
   12688 IoGetAffinityInterrupt(
   12689   IN PKINTERRUPT InterruptObject,
   12690   OUT PGROUP_AFFINITY GroupAffinity);
   12691 
   12692 NTSTATUS
   12693 NTAPI
   12694 IoGetContainerInformation(
   12695   IN IO_CONTAINER_INFORMATION_CLASS InformationClass,
   12696   IN PVOID ContainerObject OPTIONAL,
   12697   IN OUT PVOID Buffer OPTIONAL,
   12698   IN ULONG BufferLength);
   12699 
   12700 NTSTATUS
   12701 NTAPI
   12702 IoRegisterContainerNotification(
   12703   IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass,
   12704   IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction,
   12705   IN PVOID NotificationInformation OPTIONAL,
   12706   IN ULONG NotificationInformationLength,
   12707   OUT PVOID CallbackRegistration);
   12708 
   12709 VOID
   12710 NTAPI
   12711 IoUnregisterContainerNotification(
   12712   IN PVOID CallbackRegistration);
   12713 
   12714 NTKERNELAPI
   12715 NTSTATUS
   12716 NTAPI
   12717 IoUnregisterPlugPlayNotificationEx(
   12718   IN PVOID NotificationEntry);
   12719 
   12720 NTKERNELAPI
   12721 NTSTATUS
   12722 NTAPI
   12723 IoGetDeviceNumaNode(
   12724   IN PDEVICE_OBJECT Pdo,
   12725   OUT PUSHORT NodeNumber);
   12726 
   12727 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   12728 
   12729 #if defined(_WIN64)
   12730 NTKERNELAPI
   12731 ULONG
   12732 NTAPI
   12733 IoWMIDeviceObjectToProviderId(
   12734   IN PDEVICE_OBJECT DeviceObject);
   12735 #else
   12736 #define IoWMIDeviceObjectToProviderId(DeviceObject) ((ULONG)(DeviceObject))
   12737 #endif
   12738 
   12739 /*
   12740  * USHORT
   12741  * IoSizeOfIrp(
   12742  *   IN CCHAR  StackSize)
   12743  */
   12744 #define IoSizeOfIrp(_StackSize) \
   12745   ((USHORT) (sizeof(IRP) + ((_StackSize) * (sizeof(IO_STACK_LOCATION)))))
   12746 
   12747 FORCEINLINE
   12748 VOID
   12749 IoSkipCurrentIrpStackLocation(
   12750   IN OUT PIRP Irp)
   12751 {
   12752   ASSERT(Irp->CurrentLocation <= Irp->StackCount);
   12753   Irp->CurrentLocation++;
   12754 #ifdef NONAMELESSUNION
   12755   Irp->Tail.Overlay.s.u.CurrentStackLocation++;
   12756 #else
   12757   Irp->Tail.Overlay.CurrentStackLocation++;
   12758 #endif
   12759 }
   12760 
   12761 FORCEINLINE
   12762 VOID
   12763 IoSetNextIrpStackLocation(
   12764   IN OUT PIRP Irp)
   12765 {
   12766   ASSERT(Irp->CurrentLocation > 0);
   12767   Irp->CurrentLocation--;
   12768 #ifdef NONAMELESSUNION
   12769   Irp->Tail.Overlay.s.u.CurrentStackLocation--;
   12770 #else
   12771   Irp->Tail.Overlay.CurrentStackLocation--;
   12772 #endif
   12773 }
   12774 
   12775 FORCEINLINE
   12776 PIO_STACK_LOCATION
   12777 IoGetNextIrpStackLocation(
   12778   IN PIRP Irp)
   12779 {
   12780   ASSERT(Irp->CurrentLocation > 0);
   12781 #ifdef NONAMELESSUNION
   12782   return ((Irp)->Tail.Overlay.s.u.CurrentStackLocation - 1 );
   12783 #else
   12784   return ((Irp)->Tail.Overlay.CurrentStackLocation - 1 );
   12785 #endif
   12786 }
   12787 
   12788 FORCEINLINE
   12789 VOID
   12790 IoSetCompletionRoutine(
   12791   IN PIRP Irp,
   12792   IN PIO_COMPLETION_ROUTINE CompletionRoutine OPTIONAL,
   12793   IN PVOID Context OPTIONAL,
   12794   IN BOOLEAN InvokeOnSuccess,
   12795   IN BOOLEAN InvokeOnError,
   12796   IN BOOLEAN InvokeOnCancel)
   12797 {
   12798   PIO_STACK_LOCATION irpSp;
   12799   ASSERT( (InvokeOnSuccess || InvokeOnError || InvokeOnCancel) ? (CompletionRoutine != NULL) : TRUE );
   12800   irpSp = IoGetNextIrpStackLocation(Irp);
   12801   irpSp->CompletionRoutine = CompletionRoutine;
   12802   irpSp->Context = Context;
   12803   irpSp->Control = 0;
   12804 
   12805   if (InvokeOnSuccess) {
   12806     irpSp->Control = SL_INVOKE_ON_SUCCESS;
   12807   }
   12808 
   12809   if (InvokeOnError) {
   12810     irpSp->Control |= SL_INVOKE_ON_ERROR;
   12811   }
   12812 
   12813   if (InvokeOnCancel) {
   12814     irpSp->Control |= SL_INVOKE_ON_CANCEL;
   12815   }
   12816 }
   12817 
   12818 /*
   12819  * PDRIVER_CANCEL
   12820  * IoSetCancelRoutine(
   12821  *   IN PIRP  Irp,
   12822  *   IN PDRIVER_CANCEL  CancelRoutine)
   12823  */
   12824 #define IoSetCancelRoutine(_Irp, \
   12825                            _CancelRoutine) \
   12826   ((PDRIVER_CANCEL) (ULONG_PTR) InterlockedExchangePointer( \
   12827     (PVOID *) &(_Irp)->CancelRoutine, (PVOID) (ULONG_PTR) (_CancelRoutine)))
   12828 
   12829 /*
   12830  * VOID
   12831  * IoRequestDpc(
   12832  *   IN PDEVICE_OBJECT  DeviceObject,
   12833  *   IN PIRP  Irp,
   12834  *   IN PVOID  Context);
   12835  */
   12836 #define IoRequestDpc(DeviceObject, Irp, Context)( \
   12837   KeInsertQueueDpc(&(DeviceObject)->Dpc, (Irp), (Context)))
   12838 
   12839 /*
   12840  * VOID
   12841  * IoReleaseRemoveLock(
   12842  *   IN PIO_REMOVE_LOCK  RemoveLock,
   12843  *   IN PVOID  Tag)
   12844  */
   12845 #define IoReleaseRemoveLock(_RemoveLock, \
   12846                             _Tag) \
   12847   IoReleaseRemoveLockEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
   12848 
   12849 /*
   12850  * VOID
   12851  * IoReleaseRemoveLockAndWait(
   12852  *   IN PIO_REMOVE_LOCK  RemoveLock,
   12853  *   IN PVOID  Tag)
   12854  */
   12855 #define IoReleaseRemoveLockAndWait(_RemoveLock, \
   12856                                    _Tag) \
   12857   IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
   12858 
   12859 #if defined(_WIN64)
   12860 NTKERNELAPI
   12861 BOOLEAN
   12862 IoIs32bitProcess(
   12863   IN PIRP Irp OPTIONAL);
   12864 #endif
   12865 
   12866 #define PLUGPLAY_REGKEY_DEVICE                            1
   12867 #define PLUGPLAY_REGKEY_DRIVER                            2
   12868 #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE                 4
   12869 
   12870 FORCEINLINE
   12871 PIO_STACK_LOCATION
   12872 IoGetCurrentIrpStackLocation(
   12873   IN PIRP Irp)
   12874 {
   12875   ASSERT(Irp->CurrentLocation <= Irp->StackCount + 1);
   12876 #ifdef NONAMELESSUNION
   12877   return Irp->Tail.Overlay.s.u.CurrentStackLocation;
   12878 #else
   12879   return Irp->Tail.Overlay.CurrentStackLocation;
   12880 #endif
   12881 }
   12882 
   12883 FORCEINLINE
   12884 VOID
   12885 IoMarkIrpPending(
   12886   IN OUT PIRP Irp)
   12887 {
   12888   IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED;
   12889 }
   12890 
   12891 /*
   12892  * BOOLEAN
   12893  * IoIsErrorUserInduced(
   12894  *   IN NTSTATUS  Status);
   12895  */
   12896 #define IoIsErrorUserInduced(Status) \
   12897    ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \
   12898    ((Status) == STATUS_IO_TIMEOUT) || \
   12899    ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
   12900    ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
   12901    ((Status) == STATUS_VERIFY_REQUIRED) || \
   12902    ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
   12903    ((Status) == STATUS_WRONG_VOLUME)))
   12904 
   12905 /* VOID
   12906  * IoInitializeRemoveLock(
   12907  *   IN PIO_REMOVE_LOCK  Lock,
   12908  *   IN ULONG  AllocateTag,
   12909  *   IN ULONG  MaxLockedMinutes,
   12910  *   IN ULONG  HighWatermark)
   12911  */
   12912 #define IoInitializeRemoveLock( \
   12913   Lock, AllocateTag, MaxLockedMinutes, HighWatermark) \
   12914   IoInitializeRemoveLockEx(Lock, AllocateTag, MaxLockedMinutes, \
   12915     HighWatermark, sizeof(IO_REMOVE_LOCK))
   12916 
   12917 FORCEINLINE
   12918 VOID
   12919 IoInitializeDpcRequest(
   12920   IN PDEVICE_OBJECT DeviceObject,
   12921   IN PIO_DPC_ROUTINE DpcRoutine)
   12922 {
   12923   KeInitializeDpc( &DeviceObject->Dpc,
   12924                    (PKDEFERRED_ROUTINE) DpcRoutine,
   12925                    DeviceObject );
   12926 }
   12927 
   12928 #define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
   12929 
   12930 /*
   12931  * ULONG
   12932  * IoGetFunctionCodeFromCtlCode(
   12933  *   IN ULONG  ControlCode)
   12934  */
   12935 #define IoGetFunctionCodeFromCtlCode(_ControlCode) \
   12936   (((_ControlCode) >> 2) & 0x00000FFF)
   12937 
   12938 FORCEINLINE
   12939 VOID
   12940 IoCopyCurrentIrpStackLocationToNext(
   12941   IN OUT PIRP Irp)
   12942 {
   12943   PIO_STACK_LOCATION irpSp;
   12944   PIO_STACK_LOCATION nextIrpSp;
   12945   irpSp = IoGetCurrentIrpStackLocation(Irp);
   12946   nextIrpSp = IoGetNextIrpStackLocation(Irp);
   12947   RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine));
   12948   nextIrpSp->Control = 0;
   12949 }
   12950 
   12951 NTKERNELAPI
   12952 VOID
   12953 NTAPI
   12954 IoGetStackLimits(
   12955   OUT PULONG_PTR LowLimit,
   12956   OUT PULONG_PTR HighLimit);
   12957 
   12958 FORCEINLINE
   12959 ULONG_PTR
   12960 IoGetRemainingStackSize(VOID)
   12961 {
   12962   ULONG_PTR End, Begin;
   12963   ULONG_PTR Result;
   12964 
   12965   IoGetStackLimits(&Begin, &End);
   12966   Result = (ULONG_PTR)(&End) - Begin;
   12967   return Result;
   12968 }
   12969 
   12970 #if (NTDDI_VERSION >= NTDDI_WS03)
   12971 FORCEINLINE
   12972 VOID
   12973 IoInitializeThreadedDpcRequest(
   12974   IN PDEVICE_OBJECT DeviceObject,
   12975   IN PIO_DPC_ROUTINE DpcRoutine)
   12976 {
   12977   KeInitializeThreadedDpc(&DeviceObject->Dpc,
   12978                           (PKDEFERRED_ROUTINE) DpcRoutine,
   12979                           DeviceObject );
   12980 }
   12981 #endif
   12982 
   12983 /******************************************************************************
   12984  *                     Power Management Support Functions                     *
   12985  ******************************************************************************/
   12986 
   12987 #define PoSetDeviceBusy(IdlePointer) ((void)(*(IdlePointer) = 0))
   12988 
   12989 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   12990 
   12991 NTKERNELAPI
   12992 NTSTATUS
   12993 NTAPI
   12994 PoCallDriver(
   12995   IN struct _DEVICE_OBJECT *DeviceObject,
   12996   IN OUT struct _IRP *Irp);
   12997 
   12998 NTKERNELAPI
   12999 PULONG
   13000 NTAPI
   13001 PoRegisterDeviceForIdleDetection(
   13002   IN struct _DEVICE_OBJECT *DeviceObject,
   13003   IN ULONG ConservationIdleTime,
   13004   IN ULONG PerformanceIdleTime,
   13005   IN DEVICE_POWER_STATE State);
   13006 
   13007 NTKERNELAPI
   13008 PVOID
   13009 NTAPI
   13010 PoRegisterSystemState(
   13011   IN OUT PVOID StateHandle OPTIONAL,
   13012   IN EXECUTION_STATE Flags);
   13013 
   13014 NTKERNELAPI
   13015 NTSTATUS
   13016 NTAPI
   13017 PoRequestPowerIrp(
   13018   IN struct _DEVICE_OBJECT *DeviceObject,
   13019   IN UCHAR MinorFunction,
   13020   IN POWER_STATE PowerState,
   13021   IN PREQUEST_POWER_COMPLETE CompletionFunction OPTIONAL,
   13022   IN PVOID Context OPTIONAL,
   13023   OUT struct _IRP **Irp OPTIONAL);
   13024 
   13025 NTKERNELAPI
   13026 POWER_STATE
   13027 NTAPI
   13028 PoSetPowerState(
   13029   IN struct _DEVICE_OBJECT *DeviceObject,
   13030   IN POWER_STATE_TYPE Type,
   13031   IN POWER_STATE State);
   13032 
   13033 NTKERNELAPI
   13034 VOID
   13035 NTAPI
   13036 PoSetSystemState(
   13037   IN EXECUTION_STATE Flags);
   13038 
   13039 NTKERNELAPI
   13040 VOID
   13041 NTAPI
   13042 PoStartNextPowerIrp(
   13043   IN OUT struct _IRP *Irp);
   13044 
   13045 NTKERNELAPI
   13046 VOID
   13047 NTAPI
   13048 PoUnregisterSystemState(
   13049   IN OUT PVOID StateHandle);
   13050 
   13051 NTKERNELAPI
   13052 NTSTATUS
   13053 NTAPI
   13054 PoRequestShutdownEvent(
   13055   OUT PVOID *Event);
   13056 
   13057 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   13058 
   13059 #if (NTDDI_VERSION >= NTDDI_VISTA)
   13060 
   13061 NTKERNELAPI
   13062 VOID
   13063 NTAPI
   13064 PoSetSystemWake(
   13065   IN OUT struct _IRP *Irp);
   13066 
   13067 NTKERNELAPI
   13068 BOOLEAN
   13069 NTAPI
   13070 PoGetSystemWake(
   13071   IN struct _IRP *Irp);
   13072 
   13073 NTKERNELAPI
   13074 NTSTATUS
   13075 NTAPI
   13076 PoRegisterPowerSettingCallback(
   13077   IN PDEVICE_OBJECT DeviceObject OPTIONAL,
   13078   IN LPCGUID SettingGuid,
   13079   IN PPOWER_SETTING_CALLBACK Callback,
   13080   IN PVOID Context OPTIONAL,
   13081   OUT PVOID *Handle OPTIONAL);
   13082 
   13083 NTKERNELAPI
   13084 NTSTATUS
   13085 NTAPI
   13086 PoUnregisterPowerSettingCallback(
   13087   IN OUT PVOID Handle);
   13088 
   13089 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   13090 
   13091 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
   13092 NTKERNELAPI
   13093 VOID
   13094 NTAPI
   13095 PoSetDeviceBusyEx(
   13096   IN OUT PULONG IdlePointer);
   13097 #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */
   13098 
   13099 #if (NTDDI_VERSION >= NTDDI_WIN7)
   13100 
   13101 NTKERNELAPI
   13102 VOID
   13103 NTAPI
   13104 PoStartDeviceBusy(
   13105   IN OUT PULONG IdlePointer);
   13106 
   13107 NTKERNELAPI
   13108 VOID
   13109 NTAPI
   13110 PoEndDeviceBusy(
   13111   IN OUT PULONG IdlePointer);
   13112 
   13113 NTKERNELAPI
   13114 BOOLEAN
   13115 NTAPI
   13116 PoQueryWatchdogTime(
   13117   IN PDEVICE_OBJECT Pdo,
   13118   OUT PULONG SecondsRemaining);
   13119 
   13120 NTKERNELAPI
   13121 VOID
   13122 NTAPI
   13123 PoDeletePowerRequest(
   13124   IN OUT PVOID PowerRequest);
   13125 
   13126 NTKERNELAPI
   13127 NTSTATUS
   13128 NTAPI
   13129 PoSetPowerRequest(
   13130   IN OUT PVOID PowerRequest,
   13131   IN POWER_REQUEST_TYPE Type);
   13132 
   13133 NTKERNELAPI
   13134 NTSTATUS
   13135 NTAPI
   13136 PoClearPowerRequest(
   13137   IN OUT PVOID PowerRequest,
   13138   IN POWER_REQUEST_TYPE Type);
   13139 
   13140 NTKERNELAPI
   13141 NTSTATUS
   13142 NTAPI
   13143 PoCreatePowerRequest(
   13144   OUT PVOID *PowerRequest,
   13145   IN PDEVICE_OBJECT DeviceObject,
   13146   IN PCOUNTED_REASON_CONTEXT Context);
   13147 
   13148 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   13149 
   13150 /******************************************************************************
   13151  *                          Executive Functions                               *
   13152  ******************************************************************************/
   13153 
   13154 #define ExInterlockedIncrementLong(Addend,Lock) Exfi386InterlockedIncrementLong(Addend)
   13155 #define ExInterlockedDecrementLong(Addend,Lock) Exfi386InterlockedDecrementLong(Addend)
   13156 #define ExInterlockedExchangeUlong(Target, Value, Lock) Exfi386InterlockedExchangeUlong(Target, Value)
   13157 
   13158 #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
   13159 #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
   13160 #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
   13161 #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
   13162 
   13163 #define ExInitializeSListHead InitializeSListHead
   13164 
   13165 #if defined(_NTHAL_) && defined(_X86_)
   13166 
   13167 NTKERNELAPI
   13168 VOID
   13169 FASTCALL
   13170 ExiAcquireFastMutex(
   13171   IN OUT PFAST_MUTEX FastMutex);
   13172 
   13173 NTKERNELAPI
   13174 VOID
   13175 FASTCALL
   13176 ExiReleaseFastMutex(
   13177   IN OUT PFAST_MUTEX FastMutex);
   13178 
   13179 NTKERNELAPI
   13180 BOOLEAN
   13181 FASTCALL
   13182 ExiTryToAcquireFastMutex(
   13183     IN OUT PFAST_MUTEX FastMutex);
   13184 
   13185 #define ExAcquireFastMutex ExiAcquireFastMutex
   13186 #define ExReleaseFastMutex ExiReleaseFastMutex
   13187 #define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex
   13188 
   13189 #else
   13190 
   13191 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   13192 
   13193 NTKERNELAPI
   13194 VOID
   13195 FASTCALL
   13196 ExAcquireFastMutex(
   13197   IN OUT PFAST_MUTEX FastMutex);
   13198 
   13199 NTKERNELAPI
   13200 VOID
   13201 FASTCALL
   13202 ExReleaseFastMutex(
   13203   IN OUT PFAST_MUTEX FastMutex);
   13204 
   13205 NTKERNELAPI
   13206 BOOLEAN
   13207 FASTCALL
   13208 ExTryToAcquireFastMutex(
   13209   IN OUT PFAST_MUTEX FastMutex);
   13210 
   13211 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   13212 
   13213 #endif /* defined(_NTHAL_) && defined(_X86_) */
   13214 
   13215 #if defined(_X86_)
   13216 #define ExInterlockedAddUlong ExfInterlockedAddUlong
   13217 #define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList
   13218 #define ExInterlockedInsertTailList ExfInterlockedInsertTailList
   13219 #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList
   13220 #define ExInterlockedPopEntryList ExfInterlockedPopEntryList
   13221 #define ExInterlockedPushEntryList ExfInterlockedPushEntryList
   13222 #endif /* defined(_X86_) */
   13223 
   13224 #if defined(_WIN64)
   13225 
   13226 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || \
   13227     defined(_NTHAL_) || defined(_NTOSP_)
   13228 NTKERNELAPI
   13229 USHORT
   13230 ExQueryDepthSList(IN PSLIST_HEADER ListHead);
   13231 #else
   13232 FORCEINLINE
   13233 USHORT
   13234 ExQueryDepthSList(IN PSLIST_HEADER ListHead)
   13235 {
   13236   return (USHORT)(ListHead->Alignment & 0xffff);
   13237 }
   13238 #endif
   13239 
   13240 NTKERNELAPI
   13241 PSLIST_ENTRY
   13242 ExpInterlockedFlushSList(
   13243   PSLIST_HEADER ListHead);
   13244 
   13245 NTKERNELAPI
   13246 PSLIST_ENTRY
   13247 ExpInterlockedPopEntrySList(
   13248   PSLIST_HEADER ListHead);
   13249 
   13250 NTKERNELAPI
   13251 PSLIST_ENTRY
   13252 ExpInterlockedPushEntrySList(
   13253   PSLIST_HEADER ListHead,
   13254   PSLIST_ENTRY ListEntry);
   13255 
   13256 #define ExInterlockedFlushSList(Head) \
   13257     ExpInterlockedFlushSList(Head)
   13258 #define ExInterlockedPopEntrySList(Head, Lock) \
   13259     ExpInterlockedPopEntrySList(Head)
   13260 #define ExInterlockedPushEntrySList(Head, Entry, Lock) \
   13261     ExpInterlockedPushEntrySList(Head, Entry)
   13262 
   13263 #else /* !defined(_WIN64) */
   13264 
   13265 #ifdef NONAMELESSUNION
   13266 #define ExQueryDepthSList(listhead) (listhead)->s.Depth
   13267 #else
   13268 #define ExQueryDepthSList(listhead) (listhead)->Depth
   13269 #endif
   13270 
   13271 NTKERNELAPI
   13272 PSINGLE_LIST_ENTRY
   13273 FASTCALL
   13274 ExInterlockedFlushSList(
   13275   IN OUT PSLIST_HEADER ListHead);
   13276 
   13277 #endif /* !defined(_WIN64) */
   13278 
   13279 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
   13280 
   13281 NTKERNELAPI
   13282 PSINGLE_LIST_ENTRY
   13283 FASTCALL
   13284 ExInterlockedPopEntrySList(
   13285   IN PSLIST_HEADER ListHead,
   13286   IN PKSPIN_LOCK Lock);
   13287 
   13288 NTKERNELAPI
   13289 PSINGLE_LIST_ENTRY
   13290 FASTCALL
   13291 ExInterlockedPushEntrySList(
   13292   IN PSLIST_HEADER ListHead,
   13293   IN PSINGLE_LIST_ENTRY ListEntry,
   13294   IN PKSPIN_LOCK Lock);
   13295 
   13296 NTKERNELAPI
   13297 PVOID
   13298 NTAPI
   13299 ExAllocateFromPagedLookasideList(
   13300   IN OUT PPAGED_LOOKASIDE_LIST Lookaside);
   13301 
   13302 NTKERNELAPI
   13303 VOID
   13304 NTAPI
   13305 ExFreeToPagedLookasideList(
   13306   IN OUT PPAGED_LOOKASIDE_LIST Lookaside,
   13307   IN PVOID Entry);
   13308 
   13309 #else /* !_WIN2K_COMPAT_SLIST_USAGE */
   13310 
   13311 #if !defined(_WIN64)
   13312 #define ExInterlockedPopEntrySList(_ListHead, _Lock) \
   13313     InterlockedPopEntrySList(_ListHead)
   13314 #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \
   13315     InterlockedPushEntrySList(_ListHead, _ListEntry)
   13316 #endif
   13317 
   13318 static __inline
   13319 PVOID
   13320 ExAllocateFromPagedLookasideList(
   13321   IN OUT PPAGED_LOOKASIDE_LIST Lookaside)
   13322 {
   13323   PVOID Entry;
   13324 
   13325   Lookaside->L.TotalAllocates++;
   13326 #ifdef NONAMELESSUNION
   13327   Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
   13328   if (Entry == NULL) {
   13329     Lookaside->L.u2.AllocateMisses++;
   13330     Entry = (Lookaside->L.u4.Allocate)(Lookaside->L.Type,
   13331                                        Lookaside->L.Size,
   13332                                        Lookaside->L.Tag);
   13333   }
   13334 #else /* NONAMELESSUNION */
   13335   Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
   13336   if (Entry == NULL) {
   13337     Lookaside->L.AllocateMisses++;
   13338     Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
   13339                                     Lookaside->L.Size,
   13340                                     Lookaside->L.Tag);
   13341   }
   13342 #endif /* NONAMELESSUNION */
   13343   return Entry;
   13344 }
   13345 
   13346 static __inline
   13347 VOID
   13348 ExFreeToPagedLookasideList(
   13349   IN OUT PPAGED_LOOKASIDE_LIST Lookaside,
   13350   IN PVOID Entry)
   13351 {
   13352   Lookaside->L.TotalFrees++;
   13353 #ifdef NONAMELESSUNION
   13354   if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) {
   13355     Lookaside->L.u3.FreeMisses++;
   13356     (Lookaside->L.u5.Free)(Entry);
   13357   } else {
   13358     InterlockedPushEntrySList(&Lookaside->L.u.ListHead, (PSLIST_ENTRY)Entry);
   13359   }
   13360 #else /* NONAMELESSUNION */
   13361   if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
   13362     Lookaside->L.FreeMisses++;
   13363     (Lookaside->L.Free)(Entry);
   13364   } else {
   13365     InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
   13366   }
   13367 #endif /* NONAMELESSUNION */
   13368 }
   13369 
   13370 #endif /* _WIN2K_COMPAT_SLIST_USAGE */
   13371 
   13372 
   13373 /* ERESOURCE_THREAD
   13374  * ExGetCurrentResourceThread(
   13375  *     VOID);
   13376  */
   13377 #define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread())
   13378 
   13379 #define ExReleaseResource(R) (ExReleaseResourceLite(R))
   13380 
   13381 /* VOID
   13382  * ExInitializeWorkItem(
   13383  *     IN PWORK_QUEUE_ITEM Item,
   13384  *     IN PWORKER_THREAD_ROUTINE Routine,
   13385  *     IN PVOID Context)
   13386  */
   13387 #define ExInitializeWorkItem(Item, Routine, Context) \
   13388 { \
   13389   (Item)->WorkerRoutine = Routine; \
   13390   (Item)->Parameter = Context; \
   13391   (Item)->List.Flink = NULL; \
   13392 }
   13393 
   13394 FORCEINLINE
   13395 VOID
   13396 ExInitializeFastMutex(
   13397   OUT PFAST_MUTEX FastMutex)
   13398 {
   13399   FastMutex->Count = FM_LOCK_BIT;
   13400   FastMutex->Owner = NULL;
   13401   FastMutex->Contention = 0;
   13402   KeInitializeEvent(&FastMutex->Event, SynchronizationEvent, FALSE);
   13403   return;
   13404 }
   13405 
   13406 
   13407 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   13408 NTKERNELAPI
   13409 VOID
   13410 FASTCALL
   13411 ExAcquireFastMutexUnsafe(
   13412   IN OUT PFAST_MUTEX FastMutex);
   13413 
   13414 NTKERNELAPI
   13415 VOID
   13416 FASTCALL
   13417 ExReleaseFastMutexUnsafe(
   13418   IN OUT PFAST_MUTEX FastMutex);
   13419 
   13420 NTKERNELAPI
   13421 BOOLEAN
   13422 NTAPI
   13423 ExAcquireResourceExclusiveLite(
   13424   IN OUT PERESOURCE Resource,
   13425   IN BOOLEAN Wait);
   13426 
   13427 NTKERNELAPI
   13428 BOOLEAN
   13429 NTAPI
   13430 ExAcquireResourceSharedLite(
   13431   IN OUT PERESOURCE Resource,
   13432   IN BOOLEAN Wait);
   13433 
   13434 NTKERNELAPI
   13435 BOOLEAN
   13436 NTAPI
   13437 ExAcquireSharedStarveExclusive(
   13438   IN OUT PERESOURCE Resource,
   13439   IN BOOLEAN Wait);
   13440 
   13441 NTKERNELAPI
   13442 BOOLEAN
   13443 NTAPI
   13444 ExAcquireSharedWaitForExclusive(
   13445   IN OUT PERESOURCE Resource,
   13446   IN BOOLEAN Wait);
   13447 
   13448 NTKERNELAPI
   13449 PVOID
   13450 NTAPI
   13451 ExAllocatePool(
   13452   IN POOL_TYPE PoolType,
   13453   IN SIZE_T NumberOfBytes);
   13454 
   13455 NTKERNELAPI
   13456 PVOID
   13457 NTAPI
   13458 ExAllocatePoolWithQuota(
   13459   IN POOL_TYPE PoolType,
   13460   IN SIZE_T NumberOfBytes);
   13461 
   13462 NTKERNELAPI
   13463 PVOID
   13464 NTAPI
   13465 ExAllocatePoolWithQuotaTag(
   13466   IN POOL_TYPE PoolType,
   13467   IN SIZE_T NumberOfBytes,
   13468   IN ULONG Tag);
   13469 
   13470 #ifndef POOL_TAGGING
   13471 #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b)
   13472 #endif
   13473 
   13474 NTKERNELAPI
   13475 PVOID
   13476 NTAPI
   13477 ExAllocatePoolWithTag(
   13478   IN POOL_TYPE PoolType,
   13479   IN SIZE_T NumberOfBytes,
   13480   IN ULONG Tag);
   13481 
   13482 #ifndef POOL_TAGGING
   13483 #define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b)
   13484 #endif
   13485 
   13486 NTKERNELAPI
   13487 PVOID
   13488 NTAPI
   13489 ExAllocatePoolWithTagPriority(
   13490   IN POOL_TYPE PoolType,
   13491   IN SIZE_T NumberOfBytes,
   13492   IN ULONG Tag,
   13493   IN EX_POOL_PRIORITY Priority);
   13494 
   13495 NTKERNELAPI
   13496 VOID
   13497 NTAPI
   13498 ExConvertExclusiveToSharedLite(
   13499   IN OUT PERESOURCE Resource);
   13500 
   13501 NTKERNELAPI
   13502 NTSTATUS
   13503 NTAPI
   13504 ExCreateCallback(
   13505   OUT PCALLBACK_OBJECT *CallbackObject,
   13506   IN POBJECT_ATTRIBUTES ObjectAttributes,
   13507   IN BOOLEAN Create,
   13508   IN BOOLEAN AllowMultipleCallbacks);
   13509 
   13510 NTKERNELAPI
   13511 VOID
   13512 NTAPI
   13513 ExDeleteNPagedLookasideList(
   13514   IN OUT PNPAGED_LOOKASIDE_LIST Lookaside);
   13515 
   13516 NTKERNELAPI
   13517 VOID
   13518 NTAPI
   13519 ExDeletePagedLookasideList(
   13520   IN PPAGED_LOOKASIDE_LIST Lookaside);
   13521 
   13522 NTKERNELAPI
   13523 NTSTATUS
   13524 NTAPI
   13525 ExDeleteResourceLite(
   13526   IN OUT PERESOURCE Resource);
   13527 
   13528 NTKERNELAPI
   13529 VOID
   13530 NTAPI
   13531 ExFreePool(
   13532   IN PVOID P);
   13533 
   13534 NTKERNELAPI
   13535 VOID
   13536 NTAPI
   13537 ExFreePoolWithTag(
   13538   IN PVOID P,
   13539   IN ULONG Tag);
   13540 
   13541 NTKERNELAPI
   13542 ULONG
   13543 NTAPI
   13544 ExGetExclusiveWaiterCount(
   13545   IN PERESOURCE Resource);
   13546 
   13547 NTKERNELAPI
   13548 KPROCESSOR_MODE
   13549 NTAPI
   13550 ExGetPreviousMode(VOID);
   13551 
   13552 NTKERNELAPI
   13553 ULONG
   13554 NTAPI
   13555 ExGetSharedWaiterCount(
   13556   IN PERESOURCE Resource);
   13557 
   13558 NTKERNELAPI
   13559 VOID
   13560 NTAPI
   13561 ExInitializeNPagedLookasideList(
   13562   IN PNPAGED_LOOKASIDE_LIST Lookaside,
   13563   IN PALLOCATE_FUNCTION Allocate OPTIONAL,
   13564   IN PFREE_FUNCTION Free OPTIONAL,
   13565   IN ULONG Flags,
   13566   IN SIZE_T Size,
   13567   IN ULONG Tag,
   13568   IN USHORT Depth);
   13569 
   13570 NTKERNELAPI
   13571 VOID
   13572 NTAPI
   13573 ExInitializePagedLookasideList(
   13574   IN PPAGED_LOOKASIDE_LIST Lookaside,
   13575   IN PALLOCATE_FUNCTION Allocate OPTIONAL,
   13576   IN PFREE_FUNCTION Free OPTIONAL,
   13577   IN ULONG Flags,
   13578   IN SIZE_T Size,
   13579   IN ULONG Tag,
   13580   IN USHORT Depth);
   13581 
   13582 NTKERNELAPI
   13583 NTSTATUS
   13584 NTAPI
   13585 ExInitializeResourceLite(
   13586   OUT PERESOURCE Resource);
   13587 
   13588 NTKERNELAPI
   13589 LARGE_INTEGER
   13590 NTAPI
   13591 ExInterlockedAddLargeInteger(
   13592   IN PLARGE_INTEGER Addend,
   13593   IN LARGE_INTEGER Increment,
   13594   IN PKSPIN_LOCK Lock);
   13595 
   13596 #if defined(_WIN64)
   13597 #define ExInterlockedAddLargeStatistic(Addend, Increment) \
   13598     (VOID)InterlockedAdd64(&(Addend)->QuadPart, Increment)
   13599 #else
   13600 #define ExInterlockedAddLargeStatistic(Addend, Increment) \
   13601     _InterlockedAddLargeStatistic((PLONGLONG)&(Addend)->QuadPart, Increment)
   13602 #endif
   13603 
   13604 NTKERNELAPI
   13605 ULONG
   13606 FASTCALL
   13607 ExInterlockedAddUlong(
   13608   IN PULONG Addend,
   13609   IN ULONG Increment,
   13610   IN OUT PKSPIN_LOCK Lock);
   13611 
   13612 #if defined(_AMD64_) || defined(_IA64_)
   13613 
   13614 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
   13615     InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand))
   13616 
   13617 #elif defined(_X86_)
   13618 
   13619 NTKERNELAPI
   13620 LONGLONG
   13621 FASTCALL
   13622 ExfInterlockedCompareExchange64(
   13623   IN OUT LONGLONG volatile *Destination,
   13624   IN PLONGLONG Exchange,
   13625   IN PLONGLONG Comperand);
   13626 
   13627 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
   13628     ExfInterlockedCompareExchange64(Destination, Exchange, Comperand)
   13629 
   13630 #else
   13631 
   13632 NTKERNELAPI
   13633 LONGLONG
   13634 FASTCALL
   13635 ExInterlockedCompareExchange64(
   13636   IN OUT LONGLONG volatile *Destination,
   13637   IN PLONGLONG Exchange,
   13638   IN PLONGLONG Comparand,
   13639   IN PKSPIN_LOCK Lock);
   13640 
   13641 #endif /* defined(_AMD64_) || defined(_IA64_) */
   13642 
   13643 NTKERNELAPI
   13644 PLIST_ENTRY
   13645 FASTCALL
   13646 ExInterlockedInsertHeadList(
   13647   IN OUT PLIST_ENTRY ListHead,
   13648   IN OUT PLIST_ENTRY ListEntry,
   13649   IN OUT PKSPIN_LOCK Lock);
   13650 
   13651 NTKERNELAPI
   13652 PLIST_ENTRY
   13653 FASTCALL
   13654 ExInterlockedInsertTailList(
   13655   IN OUT PLIST_ENTRY ListHead,
   13656   IN OUT PLIST_ENTRY ListEntry,
   13657   IN OUT PKSPIN_LOCK Lock);
   13658 
   13659 NTKERNELAPI
   13660 PSINGLE_LIST_ENTRY
   13661 FASTCALL
   13662 ExInterlockedPopEntryList(
   13663   IN OUT PSINGLE_LIST_ENTRY ListHead,
   13664   IN OUT PKSPIN_LOCK Lock);
   13665 
   13666 NTKERNELAPI
   13667 PSINGLE_LIST_ENTRY
   13668 FASTCALL
   13669 ExInterlockedPushEntryList(
   13670   IN OUT PSINGLE_LIST_ENTRY ListHead,
   13671   IN OUT PSINGLE_LIST_ENTRY ListEntry,
   13672   IN OUT PKSPIN_LOCK Lock);
   13673 
   13674 NTKERNELAPI
   13675 PLIST_ENTRY
   13676 FASTCALL
   13677 ExInterlockedRemoveHeadList(
   13678   IN OUT PLIST_ENTRY ListHead,
   13679   IN OUT PKSPIN_LOCK Lock);
   13680 
   13681 NTKERNELAPI
   13682 BOOLEAN
   13683 NTAPI
   13684 ExIsProcessorFeaturePresent(
   13685   IN ULONG ProcessorFeature);
   13686 
   13687 NTKERNELAPI
   13688 BOOLEAN
   13689 NTAPI
   13690 ExIsResourceAcquiredExclusiveLite(
   13691   IN PERESOURCE Resource);
   13692 
   13693 NTKERNELAPI
   13694 ULONG
   13695 NTAPI
   13696 ExIsResourceAcquiredSharedLite(
   13697   IN PERESOURCE Resource);
   13698 
   13699 #define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite
   13700 
   13701 NTKERNELAPI
   13702 VOID
   13703 NTAPI
   13704 ExLocalTimeToSystemTime(
   13705   IN PLARGE_INTEGER LocalTime,
   13706   OUT PLARGE_INTEGER SystemTime);
   13707 
   13708 NTKERNELAPI
   13709 VOID
   13710 NTAPI
   13711 ExNotifyCallback(
   13712   IN PCALLBACK_OBJECT CallbackObject,
   13713   IN PVOID Argument1 OPTIONAL,
   13714   IN PVOID Argument2 OPTIONAL);
   13715 
   13716 NTKERNELAPI
   13717 VOID
   13718 NTAPI
   13719 ExQueueWorkItem(
   13720   IN OUT PWORK_QUEUE_ITEM WorkItem,
   13721   IN WORK_QUEUE_TYPE QueueType);
   13722 
   13723 NTKERNELAPI
   13724 DECLSPEC_NORETURN
   13725 VOID
   13726 NTAPI
   13727 ExRaiseStatus(
   13728   IN NTSTATUS Status);
   13729 
   13730 NTKERNELAPI
   13731 PVOID
   13732 NTAPI
   13733 ExRegisterCallback(
   13734   IN PCALLBACK_OBJECT CallbackObject,
   13735   IN PCALLBACK_FUNCTION CallbackFunction,
   13736   IN PVOID CallbackContext OPTIONAL);
   13737 
   13738 NTKERNELAPI
   13739 NTSTATUS
   13740 NTAPI
   13741 ExReinitializeResourceLite(
   13742   IN OUT PERESOURCE Resource);
   13743 
   13744 NTKERNELAPI
   13745 VOID
   13746 NTAPI
   13747 ExReleaseResourceForThreadLite(
   13748   IN OUT PERESOURCE Resource,
   13749   IN ERESOURCE_THREAD ResourceThreadId);
   13750 
   13751 NTKERNELAPI
   13752 VOID
   13753 FASTCALL
   13754 ExReleaseResourceLite(
   13755   IN OUT PERESOURCE Resource);
   13756 
   13757 NTKERNELAPI
   13758 VOID
   13759 NTAPI
   13760 ExSetResourceOwnerPointer(
   13761   IN OUT PERESOURCE Resource,
   13762   IN PVOID OwnerPointer);
   13763 
   13764 NTKERNELAPI
   13765 ULONG
   13766 NTAPI
   13767 ExSetTimerResolution(
   13768   IN ULONG DesiredTime,
   13769   IN BOOLEAN SetResolution);
   13770 
   13771 NTKERNELAPI
   13772 VOID
   13773 NTAPI
   13774 ExSystemTimeToLocalTime(
   13775   IN PLARGE_INTEGER SystemTime,
   13776   OUT PLARGE_INTEGER LocalTime);
   13777 
   13778 NTKERNELAPI
   13779 VOID
   13780 NTAPI
   13781 ExUnregisterCallback(
   13782   IN OUT PVOID CbRegistration);
   13783 
   13784 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   13785 
   13786 #if (NTDDI_VERSION >= NTDDI_WINXP)
   13787 
   13788 NTKERNELAPI
   13789 BOOLEAN
   13790 FASTCALL
   13791 ExAcquireRundownProtection(
   13792   IN OUT PEX_RUNDOWN_REF RunRef);
   13793 
   13794 NTKERNELAPI
   13795 VOID
   13796 FASTCALL
   13797 ExInitializeRundownProtection(
   13798   OUT PEX_RUNDOWN_REF RunRef);
   13799 
   13800 NTKERNELAPI
   13801 VOID
   13802 FASTCALL
   13803 ExReInitializeRundownProtection(
   13804   IN OUT PEX_RUNDOWN_REF RunRef);
   13805 
   13806 NTKERNELAPI
   13807 VOID
   13808 FASTCALL
   13809 ExReleaseRundownProtection(
   13810   IN OUT PEX_RUNDOWN_REF RunRef);
   13811 
   13812 NTKERNELAPI
   13813 VOID
   13814 FASTCALL
   13815 ExRundownCompleted(
   13816   OUT PEX_RUNDOWN_REF RunRef);
   13817 
   13818 NTKERNELAPI
   13819 BOOLEAN
   13820 NTAPI
   13821 ExVerifySuite(
   13822   IN SUITE_TYPE SuiteType);
   13823 
   13824 NTKERNELAPI
   13825 VOID
   13826 FASTCALL
   13827 ExWaitForRundownProtectionRelease(
   13828   IN OUT PEX_RUNDOWN_REF RunRef);
   13829 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
   13830 
   13831 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
   13832 
   13833 NTKERNELAPI
   13834 BOOLEAN
   13835 FASTCALL
   13836 ExAcquireRundownProtectionEx(
   13837   IN OUT PEX_RUNDOWN_REF RunRef,
   13838   IN ULONG Count);
   13839 
   13840 NTKERNELAPI
   13841 VOID
   13842 FASTCALL
   13843 ExReleaseRundownProtectionEx(
   13844   IN OUT PEX_RUNDOWN_REF RunRef,
   13845   IN ULONG Count);
   13846 
   13847 #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
   13848 
   13849 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
   13850 
   13851 NTKERNELAPI
   13852 PEX_RUNDOWN_REF_CACHE_AWARE
   13853 NTAPI
   13854 ExAllocateCacheAwareRundownProtection(
   13855   IN POOL_TYPE PoolType,
   13856   IN ULONG PoolTag);
   13857 
   13858 NTKERNELAPI
   13859 SIZE_T
   13860 NTAPI
   13861 ExSizeOfRundownProtectionCacheAware(VOID);
   13862 
   13863 NTKERNELAPI
   13864 PVOID
   13865 NTAPI
   13866 ExEnterCriticalRegionAndAcquireResourceShared(
   13867   IN OUT PERESOURCE Resource);
   13868 
   13869 NTKERNELAPI
   13870 PVOID
   13871 NTAPI
   13872 ExEnterCriticalRegionAndAcquireResourceExclusive(
   13873   IN OUT PERESOURCE Resource);
   13874 
   13875 NTKERNELAPI
   13876 PVOID
   13877 NTAPI
   13878 ExEnterCriticalRegionAndAcquireSharedWaitForExclusive(
   13879   IN OUT PERESOURCE Resource);
   13880 
   13881 NTKERNELAPI
   13882 VOID
   13883 FASTCALL
   13884 ExReleaseResourceAndLeaveCriticalRegion(
   13885   IN OUT PERESOURCE Resource);
   13886 
   13887 NTKERNELAPI
   13888 VOID
   13889 NTAPI
   13890 ExInitializeRundownProtectionCacheAware(
   13891   OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
   13892   IN SIZE_T RunRefSize);
   13893 
   13894 NTKERNELAPI
   13895 VOID
   13896 NTAPI
   13897 ExFreeCacheAwareRundownProtection(
   13898   IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
   13899 
   13900 NTKERNELAPI
   13901 BOOLEAN
   13902 FASTCALL
   13903 ExAcquireRundownProtectionCacheAware(
   13904   IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
   13905 
   13906 NTKERNELAPI
   13907 VOID
   13908 FASTCALL
   13909 ExReleaseRundownProtectionCacheAware(
   13910   IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
   13911 
   13912 NTKERNELAPI
   13913 BOOLEAN
   13914 FASTCALL
   13915 ExAcquireRundownProtectionCacheAwareEx(
   13916   IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
   13917   IN ULONG Count);
   13918 
   13919 NTKERNELAPI
   13920 VOID
   13921 FASTCALL
   13922 ExReleaseRundownProtectionCacheAwareEx(
   13923   IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef,
   13924   IN ULONG Count);
   13925 
   13926 NTKERNELAPI
   13927 VOID
   13928 FASTCALL
   13929 ExWaitForRundownProtectionReleaseCacheAware(
   13930   IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef);
   13931 
   13932 NTKERNELAPI
   13933 VOID
   13934 FASTCALL
   13935 ExReInitializeRundownProtectionCacheAware(
   13936   IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
   13937 
   13938 NTKERNELAPI
   13939 VOID
   13940 FASTCALL
   13941 ExRundownCompletedCacheAware(
   13942   IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
   13943 
   13944 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
   13945 
   13946 #if (NTDDI_VERSION >= NTDDI_VISTA)
   13947 
   13948 NTKERNELAPI
   13949 NTSTATUS
   13950 NTAPI
   13951 ExInitializeLookasideListEx(
   13952   OUT PLOOKASIDE_LIST_EX Lookaside,
   13953   IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL,
   13954   IN PFREE_FUNCTION_EX Free OPTIONAL,
   13955   IN POOL_TYPE PoolType,
   13956   IN ULONG Flags,
   13957   IN SIZE_T Size,
   13958   IN ULONG Tag,
   13959   IN USHORT Depth);
   13960 
   13961 NTKERNELAPI
   13962 VOID
   13963 NTAPI
   13964 ExDeleteLookasideListEx(
   13965   IN OUT PLOOKASIDE_LIST_EX Lookaside);
   13966 
   13967 NTKERNELAPI
   13968 VOID
   13969 NTAPI
   13970 ExFlushLookasideListEx(
   13971   IN OUT PLOOKASIDE_LIST_EX Lookaside);
   13972 
   13973 FORCEINLINE
   13974 PVOID
   13975 ExAllocateFromLookasideListEx(
   13976   IN OUT PLOOKASIDE_LIST_EX Lookaside)
   13977 {
   13978   PVOID Entry;
   13979 
   13980   Lookaside->L.TotalAllocates += 1;
   13981 #ifdef NONAMELESSUNION
   13982   Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
   13983   if (Entry == NULL) {
   13984     Lookaside->L.u2.AllocateMisses += 1;
   13985     Entry = (Lookaside->L.u4.AllocateEx)(Lookaside->L.Type,
   13986                                          Lookaside->L.Size,
   13987                                          Lookaside->L.Tag,
   13988                                          Lookaside);
   13989   }
   13990 #else /* NONAMELESSUNION */
   13991   Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
   13992   if (Entry == NULL) {
   13993     Lookaside->L.AllocateMisses += 1;
   13994     Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type,
   13995                                       Lookaside->L.Size,
   13996                                       Lookaside->L.Tag,
   13997                                       Lookaside);
   13998   }
   13999 #endif /* NONAMELESSUNION */
   14000   return Entry;
   14001 }
   14002 
   14003 FORCEINLINE
   14004 VOID
   14005 ExFreeToLookasideListEx(
   14006   IN OUT PLOOKASIDE_LIST_EX Lookaside,
   14007   IN PVOID Entry)
   14008 {
   14009   Lookaside->L.TotalFrees += 1;
   14010   if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
   14011     Lookaside->L.FreeMisses += 1;
   14012     (Lookaside->L.FreeEx)(Entry, Lookaside);
   14013   } else {
   14014     InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
   14015   }
   14016   return;
   14017 }
   14018 
   14019 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   14020 
   14021 #if (NTDDI_VERSION >= NTDDI_WIN7)
   14022 
   14023 NTKERNELAPI
   14024 VOID
   14025 NTAPI
   14026 ExSetResourceOwnerPointerEx(
   14027   IN OUT PERESOURCE Resource,
   14028   IN PVOID OwnerPointer,
   14029   IN ULONG Flags);
   14030 
   14031 #define FLAG_OWNER_POINTER_IS_THREAD 0x1
   14032 
   14033 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   14034 
   14035 static __inline PVOID
   14036 ExAllocateFromNPagedLookasideList(
   14037   IN OUT PNPAGED_LOOKASIDE_LIST Lookaside)
   14038 {
   14039   PVOID Entry;
   14040 
   14041   Lookaside->L.TotalAllocates++;
   14042 #ifdef NONAMELESSUNION
   14043 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
   14044   Entry = ExInterlockedPopEntrySList(&Lookaside->L.u.ListHead,
   14045                                      &Lookaside->Lock__ObsoleteButDoNotDelete);
   14046 #else
   14047   Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
   14048 #endif
   14049   if (Entry == NULL) {
   14050     Lookaside->L.u2.AllocateMisses++;
   14051     Entry = (Lookaside->L.u4.Allocate)(Lookaside->L.Type,
   14052                                        Lookaside->L.Size,
   14053                                        Lookaside->L.Tag);
   14054   }
   14055 #else /* NONAMELESSUNION */
   14056 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
   14057   Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead,
   14058                                      &Lookaside->Lock__ObsoleteButDoNotDelete);
   14059 #else
   14060   Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
   14061 #endif
   14062   if (Entry == NULL) {
   14063     Lookaside->L.AllocateMisses++;
   14064     Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
   14065                                     Lookaside->L.Size,
   14066                                     Lookaside->L.Tag);
   14067   }
   14068 #endif /* NONAMELESSUNION */
   14069   return Entry;
   14070 }
   14071 
   14072 static __inline VOID
   14073 ExFreeToNPagedLookasideList(
   14074   IN OUT PNPAGED_LOOKASIDE_LIST Lookaside,
   14075   IN PVOID Entry)
   14076 {
   14077   Lookaside->L.TotalFrees++;
   14078 #ifdef NONAMELESSUNION
   14079   if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) {
   14080     Lookaside->L.u3.FreeMisses++;
   14081     (Lookaside->L.u5.Free)(Entry);
   14082   } else {
   14083 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
   14084       ExInterlockedPushEntrySList(&Lookaside->L.u.ListHead,
   14085                                   (PSLIST_ENTRY)Entry,
   14086                                   &Lookaside->Lock__ObsoleteButDoNotDelete);
   14087 #else
   14088       InterlockedPushEntrySList(&Lookaside->L.u.ListHead, (PSLIST_ENTRY)Entry);
   14089 #endif
   14090    }
   14091 #else /* NONAMELESSUNION */
   14092   if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
   14093     Lookaside->L.FreeMisses++;
   14094     (Lookaside->L.Free)(Entry);
   14095   } else {
   14096 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
   14097       ExInterlockedPushEntrySList(&Lookaside->L.ListHead,
   14098                                   (PSLIST_ENTRY)Entry,
   14099                                   &Lookaside->Lock__ObsoleteButDoNotDelete);
   14100 #else
   14101       InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
   14102 #endif
   14103    }
   14104 #endif /* NONAMELESSUNION */
   14105 }
   14106 
   14107 /******************************************************************************
   14108  *                          Object Manager Functions                          *
   14109  ******************************************************************************/
   14110 
   14111 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   14112 NTKERNELAPI
   14113 LONG_PTR
   14114 FASTCALL
   14115 ObfDereferenceObject(
   14116   IN PVOID Object);
   14117 #define ObDereferenceObject ObfDereferenceObject
   14118 
   14119 NTKERNELAPI
   14120 NTSTATUS
   14121 NTAPI
   14122 ObGetObjectSecurity(
   14123   IN PVOID Object,
   14124   OUT PSECURITY_DESCRIPTOR *SecurityDescriptor,
   14125   OUT PBOOLEAN MemoryAllocated);
   14126 
   14127 NTKERNELAPI
   14128 LONG_PTR
   14129 FASTCALL
   14130 ObfReferenceObject(
   14131   IN PVOID Object);
   14132 #define ObReferenceObject ObfReferenceObject
   14133 
   14134 NTKERNELAPI
   14135 NTSTATUS
   14136 NTAPI
   14137 ObReferenceObjectByHandle(
   14138   IN HANDLE Handle,
   14139   IN ACCESS_MASK DesiredAccess,
   14140   IN POBJECT_TYPE ObjectType OPTIONAL,
   14141   IN KPROCESSOR_MODE AccessMode,
   14142   OUT PVOID *Object,
   14143   OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL);
   14144 
   14145 NTKERNELAPI
   14146 NTSTATUS
   14147 NTAPI
   14148 ObReferenceObjectByPointer(
   14149   IN PVOID Object,
   14150   IN ACCESS_MASK DesiredAccess,
   14151   IN POBJECT_TYPE ObjectType OPTIONAL,
   14152   IN KPROCESSOR_MODE AccessMode);
   14153 
   14154 NTKERNELAPI
   14155 VOID
   14156 NTAPI
   14157 ObReleaseObjectSecurity(
   14158   IN PSECURITY_DESCRIPTOR SecurityDescriptor,
   14159   IN BOOLEAN MemoryAllocated);
   14160 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   14161 
   14162 #if (NTDDI_VERSION >= NTDDI_VISTA)
   14163 NTKERNELAPI
   14164 VOID
   14165 NTAPI
   14166 ObDereferenceObjectDeferDelete(
   14167   IN PVOID Object);
   14168 #endif
   14169 
   14170 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
   14171 NTKERNELAPI
   14172 NTSTATUS
   14173 NTAPI
   14174 ObRegisterCallbacks(
   14175   IN POB_CALLBACK_REGISTRATION CallbackRegistration,
   14176   OUT PVOID *RegistrationHandle);
   14177 
   14178 NTKERNELAPI
   14179 VOID
   14180 NTAPI
   14181 ObUnRegisterCallbacks(
   14182   IN PVOID RegistrationHandle);
   14183 
   14184 NTKERNELAPI
   14185 USHORT
   14186 NTAPI
   14187 ObGetFilterVersion(VOID);
   14188 
   14189 #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */
   14190 
   14191 #if (NTDDI_VERSION >= NTDDI_WIN7)
   14192 NTKERNELAPI
   14193 NTSTATUS
   14194 NTAPI
   14195 ObReferenceObjectByHandleWithTag(
   14196   IN HANDLE Handle,
   14197   IN ACCESS_MASK DesiredAccess,
   14198   IN POBJECT_TYPE ObjectType OPTIONAL,
   14199   IN KPROCESSOR_MODE AccessMode,
   14200   IN ULONG Tag,
   14201   OUT PVOID *Object,
   14202   OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL);
   14203 
   14204 NTKERNELAPI
   14205 LONG_PTR
   14206 FASTCALL
   14207 ObfReferenceObjectWithTag(
   14208   IN PVOID Object,
   14209   IN ULONG Tag);
   14210 
   14211 NTKERNELAPI
   14212 NTSTATUS
   14213 NTAPI
   14214 ObReferenceObjectByPointerWithTag(
   14215   IN PVOID Object,
   14216   IN ACCESS_MASK DesiredAccess,
   14217   IN POBJECT_TYPE ObjectType OPTIONAL,
   14218   IN KPROCESSOR_MODE AccessMode,
   14219   IN ULONG Tag);
   14220 
   14221 NTKERNELAPI
   14222 LONG_PTR
   14223 FASTCALL
   14224 ObfDereferenceObjectWithTag(
   14225   IN PVOID Object,
   14226   IN ULONG Tag);
   14227 
   14228 NTKERNELAPI
   14229 VOID
   14230 NTAPI
   14231 ObDereferenceObjectDeferDeleteWithTag(
   14232   IN PVOID Object,
   14233   IN ULONG Tag);
   14234 
   14235 #define ObDereferenceObject ObfDereferenceObject
   14236 #define ObReferenceObject ObfReferenceObject
   14237 #define ObDereferenceObjectWithTag ObfDereferenceObjectWithTag
   14238 #define ObReferenceObjectWithTag ObfReferenceObjectWithTag
   14239 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   14240 
   14241 /******************************************************************************
   14242  *                          Process Manager Functions                         *
   14243  ******************************************************************************/
   14244 
   14245 NTKERNELAPI
   14246 NTSTATUS
   14247 NTAPI
   14248 PsWrapApcWow64Thread(
   14249   IN OUT PVOID *ApcContext,
   14250   IN OUT PVOID *ApcRoutine);
   14251 
   14252 /*
   14253  * PEPROCESS
   14254  * PsGetCurrentProcess(VOID)
   14255  */
   14256 #define PsGetCurrentProcess IoGetCurrentProcess
   14257 
   14258 #if !defined(_PSGETCURRENTTHREAD_)
   14259 #define _PSGETCURRENTTHREAD_
   14260 FORCEINLINE
   14261 PETHREAD
   14262 NTAPI
   14263 PsGetCurrentThread(VOID)
   14264 {
   14265   return (PETHREAD)KeGetCurrentThread();
   14266 }
   14267 #endif /* !_PSGETCURRENTTHREAD_ */
   14268 
   14269 
   14270 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   14271 
   14272 NTKERNELAPI
   14273 NTSTATUS
   14274 NTAPI
   14275 PsCreateSystemThread(
   14276   OUT PHANDLE ThreadHandle,
   14277   IN ULONG DesiredAccess,
   14278   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   14279   IN HANDLE ProcessHandle OPTIONAL,
   14280   OUT PCLIENT_ID ClientId OPTIONAL,
   14281   IN PKSTART_ROUTINE StartRoutine,
   14282   IN PVOID StartContext OPTIONAL);
   14283 
   14284 NTKERNELAPI
   14285 NTSTATUS
   14286 NTAPI
   14287 PsTerminateSystemThread(
   14288   IN NTSTATUS ExitStatus);
   14289 
   14290 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   14291 
   14292 
   14293 /******************************************************************************
   14294  *                          WMI Library Support Functions                     *
   14295  ******************************************************************************/
   14296 
   14297 #ifdef RUN_WPP
   14298 #if (NTDDI_VERSION >= NTDDI_WINXP)
   14299 NTKERNELAPI
   14300 NTSTATUS
   14301 __cdecl
   14302 WmiTraceMessage(
   14303   IN TRACEHANDLE LoggerHandle,
   14304   IN ULONG MessageFlags,
   14305   IN LPGUID MessageGuid,
   14306   IN USHORT MessageNumber,
   14307   IN ...);
   14308 #endif
   14309 #endif /* RUN_WPP */
   14310 
   14311 #if (NTDDI_VERSION >= NTDDI_WINXP)
   14312 
   14313 NTKERNELAPI
   14314 NTSTATUS
   14315 NTAPI
   14316 WmiQueryTraceInformation(
   14317   IN TRACE_INFORMATION_CLASS TraceInformationClass,
   14318   OUT PVOID TraceInformation,
   14319   IN ULONG TraceInformationLength,
   14320   OUT PULONG RequiredLength OPTIONAL,
   14321   IN PVOID Buffer OPTIONAL);
   14322 
   14323 #if 0
   14324 /* FIXME: Get va_list from where? */
   14325 NTKERNELAPI
   14326 NTSTATUS
   14327 NTAPI
   14328 WmiTraceMessageVa(
   14329   IN TRACEHANDLE LoggerHandle,
   14330   IN ULONG MessageFlags,
   14331   IN LPGUID MessageGuid,
   14332   IN USHORT MessageNumber,
   14333   IN va_list MessageArgList);
   14334 #endif
   14335 
   14336 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
   14337 
   14338 #ifndef TRACE_INFORMATION_CLASS_DEFINE
   14339 
   14340 #if (NTDDI_VERSION >= NTDDI_WINXP)
   14341 NTKERNELAPI
   14342 NTSTATUS
   14343 NTAPI
   14344 WmiQueryTraceInformation(
   14345   IN TRACE_INFORMATION_CLASS TraceInformationClass,
   14346   OUT PVOID TraceInformation,
   14347   IN ULONG TraceInformationLength,
   14348   OUT PULONG RequiredLength OPTIONAL,
   14349   IN PVOID Buffer OPTIONAL);
   14350 #endif
   14351 
   14352 #define TRACE_INFORMATION_CLASS_DEFINE
   14353 
   14354 #endif /* TRACE_INFOPRMATION_CLASS_DEFINE */
   14355 
   14356 #if (NTDDI_VERSION >= NTDDI_VISTA)
   14357 
   14358 NTSTATUS
   14359 NTKERNELAPI
   14360 NTAPI
   14361 EtwRegister(
   14362   IN LPCGUID ProviderId,
   14363   IN PETWENABLECALLBACK EnableCallback OPTIONAL,
   14364   IN PVOID CallbackContext OPTIONAL,
   14365   OUT PREGHANDLE RegHandle);
   14366 
   14367 NTSTATUS
   14368 NTKERNELAPI
   14369 NTAPI
   14370 EtwUnregister(
   14371   IN REGHANDLE RegHandle);
   14372 
   14373 BOOLEAN
   14374 NTKERNELAPI
   14375 NTAPI
   14376 EtwEventEnabled(
   14377   IN REGHANDLE RegHandle,
   14378   IN PCEVENT_DESCRIPTOR EventDescriptor);
   14379 
   14380 BOOLEAN
   14381 NTKERNELAPI
   14382 NTAPI
   14383 EtwProviderEnabled(
   14384   IN REGHANDLE RegHandle,
   14385   IN UCHAR Level,
   14386   IN ULONGLONG Keyword);
   14387 
   14388 NTSTATUS
   14389 NTKERNELAPI
   14390 NTAPI
   14391 EtwActivityIdControl(
   14392   IN ULONG ControlCode,
   14393   IN OUT LPGUID ActivityId);
   14394 
   14395 NTSTATUS
   14396 NTKERNELAPI
   14397 NTAPI
   14398 EtwWrite(
   14399   IN REGHANDLE RegHandle,
   14400   IN PCEVENT_DESCRIPTOR EventDescriptor,
   14401   IN LPCGUID ActivityId OPTIONAL,
   14402   IN ULONG UserDataCount,
   14403   IN PEVENT_DATA_DESCRIPTOR  UserData OPTIONAL);
   14404 
   14405 NTSTATUS
   14406 NTKERNELAPI
   14407 NTAPI
   14408 EtwWriteTransfer(
   14409   IN REGHANDLE RegHandle,
   14410   IN PCEVENT_DESCRIPTOR EventDescriptor,
   14411   IN LPCGUID ActivityId OPTIONAL,
   14412   IN LPCGUID RelatedActivityId OPTIONAL,
   14413   IN ULONG UserDataCount,
   14414   IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL);
   14415 
   14416 NTSTATUS
   14417 NTKERNELAPI
   14418 NTAPI
   14419 EtwWriteString(
   14420   IN REGHANDLE RegHandle,
   14421   IN UCHAR Level,
   14422   IN ULONGLONG Keyword,
   14423   IN LPCGUID ActivityId OPTIONAL,
   14424   IN PCWSTR String);
   14425 
   14426 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   14427 
   14428 #if (NTDDI_VERSION >= NTDDI_WIN7)
   14429 NTSTATUS
   14430 NTKERNELAPI
   14431 NTAPI
   14432 EtwWriteEx(
   14433   IN REGHANDLE RegHandle,
   14434   IN PCEVENT_DESCRIPTOR EventDescriptor,
   14435   IN ULONG64 Filter,
   14436   IN ULONG Flags,
   14437   IN LPCGUID ActivityId OPTIONAL,
   14438   IN LPCGUID RelatedActivityId OPTIONAL,
   14439   IN ULONG UserDataCount,
   14440   IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL);
   14441 #endif
   14442 
   14443 
   14444 
   14445 /******************************************************************************
   14446  *                          Kernel Debugger Functions                         *
   14447  ******************************************************************************/
   14448 
   14449 #ifndef _DBGNT_
   14450 
   14451 ULONG
   14452 __cdecl
   14453 DbgPrint(
   14454   IN PCSTR Format,
   14455   IN ...);
   14456 
   14457 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   14458 NTSYSAPI
   14459 ULONG
   14460 __cdecl
   14461 DbgPrintReturnControlC(
   14462   IN PCCH Format,
   14463   IN ...);
   14464 #endif
   14465 
   14466 #if (NTDDI_VERSION >= NTDDI_WINXP)
   14467 
   14468 NTSYSAPI
   14469 ULONG
   14470 __cdecl
   14471 DbgPrintEx(
   14472   IN ULONG ComponentId,
   14473   IN ULONG Level,
   14474   IN PCSTR Format,
   14475   IN ...);
   14476 
   14477 #ifdef _VA_LIST_DEFINED
   14478 
   14479 NTSYSAPI
   14480 ULONG
   14481 NTAPI
   14482 vDbgPrintEx(
   14483   IN ULONG ComponentId,
   14484   IN ULONG Level,
   14485   IN PCCH Format,
   14486   IN va_list ap);
   14487 
   14488 NTSYSAPI
   14489 ULONG
   14490 NTAPI
   14491 vDbgPrintExWithPrefix(
   14492   IN PCCH Prefix,
   14493   IN ULONG ComponentId,
   14494   IN ULONG Level,
   14495   IN PCCH Format,
   14496   IN va_list ap);
   14497 
   14498 #endif /* _VA_LIST_DEFINED */
   14499 
   14500 NTSYSAPI
   14501 NTSTATUS
   14502 NTAPI
   14503 DbgQueryDebugFilterState(
   14504   IN ULONG ComponentId,
   14505   IN ULONG Level);
   14506 
   14507 NTSYSAPI
   14508 NTSTATUS
   14509 NTAPI
   14510 DbgSetDebugFilterState(
   14511   IN ULONG ComponentId,
   14512   IN ULONG Level,
   14513   IN BOOLEAN State);
   14514 
   14515 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
   14516 
   14517 #if (NTDDI_VERSION >= NTDDI_VISTA)
   14518 
   14519 typedef VOID
   14520 (*PDEBUG_PRINT_CALLBACK)(
   14521   IN PSTRING Output,
   14522   IN ULONG ComponentId,
   14523   IN ULONG Level);
   14524 
   14525 NTSYSAPI
   14526 NTSTATUS
   14527 NTAPI
   14528 DbgSetDebugPrintCallback(
   14529   IN PDEBUG_PRINT_CALLBACK DebugPrintCallback,
   14530   IN BOOLEAN Enable);
   14531 
   14532 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   14533 
   14534 #endif /* _DBGNT_ */
   14535 
   14536 #if DBG
   14537 
   14538 #define KdPrint(_x_) DbgPrint _x_
   14539 #define KdPrintEx(_x_) DbgPrintEx _x_
   14540 #define vKdPrintEx(_x_) vDbgPrintEx _x_
   14541 #define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_
   14542 #define KdBreakPoint() DbgBreakPoint()
   14543 #define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s)
   14544 
   14545 #else /* !DBG */
   14546 
   14547 #define KdPrint(_x_)
   14548 #define KdPrintEx(_x_)
   14549 #define vKdPrintEx(_x_)
   14550 #define vKdPrintExWithPrefix(_x_)
   14551 #define KdBreakPoint()
   14552 #define KdBreakPointWithStatus(s)
   14553 
   14554 #endif /* !DBG */
   14555 
   14556 #if defined(__GNUC__)
   14557 
   14558 extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent;
   14559 extern NTKERNELAPI BOOLEAN KdDebuggerEnabled;
   14560 #define KD_DEBUGGER_ENABLED KdDebuggerEnabled
   14561 #define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent
   14562 
   14563 #elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_)
   14564 
   14565 extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent;
   14566 extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled;
   14567 #define KD_DEBUGGER_ENABLED *KdDebuggerEnabled
   14568 #define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent
   14569 
   14570 #else
   14571 
   14572 extern BOOLEAN KdDebuggerNotPresent;
   14573 extern BOOLEAN KdDebuggerEnabled;
   14574 #define KD_DEBUGGER_ENABLED KdDebuggerEnabled
   14575 #define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent
   14576 
   14577 #endif
   14578 
   14579 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   14580 
   14581 NTKERNELAPI
   14582 NTSTATUS
   14583 NTAPI
   14584 KdDisableDebugger(VOID);
   14585 
   14586 NTKERNELAPI
   14587 NTSTATUS
   14588 NTAPI
   14589 KdEnableDebugger(VOID);
   14590 
   14591 #if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK)
   14592 #define DbgBreakPoint __debugbreak
   14593 #else
   14594 VOID
   14595 NTAPI
   14596 DbgBreakPoint(VOID);
   14597 #endif
   14598 
   14599 NTSYSAPI
   14600 VOID
   14601 NTAPI
   14602 DbgBreakPointWithStatus(
   14603   IN ULONG Status);
   14604 
   14605 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   14606 
   14607 #if (NTDDI_VERSION >= NTDDI_WS03)
   14608 NTKERNELAPI
   14609 BOOLEAN
   14610 NTAPI
   14611 KdRefreshDebuggerNotPresent(VOID);
   14612 #endif
   14613 
   14614 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
   14615 NTKERNELAPI
   14616 NTSTATUS
   14617 NTAPI
   14618 KdChangeOption(
   14619   IN KD_OPTION Option,
   14620   IN ULONG InBufferBytes OPTIONAL,
   14621   IN PVOID InBuffer,
   14622   IN ULONG OutBufferBytes OPTIONAL,
   14623   OUT PVOID OutBuffer,
   14624   OUT PULONG OutBufferNeeded OPTIONAL);
   14625 #endif
   14626 /* Hardware Abstraction Layer Functions */
   14627 
   14628 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   14629 
   14630 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
   14631 
   14632 FORCEINLINE
   14633 PVOID
   14634 NTAPI
   14635 HalAllocateCommonBuffer(
   14636   IN PDMA_ADAPTER DmaAdapter,
   14637   IN ULONG Length,
   14638   OUT PPHYSICAL_ADDRESS LogicalAddress,
   14639   IN BOOLEAN CacheEnabled)
   14640 {
   14641   PALLOCATE_COMMON_BUFFER allocateCommonBuffer;
   14642   PVOID commonBuffer;
   14643 
   14644   allocateCommonBuffer = *(DmaAdapter)->DmaOperations->AllocateCommonBuffer;
   14645   ASSERT( allocateCommonBuffer != NULL );
   14646   commonBuffer = allocateCommonBuffer( DmaAdapter, Length, LogicalAddress, CacheEnabled );
   14647   return commonBuffer;
   14648 }
   14649 
   14650 FORCEINLINE
   14651 VOID
   14652 NTAPI
   14653 HalFreeCommonBuffer(
   14654   IN PDMA_ADAPTER DmaAdapter,
   14655   IN ULONG Length,
   14656   IN PHYSICAL_ADDRESS LogicalAddress,
   14657   IN PVOID VirtualAddress,
   14658   IN BOOLEAN CacheEnabled)
   14659 {
   14660   PFREE_COMMON_BUFFER freeCommonBuffer;
   14661 
   14662   freeCommonBuffer = *(DmaAdapter)->DmaOperations->FreeCommonBuffer;
   14663   ASSERT( freeCommonBuffer != NULL );
   14664   freeCommonBuffer( DmaAdapter, Length, LogicalAddress, VirtualAddress, CacheEnabled );
   14665 }
   14666 
   14667 FORCEINLINE
   14668 ULONG
   14669 NTAPI
   14670 HalReadDmaCounter(
   14671   IN PDMA_ADAPTER DmaAdapter)
   14672 {
   14673   PREAD_DMA_COUNTER readDmaCounter;
   14674   ULONG counter;
   14675 
   14676   readDmaCounter = *(DmaAdapter)->DmaOperations->ReadDmaCounter;
   14677   ASSERT( readDmaCounter != NULL );
   14678   counter = readDmaCounter( DmaAdapter );
   14679   return counter;
   14680 }
   14681 
   14682 FORCEINLINE
   14683 ULONG
   14684 HalGetDmaAlignment(
   14685   IN PDMA_ADAPTER DmaAdapter)
   14686 {
   14687   PGET_DMA_ALIGNMENT getDmaAlignment;
   14688   ULONG alignment;
   14689 
   14690   getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment;
   14691   ASSERT( getDmaAlignment != NULL );
   14692   alignment = getDmaAlignment( DmaAdapter );
   14693   return alignment;
   14694 }
   14695 
   14696 #endif /* USE_DMA_MACROS ... */
   14697 
   14698 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   14699 
   14700 #ifndef _NTTMAPI_
   14701 #define _NTTMAPI_
   14702 
   14703 #include <ktmtypes.h>
   14704 
   14705 #define TRANSACTIONMANAGER_QUERY_INFORMATION     (0x0001)
   14706 #define TRANSACTIONMANAGER_SET_INFORMATION       (0x0002)
   14707 #define TRANSACTIONMANAGER_RECOVER               (0x0004)
   14708 #define TRANSACTIONMANAGER_RENAME                (0x0008)
   14709 #define TRANSACTIONMANAGER_CREATE_RM             (0x0010)
   14710 #define TRANSACTIONMANAGER_BIND_TRANSACTION      (0x0020)
   14711 
   14712 #define TRANSACTIONMANAGER_GENERIC_READ            (STANDARD_RIGHTS_READ            |\
   14713                                                     TRANSACTIONMANAGER_QUERY_INFORMATION)
   14714 
   14715 #define TRANSACTIONMANAGER_GENERIC_WRITE           (STANDARD_RIGHTS_WRITE           |\
   14716                                                     TRANSACTIONMANAGER_SET_INFORMATION     |\
   14717                                                     TRANSACTIONMANAGER_RECOVER             |\
   14718                                                     TRANSACTIONMANAGER_RENAME              |\
   14719                                                     TRANSACTIONMANAGER_CREATE_RM)
   14720 
   14721 #define TRANSACTIONMANAGER_GENERIC_EXECUTE         (STANDARD_RIGHTS_EXECUTE)
   14722 
   14723 #define TRANSACTIONMANAGER_ALL_ACCESS              (STANDARD_RIGHTS_REQUIRED        |\
   14724                                                     TRANSACTIONMANAGER_GENERIC_READ        |\
   14725                                                     TRANSACTIONMANAGER_GENERIC_WRITE       |\
   14726                                                     TRANSACTIONMANAGER_GENERIC_EXECUTE     |\
   14727                                                     TRANSACTIONMANAGER_BIND_TRANSACTION)
   14728 
   14729 #define TRANSACTION_QUERY_INFORMATION     (0x0001)
   14730 #define TRANSACTION_SET_INFORMATION       (0x0002)
   14731 #define TRANSACTION_ENLIST                (0x0004)
   14732 #define TRANSACTION_COMMIT                (0x0008)
   14733 #define TRANSACTION_ROLLBACK              (0x0010)
   14734 #define TRANSACTION_PROPAGATE             (0x0020)
   14735 #define TRANSACTION_RIGHT_RESERVED1       (0x0040)
   14736 
   14737 #define TRANSACTION_GENERIC_READ            (STANDARD_RIGHTS_READ            |\
   14738                                              TRANSACTION_QUERY_INFORMATION   |\
   14739                                              SYNCHRONIZE)
   14740 
   14741 #define TRANSACTION_GENERIC_WRITE           (STANDARD_RIGHTS_WRITE           |\
   14742                                              TRANSACTION_SET_INFORMATION     |\
   14743                                              TRANSACTION_COMMIT              |\
   14744                                              TRANSACTION_ENLIST              |\
   14745                                              TRANSACTION_ROLLBACK            |\
   14746                                              TRANSACTION_PROPAGATE           |\
   14747                                              SYNCHRONIZE)
   14748 
   14749 #define TRANSACTION_GENERIC_EXECUTE         (STANDARD_RIGHTS_EXECUTE         |\
   14750                                              TRANSACTION_COMMIT              |\
   14751                                              TRANSACTION_ROLLBACK            |\
   14752                                              SYNCHRONIZE)
   14753 
   14754 #define TRANSACTION_ALL_ACCESS              (STANDARD_RIGHTS_REQUIRED        |\
   14755                                              TRANSACTION_GENERIC_READ        |\
   14756                                              TRANSACTION_GENERIC_WRITE       |\
   14757                                              TRANSACTION_GENERIC_EXECUTE)
   14758 
   14759 #define TRANSACTION_RESOURCE_MANAGER_RIGHTS (TRANSACTION_GENERIC_READ        |\
   14760                                              STANDARD_RIGHTS_WRITE           |\
   14761                                              TRANSACTION_SET_INFORMATION     |\
   14762                                              TRANSACTION_ENLIST              |\
   14763                                              TRANSACTION_ROLLBACK            |\
   14764                                              TRANSACTION_PROPAGATE           |\
   14765                                              SYNCHRONIZE)
   14766 
   14767 #define RESOURCEMANAGER_QUERY_INFORMATION        (0x0001)
   14768 #define RESOURCEMANAGER_SET_INFORMATION          (0x0002)
   14769 #define RESOURCEMANAGER_RECOVER                  (0x0004)
   14770 #define RESOURCEMANAGER_ENLIST                   (0x0008)
   14771 #define RESOURCEMANAGER_GET_NOTIFICATION         (0x0010)
   14772 #define RESOURCEMANAGER_REGISTER_PROTOCOL        (0x0020)
   14773 #define RESOURCEMANAGER_COMPLETE_PROPAGATION     (0x0040)
   14774 
   14775 #define RESOURCEMANAGER_GENERIC_READ        (STANDARD_RIGHTS_READ                 |\
   14776                                              RESOURCEMANAGER_QUERY_INFORMATION    |\
   14777                                              SYNCHRONIZE)
   14778 
   14779 #define RESOURCEMANAGER_GENERIC_WRITE       (STANDARD_RIGHTS_WRITE                |\
   14780                                              RESOURCEMANAGER_SET_INFORMATION      |\
   14781                                              RESOURCEMANAGER_RECOVER              |\
   14782                                              RESOURCEMANAGER_ENLIST               |\
   14783                                              RESOURCEMANAGER_GET_NOTIFICATION     |\
   14784                                              RESOURCEMANAGER_REGISTER_PROTOCOL    |\
   14785                                              RESOURCEMANAGER_COMPLETE_PROPAGATION |\
   14786                                              SYNCHRONIZE)
   14787 
   14788 #define RESOURCEMANAGER_GENERIC_EXECUTE     (STANDARD_RIGHTS_EXECUTE              |\
   14789                                              RESOURCEMANAGER_RECOVER              |\
   14790                                              RESOURCEMANAGER_ENLIST               |\
   14791                                              RESOURCEMANAGER_GET_NOTIFICATION     |\
   14792                                              RESOURCEMANAGER_COMPLETE_PROPAGATION |\
   14793                                              SYNCHRONIZE)
   14794 
   14795 #define RESOURCEMANAGER_ALL_ACCESS          (STANDARD_RIGHTS_REQUIRED             |\
   14796                                              RESOURCEMANAGER_GENERIC_READ         |\
   14797                                              RESOURCEMANAGER_GENERIC_WRITE        |\
   14798                                              RESOURCEMANAGER_GENERIC_EXECUTE)
   14799 
   14800 #define ENLISTMENT_QUERY_INFORMATION             (0x0001)
   14801 #define ENLISTMENT_SET_INFORMATION               (0x0002)
   14802 #define ENLISTMENT_RECOVER                       (0x0004)
   14803 #define ENLISTMENT_SUBORDINATE_RIGHTS            (0x0008)
   14804 #define ENLISTMENT_SUPERIOR_RIGHTS               (0x0010)
   14805 
   14806 #define ENLISTMENT_GENERIC_READ        (STANDARD_RIGHTS_READ           |\
   14807                                         ENLISTMENT_QUERY_INFORMATION)
   14808 
   14809 #define ENLISTMENT_GENERIC_WRITE       (STANDARD_RIGHTS_WRITE          |\
   14810                                         ENLISTMENT_SET_INFORMATION     |\
   14811                                         ENLISTMENT_RECOVER             |\
   14812                                         ENLISTMENT_SUBORDINATE_RIGHTS  |\
   14813                                         ENLISTMENT_SUPERIOR_RIGHTS)
   14814 
   14815 #define ENLISTMENT_GENERIC_EXECUTE     (STANDARD_RIGHTS_EXECUTE        |\
   14816                                         ENLISTMENT_RECOVER             |\
   14817                                         ENLISTMENT_SUBORDINATE_RIGHTS  |\
   14818                                         ENLISTMENT_SUPERIOR_RIGHTS)
   14819 
   14820 #define ENLISTMENT_ALL_ACCESS          (STANDARD_RIGHTS_REQUIRED       |\
   14821                                         ENLISTMENT_GENERIC_READ        |\
   14822                                         ENLISTMENT_GENERIC_WRITE       |\
   14823                                         ENLISTMENT_GENERIC_EXECUTE)
   14824 
   14825 typedef enum _TRANSACTION_OUTCOME {
   14826   TransactionOutcomeUndetermined = 1,
   14827   TransactionOutcomeCommitted,
   14828   TransactionOutcomeAborted,
   14829 } TRANSACTION_OUTCOME;
   14830 
   14831 
   14832 typedef enum _TRANSACTION_STATE {
   14833   TransactionStateNormal = 1,
   14834   TransactionStateIndoubt,
   14835   TransactionStateCommittedNotify,
   14836 } TRANSACTION_STATE;
   14837 
   14838 
   14839 typedef struct _TRANSACTION_BASIC_INFORMATION {
   14840   GUID TransactionId;
   14841   ULONG State;
   14842   ULONG Outcome;
   14843 } TRANSACTION_BASIC_INFORMATION, *PTRANSACTION_BASIC_INFORMATION;
   14844 
   14845 typedef struct _TRANSACTIONMANAGER_BASIC_INFORMATION {
   14846   GUID TmIdentity;
   14847   LARGE_INTEGER VirtualClock;
   14848 } TRANSACTIONMANAGER_BASIC_INFORMATION, *PTRANSACTIONMANAGER_BASIC_INFORMATION;
   14849 
   14850 typedef struct _TRANSACTIONMANAGER_LOG_INFORMATION {
   14851   GUID LogIdentity;
   14852 } TRANSACTIONMANAGER_LOG_INFORMATION, *PTRANSACTIONMANAGER_LOG_INFORMATION;
   14853 
   14854 typedef struct _TRANSACTIONMANAGER_LOGPATH_INFORMATION {
   14855   ULONG LogPathLength;
   14856   WCHAR LogPath[1];
   14857 } TRANSACTIONMANAGER_LOGPATH_INFORMATION, *PTRANSACTIONMANAGER_LOGPATH_INFORMATION;
   14858 
   14859 typedef struct _TRANSACTIONMANAGER_RECOVERY_INFORMATION {
   14860   ULONGLONG LastRecoveredLsn;
   14861 } TRANSACTIONMANAGER_RECOVERY_INFORMATION, *PTRANSACTIONMANAGER_RECOVERY_INFORMATION;
   14862 
   14863 typedef struct _TRANSACTION_PROPERTIES_INFORMATION {
   14864   ULONG IsolationLevel;
   14865   ULONG IsolationFlags;
   14866   LARGE_INTEGER Timeout;
   14867   ULONG Outcome;
   14868   ULONG DescriptionLength;
   14869   WCHAR Description[1];
   14870 } TRANSACTION_PROPERTIES_INFORMATION, *PTRANSACTION_PROPERTIES_INFORMATION;
   14871 
   14872 typedef struct _TRANSACTION_BIND_INFORMATION {
   14873   HANDLE TmHandle;
   14874 } TRANSACTION_BIND_INFORMATION, *PTRANSACTION_BIND_INFORMATION;
   14875 
   14876 typedef struct _TRANSACTION_ENLISTMENT_PAIR {
   14877   GUID EnlistmentId;
   14878   GUID ResourceManagerId;
   14879 } TRANSACTION_ENLISTMENT_PAIR, *PTRANSACTION_ENLISTMENT_PAIR;
   14880 
   14881 typedef struct _TRANSACTION_ENLISTMENTS_INFORMATION {
   14882   ULONG NumberOfEnlistments;
   14883   TRANSACTION_ENLISTMENT_PAIR EnlistmentPair[1];
   14884 } TRANSACTION_ENLISTMENTS_INFORMATION, *PTRANSACTION_ENLISTMENTS_INFORMATION;
   14885 
   14886 typedef struct _TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION {
   14887   TRANSACTION_ENLISTMENT_PAIR SuperiorEnlistmentPair;
   14888 } TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION, *PTRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION;
   14889 
   14890 typedef struct _RESOURCEMANAGER_BASIC_INFORMATION {
   14891   GUID ResourceManagerId;
   14892   ULONG DescriptionLength;
   14893   WCHAR Description[1];
   14894 } RESOURCEMANAGER_BASIC_INFORMATION, *PRESOURCEMANAGER_BASIC_INFORMATION;
   14895 
   14896 typedef struct _RESOURCEMANAGER_COMPLETION_INFORMATION {
   14897   HANDLE IoCompletionPortHandle;
   14898   ULONG_PTR CompletionKey;
   14899 } RESOURCEMANAGER_COMPLETION_INFORMATION, *PRESOURCEMANAGER_COMPLETION_INFORMATION;
   14900 
   14901 typedef enum _KTMOBJECT_TYPE {
   14902   KTMOBJECT_TRANSACTION,
   14903   KTMOBJECT_TRANSACTION_MANAGER,
   14904   KTMOBJECT_RESOURCE_MANAGER,
   14905   KTMOBJECT_ENLISTMENT,
   14906   KTMOBJECT_INVALID
   14907 } KTMOBJECT_TYPE, *PKTMOBJECT_TYPE;
   14908 
   14909 typedef struct _KTMOBJECT_CURSOR {
   14910   GUID LastQuery;
   14911   ULONG ObjectIdCount;
   14912   GUID ObjectIds[1];
   14913 } KTMOBJECT_CURSOR, *PKTMOBJECT_CURSOR;
   14914 
   14915 typedef enum _TRANSACTION_INFORMATION_CLASS {
   14916   TransactionBasicInformation,
   14917   TransactionPropertiesInformation,
   14918   TransactionEnlistmentInformation,
   14919   TransactionSuperiorEnlistmentInformation
   14920 } TRANSACTION_INFORMATION_CLASS;
   14921 
   14922 typedef enum _TRANSACTIONMANAGER_INFORMATION_CLASS {
   14923   TransactionManagerBasicInformation,
   14924   TransactionManagerLogInformation,
   14925   TransactionManagerLogPathInformation,
   14926   TransactionManagerRecoveryInformation = 4
   14927 } TRANSACTIONMANAGER_INFORMATION_CLASS;
   14928 
   14929 typedef enum _RESOURCEMANAGER_INFORMATION_CLASS {
   14930   ResourceManagerBasicInformation,
   14931   ResourceManagerCompletionInformation,
   14932 } RESOURCEMANAGER_INFORMATION_CLASS;
   14933 
   14934 typedef struct _ENLISTMENT_BASIC_INFORMATION {
   14935   GUID EnlistmentId;
   14936   GUID TransactionId;
   14937   GUID ResourceManagerId;
   14938 } ENLISTMENT_BASIC_INFORMATION, *PENLISTMENT_BASIC_INFORMATION;
   14939 
   14940 typedef struct _ENLISTMENT_CRM_INFORMATION {
   14941   GUID CrmTransactionManagerId;
   14942   GUID CrmResourceManagerId;
   14943   GUID CrmEnlistmentId;
   14944 } ENLISTMENT_CRM_INFORMATION, *PENLISTMENT_CRM_INFORMATION;
   14945 
   14946 typedef enum _ENLISTMENT_INFORMATION_CLASS {
   14947   EnlistmentBasicInformation,
   14948   EnlistmentRecoveryInformation,
   14949   EnlistmentCrmInformation
   14950 } ENLISTMENT_INFORMATION_CLASS;
   14951 
   14952 typedef struct _TRANSACTION_LIST_ENTRY {
   14953 /* UOW is typedef'ed as GUID just above.  Changed type of UOW
   14954  * member from UOW to GUID for C++ compat.  Using ::UOW for C++
   14955  * works too but we were reported some problems in corner cases
   14956  */
   14957   GUID UOW;
   14958 } TRANSACTION_LIST_ENTRY, *PTRANSACTION_LIST_ENTRY;
   14959 
   14960 typedef struct _TRANSACTION_LIST_INFORMATION {
   14961   ULONG NumberOfTransactions;
   14962   TRANSACTION_LIST_ENTRY TransactionInformation[1];
   14963 } TRANSACTION_LIST_INFORMATION, *PTRANSACTION_LIST_INFORMATION;
   14964 
   14965 typedef NTSTATUS
   14966 (NTAPI *PFN_NT_CREATE_TRANSACTION)(
   14967   OUT PHANDLE TransactionHandle,
   14968   IN ACCESS_MASK DesiredAccess,
   14969   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   14970   IN LPGUID Uow OPTIONAL,
   14971   IN HANDLE TmHandle OPTIONAL,
   14972   IN ULONG CreateOptions OPTIONAL,
   14973   IN ULONG IsolationLevel OPTIONAL,
   14974   IN ULONG IsolationFlags OPTIONAL,
   14975   IN PLARGE_INTEGER Timeout OPTIONAL,
   14976   IN PUNICODE_STRING Description OPTIONAL);
   14977 
   14978 typedef NTSTATUS
   14979 (NTAPI *PFN_NT_OPEN_TRANSACTION)(
   14980   OUT PHANDLE TransactionHandle,
   14981   IN ACCESS_MASK DesiredAccess,
   14982   IN POBJECT_ATTRIBUTES ObjectAttributes,
   14983   IN LPGUID Uow OPTIONAL,
   14984   IN HANDLE TmHandle OPTIONAL);
   14985 
   14986 typedef NTSTATUS
   14987 (NTAPI *PFN_NT_QUERY_INFORMATION_TRANSACTION)(
   14988   IN HANDLE TransactionHandle,
   14989   IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass,
   14990   OUT PVOID TransactionInformation,
   14991   IN ULONG TransactionInformationLength,
   14992   OUT PULONG ReturnLength OPTIONAL);
   14993 
   14994 typedef NTSTATUS
   14995 (NTAPI *PFN_NT_SET_INFORMATION_TRANSACTION)(
   14996   IN HANDLE TransactionHandle,
   14997   IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass,
   14998   IN PVOID TransactionInformation,
   14999   IN ULONG TransactionInformationLength);
   15000 
   15001 typedef NTSTATUS
   15002 (NTAPI *PFN_NT_COMMIT_TRANSACTION)(
   15003   IN HANDLE TransactionHandle,
   15004   IN BOOLEAN Wait);
   15005 
   15006 typedef NTSTATUS
   15007 (NTAPI *PFN_NT_ROLLBACK_TRANSACTION)(
   15008   IN HANDLE TransactionHandle,
   15009   IN BOOLEAN Wait);
   15010 
   15011 #if (NTDDI_VERSION >= NTDDI_VISTA)
   15012 
   15013 NTSYSCALLAPI
   15014 NTSTATUS
   15015 NTAPI
   15016 NtCreateTransactionManager(
   15017   OUT PHANDLE TmHandle,
   15018   IN ACCESS_MASK DesiredAccess,
   15019   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15020   IN PUNICODE_STRING LogFileName OPTIONAL,
   15021   IN ULONG CreateOptions OPTIONAL,
   15022   IN ULONG CommitStrength OPTIONAL);
   15023 
   15024 NTSYSCALLAPI
   15025 NTSTATUS
   15026 NTAPI
   15027 NtOpenTransactionManager(
   15028   OUT PHANDLE TmHandle,
   15029   IN ACCESS_MASK DesiredAccess,
   15030   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15031   IN PUNICODE_STRING LogFileName OPTIONAL,
   15032   IN LPGUID TmIdentity OPTIONAL,
   15033   IN ULONG OpenOptions OPTIONAL);
   15034 
   15035 NTSYSCALLAPI
   15036 NTSTATUS
   15037 NTAPI
   15038 NtRenameTransactionManager(
   15039   IN PUNICODE_STRING LogFileName,
   15040   IN LPGUID ExistingTransactionManagerGuid);
   15041 
   15042 NTSYSCALLAPI
   15043 NTSTATUS
   15044 NTAPI
   15045 NtRollforwardTransactionManager(
   15046   IN HANDLE TransactionManagerHandle,
   15047   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15048 
   15049 NTSYSCALLAPI
   15050 NTSTATUS
   15051 NTAPI
   15052 NtRecoverTransactionManager(
   15053   IN HANDLE TransactionManagerHandle);
   15054 
   15055 NTSYSCALLAPI
   15056 NTSTATUS
   15057 NTAPI
   15058 NtQueryInformationTransactionManager(
   15059   IN HANDLE TransactionManagerHandle,
   15060   IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass,
   15061   OUT PVOID TransactionManagerInformation,
   15062   IN ULONG TransactionManagerInformationLength,
   15063   OUT PULONG ReturnLength);
   15064 
   15065 NTSYSCALLAPI
   15066 NTSTATUS
   15067 NTAPI
   15068 NtSetInformationTransactionManager(
   15069   IN HANDLE TmHandle OPTIONAL,
   15070   IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass,
   15071   IN PVOID TransactionManagerInformation,
   15072   IN ULONG TransactionManagerInformationLength);
   15073 
   15074 NTSYSCALLAPI
   15075 NTSTATUS
   15076 NTAPI
   15077 NtEnumerateTransactionObject(
   15078   IN HANDLE RootObjectHandle OPTIONAL,
   15079   IN KTMOBJECT_TYPE QueryType,
   15080   IN OUT PKTMOBJECT_CURSOR ObjectCursor,
   15081   IN ULONG ObjectCursorLength,
   15082   OUT PULONG ReturnLength);
   15083 
   15084 NTSYSCALLAPI
   15085 NTSTATUS
   15086 NTAPI
   15087 NtCreateTransaction(
   15088   OUT PHANDLE TransactionHandle,
   15089   IN ACCESS_MASK DesiredAccess,
   15090   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15091   IN LPGUID Uow OPTIONAL,
   15092   IN HANDLE TmHandle OPTIONAL,
   15093   IN ULONG CreateOptions OPTIONAL,
   15094   IN ULONG IsolationLevel OPTIONAL,
   15095   IN ULONG IsolationFlags OPTIONAL,
   15096   IN PLARGE_INTEGER Timeout OPTIONAL,
   15097   IN PUNICODE_STRING Description OPTIONAL);
   15098 
   15099 NTSYSCALLAPI
   15100 NTSTATUS
   15101 NTAPI
   15102 NtOpenTransaction(
   15103   OUT PHANDLE TransactionHandle,
   15104   IN ACCESS_MASK DesiredAccess,
   15105   IN POBJECT_ATTRIBUTES ObjectAttributes,
   15106   IN LPGUID Uow,
   15107   IN HANDLE TmHandle OPTIONAL);
   15108 
   15109 NTSYSCALLAPI
   15110 NTSTATUS
   15111 NTAPI
   15112 NtQueryInformationTransaction(
   15113   IN HANDLE TransactionHandle,
   15114   IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass,
   15115   OUT PVOID TransactionInformation,
   15116   IN ULONG TransactionInformationLength,
   15117   OUT PULONG ReturnLength OPTIONAL);
   15118 
   15119 NTSYSCALLAPI
   15120 NTSTATUS
   15121 NTAPI
   15122 NtSetInformationTransaction(
   15123   IN HANDLE TransactionHandle,
   15124   IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass,
   15125   IN PVOID TransactionInformation,
   15126   IN ULONG TransactionInformationLength);
   15127 
   15128 NTSYSCALLAPI
   15129 NTSTATUS
   15130 NTAPI
   15131 NtCommitTransaction(
   15132   IN HANDLE TransactionHandle,
   15133   IN BOOLEAN Wait);
   15134 
   15135 NTSYSCALLAPI
   15136 NTSTATUS
   15137 NTAPI
   15138 NtRollbackTransaction(
   15139   IN HANDLE TransactionHandle,
   15140   IN BOOLEAN Wait);
   15141 
   15142 NTSYSCALLAPI
   15143 NTSTATUS
   15144 NTAPI
   15145 NtCreateEnlistment(
   15146   OUT PHANDLE EnlistmentHandle,
   15147   IN ACCESS_MASK DesiredAccess,
   15148   IN HANDLE ResourceManagerHandle,
   15149   IN HANDLE TransactionHandle,
   15150   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15151   IN ULONG CreateOptions OPTIONAL,
   15152   IN NOTIFICATION_MASK NotificationMask,
   15153   IN PVOID EnlistmentKey OPTIONAL);
   15154 
   15155 NTSYSCALLAPI
   15156 NTSTATUS
   15157 NTAPI
   15158 NtOpenEnlistment(
   15159   OUT PHANDLE EnlistmentHandle,
   15160   IN ACCESS_MASK DesiredAccess,
   15161   IN HANDLE ResourceManagerHandle,
   15162   IN LPGUID EnlistmentGuid,
   15163   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL);
   15164 
   15165 NTSYSCALLAPI
   15166 NTSTATUS
   15167 NTAPI
   15168 NtQueryInformationEnlistment(
   15169   IN HANDLE EnlistmentHandle,
   15170   IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass,
   15171   OUT PVOID EnlistmentInformation,
   15172   IN ULONG EnlistmentInformationLength,
   15173   OUT PULONG ReturnLength);
   15174 
   15175 NTSYSCALLAPI
   15176 NTSTATUS
   15177 NTAPI
   15178 NtSetInformationEnlistment(
   15179   IN HANDLE EnlistmentHandle OPTIONAL,
   15180   IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass,
   15181   IN PVOID EnlistmentInformation,
   15182   IN ULONG EnlistmentInformationLength);
   15183 
   15184 NTSYSCALLAPI
   15185 NTSTATUS
   15186 NTAPI
   15187 NtRecoverEnlistment(
   15188   IN HANDLE EnlistmentHandle,
   15189   IN PVOID EnlistmentKey OPTIONAL);
   15190 
   15191 NTSYSCALLAPI
   15192 NTSTATUS
   15193 NTAPI
   15194 NtPrePrepareEnlistment(
   15195   IN HANDLE EnlistmentHandle,
   15196   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15197 
   15198 NTSYSCALLAPI
   15199 NTSTATUS
   15200 NTAPI
   15201 NtPrepareEnlistment(
   15202   IN HANDLE EnlistmentHandle,
   15203   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15204 
   15205 NTSYSCALLAPI
   15206 NTSTATUS
   15207 NTAPI
   15208 NtCommitEnlistment(
   15209   IN HANDLE EnlistmentHandle,
   15210   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15211 
   15212 NTSYSCALLAPI
   15213 NTSTATUS
   15214 NTAPI
   15215 NtRollbackEnlistment(
   15216   IN HANDLE EnlistmentHandle,
   15217   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15218 
   15219 NTSYSCALLAPI
   15220 NTSTATUS
   15221 NTAPI
   15222 NtPrePrepareComplete(
   15223   IN HANDLE EnlistmentHandle,
   15224   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15225 
   15226 NTSYSCALLAPI
   15227 NTSTATUS
   15228 NTAPI
   15229 NtPrepareComplete(
   15230   IN HANDLE EnlistmentHandle,
   15231   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15232 
   15233 NTSYSCALLAPI
   15234 NTSTATUS
   15235 NTAPI
   15236 NtCommitComplete(
   15237   IN HANDLE EnlistmentHandle,
   15238   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15239 
   15240 NTSYSCALLAPI
   15241 NTSTATUS
   15242 NTAPI
   15243 NtReadOnlyEnlistment(
   15244   IN HANDLE EnlistmentHandle,
   15245   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15246 
   15247 NTSYSCALLAPI
   15248 NTSTATUS
   15249 NTAPI
   15250 NtRollbackComplete(
   15251   IN HANDLE EnlistmentHandle,
   15252   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15253 
   15254 NTSYSCALLAPI
   15255 NTSTATUS
   15256 NTAPI
   15257 NtSinglePhaseReject(
   15258   IN HANDLE EnlistmentHandle,
   15259   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15260 
   15261 NTSYSCALLAPI
   15262 NTSTATUS
   15263 NTAPI
   15264 NtCreateResourceManager(
   15265   OUT PHANDLE ResourceManagerHandle,
   15266   IN ACCESS_MASK DesiredAccess,
   15267   IN HANDLE TmHandle,
   15268   IN LPGUID RmGuid,
   15269   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15270   IN ULONG CreateOptions OPTIONAL,
   15271   IN PUNICODE_STRING Description OPTIONAL);
   15272 
   15273 NTSYSCALLAPI
   15274 NTSTATUS
   15275 NTAPI
   15276 NtOpenResourceManager(
   15277   OUT PHANDLE ResourceManagerHandle,
   15278   IN ACCESS_MASK DesiredAccess,
   15279   IN HANDLE TmHandle,
   15280   IN LPGUID ResourceManagerGuid OPTIONAL,
   15281   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL);
   15282 
   15283 NTSYSCALLAPI
   15284 NTSTATUS
   15285 NTAPI
   15286 NtRecoverResourceManager(
   15287   IN HANDLE ResourceManagerHandle);
   15288 
   15289 NTSYSCALLAPI
   15290 NTSTATUS
   15291 NTAPI
   15292 NtGetNotificationResourceManager(
   15293   IN HANDLE ResourceManagerHandle,
   15294   OUT PTRANSACTION_NOTIFICATION TransactionNotification,
   15295   IN ULONG NotificationLength,
   15296   IN PLARGE_INTEGER Timeout OPTIONAL,
   15297   OUT PULONG ReturnLength OPTIONAL,
   15298   IN ULONG Asynchronous,
   15299   IN ULONG_PTR AsynchronousContext OPTIONAL);
   15300 
   15301 NTSYSCALLAPI
   15302 NTSTATUS
   15303 NTAPI
   15304 NtQueryInformationResourceManager(
   15305   IN HANDLE ResourceManagerHandle,
   15306   IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass,
   15307   OUT PVOID ResourceManagerInformation,
   15308   IN ULONG ResourceManagerInformationLength,
   15309   OUT PULONG ReturnLength OPTIONAL);
   15310 
   15311 NTSYSCALLAPI
   15312 NTSTATUS
   15313 NTAPI
   15314 NtSetInformationResourceManager(
   15315   IN HANDLE ResourceManagerHandle,
   15316   IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass,
   15317   IN PVOID ResourceManagerInformation,
   15318   IN ULONG ResourceManagerInformationLength);
   15319 
   15320 NTSYSCALLAPI
   15321 NTSTATUS
   15322 NTAPI
   15323 NtRegisterProtocolAddressInformation(
   15324   IN HANDLE ResourceManager,
   15325   IN PCRM_PROTOCOL_ID ProtocolId,
   15326   IN ULONG ProtocolInformationSize,
   15327   IN PVOID ProtocolInformation,
   15328   IN ULONG CreateOptions OPTIONAL);
   15329 
   15330 NTSYSCALLAPI
   15331 NTSTATUS
   15332 NTAPI
   15333 NtPropagationComplete(
   15334   IN HANDLE ResourceManagerHandle,
   15335   IN ULONG RequestCookie,
   15336   IN ULONG BufferLength,
   15337   IN PVOID Buffer);
   15338 
   15339 NTSYSCALLAPI
   15340 NTSTATUS
   15341 NTAPI
   15342 NtPropagationFailed(
   15343   IN HANDLE ResourceManagerHandle,
   15344   IN ULONG RequestCookie,
   15345   IN NTSTATUS PropStatus);
   15346 
   15347 #endif /* NTDDI_VERSION >= NTDDI_VISTA */
   15348 
   15349 #endif /* !_NTTMAPI_ */
   15350 
   15351 /******************************************************************************
   15352  *                            ZwXxx Functions                                 *
   15353  ******************************************************************************/
   15354 
   15355 /* Constants */
   15356 #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 )
   15357 #define ZwCurrentProcess() NtCurrentProcess()
   15358 #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 )
   15359 #define ZwCurrentThread() NtCurrentThread()
   15360 
   15361 
   15362 #if (NTDDI_VERSION >= NTDDI_WIN2K)
   15363 
   15364 NTSYSAPI
   15365 NTSTATUS
   15366 NTAPI
   15367 ZwClose(
   15368   IN HANDLE Handle);
   15369 
   15370 NTSYSAPI
   15371 NTSTATUS
   15372 NTAPI
   15373 ZwCreateDirectoryObject(
   15374   OUT PHANDLE DirectoryHandle,
   15375   IN ACCESS_MASK DesiredAccess,
   15376   IN POBJECT_ATTRIBUTES ObjectAttributes);
   15377 
   15378 NTSYSAPI
   15379 NTSTATUS
   15380 NTAPI
   15381 ZwCreateFile(
   15382   OUT PHANDLE FileHandle,
   15383   IN ACCESS_MASK DesiredAccess,
   15384   IN POBJECT_ATTRIBUTES ObjectAttributes,
   15385   OUT PIO_STATUS_BLOCK IoStatusBlock,
   15386   IN PLARGE_INTEGER AllocationSize OPTIONAL,
   15387   IN ULONG FileAttributes,
   15388   IN ULONG ShareAccess,
   15389   IN ULONG CreateDisposition,
   15390   IN ULONG CreateOptions,
   15391   IN PVOID EaBuffer OPTIONAL,
   15392   IN ULONG EaLength);
   15393 
   15394 NTSYSAPI
   15395 NTSTATUS
   15396 NTAPI
   15397 ZwCreateKey(
   15398   OUT PHANDLE KeyHandle,
   15399   IN ACCESS_MASK DesiredAccess,
   15400   IN POBJECT_ATTRIBUTES ObjectAttributes,
   15401   IN ULONG TitleIndex,
   15402   IN PUNICODE_STRING Class OPTIONAL,
   15403   IN ULONG CreateOptions,
   15404   OUT PULONG Disposition OPTIONAL);
   15405 
   15406 NTSYSAPI
   15407 NTSTATUS
   15408 NTAPI
   15409 ZwCreateSection(
   15410   OUT PHANDLE SectionHandle,
   15411   IN ACCESS_MASK DesiredAccess,
   15412   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15413   IN PLARGE_INTEGER MaximumSize OPTIONAL,
   15414   IN ULONG SectionPageProtection,
   15415   IN ULONG AllocationAttributes,
   15416   IN HANDLE FileHandle OPTIONAL);
   15417 
   15418 NTSYSAPI
   15419 NTSTATUS
   15420 NTAPI
   15421 ZwDeleteKey(
   15422   IN HANDLE KeyHandle);
   15423 
   15424 NTSYSAPI
   15425 NTSTATUS
   15426 NTAPI
   15427 ZwDeleteValueKey(
   15428   IN HANDLE KeyHandle,
   15429   IN PUNICODE_STRING ValueName);
   15430 
   15431 NTSYSAPI
   15432 NTSTATUS
   15433 NTAPI
   15434 ZwEnumerateKey(
   15435   IN HANDLE KeyHandle,
   15436   IN ULONG Index,
   15437   IN KEY_INFORMATION_CLASS KeyInformationClass,
   15438   OUT PVOID KeyInformation OPTIONAL,
   15439   IN ULONG Length,
   15440   OUT PULONG ResultLength);
   15441 
   15442 NTSYSAPI
   15443 NTSTATUS
   15444 NTAPI
   15445 ZwEnumerateValueKey(
   15446   IN HANDLE KeyHandle,
   15447   IN ULONG Index,
   15448   IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
   15449   OUT PVOID KeyValueInformation OPTIONAL,
   15450   IN ULONG Length,
   15451   OUT PULONG ResultLength);
   15452 
   15453 NTSYSAPI
   15454 NTSTATUS
   15455 NTAPI
   15456 ZwFlushKey(
   15457   IN HANDLE KeyHandle);
   15458 
   15459 NTSYSAPI
   15460 NTSTATUS
   15461 NTAPI
   15462 ZwLoadDriver(
   15463   IN PUNICODE_STRING DriverServiceName);
   15464 
   15465 NTSYSAPI
   15466 NTSTATUS
   15467 NTAPI
   15468 ZwMakeTemporaryObject(
   15469   IN HANDLE Handle);
   15470 
   15471 NTSYSAPI
   15472 NTSTATUS
   15473 NTAPI
   15474 ZwMapViewOfSection(
   15475   IN HANDLE SectionHandle,
   15476   IN HANDLE ProcessHandle,
   15477   IN OUT PVOID *BaseAddress,
   15478   IN ULONG_PTR ZeroBits,
   15479   IN SIZE_T CommitSize,
   15480   IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
   15481   IN OUT PSIZE_T ViewSize,
   15482   IN SECTION_INHERIT InheritDisposition,
   15483   IN ULONG AllocationType,
   15484   IN ULONG Protect);
   15485 
   15486 NTSYSAPI
   15487 NTSTATUS
   15488 NTAPI
   15489 ZwOpenFile(
   15490   OUT PHANDLE FileHandle,
   15491   IN ACCESS_MASK DesiredAccess,
   15492   IN POBJECT_ATTRIBUTES ObjectAttributes,
   15493   OUT PIO_STATUS_BLOCK IoStatusBlock,
   15494   IN ULONG ShareAccess,
   15495   IN ULONG OpenOptions);
   15496 
   15497 NTSYSAPI
   15498 NTSTATUS
   15499 NTAPI
   15500 ZwOpenKey(
   15501   OUT PHANDLE KeyHandle,
   15502   IN ACCESS_MASK DesiredAccess,
   15503   IN POBJECT_ATTRIBUTES ObjectAttributes);
   15504 
   15505 NTSYSAPI
   15506 NTSTATUS
   15507 NTAPI
   15508 ZwOpenSection(
   15509   OUT PHANDLE SectionHandle,
   15510   IN ACCESS_MASK DesiredAccess,
   15511   IN POBJECT_ATTRIBUTES ObjectAttributes);
   15512 
   15513 NTSYSAPI
   15514 NTSTATUS
   15515 NTAPI
   15516 ZwOpenSymbolicLinkObject(
   15517   OUT PHANDLE LinkHandle,
   15518   IN ACCESS_MASK DesiredAccess,
   15519   IN POBJECT_ATTRIBUTES ObjectAttributes);
   15520 
   15521 NTSYSAPI
   15522 NTSTATUS
   15523 NTAPI
   15524 ZwQueryInformationFile(
   15525   IN HANDLE FileHandle,
   15526   OUT PIO_STATUS_BLOCK IoStatusBlock,
   15527   OUT PVOID FileInformation,
   15528   IN ULONG Length,
   15529   IN FILE_INFORMATION_CLASS FileInformationClass);
   15530 
   15531 NTSYSAPI
   15532 NTSTATUS
   15533 NTAPI
   15534 ZwQueryKey(
   15535   IN HANDLE KeyHandle,
   15536   IN KEY_INFORMATION_CLASS KeyInformationClass,
   15537   OUT PVOID KeyInformation OPTIONAL,
   15538   IN ULONG Length,
   15539   OUT PULONG ResultLength);
   15540 
   15541 NTSYSAPI
   15542 NTSTATUS
   15543 NTAPI
   15544 ZwQuerySymbolicLinkObject(
   15545   IN HANDLE LinkHandle,
   15546   IN OUT PUNICODE_STRING LinkTarget,
   15547   OUT PULONG ReturnedLength OPTIONAL);
   15548 
   15549 NTSYSAPI
   15550 NTSTATUS
   15551 NTAPI
   15552 ZwQueryValueKey(
   15553   IN HANDLE KeyHandle,
   15554   IN PUNICODE_STRING ValueName,
   15555   IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
   15556   OUT PVOID KeyValueInformation OPTIONAL,
   15557   IN ULONG Length,
   15558   OUT PULONG ResultLength);
   15559 
   15560 NTSYSAPI
   15561 NTSTATUS
   15562 NTAPI
   15563 ZwReadFile(
   15564   IN HANDLE FileHandle,
   15565   IN HANDLE Event OPTIONAL,
   15566   IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
   15567   IN PVOID ApcContext OPTIONAL,
   15568   OUT PIO_STATUS_BLOCK IoStatusBlock,
   15569   OUT PVOID Buffer,
   15570   IN ULONG Length,
   15571   IN PLARGE_INTEGER ByteOffset OPTIONAL,
   15572   IN PULONG Key OPTIONAL);
   15573 
   15574 NTSYSAPI
   15575 NTSTATUS
   15576 NTAPI
   15577 ZwSetInformationFile(
   15578   IN HANDLE FileHandle,
   15579   OUT PIO_STATUS_BLOCK IoStatusBlock,
   15580   IN PVOID FileInformation,
   15581   IN ULONG Length,
   15582   IN FILE_INFORMATION_CLASS FileInformationClass);
   15583 
   15584 NTSYSAPI
   15585 NTSTATUS
   15586 NTAPI
   15587 ZwSetValueKey(
   15588   IN HANDLE KeyHandle,
   15589   IN PUNICODE_STRING ValueName,
   15590   IN ULONG TitleIndex OPTIONAL,
   15591   IN ULONG Type,
   15592   IN PVOID Data OPTIONAL,
   15593   IN ULONG DataSize);
   15594 
   15595 NTSYSAPI
   15596 NTSTATUS
   15597 NTAPI
   15598 ZwUnloadDriver(
   15599   IN PUNICODE_STRING DriverServiceName);
   15600 
   15601 NTSYSAPI
   15602 NTSTATUS
   15603 NTAPI
   15604 ZwUnmapViewOfSection(
   15605   IN HANDLE ProcessHandle,
   15606   IN PVOID BaseAddress OPTIONAL);
   15607 
   15608 NTSYSAPI
   15609 NTSTATUS
   15610 NTAPI
   15611 ZwWriteFile(
   15612   IN HANDLE FileHandle,
   15613   IN HANDLE Event OPTIONAL,
   15614   IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
   15615   IN PVOID ApcContext OPTIONAL,
   15616   OUT PIO_STATUS_BLOCK IoStatusBlock,
   15617   IN PVOID Buffer,
   15618   IN ULONG Length,
   15619   IN PLARGE_INTEGER ByteOffset OPTIONAL,
   15620   IN PULONG Key OPTIONAL);
   15621 
   15622 NTSYSAPI
   15623 NTSTATUS
   15624 NTAPI
   15625 ZwQueryFullAttributesFile(
   15626   IN POBJECT_ATTRIBUTES ObjectAttributes,
   15627   OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation);
   15628 
   15629 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
   15630 
   15631 
   15632 #if (NTDDI_VERSION >= NTDDI_WS03)
   15633 NTSYSCALLAPI
   15634 NTSTATUS
   15635 NTAPI
   15636 ZwOpenEvent(
   15637   OUT PHANDLE EventHandle,
   15638   IN ACCESS_MASK DesiredAccess,
   15639   IN POBJECT_ATTRIBUTES ObjectAttributes);
   15640 #endif
   15641 
   15642 #if (NTDDI_VERSION >= NTDDI_VISTA)
   15643 
   15644 NTSYSAPI
   15645 NTSTATUS
   15646 ZwCreateKeyTransacted(
   15647   OUT PHANDLE KeyHandle,
   15648   IN ACCESS_MASK DesiredAccess,
   15649   IN POBJECT_ATTRIBUTES ObjectAttributes,
   15650   IN ULONG TitleIndex,
   15651   IN PUNICODE_STRING Class OPTIONAL,
   15652   IN ULONG CreateOptions,
   15653   IN HANDLE TransactionHandle,
   15654   OUT PULONG Disposition OPTIONAL);
   15655 
   15656 NTSYSAPI
   15657 NTSTATUS
   15658 NTAPI
   15659 ZwOpenKeyTransacted(
   15660   OUT PHANDLE KeyHandle,
   15661   IN ACCESS_MASK DesiredAccess,
   15662   IN POBJECT_ATTRIBUTES ObjectAttributes,
   15663   IN HANDLE TransactionHandle);
   15664 
   15665 NTSYSCALLAPI
   15666 NTSTATUS
   15667 NTAPI
   15668 ZwCreateTransactionManager(
   15669   OUT PHANDLE TmHandle,
   15670   IN ACCESS_MASK DesiredAccess,
   15671   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15672   IN PUNICODE_STRING LogFileName OPTIONAL,
   15673   IN ULONG CreateOptions OPTIONAL,
   15674   IN ULONG CommitStrength OPTIONAL);
   15675 
   15676 NTSYSCALLAPI
   15677 NTSTATUS
   15678 NTAPI
   15679 ZwOpenTransactionManager(
   15680   OUT PHANDLE TmHandle,
   15681   IN ACCESS_MASK DesiredAccess,
   15682   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15683   IN PUNICODE_STRING LogFileName OPTIONAL,
   15684   IN LPGUID TmIdentity OPTIONAL,
   15685   IN ULONG OpenOptions OPTIONAL);
   15686 
   15687 NTSYSCALLAPI
   15688 NTSTATUS
   15689 NTAPI
   15690 ZwRollforwardTransactionManager(
   15691   IN HANDLE TransactionManagerHandle,
   15692   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15693 
   15694 NTSYSCALLAPI
   15695 NTSTATUS
   15696 NTAPI
   15697 ZwRecoverTransactionManager(
   15698   IN HANDLE TransactionManagerHandle);
   15699 
   15700 NTSYSCALLAPI
   15701 NTSTATUS
   15702 NTAPI
   15703 ZwQueryInformationTransactionManager(
   15704   IN HANDLE TransactionManagerHandle,
   15705   IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass,
   15706   OUT PVOID TransactionManagerInformation,
   15707   IN ULONG TransactionManagerInformationLength,
   15708   OUT PULONG ReturnLength OPTIONAL);
   15709 
   15710 NTSYSCALLAPI
   15711 NTSTATUS
   15712 NTAPI
   15713 ZwSetInformationTransactionManager(
   15714   IN HANDLE TmHandle,
   15715   IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass,
   15716   IN PVOID TransactionManagerInformation,
   15717   IN ULONG TransactionManagerInformationLength);
   15718 
   15719 NTSYSCALLAPI
   15720 NTSTATUS
   15721 NTAPI
   15722 ZwEnumerateTransactionObject(
   15723   IN HANDLE RootObjectHandle OPTIONAL,
   15724   IN KTMOBJECT_TYPE QueryType,
   15725   IN OUT PKTMOBJECT_CURSOR ObjectCursor,
   15726   IN ULONG ObjectCursorLength,
   15727   OUT PULONG ReturnLength);
   15728 
   15729 NTSYSCALLAPI
   15730 NTSTATUS
   15731 NTAPI
   15732 ZwCreateTransaction(
   15733   OUT PHANDLE TransactionHandle,
   15734   IN ACCESS_MASK DesiredAccess,
   15735   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15736   IN LPGUID Uow OPTIONAL,
   15737   IN HANDLE TmHandle OPTIONAL,
   15738   IN ULONG CreateOptions OPTIONAL,
   15739   IN ULONG IsolationLevel OPTIONAL,
   15740   IN ULONG IsolationFlags OPTIONAL,
   15741   IN PLARGE_INTEGER Timeout OPTIONAL,
   15742   IN PUNICODE_STRING Description OPTIONAL);
   15743 
   15744 NTSYSCALLAPI
   15745 NTSTATUS
   15746 NTAPI
   15747 ZwOpenTransaction(
   15748   OUT PHANDLE TransactionHandle,
   15749   IN ACCESS_MASK DesiredAccess,
   15750   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15751   IN LPGUID Uow,
   15752   IN HANDLE TmHandle OPTIONAL);
   15753 
   15754 NTSYSCALLAPI
   15755 NTSTATUS
   15756 NTAPI
   15757 ZwQueryInformationTransaction(
   15758   IN HANDLE TransactionHandle,
   15759   IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass,
   15760   OUT PVOID TransactionInformation,
   15761   IN ULONG TransactionInformationLength,
   15762   OUT PULONG ReturnLength OPTIONAL);
   15763 
   15764 NTSYSCALLAPI
   15765 NTSTATUS
   15766 NTAPI
   15767 ZwSetInformationTransaction(
   15768   IN HANDLE TransactionHandle,
   15769   IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass,
   15770   IN PVOID TransactionInformation,
   15771   IN ULONG TransactionInformationLength);
   15772 
   15773 NTSYSCALLAPI
   15774 NTSTATUS
   15775 NTAPI
   15776 ZwCommitTransaction(
   15777   IN HANDLE TransactionHandle,
   15778   IN BOOLEAN Wait);
   15779 
   15780 NTSYSCALLAPI
   15781 NTSTATUS
   15782 NTAPI
   15783 ZwRollbackTransaction(
   15784   IN HANDLE TransactionHandle,
   15785   IN BOOLEAN Wait);
   15786 
   15787 NTSYSCALLAPI
   15788 NTSTATUS
   15789 NTAPI
   15790 ZwCreateResourceManager(
   15791   OUT PHANDLE ResourceManagerHandle,
   15792   IN ACCESS_MASK DesiredAccess,
   15793   IN HANDLE TmHandle,
   15794   IN LPGUID ResourceManagerGuid OPTIONAL,
   15795   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15796   IN ULONG CreateOptions OPTIONAL,
   15797   IN PUNICODE_STRING Description OPTIONAL);
   15798 
   15799 NTSYSCALLAPI
   15800 NTSTATUS
   15801 NTAPI
   15802 ZwOpenResourceManager(
   15803   OUT PHANDLE ResourceManagerHandle,
   15804   IN ACCESS_MASK DesiredAccess,
   15805   IN HANDLE TmHandle,
   15806   IN LPGUID ResourceManagerGuid,
   15807   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL);
   15808 
   15809 NTSYSCALLAPI
   15810 NTSTATUS
   15811 NTAPI
   15812 ZwRecoverResourceManager(
   15813   IN HANDLE ResourceManagerHandle);
   15814 
   15815 NTSYSCALLAPI
   15816 NTSTATUS
   15817 NTAPI
   15818 ZwGetNotificationResourceManager(
   15819   IN HANDLE ResourceManagerHandle,
   15820   OUT PTRANSACTION_NOTIFICATION TransactionNotification,
   15821   IN ULONG NotificationLength,
   15822   IN PLARGE_INTEGER Timeout,
   15823   IN PULONG ReturnLength OPTIONAL,
   15824   IN ULONG Asynchronous,
   15825   IN ULONG_PTR AsynchronousContext OPTIONAL);
   15826 
   15827 NTSYSCALLAPI
   15828 NTSTATUS
   15829 NTAPI
   15830 ZwQueryInformationResourceManager(
   15831   IN HANDLE ResourceManagerHandle,
   15832   IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass,
   15833   OUT PVOID ResourceManagerInformation,
   15834   IN ULONG ResourceManagerInformationLength,
   15835   IN PULONG ReturnLength OPTIONAL);
   15836 
   15837 NTSYSCALLAPI
   15838 NTSTATUS
   15839 NTAPI
   15840 ZwSetInformationResourceManager(
   15841   IN HANDLE ResourceManagerHandle,
   15842   IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass,
   15843   IN PVOID ResourceManagerInformation,
   15844   IN ULONG ResourceManagerInformationLength);
   15845 
   15846 NTSYSCALLAPI
   15847 NTSTATUS
   15848 NTAPI
   15849 ZwCreateEnlistment(
   15850   OUT PHANDLE EnlistmentHandle,
   15851   IN ACCESS_MASK DesiredAccess,
   15852   IN HANDLE ResourceManagerHandle,
   15853   IN HANDLE TransactionHandle,
   15854   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   15855   IN ULONG CreateOptions OPTIONAL,
   15856   IN NOTIFICATION_MASK NotificationMask,
   15857   IN PVOID EnlistmentKey OPTIONAL);
   15858 
   15859 NTSYSCALLAPI
   15860 NTSTATUS
   15861 NTAPI
   15862 ZwOpenEnlistment(
   15863   OUT PHANDLE EnlistmentHandle,
   15864   IN ACCESS_MASK DesiredAccess,
   15865   IN HANDLE RmHandle,
   15866   IN LPGUID EnlistmentGuid,
   15867   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL);
   15868 
   15869 NTSYSCALLAPI
   15870 NTSTATUS
   15871 NTAPI
   15872 ZwQueryInformationEnlistment(
   15873   IN HANDLE EnlistmentHandle,
   15874   IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass,
   15875   OUT PVOID EnlistmentInformation,
   15876   IN ULONG EnlistmentInformationLength,
   15877   IN PULONG ReturnLength OPTIONAL);
   15878 
   15879 NTSYSCALLAPI
   15880 NTSTATUS
   15881 NTAPI
   15882 ZwSetInformationEnlistment(
   15883   IN HANDLE EnlistmentHandle,
   15884   IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass,
   15885   IN PVOID EnlistmentInformation,
   15886   IN ULONG EnlistmentInformationLength);
   15887 
   15888 NTSYSCALLAPI
   15889 NTSTATUS
   15890 NTAPI
   15891 ZwRecoverEnlistment(
   15892   IN HANDLE EnlistmentHandle,
   15893   IN PVOID EnlistmentKey OPTIONAL);
   15894 
   15895 NTSYSCALLAPI
   15896 NTSTATUS
   15897 NTAPI
   15898 ZwPrePrepareEnlistment(
   15899   IN HANDLE EnlistmentHandle,
   15900   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15901 
   15902 NTSYSCALLAPI
   15903 NTSTATUS
   15904 NTAPI
   15905 ZwPrepareEnlistment(
   15906   IN HANDLE EnlistmentHandle,
   15907   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15908 
   15909 NTSYSCALLAPI
   15910 NTSTATUS
   15911 NTAPI
   15912 ZwCommitEnlistment(
   15913   IN HANDLE EnlistmentHandle,
   15914   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15915 
   15916 NTSYSCALLAPI
   15917 NTSTATUS
   15918 NTAPI
   15919 ZwRollbackEnlistment(
   15920   IN HANDLE EnlistmentHandle,
   15921   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15922 
   15923 NTSYSCALLAPI
   15924 NTSTATUS
   15925 NTAPI
   15926 ZwPrePrepareComplete(
   15927   IN HANDLE EnlistmentHandle,
   15928   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15929 
   15930 NTSYSCALLAPI
   15931 NTSTATUS
   15932 NTAPI
   15933 ZwPrepareComplete(
   15934   IN HANDLE EnlistmentHandle,
   15935   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15936 
   15937 NTSYSCALLAPI
   15938 NTSTATUS
   15939 NTAPI
   15940 ZwCommitComplete(
   15941   IN HANDLE EnlistmentHandle,
   15942   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15943 
   15944 NTSYSCALLAPI
   15945 NTSTATUS
   15946 NTAPI
   15947 ZwReadOnlyEnlistment(
   15948   IN HANDLE EnlistmentHandle,
   15949   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15950 
   15951 NTSYSCALLAPI
   15952 NTSTATUS
   15953 NTAPI
   15954 ZwRollbackComplete(
   15955   IN HANDLE EnlistmentHandle,
   15956   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15957 
   15958 NTSYSCALLAPI
   15959 NTSTATUS
   15960 NTAPI
   15961 ZwSinglePhaseReject(
   15962   IN HANDLE EnlistmentHandle,
   15963   IN PLARGE_INTEGER TmVirtualClock OPTIONAL);
   15964 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
   15965 
   15966 #if (NTDDI_VERSION >= NTDDI_WIN7)
   15967 NTSYSAPI
   15968 NTSTATUS
   15969 NTAPI
   15970 ZwOpenKeyEx(
   15971   OUT PHANDLE KeyHandle,
   15972   IN ACCESS_MASK DesiredAccess,
   15973   IN POBJECT_ATTRIBUTES ObjectAttributes,
   15974   IN ULONG OpenOptions);
   15975 
   15976 NTSYSAPI
   15977 NTSTATUS
   15978 NTAPI
   15979 ZwOpenKeyTransactedEx(
   15980   OUT PHANDLE KeyHandle,
   15981   IN ACCESS_MASK DesiredAccess,
   15982   IN POBJECT_ATTRIBUTES ObjectAttributes,
   15983   IN ULONG OpenOptions,
   15984   IN HANDLE TransactionHandle);
   15985 
   15986 NTSYSAPI
   15987 NTSTATUS
   15988 NTAPI
   15989 ZwNotifyChangeMultipleKeys(
   15990   IN HANDLE MasterKeyHandle,
   15991   IN ULONG Count OPTIONAL,
   15992   IN OBJECT_ATTRIBUTES SubordinateObjects[] OPTIONAL,
   15993   IN HANDLE Event OPTIONAL,
   15994   IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
   15995   IN PVOID ApcContext OPTIONAL,
   15996   OUT PIO_STATUS_BLOCK IoStatusBlock,
   15997   IN ULONG CompletionFilter,
   15998   IN BOOLEAN WatchTree,
   15999   OUT PVOID Buffer OPTIONAL,
   16000   IN ULONG BufferSize,
   16001   IN BOOLEAN Asynchronous);
   16002 
   16003 NTSYSAPI
   16004 NTSTATUS
   16005 NTAPI
   16006 ZwQueryMultipleValueKey(
   16007   IN HANDLE KeyHandle,
   16008   IN OUT PKEY_VALUE_ENTRY ValueEntries,
   16009   IN ULONG EntryCount,
   16010   OUT PVOID ValueBuffer,
   16011   IN OUT PULONG BufferLength,
   16012   OUT PULONG RequiredBufferLength OPTIONAL);
   16013 
   16014 NTSYSAPI
   16015 NTSTATUS
   16016 NTAPI
   16017 ZwRenameKey(
   16018   IN HANDLE KeyHandle,
   16019   IN PUNICODE_STRING NewName);
   16020 
   16021 NTSYSAPI
   16022 NTSTATUS
   16023 NTAPI
   16024 ZwSetInformationKey(
   16025   IN HANDLE KeyHandle,
   16026   IN KEY_SET_INFORMATION_CLASS KeySetInformationClass,
   16027   IN PVOID KeySetInformation,
   16028   IN ULONG KeySetInformationLength);
   16029 
   16030 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   16031 
   16032 #ifdef __cplusplus
   16033 }
   16034 #endif
   16035 
   16036 #endif /* !_WDMDDK_ */
   16037