Recommit rest of ntifs.h and wdm.h from header merge revert
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 21 Apr 2010 01:12:04 +0000 (01:12 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 21 Apr 2010 01:12:04 +0000 (01:12 +0000)
svn path=/trunk/; revision=46972

reactos/include/ddk/ntddk.h
reactos/include/ddk/ntifs.h
reactos/include/ddk/wdm.h

index 6d8bacd..5556969 100644 (file)
@@ -2957,6 +2957,159 @@ ZwSetTimer(
 
 #endif
 
+typedef struct _QUOTA_LIMITS {
+  SIZE_T PagedPoolLimit;
+  SIZE_T NonPagedPoolLimit;
+  SIZE_T MinimumWorkingSetSize;
+  SIZE_T MaximumWorkingSetSize;
+  SIZE_T PagefileLimit;
+  LARGE_INTEGER TimeLimit;
+} QUOTA_LIMITS, *PQUOTA_LIMITS;
+
+struct _RTL_GENERIC_COMPARE_ROUTINE;
+struct _RTL_GENERIC_ALLOCATE_ROUTINE;
+struct _RTL_GENERIC_FREE_ROUTINE;
+
+typedef struct _RTL_GENERIC_TABLE {
+  PRTL_SPLAY_LINKS TableRoot;
+  LIST_ENTRY InsertOrderList;
+  PLIST_ENTRY OrderedPointer;
+  ULONG WhichOrderedElement;
+  ULONG NumberGenericTableElements;
+  struct _RTL_GENERIC_COMPARE_ROUTINE *CompareRoutine;
+  struct _RTL_GENERIC_ALLOCATE_ROUTINE *AllocateRoutine;
+  struct _RTL_GENERIC_FREE_ROUTINE *FreeRoutine;
+  PVOID TableContext;
+} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
+
+typedef enum _TABLE_SEARCH_RESULT {
+  TableEmptyTree,
+  TableFoundNode,
+  TableInsertAsLeft,
+  TableInsertAsRight
+} TABLE_SEARCH_RESULT;
+
+typedef struct _FILE_FS_SIZE_INFORMATION {
+  LARGE_INTEGER TotalAllocationUnits;
+  LARGE_INTEGER AvailableAllocationUnits;
+  ULONG SectorsPerAllocationUnit;
+  ULONG BytesPerSector;
+} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
+
+#define IO_CHECK_CREATE_PARAMETERS      0x0200
+#define IO_ATTACH_DEVICE                0x0400
+#define IO_IGNORE_SHARE_ACCESS_CHECK    0x0800
+
+typedef struct _FILE_FS_VOLUME_INFORMATION {
+  LARGE_INTEGER VolumeCreationTime;
+  ULONG VolumeSerialNumber;
+  ULONG VolumeLabelLength;
+  BOOLEAN SupportsObjects;
+  WCHAR VolumeLabel[1];
+} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
+
+typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
+  LARGE_INTEGER TotalAllocationUnits;
+  LARGE_INTEGER CallerAvailableAllocationUnits;
+  LARGE_INTEGER ActualAvailableAllocationUnits;
+  ULONG SectorsPerAllocationUnit;
+  ULONG BytesPerSector;
+} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
+
+typedef struct _FILE_FS_OBJECTID_INFORMATION {
+  UCHAR ObjectId[16];
+  UCHAR ExtendedInfo[48];
+} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
+
+typedef struct _FILE_FS_LABEL_INFORMATION {
+  ULONG VolumeLabelLength;
+  WCHAR VolumeLabel[1];
+} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
+
+typedef enum _RTL_GENERIC_COMPARE_RESULTS {
+  GenericLessThan,
+  GenericGreaterThan,
+  GenericEqual
+} RTL_GENERIC_COMPARE_RESULTS;
+
+// Forwarder
+struct _RTL_AVL_TABLE;
+
+typedef RTL_GENERIC_COMPARE_RESULTS
+(NTAPI *PRTL_AVL_COMPARE_ROUTINE) (
+  IN struct _RTL_AVL_TABLE *Table,
+  IN PVOID FirstStruct,
+  IN PVOID SecondStruct);
+
+typedef PVOID
+(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) (
+  IN struct _RTL_AVL_TABLE *Table,
+  IN CLONG ByteSize);
+
+typedef VOID
+(NTAPI *PRTL_AVL_FREE_ROUTINE) (
+  IN struct _RTL_AVL_TABLE *Table,
+  IN PVOID Buffer);
+
+typedef NTSTATUS
+(NTAPI *PRTL_AVL_MATCH_FUNCTION) (
+  IN struct _RTL_AVL_TABLE *Table,
+  IN PVOID UserData,
+  IN PVOID MatchData);
+
+typedef struct _RTL_BALANCED_LINKS {
+  struct _RTL_BALANCED_LINKS *Parent;
+  struct _RTL_BALANCED_LINKS *LeftChild;
+  struct _RTL_BALANCED_LINKS *RightChild;
+  CHAR Balance;
+  UCHAR Reserved[3];
+} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
+
+typedef struct _RTL_AVL_TABLE {
+  RTL_BALANCED_LINKS BalancedRoot;
+  PVOID OrderedPointer;
+  ULONG WhichOrderedElement;
+  ULONG NumberGenericTableElements;
+  ULONG DepthOfTree;
+  PRTL_BALANCED_LINKS RestartKey;
+  ULONG DeleteCount;
+  PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
+  PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
+  PRTL_AVL_FREE_ROUTINE FreeRoutine;
+  PVOID TableContext;
+} RTL_AVL_TABLE, *PRTL_AVL_TABLE;
+
+#ifndef RTL_USE_AVL_TABLES
+
+struct _RTL_GENERIC_TABLE;
+
+typedef RTL_GENERIC_COMPARE_RESULTS
+(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) (
+  IN struct _RTL_GENERIC_TABLE *Table,
+  IN PVOID FirstStruct,
+  IN PVOID SecondStruct);
+
+typedef PVOID
+(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) (
+  IN struct _RTL_GENERIC_TABLE *Table,
+  IN CLONG ByteSize);
+
+typedef VOID
+(NTAPI *PRTL_GENERIC_FREE_ROUTINE) (
+  IN struct _RTL_GENERIC_TABLE *Table,
+  IN PVOID Buffer);
+
+#endif /* !RTL_USE_AVL_TABLES */
+
+NTSYSAPI
+VOID
+NTAPI
+RtlInitializeGenericTableAvl(
+  OUT PRTL_AVL_TABLE Table,
+  IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine,
+  IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine,
+  IN PRTL_AVL_FREE_ROUTINE FreeRoutine,
+  IN PVOID TableContext OPTIONAL);
 
 #ifdef __cplusplus
 }
index 8af993f..15bace8 100644 (file)
@@ -6750,145 +6750,6 @@ FsRtlDeleteTunnelCache(
   IN PTUNNEL Cache);
 
 NTKERNELAPI
-#define IO_ATTACH_DEVICE                0x0400
-struct _RTL_AVL_TABLE;
-struct _RTL_GENERIC_TABLE;
-
-typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
-    LARGE_INTEGER   TotalAllocationUnits;
-    LARGE_INTEGER   CallerAvailableAllocationUnits;
-    LARGE_INTEGER   ActualAvailableAllocationUnits;
-    ULONG           SectorsPerAllocationUnit;
-    ULONG           BytesPerSector;
-} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
-
-typedef struct _FILE_FS_LABEL_INFORMATION {
-    ULONG VolumeLabelLength;
-    WCHAR VolumeLabel[1];
-} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
-
-typedef struct _FILE_FS_SIZE_INFORMATION {
-    LARGE_INTEGER   TotalAllocationUnits;
-    LARGE_INTEGER   AvailableAllocationUnits;
-    ULONG           SectorsPerAllocationUnit;
-    ULONG           BytesPerSector;
-} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
-
-typedef struct _FILE_FS_VOLUME_INFORMATION {
-    LARGE_INTEGER   VolumeCreationTime;
-    ULONG           VolumeSerialNumber;
-    ULONG           VolumeLabelLength;
-    BOOLEAN         SupportsObjects;
-    WCHAR           VolumeLabel[1];
-} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
-
-typedef struct _FILE_FS_OBJECTID_INFORMATION
-{
-    UCHAR ObjectId[16];
-    UCHAR ExtendedInfo[48];
-} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
-
-typedef enum _RTL_GENERIC_COMPARE_RESULTS
-{
-    GenericLessThan,
-    GenericGreaterThan,
-    GenericEqual
-} RTL_GENERIC_COMPARE_RESULTS;
-
-typedef enum _TABLE_SEARCH_RESULT
-{
-    TableEmptyTree,
-    TableFoundNode,
-    TableInsertAsLeft,
-    TableInsertAsRight
-} TABLE_SEARCH_RESULT;
-
-typedef RTL_GENERIC_COMPARE_RESULTS
-(NTAPI *PRTL_AVL_COMPARE_ROUTINE) (
-    struct _RTL_AVL_TABLE *Table,
-    PVOID FirstStruct,
-    PVOID SecondStruct
-);
-
-typedef RTL_GENERIC_COMPARE_RESULTS
-(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) (
-    struct _RTL_GENERIC_TABLE *Table,
-    PVOID FirstStruct,
-    PVOID SecondStruct
-);
-
-typedef PVOID
-(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) (
-    struct _RTL_GENERIC_TABLE *Table,
-    CLONG ByteSize
-);
-
-typedef VOID
-(NTAPI *PRTL_GENERIC_FREE_ROUTINE) (
-    struct _RTL_GENERIC_TABLE *Table,
-    PVOID Buffer
-);
-
-typedef PVOID
-(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) (
-    struct _RTL_AVL_TABLE *Table,
-    CLONG ByteSize
-);
-
-typedef VOID
-(NTAPI *PRTL_AVL_FREE_ROUTINE) (
-    struct _RTL_AVL_TABLE *Table,
-    PVOID Buffer
-);
-
-typedef struct _RTL_BALANCED_LINKS
-{
-    struct _RTL_BALANCED_LINKS *Parent;
-    struct _RTL_BALANCED_LINKS *LeftChild;
-    struct _RTL_BALANCED_LINKS *RightChild;
-    CHAR Balance;
-    UCHAR Reserved[3];
-} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
-
-typedef struct _RTL_GENERIC_TABLE
-{
-    PRTL_SPLAY_LINKS TableRoot;
-    LIST_ENTRY InsertOrderList;
-    PLIST_ENTRY OrderedPointer;
-    ULONG WhichOrderedElement;
-    ULONG NumberGenericTableElements;
-    PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine;
-    PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine;
-    PRTL_GENERIC_FREE_ROUTINE FreeRoutine;
-    PVOID TableContext;
-} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
-
-typedef struct _RTL_AVL_TABLE
-{
-    RTL_BALANCED_LINKS BalancedRoot;
-    PVOID OrderedPointer;
-    ULONG WhichOrderedElement;
-    ULONG NumberGenericTableElements;
-    ULONG DepthOfTree;
-    PRTL_BALANCED_LINKS RestartKey;
-    ULONG DeleteCount;
-    PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
-    PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
-    PRTL_AVL_FREE_ROUTINE FreeRoutine;
-    PVOID TableContext;
-} RTL_AVL_TABLE, *PRTL_AVL_TABLE;
-
-NTSYSAPI
-VOID
-NTAPI
-RtlInitializeGenericTableAvl(
-    PRTL_AVL_TABLE Table,
-    PRTL_AVL_COMPARE_ROUTINE CompareRoutine,
-    PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine,
-    PRTL_AVL_FREE_ROUTINE FreeRoutine,
-    PVOID TableContext
-);
-
 VOID
 NTAPI
 FsRtlDissectDbcs(
index 285d216..3a52323 100644 (file)
 #include <excpt.h>
 #include <ntdef.h>
 #include <ntstatus.h>
+#include <ntiologc.h>
 
 #ifndef GUID_DEFINED
 #include <guiddef.h>
 #endif
 
+#ifdef _MAC
+#ifndef _INC_STRING
+#include <string.h>
+#endif /* _INC_STRING */
+#else
+#include <string.h>
+#endif /* _MAC */
+
 #ifndef _KTMTYPES_
 typedef GUID UOW, *PUOW;
 #endif
 
+typedef GUID *PGUID;
+
 #if (NTDDI_VERSION >= NTDDI_WINXP)
 #include <dpfilter.h>
 #endif
@@ -133,8 +144,6 @@ struct _IO_RESOURCE_DESCRIPTOR;
 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE;
 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE;
-typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
-typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; 
 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
 typedef struct _EPROCESS *PEPROCESS;
 typedef struct _ETHREAD *PETHREAD;
@@ -144,6 +153,42 @@ typedef struct _KPROCESS *PKPROCESS;
 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
 typedef struct _CONTEXT *PCONTEXT;
 
+#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && ( defined(_NTDDK_) || defined(_NTDRIVER_) || defined(_NTOSP_))
+typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
+#elif defined(_WDM_INCLUDED_)
+typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
+#else
+typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; 
+#endif
+
+#ifndef DEFINE_GUIDEX
+#ifdef _MSC_VER
+#define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
+#else
+#define DEFINE_GUIDEX(name) EXTERN_C const GUID name
+#endif
+#endif /* DEFINE_GUIDEX */
+
+#ifndef STATICGUIDOF
+#define STATICGUIDOF(guid) STATIC_##guid
+#endif
+
+/* GUID Comparison */
+#ifndef __IID_ALIGNED__
+#define __IID_ALIGNED__
+#ifdef __cplusplus
+inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2)
+{
+    return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && 
+             (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) );
+}
+#else
+#define IsEqualGUIDAligned(guid1, guid2) \
+           ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \
+             (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) )
+#endif /* __cplusplus */
+#endif /* !__IID_ALIGNED__ */
+
 
 /******************************************************************************
  *                           INTERLOCKED Functions                            *
@@ -482,17 +527,29 @@ typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32;
 
 #endif /* _SLIST_HEADER_ */
 
-
-/* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
-#if defined(_NTSYSTEM_) || defined(__GNUC__)
+/* MS definition is broken! */
+extern BOOLEAN NTSYSAPI NlsMbCodePageTag;
+extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag;
 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
-#else
-#define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
-#define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
-#endif /* _NT_SYSTEM */
-extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG;
-extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG;
+
+#define SHORT_LEAST_SIGNIFICANT_BIT       0
+#define SHORT_MOST_SIGNIFICANT_BIT        1
+
+#define LONG_LEAST_SIGNIFICANT_BIT        0
+#define LONG_3RD_MOST_SIGNIFICANT_BIT     1
+#define LONG_2ND_MOST_SIGNIFICANT_BIT     2
+#define LONG_MOST_SIGNIFICANT_BIT         3
+
+#define RTLVERLIB_DDI(x) Wdmlib##x
+
+typedef BOOLEAN
+(*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)(
+  IN ULONG Version);
+
+typedef BOOLEAN
+(*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)(
+  IN ULONG Version);
 
 
 /******************************************************************************
@@ -503,14 +560,21 @@ typedef UCHAR KIRQL, *PKIRQL;
 typedef CCHAR KPROCESSOR_MODE;
 typedef LONG KPRIORITY;
 
-typedef ULONG EXECUTION_STATE;
-
 typedef enum _MODE {
   KernelMode,
   UserMode,
   MaximumMode
 } MODE;
 
+#define CACHE_FULLY_ASSOCIATIVE 0xFF
+#define MAXIMUM_SUSPEND_COUNT   MAXCHAR
+
+#define EVENT_QUERY_STATE (0x0001)
+#define EVENT_MODIFY_STATE (0x0002)
+#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
+
+#define LTP_PC_SMT 0x1
+
 #if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS)
 #define SINGLE_GROUP_LEGACY_API        1
 #endif
@@ -543,6 +607,69 @@ typedef struct _CACHE_DESCRIPTOR {
   PROCESSOR_CACHE_TYPE Type;
 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
 
+typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION {
+  ULONG_PTR ProcessorMask;
+  LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
+  union {
+    struct {
+      UCHAR Flags;
+    } ProcessorCore;
+    struct {
+      ULONG NodeNumber;
+    } NumaNode;
+    CACHE_DESCRIPTOR Cache;
+    ULONGLONG  Reserved[2];
+  } DUMMYUNIONNAME;
+} SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
+
+typedef struct _PROCESSOR_RELATIONSHIP {
+  UCHAR Flags;
+  UCHAR Reserved[21];
+  USHORT GroupCount;
+  GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
+} PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
+
+typedef struct _NUMA_NODE_RELATIONSHIP {
+  ULONG NodeNumber;
+  UCHAR Reserved[20];
+  GROUP_AFFINITY GroupMask;
+} NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
+
+typedef struct _CACHE_RELATIONSHIP {
+  UCHAR Level;
+  UCHAR Associativity;
+  USHORT LineSize;
+  ULONG CacheSize;
+  PROCESSOR_CACHE_TYPE Type;
+  UCHAR Reserved[20];
+  GROUP_AFFINITY GroupMask;
+} CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
+
+typedef struct _PROCESSOR_GROUP_INFO {
+  UCHAR MaximumProcessorCount;
+  UCHAR ActiveProcessorCount;
+  UCHAR Reserved[38];
+  KAFFINITY ActiveProcessorMask;
+} PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
+
+typedef struct _GROUP_RELATIONSHIP {
+  USHORT MaximumGroupCount;
+  USHORT ActiveGroupCount;
+  UCHAR Reserved[20];
+  PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
+} GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
+
+typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX {
+  LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
+  ULONG Size;
+  union {
+    PROCESSOR_RELATIONSHIP Processor;
+    NUMA_NODE_RELATIONSHIP NumaNode;
+    CACHE_RELATIONSHIP Cache;
+    GROUP_RELATIONSHIP Group;
+  } DUMMYUNIONNAME;
+} SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;;
+
 /* Processor features */
 #define PF_FLOATING_POINT_PRECISION_ERRATA  0   
 #define PF_FLOATING_POINT_EMULATED          1   
@@ -563,7 +690,6 @@ typedef struct _CACHE_DESCRIPTOR {
 #define PF_CHANNELS_ENABLED                16   
 #define PF_XSAVE_ENABLED                   17   
 
-#define MAXIMUM_SUPPORTED_EXTENSION  512
 #define MAXIMUM_WAIT_OBJECTS              64
 
 #define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject)
@@ -631,6 +757,23 @@ typedef struct _CACHE_DESCRIPTOR {
 #define EXCEPTION_NONCONTINUABLE 1
 #define EXCEPTION_MAXIMUM_PARAMETERS 15
 
+#define EXCEPTION_DIVIDED_BY_ZERO       0
+#define EXCEPTION_DEBUG                 1
+#define EXCEPTION_NMI                   2
+#define EXCEPTION_INT3                  3
+#define EXCEPTION_BOUND_CHECK           5
+#define EXCEPTION_INVALID_OPCODE        6
+#define EXCEPTION_NPX_NOT_AVAILABLE     7
+#define EXCEPTION_DOUBLE_FAULT          8
+#define EXCEPTION_NPX_OVERRUN           9
+#define EXCEPTION_INVALID_TSS           0x0A
+#define EXCEPTION_SEGMENT_NOT_PRESENT   0x0B
+#define EXCEPTION_STACK_FAULT           0x0C
+#define EXCEPTION_GP_FAULT              0x0D
+#define EXCEPTION_RESERVED_TRAP         0x0F
+#define EXCEPTION_NPX_ERROR             0x010
+#define EXCEPTION_ALIGNMENT_CHECK       0x011
+
 typedef struct _EXCEPTION_RECORD {
     NTSTATUS ExceptionCode;
     ULONG ExceptionFlags;
@@ -682,6 +825,42 @@ typedef VOID
   IN ULONG  ReasonSpecificDataLength);
 typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE;
 
+typedef struct _KBUGCHECK_ADD_PAGES {
+  IN OUT PVOID Context;
+  IN OUT ULONG Flags;
+  IN ULONG BugCheckCode;
+  OUT ULONG_PTR Address;
+  OUT ULONG_PTR Count;
+} KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES;
+
+typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA {
+  IN PVOID InBuffer;
+  IN ULONG InBufferLength;
+  IN ULONG MaximumAllowed;
+  OUT GUID Guid;
+  OUT PVOID OutBuffer;
+  OUT ULONG OutBufferLength;
+} KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA;
+
+typedef enum _KBUGCHECK_DUMP_IO_TYPE {
+  KbDumpIoInvalid,
+  KbDumpIoHeader,
+  KbDumpIoBody,
+  KbDumpIoSecondaryData,
+  KbDumpIoComplete
+} KBUGCHECK_DUMP_IO_TYPE;
+
+typedef struct _KBUGCHECK_DUMP_IO {
+  IN ULONG64 Offset;
+  IN PVOID Buffer;
+  IN ULONG BufferLength;
+  IN KBUGCHECK_DUMP_IO_TYPE Type;
+} KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO;
+
+#define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS         0x00000001UL
+#define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS        0x00000002UL
+#define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL
+
 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
   LIST_ENTRY  Entry;
   PKBUGCHECK_REASON_CALLBACK_ROUTINE  CallbackRoutine;
@@ -721,20 +900,31 @@ typedef BOOLEAN
     IN BOOLEAN Handled);
 typedef NMI_CALLBACK *PNMI_CALLBACK;
 
-typedef enum _TRACE_INFORMATION_CLASS {
-  TraceIdClass,
-  TraceHandleClass,
-  TraceEnableFlagsClass,
-  TraceEnableLevelClass,
-  GlobalLoggerHandleClass,
-  EventLoggerHandleClass,
-  AllLoggerHandlesClass,
-  TraceHandleByNameClass,
-  LoggerEventsLostClass,
-  TraceSessionSettingsClass,
-  LoggerEventsLoggedClass,
-  MaxTraceInformationClass
-} TRACE_INFORMATION_CLASS;
+typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE {
+  KeProcessorAddStartNotify = 0,
+  KeProcessorAddCompleteNotify,
+  KeProcessorAddFailureNotify
+} KE_PROCESSOR_CHANGE_NOTIFY_STATE;
+
+typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT {
+  KE_PROCESSOR_CHANGE_NOTIFY_STATE State;
+  ULONG NtNumber;
+  NTSTATUS Status;
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+  PROCESSOR_NUMBER ProcNumber;
+#endif
+} KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT;
+
+typedef VOID
+(NTAPI PROCESSOR_CALLBACK_FUNCTION)(
+  IN PVOID CallbackContext,
+  IN PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext,
+  IN OUT PNTSTATUS OperationStatus);
+typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION;
+
+#define KE_PROCESSOR_CHANGE_ADD_EXISTING         1
+
+#define INVALID_PROCESSOR_INDEX     0xffffffff
 
 typedef enum _KINTERRUPT_POLARITY {
   InterruptPolarityUnknown,
@@ -831,36 +1021,32 @@ typedef enum _KINTERRUPT_MODE {
 
 #define THREAD_WAIT_OBJECTS 3
 
+typedef VOID
+(NTAPI KSTART_ROUTINE)(
+  IN PVOID StartContext);
+typedef KSTART_ROUTINE *PKSTART_ROUTINE;
+
 typedef VOID
 (NTAPI *PKINTERRUPT_ROUTINE)(
   VOID);
 
+typedef BOOLEAN
+(NTAPI KSERVICE_ROUTINE)(
+  IN struct _KINTERRUPT *Interrupt,
+  IN PVOID ServiceContext);
+typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
+
+typedef BOOLEAN
+(NTAPI KMESSAGE_SERVICE_ROUTINE)(
+  IN struct _KINTERRUPT *Interrupt,
+  IN PVOID ServiceContext,
+  IN ULONG MessageID);
+typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE;
+
 typedef enum _KD_OPTION {
     KD_OPTION_SET_BLOCK_ENABLE,
 } KD_OPTION;
 
-typedef enum _INTERFACE_TYPE {
-  InterfaceTypeUndefined = -1,
-  Internal,
-  Isa,
-  Eisa,
-  MicroChannel,
-  TurboChannel,
-  PCIBus,
-  VMEBus,
-  NuBus,
-  PCMCIABus,
-  CBus,
-  MPIBus,
-  MPSABus,
-  ProcessorInternal,
-  InternalPowerBus,
-  PNPISABus,
-  PNPBus,
-  Vmcs,
-  MaximumInterfaceType
-} INTERFACE_TYPE, *PINTERFACE_TYPE;
-
 typedef VOID
 (NTAPI *PKNORMAL_ROUTINE)(
   IN PVOID NormalContext OPTIONAL,
@@ -898,6 +1084,14 @@ typedef struct _KAPC {
   BOOLEAN Inserted;
 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
 
+#define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0)
+#define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1)
+#define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0)
+#define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1)
+#define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2)
+#define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex)
+#define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN))
+
 typedef struct _KDEVICE_QUEUE_ENTRY {
   LIST_ENTRY  DeviceListEntry;
   ULONG  SortKey;
@@ -914,10 +1108,27 @@ typedef VOID
   IN PVOID Parameter2 OPTIONAL,
   IN PVOID Parameter3 OPTIONAL);
 
-typedef
-ULONG_PTR
-(NTAPI *PKIPI_BROADCAST_WORKER)(
+typedef struct _KIPI_COUNTS {
+  ULONG Freeze;
+  ULONG Packet;
+  ULONG DPC;
+  ULONG APC;
+  ULONG FlushSingleTb;
+  ULONG FlushMultipleTb;
+  ULONG FlushEntireTb;
+  ULONG GenericCall;
+  ULONG ChangeColor;
+  ULONG SweepDcache;
+  ULONG SweepIcache;
+  ULONG SweepIcacheRange;
+  ULONG FlushIoBuffers;
+  ULONG GratuitousDPC;
+} KIPI_COUNTS, *PKIPI_COUNTS;
+
+typedef ULONG_PTR
+(NTAPI KIPI_BROADCAST_WORKER)(
     IN ULONG_PTR Argument);
+typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER;
 
 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
 
@@ -1116,6 +1327,8 @@ typedef struct _KSEMAPHORE {
     LONG Limit;
 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
 
+#define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG))
+
 typedef struct _KGATE {
     DISPATCHER_HEADER Header;
 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
@@ -1156,6 +1369,14 @@ typedef struct _KTIMER {
   ULONG Period;
 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
 
+typedef enum _LOCK_OPERATION {
+  IoReadAccess,
+  IoWriteAccess,
+  IoModifyAccess
+} LOCK_OPERATION;
+
+#define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG))
+
 typedef BOOLEAN
 (NTAPI *PKSYNCHRONIZE_ROUTINE)(
   IN PVOID  SynchronizeContext);
@@ -1184,19 +1405,32 @@ typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE {
     EndAlternatives
 } ALTERNATIVE_ARCHITECTURE_TYPE;
 
-typedef struct _KSYSTEM_TIME
-{
+#ifndef _X86_
+
+#ifndef IsNEC_98
+#define IsNEC_98 (FALSE)
+#endif
+
+#ifndef IsNotNEC_98
+#define IsNotNEC_98 (TRUE)
+#endif
+
+#ifndef SetNEC_98
+#define SetNEC_98
+#endif
+
+#ifndef SetNotNEC_98
+#define SetNotNEC_98
+#endif
+
+#endif
+
+typedef struct _KSYSTEM_TIME {
     ULONG LowPart;
     LONG High1Time;
     LONG High2Time;
 } KSYSTEM_TIME, *PKSYSTEM_TIME;
 
-typedef struct _PNP_BUS_INFORMATION {
-  GUID  BusTypeGuid;
-  INTERFACE_TYPE  LegacyBusType;
-  ULONG  BusNumber;
-} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
-
 typedef struct DECLSPEC_ALIGN(16) _M128A {
     ULONGLONG Low;
     LONGLONG High;
@@ -1228,12 +1462,104 @@ typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT {
 #endif
 } XSAVE_FORMAT, *PXSAVE_FORMAT;
 
+typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER {
+  ULONG64 Mask;
+  ULONG64 Reserved[7];
+} XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER;
+
+typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA {
+  XSAVE_FORMAT LegacyState;
+  XSAVE_AREA_HEADER Header;
+} XSAVE_AREA, *PXSAVE_AREA;
+
+typedef struct _XSTATE_CONTEXT {
+  ULONG64 Mask;
+  ULONG Length;
+  ULONG Reserved1;
+  PXSAVE_AREA Area;
+#if defined(_X86_)
+  ULONG Reserved2;
+#endif
+  PVOID Buffer;
+#if defined(_X86_)
+  ULONG Reserved3;
+#endif
+} XSTATE_CONTEXT, *PXSTATE_CONTEXT;
+
+typedef struct _XSTATE_SAVE {
+#if defined(_AMD64_)
+  struct _XSTATE_SAVE* Prev;
+  struct _KTHREAD* Thread;
+  UCHAR Level;
+  XSTATE_CONTEXT XStateContext;
+#elif defined(_IA64_)
+  ULONG Dummy;
+#elif defined(_X86_)
+  union {
+    struct {
+      LONG64 Reserved1;
+      ULONG Reserved2;
+      struct _XSTATE_SAVE* Prev;
+      PXSAVE_AREA Reserved3;
+      struct _KTHREAD* Thread;
+      PVOID Reserved4;
+      UCHAR Level;
+    };
+    XSTATE_CONTEXT XStateContext;
+  };
+#endif
+} XSTATE_SAVE, *PXSTATE_SAVE;
+
+#ifdef _X86_
+
+#define MAXIMUM_SUPPORTED_EXTENSION  512
+
+#if !defined(__midl) && !defined(MIDL_PASS)
+C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION);
+#endif
+
+#endif /* _X86_ */
+
+#define XSAVE_ALIGN                    64
+#define MINIMAL_XSTATE_AREA_LENGTH     sizeof(XSAVE_AREA)
+
+#if !defined(__midl) && !defined(MIDL_PASS)
+C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0);
+C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0);
+C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64);
+#endif
+
+typedef struct _CONTEXT_CHUNK {
+  LONG Offset;
+  ULONG Length;
+} CONTEXT_CHUNK, *PCONTEXT_CHUNK;
+
+typedef struct _CONTEXT_EX {
+  CONTEXT_CHUNK All;
+  CONTEXT_CHUNK Legacy;
+  CONTEXT_CHUNK XState;
+} CONTEXT_EX, *PCONTEXT_EX;
+
+#define CONTEXT_EX_LENGTH         ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN)
+
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+extern NTSYSAPI volatile CCHAR KeNumberProcessors;
+#elif (NTDDI_VERSION >= NTDDI_WINXP)
+extern NTSYSAPI CCHAR KeNumberProcessors;
+#else
+extern PCCHAR KeNumberProcessors;
+#endif
 
 
 /******************************************************************************
  *                         Memory manager Types                               *
  ******************************************************************************/
 
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
+typedef ULONG NODE_REQUIREMENT;
+#define MM_ANY_NODE_OK                           0x80000000
+#endif
+
 #define MM_DONT_ZERO_ALLOCATION                 0x00000001
 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY        0x00000002
 #define MM_ALLOCATE_FULLY_REQUIRED              0x00000004
@@ -1362,12 +1688,6 @@ typedef enum _MM_PAGE_PRIORITY {
   HighPagePriority = 32
 } MM_PAGE_PRIORITY;
 
-typedef enum _LOCK_OPERATION {
-  IoReadAccess,
-  IoWriteAccess,
-  IoModifyAccess
-} LOCK_OPERATION;
-
 typedef enum _MM_SYSTEM_SIZE {
   MmSmallSystem,
   MmMediumSystem,
@@ -1386,12 +1706,6 @@ extern PVOID MmBadPointer;
 #define EX_RUNDOWN_COUNT_SHIFT            0x1
 #define EX_RUNDOWN_COUNT_INC              (1 << EX_RUNDOWN_COUNT_SHIFT)
 
-#ifdef _WIN64
-#define PORT_MAXIMUM_MESSAGE_LENGTH 512
-#else
-#define PORT_MAXIMUM_MESSAGE_LENGTH 256
-#endif
-
 typedef struct _FAST_MUTEX {
   volatile LONG Count;
   PKTHREAD Owner;
@@ -1563,6 +1877,13 @@ typedef struct _EX_RUNDOWN_REF {
 
 typedef struct _EX_RUNDOWN_REF_CACHE_AWARE  *PEX_RUNDOWN_REF_CACHE_AWARE;
 
+typedef enum _WORK_QUEUE_TYPE {
+  CriticalWorkQueue,
+  DelayedWorkQueue,
+  HyperCriticalWorkQueue,
+  MaximumWorkQueue
+} WORK_QUEUE_TYPE;
+
 typedef VOID
 (NTAPI WORKER_THREAD_ROUTINE)(
   IN PVOID Parameter);
@@ -1574,6 +1895,78 @@ typedef struct _WORK_QUEUE_ITEM {
   volatile PVOID  Parameter;
 } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
 
+typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
+
+typedef struct _OWNER_ENTRY {
+  ERESOURCE_THREAD OwnerThread;
+  union {
+    struct {
+      ULONG IoPriorityBoosted:1;
+      ULONG OwnerReferenced:1;
+      ULONG OwnerCount:30;
+    };
+    ULONG TableSize;
+  };
+} OWNER_ENTRY, *POWNER_ENTRY;
+
+typedef struct _ERESOURCE {
+  LIST_ENTRY SystemResourcesList;
+  POWNER_ENTRY OwnerTable;
+  SHORT ActiveCount;
+  USHORT Flag;
+  volatile PKSEMAPHORE SharedWaiters;
+  volatile PKEVENT ExclusiveWaiters;
+  OWNER_ENTRY OwnerEntry;
+  ULONG ActiveEntries;
+  ULONG ContentionCount;
+  ULONG NumberOfSharedWaiters;
+  ULONG NumberOfExclusiveWaiters;
+#if defined(_WIN64)
+  PVOID Reserved2;
+#endif
+  __GNU_EXTENSION union {
+    PVOID Address;
+    ULONG_PTR CreatorBackTraceIndex;
+  };
+  KSPIN_LOCK SpinLock;
+} ERESOURCE, *PERESOURCE;
+
+/* ERESOURCE.Flag */
+#define ResourceNeverExclusive            0x0010
+#define ResourceReleaseByOtherThread      0x0020
+#define ResourceOwnedExclusive            0x0080
+
+#define RESOURCE_HASH_TABLE_SIZE          64
+
+typedef struct _RESOURCE_HASH_ENTRY {
+  LIST_ENTRY ListEntry;
+  PVOID Address;
+  ULONG ContentionCount;
+  ULONG Number;
+} RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY;
+
+typedef struct _RESOURCE_PERFORMANCE_DATA {
+  ULONG ActiveResourceCount;
+  ULONG TotalResourceCount;
+  ULONG ExclusiveAcquire;
+  ULONG SharedFirstLevel;
+  ULONG SharedSecondLevel;
+  ULONG StarveFirstLevel;
+  ULONG StarveSecondLevel;
+  ULONG WaitForExclusive;
+  ULONG OwnerTableExpands;
+  ULONG MaximumTableExpand;
+  LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE];
+} RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA;
+
+/* Global debug flag */
+#if DEVL
+extern ULONG NtGlobalFlag;
+#define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName))
+#else
+#define IF_NTOS_DEBUG(FlagName) if(FALSE)
+#endif
+
 
 /******************************************************************************
  *                            Security Manager Types                          *
@@ -2000,28 +2393,166 @@ typedef enum _POWER_STATE_TYPE {
   DevicePowerState
 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
 
-#if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
-typedef struct {
-    ULONG Granularity;
-    ULONG Capacity;
-} BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
-#endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+typedef struct _SYSTEM_POWER_STATE_CONTEXT {
+  union {
+    struct {
+      ULONG Reserved1:8;
+      ULONG TargetSystemState:4;
+      ULONG EffectiveSystemState:4;
+      ULONG CurrentSystemState:4;
+      ULONG IgnoreHibernationPath:1;
+      ULONG PseudoTransition:1;
+      ULONG Reserved2:10;
+    } DUMMYSTRUCTNAME;
+    ULONG ContextAsUlong;
+  } DUMMYUNIONNAME;
+} SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT;
+#endif
 
-#endif /* !_PO_DDK_ */
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+typedef struct _COUNTED_REASON_CONTEXT {
+  ULONG Version;
+  ULONG Flags;
+  union {
+    struct {
+      UNICODE_STRING ResourceFileName;
+      USHORT ResourceReasonId;
+      ULONG StringCount;
+      PUNICODE_STRING ReasonStrings;
+    } DUMMYSTRUCTNAME;
+    UNICODE_STRING SimpleString;
+  } DUMMYUNIONNAME;
+} COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT;
+#endif
 
-#define CORE_PARKING_POLICY_CHANGE_IDEAL         0
-#define CORE_PARKING_POLICY_CHANGE_SINGLE        1
-#define CORE_PARKING_POLICY_CHANGE_ROCKET        2
-#define CORE_PARKING_POLICY_CHANGE_MAX           CORE_PARKING_POLICY_CHANGE_ROCKET
+#define IOCTL_QUERY_DEVICE_POWER_STATE  \
+        CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS)
 
-DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A );
-DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C );
-DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E );
-DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 );
-DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 );
-DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 );
-DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 );
-DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 );
+#define IOCTL_SET_DEVICE_WAKE           \
+        CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
+
+#define IOCTL_CANCEL_DEVICE_WAKE        \
+        CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
+
+#define ES_SYSTEM_REQUIRED                       0x00000001
+#define ES_DISPLAY_REQUIRED                      0x00000002
+#define ES_USER_PRESENT                          0x00000004
+#define ES_CONTINUOUS                            0x80000000
+
+typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE;
+
+typedef enum {
+  LT_DONT_CARE,
+  LT_LOWEST_LATENCY
+} LATENCY_TIME;
+
+#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
+#define DIAGNOSTIC_REASON_VERSION                0
+#define DIAGNOSTIC_REASON_SIMPLE_STRING          0x00000001
+#define DIAGNOSTIC_REASON_DETAILED_STRING        0x00000002
+#define DIAGNOSTIC_REASON_NOT_SPECIFIED          0x80000000
+#define DIAGNOSTIC_REASON_INVALID_FLAGS          (~0x80000003)
+#endif
+
+#define POWER_REQUEST_CONTEXT_VERSION            0
+#define POWER_REQUEST_CONTEXT_SIMPLE_STRING      0x00000001
+#define POWER_REQUEST_CONTEXT_DETAILED_STRING    0x00000002
+
+#define PowerRequestMaximum                      3
+
+typedef enum _POWER_REQUEST_TYPE {
+  PowerRequestDisplayRequired,
+  PowerRequestSystemRequired,
+  PowerRequestAwayModeRequired
+} POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
+
+#if (NTDDI_VERSION >= NTDDI_WINXP)
+
+#define PDCAP_D0_SUPPORTED                       0x00000001
+#define PDCAP_D1_SUPPORTED                       0x00000002
+#define PDCAP_D2_SUPPORTED                       0x00000004
+#define PDCAP_D3_SUPPORTED                       0x00000008
+#define PDCAP_WAKE_FROM_D0_SUPPORTED             0x00000010
+#define PDCAP_WAKE_FROM_D1_SUPPORTED             0x00000020
+#define PDCAP_WAKE_FROM_D2_SUPPORTED             0x00000040
+#define PDCAP_WAKE_FROM_D3_SUPPORTED             0x00000080
+#define PDCAP_WARM_EJECT_SUPPORTED               0x00000100
+
+typedef struct CM_Power_Data_s {
+  ULONG PD_Size;
+  DEVICE_POWER_STATE PD_MostRecentPowerState;
+  ULONG PD_Capabilities;
+  ULONG PD_D1Latency;
+  ULONG PD_D2Latency;
+  ULONG PD_D3Latency;
+  DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
+  SYSTEM_POWER_STATE PD_DeepestSystemWake;
+} CM_POWER_DATA, *PCM_POWER_DATA;
+
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
+
+typedef enum _SYSTEM_POWER_CONDITION {
+  PoAc,
+  PoDc,
+  PoHot,
+  PoConditionMaximum
+} SYSTEM_POWER_CONDITION;
+
+typedef struct _SET_POWER_SETTING_VALUE {
+  ULONG Version;
+  GUID Guid;
+  SYSTEM_POWER_CONDITION PowerCondition;
+  ULONG DataLength;
+  UCHAR Data[ANYSIZE_ARRAY];
+} SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE;
+
+#define POWER_SETTING_VALUE_VERSION              (0x1)
+
+typedef struct _NOTIFY_USER_POWER_SETTING {
+  GUID Guid;
+} NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING;
+
+typedef struct _APPLICATIONLAUNCH_SETTING_VALUE {
+  LARGE_INTEGER ActivationTime;
+  ULONG Flags;
+  ULONG ButtonInstanceID;
+} APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE;
+
+typedef enum _POWER_PLATFORM_ROLE {
+  PlatformRoleUnspecified = 0,
+  PlatformRoleDesktop,
+  PlatformRoleMobile,
+  PlatformRoleWorkstation,
+  PlatformRoleEnterpriseServer,
+  PlatformRoleSOHOServer,
+  PlatformRoleAppliancePC,
+  PlatformRolePerformanceServer,
+  PlatformRoleMaximum
+} POWER_PLATFORM_ROLE;
+
+#if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
+typedef struct {
+    ULONG Granularity;
+    ULONG Capacity;
+} BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
+
+#endif /* !_PO_DDK_ */
+
+#define CORE_PARKING_POLICY_CHANGE_IDEAL         0
+#define CORE_PARKING_POLICY_CHANGE_SINGLE        1
+#define CORE_PARKING_POLICY_CHANGE_ROCKET        2
+#define CORE_PARKING_POLICY_CHANGE_MAX           CORE_PARKING_POLICY_CHANGE_ROCKET
+
+DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A );
+DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C );
+DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E );
+DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 );
+DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 );
+DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 );
+DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 );
+DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 );
 DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E );
 DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63 );
 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64 );
@@ -2153,12 +2684,6 @@ NTSTATUS
   IN OUT PVOID Context OPTIONAL);
 typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK;
 
-#define PO_CB_SYSTEM_POWER_POLICY       0
-#define PO_CB_AC_STATUS                 1
-#define PO_CB_BUTTON_COLLISION          2
-#define PO_CB_SYSTEM_STATE_LOCK         3
-#define PO_CB_LID_SWITCH_STATE          4
-#define PO_CB_PROCESSOR_POWER_POLICY    5
 
 /******************************************************************************
  *                            Configuration Manager Types                     *
@@ -2250,6 +2775,15 @@ typedef int CM_RESOURCE_TYPE;
                  REG_OPTION_BACKUP_RESTORE      |\
                  REG_OPTION_OPEN_LINK)
 
+#define REG_OPEN_LEGAL_OPTION       \
+                (REG_OPTION_RESERVED            |\
+                 REG_OPTION_BACKUP_RESTORE      |\
+                 REG_OPTION_OPEN_LINK)
+
+#define REG_STANDARD_FORMAT            1
+#define REG_LATEST_FORMAT              2
+#define REG_NO_COMPRESSION             4
+
 /* Key creation/open disposition */
 #define REG_CREATED_NEW_KEY         (0x00000001L)
 #define REG_OPENED_EXISTING_KEY     (0x00000002L)
@@ -2282,27 +2816,6 @@ typedef int CM_RESOURCE_TYPE;
                  REG_NOTIFY_CHANGE_LAST_SET      |\
                  REG_NOTIFY_CHANGE_SECURITY)
 
-typedef struct _CM_FLOPPY_DEVICE_DATA {
-  USHORT  Version;
-  USHORT  Revision;
-  CHAR  Size[8];
-  ULONG  MaxDensity;
-  ULONG  MountDensity;
-  UCHAR  StepRateHeadUnloadTime;
-  UCHAR  HeadLoadTime;
-  UCHAR  MotorOffTime;
-  UCHAR  SectorLengthCode;
-  UCHAR  SectorPerTrack;
-  UCHAR  ReadWriteGapLength;
-  UCHAR  DataTransferLength;
-  UCHAR  FormatGapLength;
-  UCHAR  FormatFillCharacter;
-  UCHAR  HeadSettleTime;
-  UCHAR  MotorSettleTime;
-  UCHAR  MaximumTrackValue;
-  UCHAR  DataTransferRate;
-} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
-
 #include <pshpack4.h>
 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
   UCHAR Type;
@@ -2469,6 +2982,50 @@ typedef enum _CM_SHARE_DISPOSITION {
 #define CM_RESOURCE_DMA_TYPE_B            0x0020
 #define CM_RESOURCE_DMA_TYPE_F            0x0040
 
+typedef struct _DEVICE_FLAGS {
+  ULONG Failed:1;
+  ULONG ReadOnly:1;
+  ULONG Removable:1;
+  ULONG ConsoleIn:1;
+  ULONG ConsoleOut:1;
+  ULONG Input:1;
+  ULONG Output:1;
+} DEVICE_FLAGS, *PDEVICE_FLAGS;
+
+typedef enum _INTERFACE_TYPE {
+  InterfaceTypeUndefined = -1,
+  Internal,
+  Isa,
+  Eisa,
+  MicroChannel,
+  TurboChannel,
+  PCIBus,
+  VMEBus,
+  NuBus,
+  PCMCIABus,
+  CBus,
+  MPIBus,
+  MPSABus,
+  ProcessorInternal,
+  InternalPowerBus,
+  PNPISABus,
+  PNPBus,
+  Vmcs,
+  MaximumInterfaceType
+} INTERFACE_TYPE, *PINTERFACE_TYPE;
+
+typedef struct _CM_COMPONENT_INFORMATION {
+  DEVICE_FLAGS Flags;
+  ULONG Version;
+  ULONG Key;
+  KAFFINITY AffinityMask;
+} CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
+
+typedef struct _CM_ROM_BLOCK {
+  ULONG Address;
+  ULONG Size;
+} CM_ROM_BLOCK, *PCM_ROM_BLOCK;
+
 typedef struct _CM_PARTIAL_RESOURCE_LIST {
   USHORT  Version;
   USHORT  Revision;
@@ -2487,6 +3044,12 @@ typedef struct _CM_RESOURCE_LIST {
   CM_FULL_RESOURCE_DESCRIPTOR  List[1];
 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
 
+typedef struct _PNP_BUS_INFORMATION {
+  GUID BusTypeGuid;
+  INTERFACE_TYPE LegacyBusType;
+  ULONG BusNumber;
+} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
+
 #include <pshpack1.h>
 
 typedef struct _CM_INT13_DRIVE_PARAMETER {
@@ -2497,6 +3060,14 @@ typedef struct _CM_INT13_DRIVE_PARAMETER {
   USHORT  NumberDrives;
 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
 
+typedef struct _CM_MCA_POS_DATA {
+  USHORT AdapterId;
+  UCHAR PosData1;
+  UCHAR PosData2;
+  UCHAR PosData3;
+  UCHAR PosData4;
+} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
+
 typedef struct _CM_PNP_BIOS_DEVICE_NODE {
   USHORT Size;
   UCHAR Node;
@@ -2538,50 +3109,82 @@ typedef struct _CM_KEYBOARD_DEVICE_DATA {
   USHORT  KeyboardFlags;
 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
 
-typedef struct _CM_MCA_POS_DATA {
-  USHORT  AdapterId;
-  UCHAR  PosData1;
-  UCHAR  PosData2;
-  UCHAR  PosData3;
-  UCHAR  PosData4;
-} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
-
-#if (NTDDI_VERSION >= NTDDI_WINXP)
-typedef struct CM_Power_Data_s {
-  ULONG  PD_Size;
-  DEVICE_POWER_STATE  PD_MostRecentPowerState;
-  ULONG  PD_Capabilities;
-  ULONG  PD_D1Latency;
-  ULONG  PD_D2Latency;
-  ULONG  PD_D3Latency;
-  DEVICE_POWER_STATE  PD_PowerStateMapping[PowerSystemMaximum];
-  SYSTEM_POWER_STATE  PD_DeepestSystemWake;
-} CM_POWER_DATA, *PCM_POWER_DATA;
-
-#define PDCAP_D0_SUPPORTED                0x00000001
-#define PDCAP_D1_SUPPORTED                0x00000002
-#define PDCAP_D2_SUPPORTED                0x00000004
-#define PDCAP_D3_SUPPORTED                0x00000008
-#define PDCAP_WAKE_FROM_D0_SUPPORTED      0x00000010
-#define PDCAP_WAKE_FROM_D1_SUPPORTED      0x00000020
-#define PDCAP_WAKE_FROM_D2_SUPPORTED      0x00000040
-#define PDCAP_WAKE_FROM_D3_SUPPORTED      0x00000080
-#define PDCAP_WARM_EJECT_SUPPORTED        0x00000100
-
-#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
-
 typedef struct _CM_SCSI_DEVICE_DATA {
   USHORT  Version;
   USHORT  Revision;
   UCHAR  HostIdentifier;
 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
 
+typedef struct _CM_VIDEO_DEVICE_DATA {
+  USHORT Version;
+  USHORT Revision;
+  ULONG VideoClock;
+} CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA;
+
+typedef struct _CM_SONIC_DEVICE_DATA {
+  USHORT Version;
+  USHORT Revision;
+  USHORT DataConfigurationRegister;
+  UCHAR EthernetAddress[8];
+} CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA;
+
 typedef struct _CM_SERIAL_DEVICE_DATA {
   USHORT  Version;
   USHORT  Revision;
   ULONG  BaudClock;
 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
 
+typedef struct _CM_MONITOR_DEVICE_DATA {
+  USHORT Version;
+  USHORT Revision;
+  USHORT HorizontalScreenSize;
+  USHORT VerticalScreenSize;
+  USHORT HorizontalResolution;
+  USHORT VerticalResolution;
+  USHORT HorizontalDisplayTimeLow;
+  USHORT HorizontalDisplayTime;
+  USHORT HorizontalDisplayTimeHigh;
+  USHORT HorizontalBackPorchLow;
+  USHORT HorizontalBackPorch;
+  USHORT HorizontalBackPorchHigh;
+  USHORT HorizontalFrontPorchLow;
+  USHORT HorizontalFrontPorch;
+  USHORT HorizontalFrontPorchHigh;
+  USHORT HorizontalSyncLow;
+  USHORT HorizontalSync;
+  USHORT HorizontalSyncHigh;
+  USHORT VerticalBackPorchLow;
+  USHORT VerticalBackPorch;
+  USHORT VerticalBackPorchHigh;
+  USHORT VerticalFrontPorchLow;
+  USHORT VerticalFrontPorch;
+  USHORT VerticalFrontPorchHigh;
+  USHORT VerticalSyncLow;
+  USHORT VerticalSync;
+  USHORT VerticalSyncHigh;
+} CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA;
+
+typedef struct _CM_FLOPPY_DEVICE_DATA {
+  USHORT Version;
+  USHORT Revision;
+  CHAR Size[8];
+  ULONG MaxDensity;
+  ULONG MountDensity;
+  UCHAR StepRateHeadUnloadTime;
+  UCHAR HeadLoadTime;
+  UCHAR MotorOffTime;
+  UCHAR SectorLengthCode;
+  UCHAR SectorPerTrack;
+  UCHAR ReadWriteGapLength;
+  UCHAR DataTransferLength;
+  UCHAR FormatGapLength;
+  UCHAR FormatFillCharacter;
+  UCHAR HeadSettleTime;
+  UCHAR MotorSettleTime;
+  UCHAR MaximumTrackValue;
+  UCHAR DataTransferRate;
+} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
+
 typedef enum _KEY_INFORMATION_CLASS {
   KeyBasicInformation,
   KeyNodeInformation,
@@ -2601,6 +3204,10 @@ typedef struct _KEY_BASIC_INFORMATION {
   WCHAR  Name[1];
 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
 
+typedef struct _KEY_CONTROL_FLAGS_INFORMATION {
+  ULONG ControlFlags;
+} KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION;
+
 typedef struct _KEY_FULL_INFORMATION {
   LARGE_INTEGER  LastWriteTime;
   ULONG  TitleIndex;
@@ -2615,6 +3222,10 @@ typedef struct _KEY_FULL_INFORMATION {
   WCHAR  Class[1];
 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
 
+typedef struct _KEY_HANDLE_TAGS_INFORMATION {
+  ULONG HandleTags;
+} KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION;
+
 typedef struct _KEY_NODE_INFORMATION {
   LARGE_INTEGER  LastWriteTime;
   ULONG  TitleIndex;
@@ -2624,6 +3235,23 @@ typedef struct _KEY_NODE_INFORMATION {
   WCHAR  Name[1];
 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
 
+typedef enum _KEY_SET_INFORMATION_CLASS {
+  KeyWriteTimeInformation,
+  KeyWow64FlagsInformation,
+  KeyControlFlagsInformation,
+  KeySetVirtualizationInformation,
+  KeySetDebugInformation,
+  KeySetHandleTagsInformation,
+  MaxKeySetInfoClass
+} KEY_SET_INFORMATION_CLASS;
+
+typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION {
+  ULONG VirtualTarget:1;
+  ULONG VirtualStore:1;
+  ULONG VirtualSource:1;
+  ULONG Reserved:29;
+} KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION;
+
 typedef struct _KEY_VALUE_BASIC_INFORMATION {
   ULONG  TitleIndex;
   ULONG  Type;
@@ -2668,20 +3296,14 @@ typedef enum _KEY_VALUE_INFORMATION_CLASS {
   KeyValuePartialInformationAlign64
 } KEY_VALUE_INFORMATION_CLASS;
 
+typedef struct _KEY_WOW64_FLAGS_INFORMATION {
+  ULONG UserFlags;
+} KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION;
+
 typedef struct _KEY_WRITE_TIME_INFORMATION {
   LARGE_INTEGER  LastWriteTime;
 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
 
-typedef enum _KEY_SET_INFORMATION_CLASS {
-  KeyWriteTimeInformation,
-  KeyWow64FlagsInformation,
-  KeyControlFlagsInformation,
-  KeySetVirtualizationInformation,
-  KeySetDebugInformation,
-  KeySetHandleTagsInformation,
-  MaxKeySetInfoClass
-} KEY_SET_INFORMATION_CLASS;
-
 typedef enum _REG_NOTIFY_CLASS {
   RegNtDeleteKey,
   RegNtPreDeleteKey = RegNtDeleteKey,
@@ -2851,6 +3473,54 @@ typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION {
   PVOID Reserved;
 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
 
+typedef struct _REG_RENAME_KEY_INFORMATION {
+  PVOID Object;
+  PUNICODE_STRING NewName;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION;
+
+typedef struct _REG_CREATE_KEY_INFORMATION {
+  PUNICODE_STRING CompleteName;
+  PVOID RootObject;
+  PVOID ObjectType;
+  ULONG CreateOptions;
+  PUNICODE_STRING Class;
+  PVOID SecurityDescriptor;
+  PVOID SecurityQualityOfService;
+  ACCESS_MASK DesiredAccess;
+  ACCESS_MASK GrantedAccess;
+  PULONG Disposition;
+  PVOID *ResultObject;
+  PVOID CallContext;
+  PVOID RootObjectContext;
+  PVOID Transaction;
+  PVOID Reserved;
+} REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION;
+
+typedef struct _REG_CREATE_KEY_INFORMATION_V1 {
+  PUNICODE_STRING CompleteName;
+  PVOID RootObject;
+  PVOID ObjectType;
+  ULONG Options;
+  PUNICODE_STRING Class;
+  PVOID SecurityDescriptor;
+  PVOID SecurityQualityOfService;
+  ACCESS_MASK DesiredAccess;
+  ACCESS_MASK GrantedAccess;
+  PULONG Disposition;
+  PVOID *ResultObject;
+  PVOID CallContext;
+  PVOID RootObjectContext;
+  PVOID Transaction;
+  ULONG_PTR Version;
+  PUNICODE_STRING RemainingName;
+  ULONG Wow64Flags;
+  ULONG Attributes;
+  KPROCESSOR_MODE CheckAccessMode;
+} REG_CREATE_KEY_INFORMATION_V1, REG_OPEN_KEY_INFORMATION_V1,*PREG_CREATE_KEY_INFORMATION_V1, *PREG_OPEN_KEY_INFORMATION_V1;
+
 typedef struct _REG_PRE_CREATE_KEY_INFORMATION {
   PUNICODE_STRING CompleteName;
 } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;;
@@ -2878,142 +3548,83 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION {
   PVOID Reserved;
 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
 
-/******************************************************************************
- *                         I/O Manager Types                                  *
- ******************************************************************************/
-
- /* PCI_COMMON_CONFIG.Command */
-#define PCI_ENABLE_IO_SPACE               0x0001
-#define PCI_ENABLE_MEMORY_SPACE           0x0002
-#define PCI_ENABLE_BUS_MASTER             0x0004
-#define PCI_ENABLE_SPECIAL_CYCLES         0x0008
-#define PCI_ENABLE_WRITE_AND_INVALIDATE   0x0010
-#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
-#define PCI_ENABLE_PARITY                 0x0040
-#define PCI_ENABLE_WAIT_CYCLE             0x0080
-#define PCI_ENABLE_SERR                   0x0100
-#define PCI_ENABLE_FAST_BACK_TO_BACK      0x0200
-#define PCI_DISABLE_LEVEL_INTERRUPT       0x0400
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 
-/* PCI_COMMON_CONFIG.Status */
-#define PCI_STATUS_INTERRUPT_PENDING      0x0008
-#define PCI_STATUS_CAPABILITIES_LIST      0x0010
-#define PCI_STATUS_66MHZ_CAPABLE          0x0020
-#define PCI_STATUS_UDF_SUPPORTED          0x0040
-#define PCI_STATUS_FAST_BACK_TO_BACK      0x0080
-#define PCI_STATUS_DATA_PARITY_DETECTED   0x0100
-#define PCI_STATUS_DEVSEL                 0x0600
-#define PCI_STATUS_SIGNALED_TARGET_ABORT  0x0800
-#define PCI_STATUS_RECEIVED_TARGET_ABORT  0x1000
-#define PCI_STATUS_RECEIVED_MASTER_ABORT  0x2000
-#define PCI_STATUS_SIGNALED_SYSTEM_ERROR  0x4000
-#define PCI_STATUS_DETECTED_PARITY_ERROR  0x8000
+typedef struct _REG_LOAD_KEY_INFORMATION {
+  PVOID Object;
+  PUNICODE_STRING KeyName;
+  PUNICODE_STRING SourceFile;
+  ULONG Flags;
+  PVOID TrustClassObject;
+  PVOID UserEvent;
+  ACCESS_MASK DesiredAccess;
+  PHANDLE RootHandle;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_LOAD_KEY_INFORMATION, *PREG_LOAD_KEY_INFORMATION;
 
-/* PCI_COMMON_CONFIG.HeaderType */
-#define PCI_MULTIFUNCTION                 0x80
-#define PCI_DEVICE_TYPE                   0x00
-#define PCI_BRIDGE_TYPE                   0x01
-#define PCI_CARDBUS_BRIDGE_TYPE           0x02
+typedef struct _REG_UNLOAD_KEY_INFORMATION {
+  PVOID Object;
+  PVOID UserEvent;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_UNLOAD_KEY_INFORMATION, *PREG_UNLOAD_KEY_INFORMATION;
 
-#define PCI_CONFIGURATION_TYPE(PciData) \
-  (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
+typedef struct _REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION {
+  PVOID Object;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION, *PREG_CALLBACK_CONTEXT_CLEANUP_INFORMATION;
 
-#define PCI_MULTIFUNCTION_DEVICE(PciData) \
-  ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
+typedef struct _REG_QUERY_KEY_SECURITY_INFORMATION {
+  PVOID Object;
+  PSECURITY_INFORMATION SecurityInformation;
+  PSECURITY_DESCRIPTOR SecurityDescriptor;
+  PULONG Length;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_QUERY_KEY_SECURITY_INFORMATION, *PREG_QUERY_KEY_SECURITY_INFORMATION;
 
-/* PCI device classes */
-#define PCI_CLASS_PRE_20                    0x00
-#define PCI_CLASS_MASS_STORAGE_CTLR         0x01
-#define PCI_CLASS_NETWORK_CTLR              0x02
-#define PCI_CLASS_DISPLAY_CTLR              0x03
-#define PCI_CLASS_MULTIMEDIA_DEV            0x04
-#define PCI_CLASS_MEMORY_CTLR               0x05
-#define PCI_CLASS_BRIDGE_DEV                0x06
-#define PCI_CLASS_SIMPLE_COMMS_CTLR         0x07
-#define PCI_CLASS_BASE_SYSTEM_DEV           0x08
-#define PCI_CLASS_INPUT_DEV                 0x09
-#define PCI_CLASS_DOCKING_STATION           0x0a
-#define PCI_CLASS_PROCESSOR                 0x0b
-#define PCI_CLASS_SERIAL_BUS_CTLR           0x0c
-#define PCI_CLASS_WIRELESS_CTLR             0x0d
-#define PCI_CLASS_INTELLIGENT_IO_CTLR       0x0e
-#define PCI_CLASS_SATELLITE_COMMS_CTLR      0x0f
-#define PCI_CLASS_ENCRYPTION_DECRYPTION     0x10
-#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC      0x11
+typedef struct _REG_SET_KEY_SECURITY_INFORMATION {
+  PVOID Object;
+  PSECURITY_INFORMATION SecurityInformation;
+  PSECURITY_DESCRIPTOR SecurityDescriptor;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_SET_KEY_SECURITY_INFORMATION, *PREG_SET_KEY_SECURITY_INFORMATION;
 
-/* PCI device subclasses for class 0 */
-#define PCI_SUBCLASS_PRE_20_NON_VGA         0x00
-#define PCI_SUBCLASS_PRE_20_VGA             0x01
+typedef struct _REG_RESTORE_KEY_INFORMATION {
+  PVOID Object;
+  HANDLE FileHandle;
+  ULONG Flags;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_RESTORE_KEY_INFORMATION, *PREG_RESTORE_KEY_INFORMATION;
 
-/* PCI device subclasses for class 1 (mass storage controllers)*/
-#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR      0x00
-#define PCI_SUBCLASS_MSC_IDE_CTLR           0x01
-#define PCI_SUBCLASS_MSC_FLOPPY_CTLR        0x02
-#define PCI_SUBCLASS_MSC_IPI_CTLR           0x03
-#define PCI_SUBCLASS_MSC_RAID_CTLR          0x04
-#define PCI_SUBCLASS_MSC_OTHER              0x80
+typedef struct _REG_SAVE_KEY_INFORMATION {
+  PVOID Object;
+  HANDLE FileHandle;
+  ULONG Format;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_SAVE_KEY_INFORMATION, *PREG_SAVE_KEY_INFORMATION;
 
-/* PCI device subclasses for class 2 (network controllers)*/
-#define PCI_SUBCLASS_NET_ETHERNET_CTLR      0x00
-#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR    0x01
-#define PCI_SUBCLASS_NET_FDDI_CTLR          0x02
-#define PCI_SUBCLASS_NET_ATM_CTLR           0x03
-#define PCI_SUBCLASS_NET_ISDN_CTLR          0x04
-#define PCI_SUBCLASS_NET_OTHER              0x80
+typedef struct _REG_REPLACE_KEY_INFORMATION {
+  PVOID Object;
+  PUNICODE_STRING OldFileName;
+  PUNICODE_STRING NewFileName;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_REPLACE_KEY_INFORMATION, *PREG_REPLACE_KEY_INFORMATION;
 
-/* PCI device subclasses for class 3 (display controllers)*/
-#define PCI_SUBCLASS_VID_VGA_CTLR           0x00
-#define PCI_SUBCLASS_VID_XGA_CTLR           0x01
-#define PCI_SUBCLASS_VID_3D_CTLR            0x02
-#define PCI_SUBCLASS_VID_OTHER              0x80
-
-/* PCI device subclasses for class 4 (multimedia device)*/
-#define PCI_SUBCLASS_MM_VIDEO_DEV           0x00
-#define PCI_SUBCLASS_MM_AUDIO_DEV           0x01
-#define PCI_SUBCLASS_MM_TELEPHONY_DEV       0x02
-#define PCI_SUBCLASS_MM_OTHER               0x80
-
-/* PCI device subclasses for class 5 (memory controller)*/
-#define PCI_SUBCLASS_MEM_RAM                0x00
-#define PCI_SUBCLASS_MEM_FLASH              0x01
-#define PCI_SUBCLASS_MEM_OTHER              0x80
-
-/* PCI device subclasses for class 6 (bridge device)*/
-#define PCI_SUBCLASS_BR_HOST                0x00
-#define PCI_SUBCLASS_BR_ISA                 0x01
-#define PCI_SUBCLASS_BR_EISA                0x02
-#define PCI_SUBCLASS_BR_MCA                 0x03
-#define PCI_SUBCLASS_BR_PCI_TO_PCI          0x04
-#define PCI_SUBCLASS_BR_PCMCIA              0x05
-#define PCI_SUBCLASS_BR_NUBUS               0x06
-#define PCI_SUBCLASS_BR_CARDBUS             0x07
-#define PCI_SUBCLASS_BR_RACEWAY             0x08
-#define PCI_SUBCLASS_BR_OTHER               0x80
-
-/* PCI device subclasses for class C (serial bus controller)*/
-#define PCI_SUBCLASS_SB_IEEE1394            0x00
-#define PCI_SUBCLASS_SB_ACCESS              0x01
-#define PCI_SUBCLASS_SB_SSA                 0x02
-#define PCI_SUBCLASS_SB_USB                 0x03
-#define PCI_SUBCLASS_SB_FIBRE_CHANNEL       0x04
-#define PCI_SUBCLASS_SB_SMBUS               0x05
-
-#define PCI_MAX_DEVICES        32
-#define PCI_MAX_FUNCTION       8
-#define PCI_MAX_BRIDGE_NUMBER  0xFF
-#define PCI_INVALID_VENDORID   0xFFFF
-#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
-
-#define PCI_ADDRESS_IO_SPACE                0x00000001
-#define PCI_ADDRESS_MEMORY_TYPE_MASK        0x00000006
-#define PCI_ADDRESS_MEMORY_PREFETCHABLE     0x00000008
-#define PCI_ADDRESS_IO_ADDRESS_MASK         0xfffffffc
-#define PCI_ADDRESS_MEMORY_ADDRESS_MASK     0xfffffff0
-#define PCI_ADDRESS_ROM_ADDRESS_MASK        0xfffff800
-
-#define PCI_TYPE_32BIT 0
-#define PCI_TYPE_20BIT 2
-#define PCI_TYPE_64BIT 4
+#endif /* NTDDI_VERSION >= NTDDI_VISTA */
 
 #define SERVICE_KERNEL_DRIVER          0x00000001
 #define SERVICE_FILE_SYSTEM_DRIVER     0x00000002
@@ -3080,14 +3691,37 @@ typedef enum _CM_ERROR_CONTROL_TYPE {
                                          CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD |  \
                                          CM_SERVICE_USB_DISK_BOOT_LOAD)
 
+/******************************************************************************
+ *                         I/O Manager Types                                  *
+ ******************************************************************************/
+
+#define WDM_MAJORVERSION        0x06
+#define WDM_MINORVERSION        0x00
+
+#if defined(_WIN64)
+
+#ifndef USE_DMA_MACROS
+#define USE_DMA_MACROS
+#endif
+
+#ifndef NO_LEGACY_DRIVERS
+#define NO_LEGACY_DRIVERS
+#endif
+
+#endif /* defined(_WIN64) */
+
+#define STATUS_CONTINUE_COMPLETION      STATUS_SUCCESS
+
+#define CONNECT_FULLY_SPECIFIED         0x1
+#define CONNECT_LINE_BASED              0x2
+#define CONNECT_MESSAGE_BASED           0x3
+#define CONNECT_FULLY_SPECIFIED_GROUP   0x4
+#define CONNECT_CURRENT_VERSION         0x4
+
 #define POOL_COLD_ALLOCATION                256
 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE    8
 #define POOL_RAISE_IF_ALLOCATION_FAILURE    16
 
-#define PCI_TYPE0_ADDRESSES               6
-#define PCI_TYPE1_ADDRESSES               2
-#define PCI_TYPE2_ADDRESSES               5
-
 #define IO_TYPE_ADAPTER                 1
 #define IO_TYPE_CONTROLLER              2
 #define IO_TYPE_DEVICE                  3
@@ -3111,47 +3745,6 @@ typedef enum _CM_ERROR_CONTROL_TYPE {
 #define IO_RESOURCE_DEFAULT               0x02
 #define IO_RESOURCE_ALTERNATIVE           0x08
 
-/* DEVICE_OBJECT.Flags */
-#define DO_VERIFY_VOLUME                  0x00000002
-#define DO_BUFFERED_IO                    0x00000004
-#define DO_EXCLUSIVE                      0x00000008
-#define DO_DIRECT_IO                      0x00000010
-#define DO_MAP_IO_BUFFER                  0x00000020
-#define DO_DEVICE_INITIALIZING            0x00000080
-#define DO_SHUTDOWN_REGISTERED            0x00000800
-#define DO_BUS_ENUMERATED_DEVICE          0x00001000
-#define DO_POWER_PAGABLE                  0x00002000
-#define DO_POWER_INRUSH                   0x00004000
-
-/* DEVICE_OBJECT.Characteristics */
-#define FILE_REMOVABLE_MEDIA              0x00000001
-#define FILE_READ_ONLY_DEVICE             0x00000002
-#define FILE_FLOPPY_DISKETTE              0x00000004
-#define FILE_WRITE_ONCE_MEDIA             0x00000008
-#define FILE_REMOTE_DEVICE                0x00000010
-#define FILE_DEVICE_IS_MOUNTED            0x00000020
-#define FILE_VIRTUAL_VOLUME               0x00000040
-#define FILE_AUTOGENERATED_DEVICE_NAME    0x00000080
-#define FILE_DEVICE_SECURE_OPEN           0x00000100
-#define FILE_CHARACTERISTIC_PNP_DEVICE    0x00000800
-#define FILE_CHARACTERISTIC_TS_DEVICE     0x00001000
-#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000
-
-/* DEVICE_OBJECT.AlignmentRequirement */
-#define FILE_BYTE_ALIGNMENT             0x00000000
-#define FILE_WORD_ALIGNMENT             0x00000001
-#define FILE_LONG_ALIGNMENT             0x00000003
-#define FILE_QUAD_ALIGNMENT             0x00000007
-#define FILE_OCTA_ALIGNMENT             0x0000000f
-#define FILE_32_BYTE_ALIGNMENT          0x0000001f
-#define FILE_64_BYTE_ALIGNMENT          0x0000003f
-#define FILE_128_BYTE_ALIGNMENT         0x0000007f
-#define FILE_256_BYTE_ALIGNMENT         0x000000ff
-#define FILE_512_BYTE_ALIGNMENT         0x000001ff
-
-/* DEVICE_OBJECT.DeviceType */
-#define DEVICE_TYPE ULONG
-
 #define FILE_DEVICE_BEEP                  0x00000001
 #define FILE_DEVICE_CD_ROM                0x00000002
 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM    0x00000003
@@ -3220,6 +3813,44 @@ typedef enum _CM_ERROR_CONTROL_TYPE {
 #define FILE_DEVICE_BIOMETRIC             0x00000044
 #define FILE_DEVICE_PMI                   0x00000045
 
+#if defined(NT_PROCESSOR_GROUPS)
+
+typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
+
+typedef enum _IRQ_DEVICE_POLICY_USHORT {
+  IrqPolicyMachineDefault = 0,
+  IrqPolicyAllCloseProcessors = 1,
+  IrqPolicyOneCloseProcessor = 2,
+  IrqPolicyAllProcessorsInMachine = 3,
+  IrqPolicyAllProcessorsInGroup = 3,
+  IrqPolicySpecifiedProcessors = 4,
+  IrqPolicySpreadMessagesAcrossAllProcessors = 5};
+
+#else /* defined(NT_PROCESSOR_GROUPS) */
+
+typedef enum _IRQ_DEVICE_POLICY {
+  IrqPolicyMachineDefault = 0,
+  IrqPolicyAllCloseProcessors,
+  IrqPolicyOneCloseProcessor,
+  IrqPolicyAllProcessorsInMachine,
+  IrqPolicySpecifiedProcessors,
+  IrqPolicySpreadMessagesAcrossAllProcessors
+} IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
+
+#endif
+
+typedef enum _IRQ_PRIORITY {
+  IrqPriorityUndefined = 0,
+  IrqPriorityLow,
+  IrqPriorityNormal,
+  IrqPriorityHigh
+} IRQ_PRIORITY, *PIRQ_PRIORITY;
+
+typedef enum _IRQ_GROUP_POLICY {
+  GroupAffinityAllGroupZero = 0,
+  GroupAffinityDontCare
+} IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY;
+
 #define MAXIMUM_VOLUME_LABEL_LENGTH       (32 * sizeof(WCHAR))
 
 typedef struct _OBJECT_HANDLE_INFORMATION {
@@ -3232,10 +3863,6 @@ typedef struct _CLIENT_ID {
   HANDLE  UniqueThread;
 } CLIENT_ID, *PCLIENT_ID;
 
-typedef VOID
-(NTAPI *PKSTART_ROUTINE)(
-  IN PVOID  StartContext);
-
 typedef struct _VPB {
   CSHORT  Type;
   CSHORT  Size;
@@ -3272,6 +3899,47 @@ typedef struct _WAIT_CONTEXT_BLOCK {
   PKDPC  BufferChainingDpc;
 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
 
+/* DEVICE_OBJECT.Flags */
+#define DO_VERIFY_VOLUME                  0x00000002
+#define DO_BUFFERED_IO                    0x00000004
+#define DO_EXCLUSIVE                      0x00000008
+#define DO_DIRECT_IO                      0x00000010
+#define DO_MAP_IO_BUFFER                  0x00000020
+#define DO_DEVICE_INITIALIZING            0x00000080
+#define DO_SHUTDOWN_REGISTERED            0x00000800
+#define DO_BUS_ENUMERATED_DEVICE          0x00001000
+#define DO_POWER_PAGABLE                  0x00002000
+#define DO_POWER_INRUSH                   0x00004000
+
+/* DEVICE_OBJECT.Characteristics */
+#define FILE_REMOVABLE_MEDIA              0x00000001
+#define FILE_READ_ONLY_DEVICE             0x00000002
+#define FILE_FLOPPY_DISKETTE              0x00000004
+#define FILE_WRITE_ONCE_MEDIA             0x00000008
+#define FILE_REMOTE_DEVICE                0x00000010
+#define FILE_DEVICE_IS_MOUNTED            0x00000020
+#define FILE_VIRTUAL_VOLUME               0x00000040
+#define FILE_AUTOGENERATED_DEVICE_NAME    0x00000080
+#define FILE_DEVICE_SECURE_OPEN           0x00000100
+#define FILE_CHARACTERISTIC_PNP_DEVICE    0x00000800
+#define FILE_CHARACTERISTIC_TS_DEVICE     0x00001000
+#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000
+
+/* DEVICE_OBJECT.AlignmentRequirement */
+#define FILE_BYTE_ALIGNMENT             0x00000000
+#define FILE_WORD_ALIGNMENT             0x00000001
+#define FILE_LONG_ALIGNMENT             0x00000003
+#define FILE_QUAD_ALIGNMENT             0x00000007
+#define FILE_OCTA_ALIGNMENT             0x0000000f
+#define FILE_32_BYTE_ALIGNMENT          0x0000001f
+#define FILE_64_BYTE_ALIGNMENT          0x0000003f
+#define FILE_128_BYTE_ALIGNMENT         0x0000007f
+#define FILE_256_BYTE_ALIGNMENT         0x000000ff
+#define FILE_512_BYTE_ALIGNMENT         0x000001ff
+
+/* DEVICE_OBJECT.DeviceType */
+#define DEVICE_TYPE ULONG
+
 typedef struct _DEVICE_OBJECT {
   CSHORT  Type;
   USHORT  Size;
@@ -3303,6 +3971,153 @@ typedef struct _DEVICE_OBJECT {
   PVOID  Reserved;
 } DEVICE_OBJECT, *PDEVICE_OBJECT;
 
+typedef enum _IO_SESSION_STATE {
+  IoSessionStateCreated = 1,
+  IoSessionStateInitialized,
+  IoSessionStateConnected,
+  IoSessionStateDisconnected,
+  IoSessionStateDisconnectedLoggedOn,
+  IoSessionStateLoggedOn,
+  IoSessionStateLoggedOff,
+  IoSessionStateTerminated,
+  IoSessionStateMax
+} IO_SESSION_STATE, *PIO_SESSION_STATE;
+
+typedef enum _IO_COMPLETION_ROUTINE_RESULT {
+  ContinueCompletion = STATUS_CONTINUE_COMPLETION,
+  StopCompletion = STATUS_MORE_PROCESSING_REQUIRED
+} IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT;
+
+typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY {
+  PHYSICAL_ADDRESS MessageAddress;
+  KAFFINITY TargetProcessorSet;
+  PKINTERRUPT InterruptObject;
+  ULONG MessageData;
+  ULONG Vector;
+  KIRQL Irql;
+  KINTERRUPT_MODE Mode;
+  KINTERRUPT_POLARITY Polarity;
+} IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY;
+
+typedef struct _IO_INTERRUPT_MESSAGE_INFO {
+  KIRQL UnifiedIrql;
+  ULONG MessageCount;
+  IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1];
+} IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO;
+
+typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS {
+  IN PDEVICE_OBJECT PhysicalDeviceObject;
+  OUT PKINTERRUPT *InterruptObject;
+  IN PKSERVICE_ROUTINE ServiceRoutine;
+  IN PVOID ServiceContext;
+  IN PKSPIN_LOCK SpinLock OPTIONAL;
+  IN KIRQL SynchronizeIrql;
+  IN BOOLEAN FloatingSave;
+  IN BOOLEAN ShareVector;
+  IN ULONG Vector;
+  IN KIRQL Irql;
+  IN KINTERRUPT_MODE InterruptMode;
+  IN KAFFINITY ProcessorEnableMask;
+  IN USHORT Group;
+} IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS;
+
+typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS {
+  IN PDEVICE_OBJECT PhysicalDeviceObject;
+  OUT PKINTERRUPT *InterruptObject;
+  IN PKSERVICE_ROUTINE ServiceRoutine;
+  IN PVOID ServiceContext;
+  IN PKSPIN_LOCK SpinLock OPTIONAL;
+  IN KIRQL SynchronizeIrql OPTIONAL;
+  IN BOOLEAN FloatingSave;
+} IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS;
+
+typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS {
+  IN PDEVICE_OBJECT PhysicalDeviceObject;
+  union {
+    OUT PVOID *Generic;
+    OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable;
+    OUT PKINTERRUPT *InterruptObject;
+  } ConnectionContext;
+  IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine;
+  IN PVOID ServiceContext;
+  IN PKSPIN_LOCK SpinLock OPTIONAL;
+  IN KIRQL SynchronizeIrql OPTIONAL;
+  IN BOOLEAN FloatingSave;
+  IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL;
+} IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS;
+
+typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS {
+  IN OUT ULONG Version;
+  union {
+    IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified;
+    IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased;
+    IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased;
+  };
+} IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS;
+
+typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS {
+  IN ULONG Version;
+  union {
+    IN PVOID Generic;
+    IN PKINTERRUPT InterruptObject;
+    IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable;
+  } ConnectionContext;
+} IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS;
+
+typedef enum _IO_ACCESS_TYPE {
+  ReadAccess,
+  WriteAccess,
+  ModifyAccess
+} IO_ACCESS_TYPE;
+
+typedef enum _IO_ACCESS_MODE {
+  SequentialAccess,
+  RandomAccess
+} IO_ACCESS_MODE;
+
+typedef enum _IO_CONTAINER_NOTIFICATION_CLASS {
+  IoSessionStateNotification,
+  IoMaxContainerNotificationClass
+} IO_CONTAINER_NOTIFICATION_CLASS;
+
+typedef struct _IO_SESSION_STATE_NOTIFICATION {
+  ULONG Size;
+  ULONG Flags;
+  PVOID IoObject;
+  ULONG EventMask;
+  PVOID Context;
+} IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION;
+
+typedef enum _IO_CONTAINER_INFORMATION_CLASS {
+  IoSessionStateInformation,
+  IoMaxContainerInformationClass
+} IO_CONTAINER_INFORMATION_CLASS;
+
+typedef struct _IO_SESSION_STATE_INFORMATION {
+  ULONG SessionId;
+  IO_SESSION_STATE SessionState;
+  BOOLEAN LocalSession;
+} IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION;
+
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+
+typedef NTSTATUS
+(NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)(
+  VOID);
+
+typedef NTSTATUS
+(NTAPI IO_SESSION_NOTIFICATION_FUNCTION)(
+  IN PVOID SessionObject,
+  IN PVOID IoObject,
+  IN ULONG Event,
+  IN PVOID Context,
+  IN PVOID NotificationPayload,
+  IN ULONG PayloadLength);
+
+typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION;
+
+#endif
+
 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
 
 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
@@ -3431,22 +4246,6 @@ typedef struct _SHARE_ACCESS {
     } type2; \
   } u;
 
-typedef struct _PCI_COMMON_HEADER {
-  PCI_COMMON_HEADER_LAYOUT
-} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
-
-#ifdef __cplusplus
-typedef struct _PCI_COMMON_CONFIG {
-  PCI_COMMON_HEADER_LAYOUT
-  UCHAR  DeviceSpecific[192];
-} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
-#else
-typedef struct _PCI_COMMON_CONFIG {
-  PCI_COMMON_HEADER DUMMYSTRUCTNAME;
-  UCHAR  DeviceSpecific[192];
-} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
-#endif
-
 typedef enum _CREATE_FILE_TYPE {
   CreateFileTypeNone,
   CreateFileTypeNamedPipe,
@@ -3467,16 +4266,12 @@ typedef struct _IO_STATUS_BLOCK {
   ULONG_PTR  Information;
 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
 
-typedef struct _PCI_SLOT_NUMBER {
-  union {
-    struct {
-      ULONG  DeviceNumber : 5;
-      ULONG  FunctionNumber : 3;
-      ULONG  Reserved : 24;
-    } bits;
-    ULONG  AsULONG;
-  } u;
-} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
+#if defined(_WIN64)
+typedef struct _IO_STATUS_BLOCK32 {
+  NTSTATUS Status;
+  ULONG Information;
+} IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32;
+#endif
 
 typedef VOID
 (NTAPI *PIO_APC_ROUTINE)(
@@ -3484,16 +4279,35 @@ typedef VOID
   IN PIO_STATUS_BLOCK IoStatusBlock,
   IN ULONG Reserved);
 
-typedef VOID
-(NTAPI *WMI_NOTIFICATION_CALLBACK)(
-  PVOID  Wnode,
-  PVOID  Context);
+#define PIO_APC_ROUTINE_DEFINED
   
-#define WMIREG_ACTION_REGISTER      1
-#define WMIREG_ACTION_DEREGISTER    2
-#define WMIREG_ACTION_REREGISTER    3
-#define WMIREG_ACTION_UPDATE_GUIDS  4
-#define WMIREG_ACTION_BLOCK_IRPS    5
+typedef enum _IO_SESSION_EVENT {
+  IoSessionEventIgnore = 0,
+  IoSessionEventCreated,
+  IoSessionEventTerminated,
+  IoSessionEventConnected,
+  IoSessionEventDisconnected,
+  IoSessionEventLogon,
+  IoSessionEventLogoff,
+  IoSessionEventMax
+} IO_SESSION_EVENT, *PIO_SESSION_EVENT;
+
+#define IO_SESSION_STATE_ALL_EVENTS        0xffffffff
+#define IO_SESSION_STATE_CREATION_EVENT    0x00000001
+#define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002
+#define IO_SESSION_STATE_CONNECT_EVENT     0x00000004
+#define IO_SESSION_STATE_DISCONNECT_EVENT  0x00000008
+#define IO_SESSION_STATE_LOGON_EVENT       0x00000010
+#define IO_SESSION_STATE_LOGOFF_EVENT      0x00000020
+
+#define IO_SESSION_STATE_VALID_EVENT_MASK  0x0000003f
+
+#define IO_SESSION_MAX_PAYLOAD_SIZE        256L
+
+typedef struct _IO_SESSION_CONNECT_INFO {
+  ULONG SessionId;
+  BOOLEAN LocalSession;
+} IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO;
 
 #define EVENT_INCREMENT                   1
 #define IO_NO_INCREMENT                   0
@@ -3562,6 +4376,7 @@ typedef struct _BOOTDISK_INFORMATION_LITE {
 
 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
 
+#include <pshpack1.h>
 
 typedef struct _EISA_MEMORY_TYPE {
   UCHAR  ReadWrite : 1;
@@ -3573,7 +4388,6 @@ typedef struct _EISA_MEMORY_TYPE {
   UCHAR  MoreEntries : 1;
 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
 
-#include <pshpack1.h>
 typedef struct _EISA_MEMORY_CONFIGURATION {
   EISA_MEMORY_TYPE  ConfigurationByte;
   UCHAR  DataSize;
@@ -3581,7 +4395,6 @@ typedef struct _EISA_MEMORY_CONFIGURATION {
   UCHAR  AddressHighByte;
   USHORT  MemorySize;
 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
-#include <poppack.h>
 
 typedef struct _EISA_IRQ_DESCRIPTOR {
   UCHAR  Interrupt : 4;
@@ -3615,7 +4428,6 @@ typedef struct _EISA_DMA_CONFIGURATION {
   DMA_CONFIGURATION_BYTE1  ConfigurationByte1;
 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
 
-#include <pshpack1.h>
 typedef struct _EISA_PORT_DESCRIPTOR {
   UCHAR  NumberPorts : 5;
   UCHAR  Reserved : 1;
@@ -3627,7 +4439,17 @@ typedef struct _EISA_PORT_CONFIGURATION {
   EISA_PORT_DESCRIPTOR  Configuration;
   USHORT  PortAddress;
 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
-#include <poppack.h>
+
+typedef struct _CM_EISA_SLOT_INFORMATION {
+  UCHAR ReturnCode;
+  UCHAR ReturnFlags;
+  UCHAR MajorRevision;
+  UCHAR MinorRevision;
+  USHORT Checksum;
+  UCHAR NumberFunctions;
+  UCHAR FunctionInformation;
+  ULONG CompressedId;
+} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
 
 typedef struct _CM_EISA_FUNCTION_INFORMATION {
   ULONG  CompressedId;
@@ -3645,6 +4467,8 @@ typedef struct _CM_EISA_FUNCTION_INFORMATION {
   UCHAR  InitializationData[60];
 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
 
+#include <poppack.h>
+
 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
 
 #define EISA_FUNCTION_ENABLED           0x80
@@ -3659,16 +4483,9 @@ typedef struct _CM_EISA_FUNCTION_INFORMATION {
   (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
   + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
 
-typedef struct _CM_EISA_SLOT_INFORMATION {
-  UCHAR  ReturnCode;
-  UCHAR  ReturnFlags;
-  UCHAR  MajorRevision;
-  UCHAR  MinorRevision;
-  USHORT  Checksum;
-  UCHAR  NumberFunctions;
-  UCHAR  FunctionInformation;
-  ULONG  CompressedId;
-} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
+#define EISA_MORE_ENTRIES               0x80
+#define EISA_SYSTEM_MEMORY              0x00
+#define EISA_MEMORY_TYPE_RAM            0x01
 
 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
 
@@ -3715,6 +4532,45 @@ typedef ULONG
   IN ULONG  Length);
 typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA;
 
+typedef enum _DEVICE_INSTALL_STATE {
+  InstallStateInstalled,
+  InstallStateNeedsReinstall,
+  InstallStateFailedInstall,
+  InstallStateFinishInstall
+} DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE;
+
+typedef struct _LEGACY_BUS_INFORMATION {
+  GUID BusTypeGuid;
+  INTERFACE_TYPE LegacyBusType;
+  ULONG BusNumber;
+} LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION;
+
+typedef enum _DEVICE_REMOVAL_POLICY {
+  RemovalPolicyExpectNoRemoval = 1,
+  RemovalPolicyExpectOrderlyRemoval = 2,
+  RemovalPolicyExpectSurpriseRemoval = 3
+} DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY;
+
+typedef VOID
+(NTAPI*PREENUMERATE_SELF)(
+  IN PVOID Context);
+
+typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD {
+  USHORT Size;
+  USHORT Version;
+  PVOID Context;
+  PINTERFACE_REFERENCE InterfaceReference;
+  PINTERFACE_DEREFERENCE InterfaceDereference;
+  PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf;
+} REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD;
+
+typedef VOID
+(NTAPI *PIO_DEVICE_EJECT_CALLBACK)(
+  IN NTSTATUS Status,
+  IN OUT PVOID Context OPTIONAL);
+
+#define PCI_DEVICE_PRESENT_INTERFACE_VERSION     1
+
 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
 #define PCI_USE_SUBSYSTEM_IDS   0x00000001
 #define PCI_USE_REVISION        0x00000002
@@ -3775,175 +4631,6 @@ typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
   PPCI_IS_DEVICE_PRESENT_EX  IsDevicePresentEx;
 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
 
-typedef
-BOOLEAN
-(*PGPE_SERVICE_ROUTINE2)(
-    PVOID ObjectContext,
-    PVOID ServiceContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_CONNECT_VECTOR2)(
-    PVOID Context,
-    ULONG GpeNumber,
-    KINTERRUPT_MODE Mode,
-    BOOLEAN Shareable,
-    PGPE_SERVICE_ROUTINE2 ServiceRoutine,
-    PVOID ServiceContext,
-    PVOID *ObjectContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_DISCONNECT_VECTOR2)(
-    PVOID Context,
-    PVOID ObjectContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_ENABLE_EVENT2)(
-    PVOID Context,
-    PVOID ObjectContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_DISABLE_EVENT2)(
-    PVOID Context,
-    PVOID ObjectContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_CLEAR_STATUS2)(
-    PVOID Context,
-    PVOID ObjectContext
-);
-
-typedef
-VOID
-(*PDEVICE_NOTIFY_CALLBACK2)(
-    PVOID NotificationContext,
-    ULONG NotifyCode
-);
-
-typedef
-NTSTATUS
-(*PREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
-    PVOID Context,
-    PDEVICE_NOTIFY_CALLBACK2 NotificationHandler,
-    PVOID NotificationContext
-);
-
-typedef
-VOID
-(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
-    PVOID Context
-);
-
-typedef struct
-{
-    USHORT Size;
-    USHORT Version;
-    PVOID Context;
-    PINTERFACE_REFERENCE InterfaceReference;
-    PINTERFACE_DEREFERENCE InterfaceDereference;
-    PGPE_CONNECT_VECTOR2 GpeConnectVector;
-    PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector;
-    PGPE_ENABLE_EVENT2 GpeEnableEvent;
-    PGPE_DISABLE_EVENT2 GpeDisableEvent;
-    PGPE_CLEAR_STATUS2 GpeClearStatus;
-    PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications;
-    PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications;
-} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2;
-
-typedef
-BOOLEAN
-(*PGPE_SERVICE_ROUTINE)(
-    PDEVICE_OBJECT ObjectContext,
-    PVOID ServiceContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_CONNECT_VECTOR)(
-    PDEVICE_OBJECT Context,
-    ULONG GpeNumber,
-    KINTERRUPT_MODE Mode,
-    BOOLEAN Shareable,
-    PGPE_SERVICE_ROUTINE ServiceRoutine,
-    PVOID ServiceContext,
-    PVOID *ObjectContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_DISCONNECT_VECTOR)(
-    PDEVICE_OBJECT Context,
-    PVOID ObjectContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_ENABLE_EVENT)(
-    PDEVICE_OBJECT Context,
-    PVOID ObjectContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_DISABLE_EVENT)(
-    PDEVICE_OBJECT Context,
-    PVOID ObjectContext
-);
-
-typedef
-NTSTATUS
-(*PGPE_CLEAR_STATUS)(
-    PDEVICE_OBJECT Context,
-    PVOID ObjectContext
-);
-
-typedef
-VOID
-(*PDEVICE_NOTIFY_CALLBACK)(
-    PVOID NotificationContext,
-    ULONG NotifyCode
-);
-
-typedef
-NTSTATUS
-(*PREGISTER_FOR_DEVICE_NOTIFICATIONS)(
-    PDEVICE_OBJECT Context,
-    PDEVICE_NOTIFY_CALLBACK NotificationHandler,
-    PVOID NotificationContext
-);
-
-typedef
-VOID
-(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)(
-    PDEVICE_OBJECT Context,
-    PDEVICE_NOTIFY_CALLBACK NotificationHandler
-);
-
-typedef struct
-{
-    USHORT Size;
-    USHORT Version;
-    PVOID Context;
-    PINTERFACE_REFERENCE InterfaceReference;
-    PINTERFACE_DEREFERENCE InterfaceDereference;
-    PGPE_CONNECT_VECTOR GpeConnectVector;
-    PGPE_DISCONNECT_VECTOR GpeDisconnectVector;
-    PGPE_ENABLE_EVENT GpeEnableEvent;
-    PGPE_DISABLE_EVENT GpeDisableEvent;
-    PGPE_CLEAR_STATUS GpeClearStatus;
-    PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications;
-    PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications;
-} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
-
 typedef struct _DEVICE_CAPABILITIES {
   USHORT  Size;
   USHORT  Version;
@@ -4033,6 +4720,139 @@ typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
   struct _FILE_OBJECT  *FileObject;
 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
 
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+#include <devpropdef.h>
+#define PLUGPLAY_PROPERTY_PERSISTENT   0x00000001
+#endif
+
+#define PNP_REPLACE_NO_MAP             MAXLONGLONG
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_MAP_MEMORY)(
+  IN PHYSICAL_ADDRESS TargetPhysicalAddress,
+  IN PHYSICAL_ADDRESS SparePhysicalAddress,
+  IN OUT PLARGE_INTEGER NumberOfBytes,
+  OUT PVOID *TargetAddress,
+  OUT PVOID *SpareAddress);
+
+typedef struct _PNP_REPLACE_MEMORY_LIST {
+  ULONG AllocatedCount;
+  ULONG Count;
+  ULONGLONG TotalLength;
+  struct {
+    PHYSICAL_ADDRESS Address;
+    ULONGLONG Length;
+  } Ranges[ANYSIZE_ARRAY];
+} PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST;
+
+typedef struct _PNP_REPLACE_PROCESSOR_LIST {
+  PKAFFINITY Affinity;
+  ULONG GroupCount;
+  ULONG AllocatedCount;
+  ULONG Count;
+  ULONG ApicIds[ANYSIZE_ARRAY];
+} PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST;
+
+typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 {
+  KAFFINITY AffinityMask;
+  ULONG AllocatedCount;
+  ULONG Count;
+  ULONG ApicIds[ANYSIZE_ARRAY];
+} PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1;
+
+#define PNP_REPLACE_PARAMETERS_VERSION           2
+
+typedef struct _PNP_REPLACE_PARAMETERS {
+  ULONG Size;
+  ULONG Version;
+  ULONG64 Target;
+  ULONG64 Spare;
+  PPNP_REPLACE_PROCESSOR_LIST TargetProcessors;
+  PPNP_REPLACE_PROCESSOR_LIST SpareProcessors;
+  PPNP_REPLACE_MEMORY_LIST TargetMemory;
+  PPNP_REPLACE_MEMORY_LIST SpareMemory;
+  PREPLACE_MAP_MEMORY MapMemory;
+} PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS;
+
+typedef VOID
+(NTAPI *PREPLACE_UNLOAD)(
+  VOID);
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_BEGIN)(
+  IN PPNP_REPLACE_PARAMETERS Parameters,
+  OUT PVOID *Context);
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_END)(
+  IN PVOID Context);
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)(
+  IN PVOID Context,
+  IN PHYSICAL_ADDRESS PhysicalAddress,
+  IN LARGE_INTEGER ByteCount);
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_SET_PROCESSOR_ID)(
+  IN PVOID Context,
+  IN ULONG ApicId,
+  IN BOOLEAN Target);
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_SWAP)(
+  IN PVOID Context);
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)(
+  IN PVOID Context);
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)(
+  IN PVOID Context);
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_GET_MEMORY_DESTINATION)(
+  IN PVOID Context,
+  IN PHYSICAL_ADDRESS SourceAddress,
+  OUT PPHYSICAL_ADDRESS DestinationAddress);
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)(
+  IN PVOID Context,
+  IN BOOLEAN Enable);
+
+#define PNP_REPLACE_DRIVER_INTERFACE_VERSION      1
+#define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \
+             FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror)
+
+#define PNP_REPLACE_MEMORY_SUPPORTED             0x0001
+#define PNP_REPLACE_PROCESSOR_SUPPORTED          0x0002
+#define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING    0x0004
+#define PNP_REPLACE_HARDWARE_PAGE_COPY           0x0008
+#define PNP_REPLACE_HARDWARE_QUIESCE             0x0010
+
+typedef struct _PNP_REPLACE_DRIVER_INTERFACE {
+  ULONG Size;
+  ULONG Version;
+  ULONG Flags;
+  PREPLACE_UNLOAD Unload;
+  PREPLACE_BEGIN BeginReplace;
+  PREPLACE_END EndReplace;
+  PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory;
+  PREPLACE_SET_PROCESSOR_ID SetProcessorId;
+  PREPLACE_SWAP Swap;
+  PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror;
+  PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory;
+  PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination;
+  PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce;
+} PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE;
+
+typedef NTSTATUS
+(NTAPI *PREPLACE_DRIVER_INIT)(
+  IN OUT PPNP_REPLACE_DRIVER_INTERFACE Interface,
+  IN PVOID Unused);
+
 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
   DeviceUsageTypeUndefined,
   DeviceUsageTypePaging,
@@ -4079,6 +4899,15 @@ typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
   EventCategoryTargetDeviceChange
 } IO_NOTIFICATION_EVENT_CATEGORY;
 
+typedef enum _IO_PRIORITY_HINT {
+  IoPriorityVeryLow = 0,
+  IoPriorityLow,
+  IoPriorityNormal,
+  IoPriorityHigh,
+  IoPriorityCritical,
+  MaxIoPriorityTypes
+} IO_PRIORITY_HINT;
+
 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES    0x00000001
 
 typedef NTSTATUS
@@ -4155,7 +4984,6 @@ typedef struct _FILE_POSITION_INFORMATION {
   LARGE_INTEGER  CurrentByteOffset;
 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
 
-#include <pshpack8.h>
 typedef struct _FILE_BASIC_INFORMATION {
   LARGE_INTEGER  CreationTime;
   LARGE_INTEGER  LastAccessTime;
@@ -4163,7 +4991,32 @@ typedef struct _FILE_BASIC_INFORMATION {
   LARGE_INTEGER  ChangeTime;
   ULONG  FileAttributes;
 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
-#include <poppack.h>
+
+typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION {
+  IO_PRIORITY_HINT PriorityHint;
+} FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION;
+
+typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION {
+  ULONG Flags;
+} FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION;
+
+typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION {
+  PUCHAR IoStatusBlockRange;
+  ULONG Length;
+} FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION;
+
+typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION {
+  BOOLEAN IsRemote;
+} FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION;
+
+typedef struct _FILE_NUMA_NODE_INFORMATION {
+  USHORT NodeNumber;
+} FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION;
+
+typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION {
+  ULONG NumberOfProcessIdsInList;
+  ULONG_PTR ProcessIdList[1];
+} FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION;
 
 typedef struct _FILE_STANDARD_INFORMATION {
   LARGE_INTEGER  AllocationSize;
@@ -4210,49 +5063,30 @@ typedef struct _FILE_FULL_EA_INFORMATION {
   CHAR  EaName[1];
 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
 
+typedef struct _FILE_SFIO_RESERVE_INFORMATION {
+  ULONG RequestsPerPeriod;
+  ULONG Period;
+  BOOLEAN RetryFailures;
+  BOOLEAN Discardable;
+  ULONG RequestSize;
+  ULONG NumOutstandingRequests;
+} FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION;
+
+typedef struct _FILE_SFIO_VOLUME_INFORMATION {
+  ULONG MaximumRequestsPerPeriod;
+  ULONG MinimumPeriod;
+  ULONG MinimumTransferSize;
+} FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION;
+
+#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS     0x1
+#define FILE_SKIP_SET_EVENT_ON_HANDLE            0x2
+#define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO      0x4
+
 #define FM_LOCK_BIT             (0x1)
 #define FM_LOCK_BIT_V           (0x0)
 #define FM_LOCK_WAITER_WOKEN    (0x2)
 #define FM_LOCK_WAITER_INC      (0x4)
 
-typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
-
-typedef struct _OWNER_ENTRY {
-    ERESOURCE_THREAD OwnerThread;
-    _ANONYMOUS_UNION union {
-        LONG OwnerCount;
-        ULONG TableSize;
-    } DUMMYUNIONNAME;
-} OWNER_ENTRY, *POWNER_ENTRY;
-
-typedef struct _ERESOURCE
-{
-    LIST_ENTRY SystemResourcesList;
-    POWNER_ENTRY OwnerTable;
-    SHORT ActiveCount;
-    USHORT Flag;
-    volatile PKSEMAPHORE SharedWaiters;
-    volatile PKEVENT ExclusiveWaiters;
-    OWNER_ENTRY OwnerEntry;
-    ULONG ActiveEntries;
-    ULONG ContentionCount;
-    ULONG NumberOfSharedWaiters;
-    ULONG NumberOfExclusiveWaiters;
-    __GNU_EXTENSION union
-    {
-        PVOID Address;
-        ULONG_PTR CreatorBackTraceIndex;
-    };
-    KSPIN_LOCK SpinLock;
-} ERESOURCE, *PERESOURCE;
-
-/* ERESOURCE.Flag */
-#define ResourceNeverExclusive            0x0010
-#define ResourceReleaseByOtherThread      0x0020
-#define ResourceOwnedExclusive            0x0080
-
-#define RESOURCE_HASH_TABLE_SIZE          64
-
 typedef BOOLEAN
 (NTAPI FAST_IO_CHECK_IF_POSSIBLE)(
   IN struct _FILE_OBJECT  *FileObject,
@@ -4796,6 +5630,12 @@ typedef struct _IO_ERROR_LOG_MESSAGE {
 #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH -                 \
                                 IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
 
+#ifdef _WIN64
+#define PORT_MAXIMUM_MESSAGE_LENGTH    512
+#else
+#define PORT_MAXIMUM_MESSAGE_LENGTH    256
+#endif
+
 typedef enum _DMA_WIDTH {
   Width8Bits,
   Width16Bits,
@@ -5252,12 +6092,6 @@ typedef NTSTATUS
 (NTAPI *PMM_DLL_UNLOAD)(
   VOID);
 
-typedef BOOLEAN
-(NTAPI KSERVICE_ROUTINE)(
-  IN struct _KINTERRUPT  *Interrupt,
-  IN PVOID  ServiceContext);
-typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
-
 typedef VOID
 (NTAPI IO_TIMER_ROUTINE)(
   IN struct _DEVICE_OBJECT  *DeviceObject,
@@ -5341,12 +6175,135 @@ typedef enum _DEVICE_TEXT_TYPE {
   DeviceTextLocationInformation
 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
 
-typedef enum _WORK_QUEUE_TYPE {
-  CriticalWorkQueue,
-  DelayedWorkQueue,
-  HyperCriticalWorkQueue,
-  MaximumWorkQueue
-} WORK_QUEUE_TYPE;
+typedef BOOLEAN
+(NTAPI *PGPE_SERVICE_ROUTINE)(
+  PVOID,
+  PVOID);
+
+typedef NTSTATUS
+(NTAPI *PGPE_CONNECT_VECTOR)(
+  PDEVICE_OBJECT,
+  ULONG,
+  KINTERRUPT_MODE,
+  BOOLEAN,
+  PGPE_SERVICE_ROUTINE,
+  PVOID,
+  PVOID);
+
+typedef NTSTATUS
+(NTAPI *PGPE_DISCONNECT_VECTOR)(
+  PVOID);
+
+typedef NTSTATUS
+(NTAPI *PGPE_ENABLE_EVENT)(
+  PDEVICE_OBJECT,
+  PVOID);
+
+typedef NTSTATUS
+(NTAPI *PGPE_DISABLE_EVENT)(
+  PDEVICE_OBJECT,
+  PVOID);
+
+typedef NTSTATUS
+(NTAPI *PGPE_CLEAR_STATUS)(
+  PDEVICE_OBJECT,
+  PVOID);
+
+typedef VOID
+(NTAPI *PDEVICE_NOTIFY_CALLBACK)(
+  PVOID,
+  ULONG);
+
+typedef NTSTATUS
+(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)(
+  PDEVICE_OBJECT,
+  PDEVICE_NOTIFY_CALLBACK,
+  PVOID);
+
+typedef VOID
+(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)(
+  PDEVICE_OBJECT,
+  PDEVICE_NOTIFY_CALLBACK);
+
+typedef struct _ACPI_INTERFACE_STANDARD {
+  USHORT Size;
+  USHORT Version;
+  PVOID Context;
+  PINTERFACE_REFERENCE InterfaceReference;
+  PINTERFACE_DEREFERENCE InterfaceDereference;
+  PGPE_CONNECT_VECTOR GpeConnectVector;
+  PGPE_DISCONNECT_VECTOR GpeDisconnectVector;
+  PGPE_ENABLE_EVENT GpeEnableEvent;
+  PGPE_DISABLE_EVENT GpeDisableEvent;
+  PGPE_CLEAR_STATUS GpeClearStatus;
+  PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications;
+  PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications;
+} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
+
+typedef BOOLEAN
+(NTAPI *PGPE_SERVICE_ROUTINE2)(
+  PVOID ObjectContext,
+  PVOID ServiceContext);
+
+typedef NTSTATUS
+(NTAPI *PGPE_CONNECT_VECTOR2)(
+  PVOID Context,
+  ULONG GpeNumber,
+  KINTERRUPT_MODE Mode,
+  BOOLEAN Shareable,
+  PGPE_SERVICE_ROUTINE ServiceRoutine,
+  PVOID ServiceContext,
+  PVOID *ObjectContext);
+
+typedef NTSTATUS
+(NTAPI *PGPE_DISCONNECT_VECTOR2)(
+  PVOID Context,
+  PVOID ObjectContext);
+
+typedef NTSTATUS
+(NTAPI *PGPE_ENABLE_EVENT2)(
+  PVOID Context,
+  PVOID ObjectContext);
+
+typedef NTSTATUS
+(NTAPI *PGPE_DISABLE_EVENT2)(
+  PVOID Context,
+  PVOID ObjectContext);
+
+typedef NTSTATUS
+(NTAPI *PGPE_CLEAR_STATUS2)(
+  PVOID Context,
+  PVOID ObjectContext);
+
+typedef VOID
+(NTAPI *PDEVICE_NOTIFY_CALLBACK2)(
+  PVOID NotificationContext,
+  ULONG NotifyCode);
+
+typedef NTSTATUS
+(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
+  PVOID Context,
+  PDEVICE_NOTIFY_CALLBACK2 NotificationHandler,
+  PVOID NotificationContext);
+
+typedef VOID
+(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
+  PVOID Context);
+
+typedef struct _ACPI_INTERFACE_STANDARD2 {
+  USHORT Size;
+  USHORT Version;
+  PVOID Context;
+  PINTERFACE_REFERENCE InterfaceReference;
+  PINTERFACE_DEREFERENCE InterfaceDereference;
+  PGPE_CONNECT_VECTOR2 GpeConnectVector;
+  PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector;
+  PGPE_ENABLE_EVENT2 GpeEnableEvent;
+  PGPE_DISABLE_EVENT2 GpeDisableEvent;
+  PGPE_CLEAR_STATUS2 GpeClearStatus;
+  PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications;
+  PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications;
+} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2;
 
 #if !defined(_AMD64_) && !defined(_IA64_)
 #include <pshpack4.h>
@@ -5546,11 +6503,6 @@ typedef struct _IO_STACK_LOCATION {
 #define SL_INVOKE_ON_SUCCESS              0x40
 #define SL_INVOKE_ON_ERROR                0x80
 
-/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
-
-#define PCI_WHICHSPACE_CONFIG             0x0
-#define PCI_WHICHSPACE_ROM                0x52696350 /* 'PciR' */
-
 #define METHOD_BUFFERED                   0
 #define METHOD_IN_DIRECT                  1
 #define METHOD_OUT_DIRECT                 2
@@ -5680,2270 +6632,3639 @@ typedef struct _IO_STACK_LOCATION {
 
 /* end winnt.h */
 
-/******************************************************************************
- *                            Object Manager Types                            *
- ******************************************************************************/
-
-typedef struct _OBJECT_NAME_INFORMATION {
-  UNICODE_STRING  Name;
-} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
-
-/* Exported object types */
-extern POBJECT_TYPE NTSYSAPI CmKeyObjectType;
-extern POBJECT_TYPE NTSYSAPI ExEventObjectType;
-extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType;
-extern POBJECT_TYPE NTSYSAPI IoFileObjectType;
-extern POBJECT_TYPE NTSYSAPI PsThreadType;
-extern POBJECT_TYPE NTSYSAPI SeTokenObjectType;
-extern POBJECT_TYPE NTSYSAPI PsProcessType;
-
+#define WMIREG_ACTION_REGISTER      1
+#define WMIREG_ACTION_DEREGISTER    2
+#define WMIREG_ACTION_REREGISTER    3
+#define WMIREG_ACTION_UPDATE_GUIDS  4
+#define WMIREG_ACTION_BLOCK_IRPS    5
 
-/******************************************************************************
- *                           Process Manager Types                            *
- ******************************************************************************/
+#define WMIREGISTER                 0
+#define WMIUPDATE                   1
 
-#define QUOTA_LIMITS_HARDWS_MIN_ENABLE  0x00000001
-#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
-#define QUOTA_LIMITS_HARDWS_MAX_ENABLE  0x00000004
-#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
-#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
+typedef VOID
+(NTAPI FWMI_NOTIFICATION_CALLBACK)(
+  PVOID Wnode,
+  PVOID Context);
+typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK;
 
-/* Process Qoutas */
-typedef struct _QUOTA_LIMITS {
-    SIZE_T PagedPoolLimit;
-    SIZE_T NonPagedPoolLimit;
-    SIZE_T MinimumWorkingSetSize;
-    SIZE_T MaximumWorkingSetSize;
-    SIZE_T PagefileLimit;
-    LARGE_INTEGER TimeLimit;
-} QUOTA_LIMITS, *PQUOTA_LIMITS;
+#ifndef _PCI_X_
+#define _PCI_X_
 
-/* Thread Access Rights */
-#define THREAD_TERMINATE                 0x0001
-#define THREAD_SUSPEND_RESUME            0x0002
-#define THREAD_ALERT                     0x0004
-#define THREAD_GET_CONTEXT               0x0008
-#define THREAD_SET_CONTEXT               0x0010
-#define THREAD_SET_INFORMATION           0x0020
-#define THREAD_SET_LIMITED_INFORMATION   0x0400
-#define THREAD_QUERY_LIMITED_INFORMATION 0x0800
+typedef struct _PCI_SLOT_NUMBER {
+  union {
+    struct {
+      ULONG DeviceNumber:5;
+      ULONG FunctionNumber:3;
+      ULONG Reserved:24;
+    } bits;
+    ULONG AsULONG;
+  } u;
+} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
 
-#define PROCESS_DUP_HANDLE                 (0x0040)
+#define PCI_TYPE0_ADDRESSES               6
+#define PCI_TYPE1_ADDRESSES               2
+#define PCI_TYPE2_ADDRESSES               5
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
-#define PROCESS_ALL_ACCESS  (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
-#else
-#define PROCESS_ALL_ACCESS  (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF)
-#endif
+typedef struct _PCI_COMMON_HEADER {
+  PCI_COMMON_HEADER_LAYOUT
+} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
-#define THREAD_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
+#ifdef __cplusplus
+typedef struct _PCI_COMMON_CONFIG {
+  PCI_COMMON_HEADER_LAYOUT
+  UCHAR DeviceSpecific[192];
+} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
 #else
-#define THREAD_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF)
+typedef struct _PCI_COMMON_CONFIG {
+  PCI_COMMON_HEADER DUMMYSTRUCTNAME;
+  UCHAR DeviceSpecific[192];
+} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
 #endif
 
-#define ES_SYSTEM_REQUIRED                0x00000001
-#define ES_DISPLAY_REQUIRED               0x00000002
-#define ES_USER_PRESENT                   0x00000004
-#define ES_CONTINUOUS                     0x80000000
+#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
 
-#define LOW_PRIORITY                      0
-#define LOW_REALTIME_PRIORITY             16
-#define HIGH_PRIORITY                     31
-#define MAXIMUM_PRIORITY                  32
+#define PCI_EXTENDED_CONFIG_LENGTH               0x1000
 
+#define PCI_MAX_DEVICES        32
+#define PCI_MAX_FUNCTION       8
+#define PCI_MAX_BRIDGE_NUMBER  0xFF
+#define PCI_INVALID_VENDORID   0xFFFF
 
-#ifdef _X86_
-/** Kernel definitions for x86 **/
-
-/* Interrupt request levels */
-#define PASSIVE_LEVEL           0
-#define LOW_LEVEL               0
-#define APC_LEVEL               1
-#define DISPATCH_LEVEL          2
-#define CMCI_LEVEL              5
-#define PROFILE_LEVEL           27
-#define CLOCK1_LEVEL            28
-#define CLOCK2_LEVEL            28
-#define IPI_LEVEL               29
-#define POWER_LEVEL             30
-#define HIGH_LEVEL              31
-#define CLOCK_LEVEL             CLOCK2_LEVEL
+/* PCI_COMMON_CONFIG.HeaderType */
+#define PCI_MULTIFUNCTION                 0x80
+#define PCI_DEVICE_TYPE                   0x00
+#define PCI_BRIDGE_TYPE                   0x01
+#define PCI_CARDBUS_BRIDGE_TYPE           0x02
 
-#define KIP0PCRADDRESS          0xffdff000  
-#define KI_USER_SHARED_DATA     0xffdf0000
-#define SharedUserData          ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA)
+#define PCI_CONFIGURATION_TYPE(PciData) \
+  (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
 
-#define PAGE_SIZE               0x1000
-#define PAGE_SHIFT              12L
-#define KeGetDcacheFillSize()   1L
+#define PCI_MULTIFUNCTION_DEVICE(PciData) \
+  ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
 
-#define EFLAG_SIGN              0x8000
-#define EFLAG_ZERO              0x4000
-#define EFLAG_SELECT            (EFLAG_SIGN | EFLAG_ZERO)
+/* PCI_COMMON_CONFIG.Command */
+#define PCI_ENABLE_IO_SPACE               0x0001
+#define PCI_ENABLE_MEMORY_SPACE           0x0002
+#define PCI_ENABLE_BUS_MASTER             0x0004
+#define PCI_ENABLE_SPECIAL_CYCLES         0x0008
+#define PCI_ENABLE_WRITE_AND_INVALIDATE   0x0010
+#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
+#define PCI_ENABLE_PARITY                 0x0040
+#define PCI_ENABLE_WAIT_CYCLE             0x0080
+#define PCI_ENABLE_SERR                   0x0100
+#define PCI_ENABLE_FAST_BACK_TO_BACK      0x0200
+#define PCI_DISABLE_LEVEL_INTERRUPT       0x0400
 
-#define RESULT_NEGATIVE         ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
-#define RESULT_ZERO             ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
-#define RESULT_POSITIVE         ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
+/* PCI_COMMON_CONFIG.Status */
+#define PCI_STATUS_INTERRUPT_PENDING      0x0008
+#define PCI_STATUS_CAPABILITIES_LIST      0x0010
+#define PCI_STATUS_66MHZ_CAPABLE          0x0020
+#define PCI_STATUS_UDF_SUPPORTED          0x0040
+#define PCI_STATUS_FAST_BACK_TO_BACK      0x0080
+#define PCI_STATUS_DATA_PARITY_DETECTED   0x0100
+#define PCI_STATUS_DEVSEL                 0x0600
+#define PCI_STATUS_SIGNALED_TARGET_ABORT  0x0800
+#define PCI_STATUS_RECEIVED_TARGET_ABORT  0x1000
+#define PCI_STATUS_RECEIVED_MASTER_ABORT  0x2000
+#define PCI_STATUS_SIGNALED_SYSTEM_ERROR  0x4000
+#define PCI_STATUS_DETECTED_PARITY_ERROR  0x8000
 
+/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
 
-typedef struct _KFLOATING_SAVE {
-  ULONG  ControlWord;
-  ULONG  StatusWord;
-  ULONG  ErrorOffset;
-  ULONG  ErrorSelector;
-  ULONG  DataOffset;
-  ULONG  DataSelector;
-  ULONG  Cr0NpxState;
-  ULONG  Spare1;
-} KFLOATING_SAVE, *PKFLOATING_SAVE;
+#define PCI_WHICHSPACE_CONFIG             0x0
+#define PCI_WHICHSPACE_ROM                0x52696350 /* 'PciR' */
 
-extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount;
+#define PCI_CAPABILITY_ID_POWER_MANAGEMENT  0x01
+#define PCI_CAPABILITY_ID_AGP               0x02
+#define PCI_CAPABILITY_ID_VPD               0x03
+#define PCI_CAPABILITY_ID_SLOT_ID           0x04
+#define PCI_CAPABILITY_ID_MSI               0x05
+#define PCI_CAPABILITY_ID_CPCI_HOTSWAP      0x06
+#define PCI_CAPABILITY_ID_PCIX              0x07
+#define PCI_CAPABILITY_ID_HYPERTRANSPORT    0x08
+#define PCI_CAPABILITY_ID_VENDOR_SPECIFIC   0x09
+#define PCI_CAPABILITY_ID_DEBUG_PORT        0x0A
+#define PCI_CAPABILITY_ID_CPCI_RES_CTRL     0x0B
+#define PCI_CAPABILITY_ID_SHPC              0x0C
+#define PCI_CAPABILITY_ID_P2P_SSID          0x0D
+#define PCI_CAPABILITY_ID_AGP_TARGET        0x0E
+#define PCI_CAPABILITY_ID_SECURE            0x0F
+#define PCI_CAPABILITY_ID_PCI_EXPRESS       0x10
+#define PCI_CAPABILITY_ID_MSIX              0x11
+
+typedef struct _PCI_CAPABILITIES_HEADER {
+  UCHAR CapabilityID;
+  UCHAR Next;
+} PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
+
+typedef struct _PCI_PMC {
+  UCHAR Version:3;
+  UCHAR PMEClock:1;
+  UCHAR Rsvd1:1;
+  UCHAR DeviceSpecificInitialization:1;
+  UCHAR Rsvd2:2;
+  struct _PM_SUPPORT {
+    UCHAR Rsvd2:1;
+    UCHAR D1:1;
+    UCHAR D2:1;
+    UCHAR PMED0:1;
+    UCHAR PMED1:1;
+    UCHAR PMED2:1;
+    UCHAR PMED3Hot:1;
+    UCHAR PMED3Cold:1;
+  } Support;
+} PCI_PMC, *PPCI_PMC;
+
+typedef struct _PCI_PMCSR {
+  USHORT PowerState:2;
+  USHORT Rsvd1:6;
+  USHORT PMEEnable:1;
+  USHORT DataSelect:4;
+  USHORT DataScale:2;
+  USHORT PMEStatus:1;
+} PCI_PMCSR, *PPCI_PMCSR;
+
+typedef struct _PCI_PMCSR_BSE {
+  UCHAR Rsvd1:6;
+  UCHAR D3HotSupportsStopClock:1;
+  UCHAR BusPowerClockControlEnabled:1;
+} PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
+
+typedef struct _PCI_PM_CAPABILITY {
+  PCI_CAPABILITIES_HEADER Header;
+  union {
+    PCI_PMC Capabilities;
+    USHORT AsUSHORT;
+  } PMC;
+    union {
+      PCI_PMCSR ControlStatus;
+      USHORT AsUSHORT;
+    } PMCSR;
+    union {
+      PCI_PMCSR_BSE BridgeSupport;
+      UCHAR AsUCHAR;
+    } PMCSR_BSE;
+  UCHAR Data;
+} PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
 
-#define YieldProcessor _mm_pause
+typedef struct {
+  PCI_CAPABILITIES_HEADER Header;
+  union {
+    struct {
+      USHORT DataParityErrorRecoveryEnable:1;
+      USHORT EnableRelaxedOrdering:1;
+      USHORT MaxMemoryReadByteCount:2;
+      USHORT MaxOutstandingSplitTransactions:3;
+      USHORT Reserved:9;
+    } bits;
+    USHORT AsUSHORT;
+  } Command;
+  union {
+    struct {
+      ULONG FunctionNumber:3;
+      ULONG DeviceNumber:5;
+      ULONG BusNumber:8;
+      ULONG Device64Bit:1;
+      ULONG Capable133MHz:1;
+      ULONG SplitCompletionDiscarded:1;
+      ULONG UnexpectedSplitCompletion:1;
+      ULONG DeviceComplexity:1;
+      ULONG DesignedMaxMemoryReadByteCount:2;
+      ULONG DesignedMaxOutstandingSplitTransactions:3;
+      ULONG DesignedMaxCumulativeReadSize:3;
+      ULONG ReceivedSplitCompletionErrorMessage:1;
+      ULONG CapablePCIX266:1;
+      ULONG CapablePCIX533:1;
+      } bits;
+    ULONG AsULONG;
+  } Status;
+} PCI_X_CAPABILITY, *PPCI_X_CAPABILITY;
+
+#define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID                     0x0001
+#define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID                              0x0002
+#define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID                         0x0003
+#define PCI_EXPRESS_POWER_BUDGETING_CAP_ID                              0x0004
+#define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID                          0x0005
+#define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID                     0x0006
+#define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID      0x0007
+#define PCI_EXPRESS_MFVC_CAP_ID                                         0x0008
+#define PCI_EXPRESS_VC_AND_MFVC_CAP_ID                                  0x0009
+#define PCI_EXPRESS_RCRB_HEADER_CAP_ID                                  0x000A
+#define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID                0x0010
+
+typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER {
+  USHORT CapabilityID;
+  USHORT Version:4;
+  USHORT Next:12;
+} PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER;
+
+typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY {
+  PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
+  ULONG LowSerialNumber;
+  ULONG HighSerialNumber;
+} PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY;
+
+typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS {
+  struct {
+    ULONG Undefined:1;
+    ULONG Reserved1:3;
+    ULONG DataLinkProtocolError:1;
+    ULONG SurpriseDownError:1;
+    ULONG Reserved2:6;
+    ULONG PoisonedTLP:1;
+    ULONG FlowControlProtocolError:1;
+    ULONG CompletionTimeout:1;
+    ULONG CompleterAbort:1;
+    ULONG UnexpectedCompletion:1;
+    ULONG ReceiverOverflow:1;
+    ULONG MalformedTLP:1;
+    ULONG ECRCError:1;
+    ULONG UnsupportedRequestError:1;
+    ULONG Reserved3:11;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS;
 
-FORCEINLINE
-VOID
-KeMemoryBarrier(VOID)
-{
-  volatile LONG Barrier;
-#if defined(__GNUC__)
-  __asm__ __volatile__ ("xchg %%eax, %0" : : "m" (Barrier) : "%eax");
-#elif defined(_MSC_VER)
-  __asm xchg [Barrier], eax
-#endif
-}
+typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK {
+  struct {
+    ULONG Undefined:1;
+    ULONG Reserved1:3;
+    ULONG DataLinkProtocolError:1;
+    ULONG SurpriseDownError:1;
+    ULONG Reserved2:6;
+    ULONG PoisonedTLP:1;
+    ULONG FlowControlProtocolError:1;
+    ULONG CompletionTimeout:1;
+    ULONG CompleterAbort:1;
+    ULONG UnexpectedCompletion:1;
+    ULONG ReceiverOverflow:1;
+    ULONG MalformedTLP:1;
+    ULONG ECRCError:1;
+    ULONG UnsupportedRequestError:1;
+    ULONG Reserved3:11;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK;
 
-NTHALAPI
-KIRQL
-NTAPI
-KeGetCurrentIrql(VOID);
+typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY {
+  struct {
+    ULONG Undefined:1;
+    ULONG Reserved1:3;
+    ULONG DataLinkProtocolError:1;
+    ULONG SurpriseDownError:1;
+    ULONG Reserved2:6;
+    ULONG PoisonedTLP:1;
+    ULONG FlowControlProtocolError:1;
+    ULONG CompletionTimeout:1;
+    ULONG CompleterAbort:1;
+    ULONG UnexpectedCompletion:1;
+    ULONG ReceiverOverflow:1;
+    ULONG MalformedTLP:1;
+    ULONG ECRCError:1;
+    ULONG UnsupportedRequestError:1;
+    ULONG Reserved3:11;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY;
 
-NTHALAPI
-VOID
-FASTCALL
-KfLowerIrql(
-  IN KIRQL  NewIrql);
-#define KeLowerIrql(a) KfLowerIrql(a)
+typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS {
+  struct {
+    ULONG ReceiverError:1;
+    ULONG Reserved1:5;
+    ULONG BadTLP:1;
+    ULONG BadDLLP:1;
+    ULONG ReplayNumRollover:1;
+    ULONG Reserved2:3;
+    ULONG ReplayTimerTimeout:1;
+    ULONG AdvisoryNonFatalError:1;
+    ULONG Reserved3:18;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS;
 
-NTHALAPI
-KIRQL
-FASTCALL
-KfRaiseIrql(
-  IN KIRQL  NewIrql);
-#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
+typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK {
+  struct {
+    ULONG ReceiverError:1;
+    ULONG Reserved1:5;
+    ULONG BadTLP:1;
+    ULONG BadDLLP:1;
+    ULONG ReplayNumRollover:1;
+    ULONG Reserved2:3;
+    ULONG ReplayTimerTimeout:1;
+    ULONG AdvisoryNonFatalError:1;
+    ULONG Reserved3:18;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK;
 
-NTHALAPI
-KIRQL
-NTAPI
-KeRaiseIrqlToDpcLevel(VOID);
+typedef union _PCI_EXPRESS_AER_CAPABILITIES {
+  struct {
+    ULONG FirstErrorPointer:5;
+    ULONG ECRCGenerationCapable:1;
+    ULONG ECRCGenerationEnable:1;
+    ULONG ECRCCheckCapable:1;
+    ULONG ECRCCheckEnable:1;
+    ULONG Reserved:23;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES;
 
-NTHALAPI
-KIRQL
-NTAPI
-KeRaiseIrqlToSynchLevel(VOID);
+typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND {
+  struct {
+    ULONG CorrectableErrorReportingEnable:1;
+    ULONG NonFatalErrorReportingEnable:1;
+    ULONG FatalErrorReportingEnable:1;
+    ULONG Reserved:29;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND;
 
-NTHALAPI
-KIRQL
-FASTCALL
-KfAcquireSpinLock(
-  IN OUT PKSPIN_LOCK SpinLock);
-#define KeAcquireSpinLock(a,b)  *(b) = KfAcquireSpinLock(a)
+typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS {
+  struct {
+    ULONG CorrectableErrorReceived:1;
+    ULONG MultipleCorrectableErrorsReceived:1;
+    ULONG UncorrectableErrorReceived:1;
+    ULONG MultipleUncorrectableErrorsReceived:1;
+    ULONG FirstUncorrectableFatal:1;
+    ULONG NonFatalErrorMessagesReceived:1;
+    ULONG FatalErrorMessagesReceived:1;
+    ULONG Reserved:20;
+    ULONG AdvancedErrorInterruptMessageNumber:5;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS;
 
-NTHALAPI
-VOID
-FASTCALL
-KfReleaseSpinLock(
-  IN OUT PKSPIN_LOCK SpinLock,
-  IN KIRQL NewIrql);
-#define KeReleaseSpinLock(a,b)  KfReleaseSpinLock(a,b)
+typedef union _PCI_EXPRESS_ERROR_SOURCE_ID {
+  struct {
+    USHORT CorrectableSourceIdFun:3;
+    USHORT CorrectableSourceIdDev:5;
+    USHORT CorrectableSourceIdBus:8;
+    USHORT UncorrectableSourceIdFun:3;
+    USHORT UncorrectableSourceIdDev:5;
+    USHORT UncorrectableSourceIdBus:8;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID;
 
-NTKERNELAPI
-VOID
-FASTCALL
-KefAcquireSpinLockAtDpcLevel(
-  IN OUT PKSPIN_LOCK SpinLock);
-#define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
+typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS {
+  struct {
+    ULONG TargetAbortOnSplitCompletion:1;
+    ULONG MasterAbortOnSplitCompletion:1;
+    ULONG ReceivedTargetAbort:1;
+    ULONG ReceivedMasterAbort:1;
+    ULONG RsvdZ:1;
+    ULONG UnexpectedSplitCompletionError:1;
+    ULONG UncorrectableSplitCompletion:1;
+    ULONG UncorrectableDataError:1;
+    ULONG UncorrectableAttributeError:1;
+    ULONG UncorrectableAddressError:1;
+    ULONG DelayedTransactionDiscardTimerExpired:1;
+    ULONG PERRAsserted:1;
+    ULONG SERRAsserted:1;
+    ULONG InternalBridgeError:1;
+    ULONG Reserved:18;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS;
 
-NTKERNELAPI
-VOID
-FASTCALL
-KefReleaseSpinLockFromDpcLevel(
-  IN OUT PKSPIN_LOCK SpinLock);
-#define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
+typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK {
+  struct {
+    ULONG TargetAbortOnSplitCompletion:1;
+    ULONG MasterAbortOnSplitCompletion:1;
+    ULONG ReceivedTargetAbort:1;
+    ULONG ReceivedMasterAbort:1;
+    ULONG RsvdZ:1;
+    ULONG UnexpectedSplitCompletionError:1;
+    ULONG UncorrectableSplitCompletion:1;
+    ULONG UncorrectableDataError:1;
+    ULONG UncorrectableAttributeError:1;
+    ULONG UncorrectableAddressError:1;
+    ULONG DelayedTransactionDiscardTimerExpired:1;
+    ULONG PERRAsserted:1;
+    ULONG SERRAsserted:1;
+    ULONG InternalBridgeError:1;
+    ULONG Reserved:18;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK;
 
-NTSYSAPI
-PKTHREAD
-NTAPI
-KeGetCurrentThread(VOID);
+typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY {
+  struct {
+    ULONG TargetAbortOnSplitCompletion:1;
+    ULONG MasterAbortOnSplitCompletion:1;
+    ULONG ReceivedTargetAbort:1;
+    ULONG ReceivedMasterAbort:1;
+    ULONG RsvdZ:1;
+    ULONG UnexpectedSplitCompletionError:1;
+    ULONG UncorrectableSplitCompletion:1;
+    ULONG UncorrectableDataError:1;
+    ULONG UncorrectableAttributeError:1;
+    ULONG UncorrectableAddressError:1;
+    ULONG DelayedTransactionDiscardTimerExpired:1;
+    ULONG PERRAsserted:1;
+    ULONG SERRAsserted:1;
+    ULONG InternalBridgeError:1;
+    ULONG Reserved:18;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY;
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeSaveFloatingPointState(
-  OUT PKFLOATING_SAVE  FloatSave);
+typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES {
+  struct {
+    ULONG SecondaryUncorrectableFirstErrorPtr:5;
+    ULONG Reserved:27;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES;
+
+#define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING  0x00000001
+#define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING     0x00000002
+#define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING        0x00000004
+
+#define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \
+    (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \
+     ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \
+     ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING)
+
+typedef struct _PCI_EXPRESS_AER_CAPABILITY {
+  PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
+  PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
+  PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
+  PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
+  PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
+  PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
+  PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
+  ULONG HeaderLog[4];
+  PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
+  PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
+  PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
+  PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
+  ULONG SecHeaderLog[4];
+} PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY;
+
+typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY {
+  PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
+  PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
+  PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
+  PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
+  PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
+  PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
+  PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
+  ULONG HeaderLog[4];
+  PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand;
+  PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus;
+  PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId;
+} PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY;
+
+typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY {
+  PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
+  PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
+  PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
+  PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
+  PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
+  PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
+  PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
+  ULONG HeaderLog[4];
+  PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
+  PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
+  PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
+  PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
+  ULONG SecHeaderLog[4];
+} PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY;
+
+typedef union _PCI_EXPRESS_SRIOV_CAPS {
+  struct {
+    ULONG VFMigrationCapable:1;
+    ULONG Reserved1:20;
+    ULONG VFMigrationInterruptNumber:11;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS;
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeRestoreFloatingPointState(
-  IN PKFLOATING_SAVE  FloatSave);
+typedef union _PCI_EXPRESS_SRIOV_CONTROL {
+  struct {
+    USHORT VFEnable:1;
+    USHORT VFMigrationEnable:1;
+    USHORT VFMigrationInterruptEnable:1;
+    USHORT VFMemorySpaceEnable:1;
+    USHORT ARICapableHierarchy:1;
+    USHORT Reserved1:11;
+  } DUMMYSTRUCTNAME;
+  USHORT AsUSHORT;
+} PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL;
 
-/* VOID
- * KeFlushIoBuffers(
- *   IN PMDL Mdl,
- *   IN BOOLEAN ReadOperation,
- *   IN BOOLEAN DmaOperation)
- */
-#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
+typedef union _PCI_EXPRESS_SRIOV_STATUS {
+  struct {
+    USHORT VFMigrationStatus:1;
+    USHORT Reserved1:15;
+  } DUMMYSTRUCTNAME;
+  USHORT AsUSHORT;
+} PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS;
 
-/* x86 and x64 performs a 0x2C interrupt */
-#define DbgRaiseAssertionFailure __int2c
+typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY {
+  struct {
+    ULONG VFMigrationStateBIR:3;
+    ULONG VFMigrationStateOffset:29;
+  } DUMMYSTRUCTNAME;
+  ULONG AsULONG;
+} PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY;
+
+typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY {
+  PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
+  PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities;
+  PCI_EXPRESS_SRIOV_CONTROL SRIOVControl;
+  PCI_EXPRESS_SRIOV_STATUS SRIOVStatus;
+  USHORT InitialVFs;
+  USHORT TotalVFs;
+  USHORT NumVFs;
+  UCHAR FunctionDependencyLink;
+  UCHAR RsvdP1;
+  USHORT FirstVFOffset;
+  USHORT VFStride;
+  USHORT RsvdP2;
+  USHORT VFDeviceId;
+  ULONG SupportedPageSizes;
+  ULONG SystemPageSize;
+  ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
+  PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset;
+} PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY;
 
-FORCEINLINE
-VOID
-_KeQueryTickCount(
-  OUT PLARGE_INTEGER CurrentCount)
-{
-  for (;;) {
-        CurrentCount->HighPart = KeTickCount.High1Time;
-        CurrentCount->LowPart = KeTickCount.LowPart;
-        if (CurrentCount->HighPart == KeTickCount.High2Time) break;
-        YieldProcessor();
-    }
-}
-#define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount)
+/* PCI device classes */
+#define PCI_CLASS_PRE_20                    0x00
+#define PCI_CLASS_MASS_STORAGE_CTLR         0x01
+#define PCI_CLASS_NETWORK_CTLR              0x02
+#define PCI_CLASS_DISPLAY_CTLR              0x03
+#define PCI_CLASS_MULTIMEDIA_DEV            0x04
+#define PCI_CLASS_MEMORY_CTLR               0x05
+#define PCI_CLASS_BRIDGE_DEV                0x06
+#define PCI_CLASS_SIMPLE_COMMS_CTLR         0x07
+#define PCI_CLASS_BASE_SYSTEM_DEV           0x08
+#define PCI_CLASS_INPUT_DEV                 0x09
+#define PCI_CLASS_DOCKING_STATION           0x0a
+#define PCI_CLASS_PROCESSOR                 0x0b
+#define PCI_CLASS_SERIAL_BUS_CTLR           0x0c
+#define PCI_CLASS_WIRELESS_CTLR             0x0d
+#define PCI_CLASS_INTELLIGENT_IO_CTLR       0x0e
+#define PCI_CLASS_SATELLITE_COMMS_CTLR      0x0f
+#define PCI_CLASS_ENCRYPTION_DECRYPTION     0x10
+#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC      0x11
+#define PCI_CLASS_NOT_DEFINED               0xff
 
-#endif /* _X86_ */
+/* PCI device subclasses for class 0 */
+#define PCI_SUBCLASS_PRE_20_NON_VGA         0x00
+#define PCI_SUBCLASS_PRE_20_VGA             0x01
 
+/* PCI device subclasses for class 1 (mass storage controllers)*/
+#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR      0x00
+#define PCI_SUBCLASS_MSC_IDE_CTLR           0x01
+#define PCI_SUBCLASS_MSC_FLOPPY_CTLR        0x02
+#define PCI_SUBCLASS_MSC_IPI_CTLR           0x03
+#define PCI_SUBCLASS_MSC_RAID_CTLR          0x04
+#define PCI_SUBCLASS_MSC_OTHER              0x80
 
+/* PCI device subclasses for class 2 (network controllers)*/
+#define PCI_SUBCLASS_NET_ETHERNET_CTLR      0x00
+#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR    0x01
+#define PCI_SUBCLASS_NET_FDDI_CTLR          0x02
+#define PCI_SUBCLASS_NET_ATM_CTLR           0x03
+#define PCI_SUBCLASS_NET_ISDN_CTLR          0x04
+#define PCI_SUBCLASS_NET_OTHER              0x80
 
+/* PCI device subclasses for class 3 (display controllers)*/
+#define PCI_SUBCLASS_VID_VGA_CTLR           0x00
+#define PCI_SUBCLASS_VID_XGA_CTLR           0x01
+#define PCI_SUBCLASS_VID_3D_CTLR            0x02
+#define PCI_SUBCLASS_VID_OTHER              0x80
 
-FORCEINLINE
-VOID
-InitializeListHead(
-  OUT PLIST_ENTRY ListHead)
-{
-  ListHead->Flink = ListHead->Blink = ListHead;
-}
+/* PCI device subclasses for class 4 (multimedia device)*/
+#define PCI_SUBCLASS_MM_VIDEO_DEV           0x00
+#define PCI_SUBCLASS_MM_AUDIO_DEV           0x01
+#define PCI_SUBCLASS_MM_TELEPHONY_DEV       0x02
+#define PCI_SUBCLASS_MM_OTHER               0x80
 
-FORCEINLINE
-VOID
-InsertHeadList(
-  IN OUT PLIST_ENTRY  ListHead,
-  IN OUT PLIST_ENTRY  Entry)
-{
-  PLIST_ENTRY OldFlink;
-  OldFlink = ListHead->Flink;
-  Entry->Flink = OldFlink;
-  Entry->Blink = ListHead;
-  OldFlink->Blink = Entry;
-  ListHead->Flink = Entry;
-}
+/* PCI device subclasses for class 5 (memory controller)*/
+#define PCI_SUBCLASS_MEM_RAM                0x00
+#define PCI_SUBCLASS_MEM_FLASH              0x01
+#define PCI_SUBCLASS_MEM_OTHER              0x80
 
-FORCEINLINE
-VOID
-InsertTailList(
-  IN OUT PLIST_ENTRY  ListHead,
-  IN OUT PLIST_ENTRY  Entry)
-{
-  PLIST_ENTRY OldBlink;
-  OldBlink = ListHead->Blink;
-  Entry->Flink = ListHead;
-  Entry->Blink = OldBlink;
-  OldBlink->Flink = Entry;
-  ListHead->Blink = Entry;
-}
+/* PCI device subclasses for class 6 (bridge device)*/
+#define PCI_SUBCLASS_BR_HOST                0x00
+#define PCI_SUBCLASS_BR_ISA                 0x01
+#define PCI_SUBCLASS_BR_EISA                0x02
+#define PCI_SUBCLASS_BR_MCA                 0x03
+#define PCI_SUBCLASS_BR_PCI_TO_PCI          0x04
+#define PCI_SUBCLASS_BR_PCMCIA              0x05
+#define PCI_SUBCLASS_BR_NUBUS               0x06
+#define PCI_SUBCLASS_BR_CARDBUS             0x07
+#define PCI_SUBCLASS_BR_RACEWAY             0x08
+#define PCI_SUBCLASS_BR_OTHER               0x80
 
-BOOLEAN
-FORCEINLINE
-IsListEmpty(
-  IN CONST LIST_ENTRY * ListHead)
-{
-  return (BOOLEAN)(ListHead->Flink == ListHead);
-}
+#define PCI_SUBCLASS_COM_SERIAL             0x00
+#define PCI_SUBCLASS_COM_PARALLEL           0x01
+#define PCI_SUBCLASS_COM_MULTIPORT          0x02
+#define PCI_SUBCLASS_COM_MODEM              0x03
+#define PCI_SUBCLASS_COM_OTHER              0x80
+
+#define PCI_SUBCLASS_SYS_INTERRUPT_CTLR     0x00
+#define PCI_SUBCLASS_SYS_DMA_CTLR           0x01
+#define PCI_SUBCLASS_SYS_SYSTEM_TIMER       0x02
+#define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK    0x03
+#define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR   0x04
+#define PCI_SUBCLASS_SYS_SDIO_CTRL          0x05
+#define PCI_SUBCLASS_SYS_OTHER              0x80
+
+#define PCI_SUBCLASS_INP_KEYBOARD           0x00
+#define PCI_SUBCLASS_INP_DIGITIZER          0x01
+#define PCI_SUBCLASS_INP_MOUSE              0x02
+#define PCI_SUBCLASS_INP_SCANNER            0x03
+#define PCI_SUBCLASS_INP_GAMEPORT           0x04
+#define PCI_SUBCLASS_INP_OTHER              0x80
+
+#define PCI_SUBCLASS_DOC_GENERIC            0x00
+#define PCI_SUBCLASS_DOC_OTHER              0x80
+
+#define PCI_SUBCLASS_PROC_386               0x00
+#define PCI_SUBCLASS_PROC_486               0x01
+#define PCI_SUBCLASS_PROC_PENTIUM           0x02
+#define PCI_SUBCLASS_PROC_ALPHA             0x10
+#define PCI_SUBCLASS_PROC_POWERPC           0x20
+#define PCI_SUBCLASS_PROC_COPROCESSOR       0x40
 
-FORCEINLINE
-PSINGLE_LIST_ENTRY
-PopEntryList(
-  IN OUT PSINGLE_LIST_ENTRY ListHead)
-{
-  PSINGLE_LIST_ENTRY FirstEntry;
-  FirstEntry = ListHead->Next;
-  if (FirstEntry != NULL) {
-    ListHead->Next = FirstEntry->Next;
-  }
-  return FirstEntry;
-}
+/* PCI device subclasses for class C (serial bus controller)*/
+#define PCI_SUBCLASS_SB_IEEE1394            0x00
+#define PCI_SUBCLASS_SB_ACCESS              0x01
+#define PCI_SUBCLASS_SB_SSA                 0x02
+#define PCI_SUBCLASS_SB_USB                 0x03
+#define PCI_SUBCLASS_SB_FIBRE_CHANNEL       0x04
+#define PCI_SUBCLASS_SB_SMBUS               0x05
 
-FORCEINLINE
-VOID
-PushEntryList(
-  IN OUT PSINGLE_LIST_ENTRY ListHead,
-  IN OUT PSINGLE_LIST_ENTRY Entry)
-{
-  Entry->Next = ListHead->Next;
-  ListHead->Next = Entry;
-}
+#define PCI_SUBCLASS_WIRELESS_IRDA          0x00
+#define PCI_SUBCLASS_WIRELESS_CON_IR        0x01
+#define PCI_SUBCLASS_WIRELESS_RF            0x10
+#define PCI_SUBCLASS_WIRELESS_OTHER         0x80
 
-FORCEINLINE
-BOOLEAN
-RemoveEntryList(
-  IN PLIST_ENTRY  Entry)
-{
-  PLIST_ENTRY OldFlink;
-  PLIST_ENTRY OldBlink;
+#define PCI_SUBCLASS_INTIO_I2O              0x00
 
-  OldFlink = Entry->Flink;
-  OldBlink = Entry->Blink;
-  OldFlink->Blink = OldBlink;
-  OldBlink->Flink = OldFlink;
-  return (BOOLEAN)(OldFlink == OldBlink);
-}
+#define PCI_SUBCLASS_SAT_TV                 0x01
+#define PCI_SUBCLASS_SAT_AUDIO              0x02
+#define PCI_SUBCLASS_SAT_VOICE              0x03
+#define PCI_SUBCLASS_SAT_DATA               0x04
 
-FORCEINLINE
-PLIST_ENTRY
-RemoveHeadList(
-  IN OUT PLIST_ENTRY  ListHead)
-{
-  PLIST_ENTRY Flink;
-  PLIST_ENTRY Entry;
+#define PCI_SUBCLASS_CRYPTO_NET_COMP        0x00
+#define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT   0x10
+#define PCI_SUBCLASS_CRYPTO_OTHER           0x80
 
-  Entry = ListHead->Flink;
-  Flink = Entry->Flink;
-  ListHead->Flink = Flink;
-  Flink->Blink = ListHead;
-  return Entry;
-}
+#define PCI_SUBCLASS_DASP_DPIO              0x00
+#define PCI_SUBCLASS_DASP_OTHER             0x80
 
-FORCEINLINE
-PLIST_ENTRY
-RemoveTailList(
-  IN OUT PLIST_ENTRY  ListHead)
-{
-  PLIST_ENTRY Blink;
-  PLIST_ENTRY Entry;
+#define PCI_ADDRESS_IO_SPACE                0x00000001
+#define PCI_ADDRESS_MEMORY_TYPE_MASK        0x00000006
+#define PCI_ADDRESS_MEMORY_PREFETCHABLE     0x00000008
+#define PCI_ADDRESS_IO_ADDRESS_MASK         0xfffffffc
+#define PCI_ADDRESS_MEMORY_ADDRESS_MASK     0xfffffff0
+#define PCI_ADDRESS_ROM_ADDRESS_MASK        0xfffff800
 
-  Entry = ListHead->Blink;
-  Blink = Entry->Blink;
-  ListHead->Blink = Blink;
-  Blink->Flink = ListHead;
-  return Entry;
-}
+#define PCI_TYPE_32BIT                      0
+#define PCI_TYPE_20BIT                      2
+#define PCI_TYPE_64BIT                      4
 
-NTSYSAPI
-VOID
-NTAPI
-RtlAssert(
-    IN PVOID FailedAssertion,
-    IN PVOID FileName,
-    IN ULONG LineNumber,
-    IN PSTR Message);
+#define PCI_ROMADDRESS_ENABLED              0x00000001
 
-/* VOID
- * RtlCopyMemory(
- *     IN VOID UNALIGNED *Destination,
- *     IN CONST VOID UNALIGNED *Source,
- *     IN SIZE_T Length)
- */
-#define RtlCopyMemory(Destination, Source, Length) \
-    memcpy(Destination, Source, Length)
+#endif /* _PCI_X_ */
 
-#define RtlCopyBytes RtlCopyMemory
+#define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION       1
 
-#if defined(_M_AMD64)
-NTSYSAPI
-VOID
-NTAPI
-RtlCopyMemoryNonTemporal(
-    VOID UNALIGNED *Destination,
-    CONST VOID UNALIGNED *Source,
-    SIZE_T Length);
-#else
-#define RtlCopyMemoryNonTemporal RtlCopyMemory
-#endif
+typedef NTSTATUS
+(NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)(
+  IN OUT PVOID Context);
+typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE;
 
-/* BOOLEAN
- * RtlEqualLuid(
- *     IN PLUID Luid1,
- *     IN PLUID Luid2)
- */
-#define RtlEqualLuid(Luid1, Luid2) \
-    (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart))
+typedef NTSTATUS
+(NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)(
+  IN OUT PVOID Context);
+typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE;
 
-/* ULONG
- * RtlEqualMemory(
- *     IN VOID UNALIGNED *Destination,
- *     IN CONST VOID UNALIGNED *Source,
- *     IN SIZE_T Length)
- */
-#define RtlEqualMemory(Destination, Source, Length) \
-    (!memcmp(Destination, Source, Length))
+typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE {
+  USHORT Size;
+  USHORT Version;
+  PVOID Context;
+  PINTERFACE_REFERENCE InterfaceReference;
+  PINTERFACE_DEREFERENCE InterfaceDereference;
+  PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode;
+  PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode;
+} PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE;
 
-/* VOID
- * RtlFillMemory(
- *     IN VOID UNALIGNED *Destination,
- *     IN SIZE_T Length,
- *     IN UCHAR Fill)
- */
-#define RtlFillMemory(Destination, Length, Fill) \
-    memset(Destination, Fill, Length)
+#define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION            1
 
-#define RtlFillBytes RtlFillMemory
+typedef ULONG
+(NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)(
+  IN PVOID Context,
+  OUT PVOID Buffer,
+  IN ULONG Offset,
+  IN ULONG Length);
 
-NTSYSAPI
-VOID
-NTAPI
-RtlFreeUnicodeString(
-    IN OUT PUNICODE_STRING UnicodeString);
+typedef ULONG
+(NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)(
+  IN PVOID Context,
+  IN PVOID Buffer,
+  IN ULONG Offset,
+  IN ULONG Length);
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlGUIDFromString(
-    IN PUNICODE_STRING GuidString,
-    OUT GUID *Guid);
+typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE {
+  USHORT Size;
+  USHORT Version;
+  PVOID Context;
+  PINTERFACE_REFERENCE InterfaceReference;
+  PINTERFACE_DEREFERENCE InterfaceDereference;
+  PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace;
+  PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace;
+} PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE;
 
-NTSYSAPI
-VOID
-NTAPI
-RtlInitUnicodeString(
-    IN OUT PUNICODE_STRING DestinationString,
-    IN PCWSTR SourceString OPTIONAL);
+#define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION            1
 
-/* VOID
- * RtlMoveMemory(
- *    IN VOID UNALIGNED *Destination,
- *    IN CONST VOID UNALIGNED *Source,
- *    IN SIZE_T Length)
- */
-#define RtlMoveMemory(Destination, Source, Length) \
-    memmove(Destination, Source, Length)
+typedef NTSTATUS
+(NTAPI PCI_MSIX_SET_ENTRY)(
+  IN PVOID Context,
+  IN ULONG TableEntry,
+  IN ULONG MessageNumber);
+typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY;
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlStringFromGUID(
-    IN REFGUID Guid,
-    OUT PUNICODE_STRING GuidString);
+typedef NTSTATUS
+(NTAPI PCI_MSIX_MASKUNMASK_ENTRY)(
+  IN PVOID Context,
+  IN ULONG TableEntry);
+typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY;
 
-/* VOID
- * RtlZeroMemory(
*     IN VOID UNALIGNED *Destination,
- *     IN SIZE_T Length)
- */
-#define RtlZeroMemory(Destination, Length) \
-    memset(Destination, 0, Length)
+typedef NTSTATUS
+(NTAPI PCI_MSIX_GET_ENTRY)(
 IN PVOID Context,
+  IN ULONG TableEntry,
+  OUT PULONG MessageNumber,
+  OUT PBOOLEAN Masked);
+typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY;
 
-#define RtlZeroBytes RtlZeroMemory
+typedef NTSTATUS
+(NTAPI PCI_MSIX_GET_TABLE_SIZE)(
+  IN PVOID Context,
+  OUT PULONG TableSize);
+typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE;
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE {
+  USHORT Size;
+  USHORT Version;
+  PVOID Context;
+  PINTERFACE_REFERENCE InterfaceReference;
+  PINTERFACE_DEREFERENCE InterfaceDereference;
+  PPCI_MSIX_SET_ENTRY SetTableEntry;
+  PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry;
+  PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry;
+  PPCI_MSIX_GET_ENTRY GetTableEntry;
+  PPCI_MSIX_GET_TABLE_SIZE GetTableSize;
+} PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE;
+
+#define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \
+        RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry)
 
+/******************************************************************************
+ *                            Object Manager Types                            *
+ ******************************************************************************/
 
+#define MAXIMUM_FILENAME_LENGTH           256
+#define OBJ_NAME_PATH_SEPARATOR     ((WCHAR)L'\\')
 
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlAreBitsClear(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG StartingIndex,
-    IN ULONG Length);
+#define OBJECT_TYPE_CREATE 0x0001
+#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
 
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlAreBitsSet(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG StartingIndex,
-    IN ULONG Length);
+#define DIRECTORY_QUERY 0x0001
+#define DIRECTORY_TRAVERSE 0x0002
+#define DIRECTORY_CREATE_OBJECT 0x0004
+#define DIRECTORY_CREATE_SUBDIRECTORY 0x0008
+#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAnsiStringToUnicodeString(
-    IN OUT PUNICODE_STRING DestinationString,
-    IN PANSI_STRING SourceString,
-    IN BOOLEAN AllocateDestinationString);
+#define SYMBOLIC_LINK_QUERY               0x0001
+#define SYMBOLIC_LINK_ALL_ACCESS          (STANDARD_RIGHTS_REQUIRED | 0x1)
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlxAnsiStringToUnicodeSize(
-    IN PCANSI_STRING AnsiString);
+#define DUPLICATE_CLOSE_SOURCE            0x00000001
+#define DUPLICATE_SAME_ACCESS             0x00000002
+#define DUPLICATE_SAME_ATTRIBUTES         0x00000004
 
-#define RtlAnsiStringToUnicodeSize(String) (               \
-  NLS_MB_CODE_PAGE_TAG ?                                   \
-  RtlxAnsiStringToUnicodeSize(String) :                    \
-  ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR)   \
-)
+#define OB_FLT_REGISTRATION_VERSION_0100         0x0100
+#define OB_FLT_REGISTRATION_VERSION OB_FLT_REGISTRATION_VERSION_0100
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAppendUnicodeStringToString(
-    IN OUT PUNICODE_STRING Destination,
-    IN PCUNICODE_STRING Source);
+typedef ULONG OB_OPERATION;
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAppendUnicodeToString(
-    IN OUT PUNICODE_STRING Destination,
-    IN PCWSTR Source);
+#define OB_OPERATION_HANDLE_CREATE               0x00000001
+#define OB_OPERATION_HANDLE_DUPLICATE            0x00000002
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlCheckRegistryKey(
-    IN ULONG RelativeTo,
-    IN PWSTR Path);
+typedef struct _OB_PRE_CREATE_HANDLE_INFORMATION {
+  IN OUT ACCESS_MASK DesiredAccess;
+  IN ACCESS_MASK OriginalDesiredAccess;
+} OB_PRE_CREATE_HANDLE_INFORMATION, *POB_PRE_CREATE_HANDLE_INFORMATION;
 
-NTSYSAPI
-VOID
-NTAPI
-RtlClearAllBits(
-    IN PRTL_BITMAP BitMapHeader);
+typedef struct _OB_PRE_DUPLICATE_HANDLE_INFORMATION {
+  IN OUT ACCESS_MASK DesiredAccess;
+  IN ACCESS_MASK OriginalDesiredAccess;
+  IN PVOID SourceProcess;
+  IN PVOID TargetProcess;
+} OB_PRE_DUPLICATE_HANDLE_INFORMATION, *POB_PRE_DUPLICATE_HANDLE_INFORMATION;
 
-NTSYSAPI
-VOID
-NTAPI
-RtlClearBits(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG StartingIndex,
-    IN ULONG NumberToClear);
+typedef union _OB_PRE_OPERATION_PARAMETERS {
+  IN OUT OB_PRE_CREATE_HANDLE_INFORMATION CreateHandleInformation;
+  IN OUT OB_PRE_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation;
+} OB_PRE_OPERATION_PARAMETERS, *POB_PRE_OPERATION_PARAMETERS;
 
-NTSYSAPI
-SIZE_T
-NTAPI
-RtlCompareMemory(
-    IN CONST VOID *Source1,
-    IN CONST VOID *Source2,
-    IN SIZE_T Length);
+typedef struct _OB_PRE_OPERATION_INFORMATION {
+  IN OB_OPERATION Operation;
+  union {
+    IN ULONG Flags;
+    struct {
+      IN ULONG KernelHandle:1;
+      IN ULONG Reserved:31;
+    };
+  };
+  IN PVOID Object;
+  IN POBJECT_TYPE ObjectType;
+  OUT PVOID CallContext;
+  IN POB_PRE_OPERATION_PARAMETERS Parameters;
+} OB_PRE_OPERATION_INFORMATION, *POB_PRE_OPERATION_INFORMATION;
+
+typedef struct _OB_POST_CREATE_HANDLE_INFORMATION {
+  IN ACCESS_MASK GrantedAccess;
+} OB_POST_CREATE_HANDLE_INFORMATION, *POB_POST_CREATE_HANDLE_INFORMATION;
+
+typedef struct _OB_POST_DUPLICATE_HANDLE_INFORMATION {
+  IN ACCESS_MASK GrantedAccess;
+} OB_POST_DUPLICATE_HANDLE_INFORMATION, *POB_POST_DUPLICATE_HANDLE_INFORMATION;
+
+typedef union _OB_POST_OPERATION_PARAMETERS {
+  IN OB_POST_CREATE_HANDLE_INFORMATION CreateHandleInformation;
+  IN OB_POST_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation;
+} OB_POST_OPERATION_PARAMETERS, *POB_POST_OPERATION_PARAMETERS;
+
+typedef struct _OB_POST_OPERATION_INFORMATION {
+  IN OB_OPERATION Operation;
+    union {
+      IN ULONG Flags;
+      struct {
+        IN ULONG KernelHandle:1;
+        IN ULONG Reserved:31;
+      };
+    };
+  IN PVOID Object;
+  IN POBJECT_TYPE ObjectType;
+  IN PVOID CallContext;
+  IN NTSTATUS ReturnStatus;
+  IN POB_POST_OPERATION_PARAMETERS Parameters;
+} OB_POST_OPERATION_INFORMATION,*POB_POST_OPERATION_INFORMATION;
+
+typedef enum _OB_PREOP_CALLBACK_STATUS {
+  OB_PREOP_SUCCESS
+} OB_PREOP_CALLBACK_STATUS, *POB_PREOP_CALLBACK_STATUS;
+
+typedef OB_PREOP_CALLBACK_STATUS
+(NTAPI *POB_PRE_OPERATION_CALLBACK)(
+  IN PVOID RegistrationContext,
+  IN OUT POB_PRE_OPERATION_INFORMATION OperationInformation);
 
-NTSYSAPI
-LONG
-NTAPI
-RtlCompareUnicodeString(
-    IN PCUNICODE_STRING String1,
-    IN PCUNICODE_STRING String2,
-    IN BOOLEAN CaseInSensitive);
+typedef VOID
+(NTAPI *POB_POST_OPERATION_CALLBACK)(
+  IN PVOID RegistrationContext,
+  IN POB_POST_OPERATION_INFORMATION OperationInformation);
+
+typedef struct _OB_OPERATION_REGISTRATION {
+  IN POBJECT_TYPE *ObjectType;
+  IN OB_OPERATION Operations;
+  IN POB_PRE_OPERATION_CALLBACK PreOperation;
+  IN POB_POST_OPERATION_CALLBACK PostOperation;
+} OB_OPERATION_REGISTRATION, *POB_OPERATION_REGISTRATION;
+
+typedef struct _OB_CALLBACK_REGISTRATION {
+  IN USHORT Version;
+  IN USHORT OperationRegistrationCount;
+  IN UNICODE_STRING Altitude;
+  IN PVOID RegistrationContext;
+  IN OB_OPERATION_REGISTRATION *OperationRegistration;
+} OB_CALLBACK_REGISTRATION, *POB_CALLBACK_REGISTRATION;
 
-NTSYSAPI
-LONG
-NTAPI
-RtlCompareUnicodeStrings(
-    IN PCWCH String1,
-    IN SIZE_T String1Length,
-    IN PCWCH String2,
-    IN SIZE_T String2Length,
-    IN BOOLEAN CaseInSensitive);
+typedef struct _OBJECT_NAME_INFORMATION {
+  UNICODE_STRING  Name;
+} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
 
-NTSYSAPI
-VOID
-NTAPI
-RtlCopyUnicodeString(
-  IN OUT PUNICODE_STRING  DestinationString,
-  IN PCUNICODE_STRING SourceString OPTIONAL);
+/* Exported object types */
+extern POBJECT_TYPE NTSYSAPI CmKeyObjectType;
+extern POBJECT_TYPE NTSYSAPI ExEventObjectType;
+extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType;
+extern POBJECT_TYPE NTSYSAPI IoFileObjectType;
+extern POBJECT_TYPE NTSYSAPI PsThreadType;
+extern POBJECT_TYPE NTSYSAPI SeTokenObjectType;
+extern POBJECT_TYPE NTSYSAPI PsProcessType;
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlCreateRegistryKey(
-    IN ULONG RelativeTo,
-    IN PWSTR Path);
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlCreateSecurityDescriptor(
-    IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
-    IN ULONG Revision);
+/******************************************************************************
+ *                           Process Manager Types                            *
+ ******************************************************************************/
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlDeleteRegistryValue(
-    IN ULONG RelativeTo,
-    IN PCWSTR Path,
-    IN PCWSTR ValueName);
+#define QUOTA_LIMITS_HARDWS_MIN_ENABLE  0x00000001
+#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
+#define QUOTA_LIMITS_HARDWS_MAX_ENABLE  0x00000004
+#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
+#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
 
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlEqualUnicodeString(
-    IN CONST UNICODE_STRING *String1,
-    IN CONST UNICODE_STRING *String2,
-    IN BOOLEAN CaseInSensitive);
+/* Thread Access Rights */
+#define THREAD_TERMINATE                 0x0001
+#define THREAD_SUSPEND_RESUME            0x0002
+#define THREAD_ALERT                     0x0004
+#define THREAD_GET_CONTEXT               0x0008
+#define THREAD_SET_CONTEXT               0x0010
+#define THREAD_SET_INFORMATION           0x0020
+#define THREAD_SET_LIMITED_INFORMATION   0x0400
+#define THREAD_QUERY_LIMITED_INFORMATION 0x0800
 
-#if !defined(_AMD64_) && !defined(_IA64_)
-NTSYSAPI
-LARGE_INTEGER
-NTAPI
-RtlExtendedIntegerMultiply(
-    IN LARGE_INTEGER Multiplicand,
-    IN LONG Multiplier);
+#define PROCESS_DUP_HANDLE                 (0x0040)
 
-NTSYSAPI
-LARGE_INTEGER
-NTAPI
-RtlExtendedLargeIntegerDivide(
-  IN LARGE_INTEGER Dividend,
-  IN ULONG Divisor,
-  OUT PULONG Remainder OPTIONAL);
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+#define PROCESS_ALL_ACCESS  (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
+#else
+#define PROCESS_ALL_ACCESS  (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF)
 #endif
 
-#if defined(_X86_) || defined(_IA64_)
-NTSYSAPI
-LARGE_INTEGER
-NTAPI
-RtlExtendedMagicDivide(
-    IN LARGE_INTEGER Dividend,
-    IN LARGE_INTEGER MagicDivisor,
-    IN CCHAR  ShiftCount);
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+#define THREAD_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
+#else
+#define THREAD_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF)
 #endif
 
-NTSYSAPI
-VOID
-NTAPI
-RtlFreeAnsiString(
-    IN PANSI_STRING AnsiString);
+#define LOW_PRIORITY                      0
+#define LOW_REALTIME_PRIORITY             16
+#define HIGH_PRIORITY                     31
+#define MAXIMUM_PRIORITY                  32
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlFindClearBits(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG NumberToFind,
-    IN ULONG HintIndex);
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlFindClearBitsAndSet(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG NumberToFind,
-    IN ULONG HintIndex);
+/******************************************************************************
+ *                          WMI Library Support Types                         *
+ ******************************************************************************/
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlFindFirstRunClear(
-    IN PRTL_BITMAP BitMapHeader,
-    OUT PULONG StartingIndex);
+#ifdef RUN_WPP
+#include <evntrace.h>
+#include <stdarg.h>
+#endif
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlFindClearRuns(
-    IN PRTL_BITMAP BitMapHeader,
-    OUT PRTL_BITMAP_RUN RunArray,
-    IN ULONG SizeOfRunArray,
-    IN BOOLEAN LocateLongestRuns);
+#ifndef _TRACEHANDLE_DEFINED
+#define _TRACEHANDLE_DEFINED
+typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE;
+#endif
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlFindLastBackwardRunClear(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG FromIndex,
-    OUT PULONG StartingRunIndex);
+#ifndef TRACE_INFORMATION_CLASS_DEFINE
 
-NTSYSAPI
-CCHAR
-NTAPI
-RtlFindLeastSignificantBit(
-    IN ULONGLONG Set);
+typedef struct _ETW_TRACE_SESSION_SETTINGS {
+  ULONG Version;
+  ULONG BufferSize;
+  ULONG MinimumBuffers;
+  ULONG MaximumBuffers;
+  ULONG LoggerMode;
+  ULONG FlushTimer;
+  ULONG FlushThreshold;
+  ULONG ClockType;
+} ETW_TRACE_SESSION_SETTINGS, *PETW_TRACE_SESSION_SETTINGS;
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlFindLongestRunClear(
-    IN PRTL_BITMAP BitMapHeader,
-    OUT PULONG StartingIndex);
+typedef enum _TRACE_INFORMATION_CLASS {
+  TraceIdClass,
+  TraceHandleClass,
+  TraceEnableFlagsClass,
+  TraceEnableLevelClass,
+  GlobalLoggerHandleClass,
+  EventLoggerHandleClass,
+  AllLoggerHandlesClass,
+  TraceHandleByNameClass,
+  LoggerEventsLostClass,
+  TraceSessionSettingsClass,
+  LoggerEventsLoggedClass,
+  MaxTraceInformationClass
+} TRACE_INFORMATION_CLASS;
 
-NTSYSAPI
-CCHAR
-NTAPI
-RtlFindMostSignificantBit(
-    IN ULONGLONG Set);
+#endif /* TRACE_INFORMATION_CLASS_DEFINE */
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlFindNextForwardRunClear(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG FromIndex,
-    OUT PULONG StartingRunIndex);
+#ifndef _ETW_KM_
+#define _ETW_KM_
+#endif
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlFindSetBits(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG NumberToFind,
-    IN ULONG HintIndex);
+#include <evntprov.h>
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlFindSetBitsAndClear(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG NumberToFind,
-    IN ULONG HintIndex);
+typedef VOID
+(NTAPI *PETWENABLECALLBACK)(
+  IN LPCGUID SourceId,
+  IN ULONG ControlCode,
+  IN UCHAR Level,
+  IN ULONGLONG MatchAnyKeyword,
+  IN ULONGLONG MatchAllKeyword,
+  IN PEVENT_FILTER_DESCRIPTOR FilterData OPTIONAL,
+  IN OUT PVOID CallbackContext OPTIONAL);
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlHashUnicodeString(
-    IN CONST UNICODE_STRING *String,
-    IN BOOLEAN CaseInSensitive,
-    IN ULONG HashAlgorithm,
-    OUT PULONG HashValue);
+#define EVENT_WRITE_FLAG_NO_FAULTING             0x00000001
 
-NTSYSAPI
-VOID
-NTAPI
-RtlInitAnsiString(
-    IN OUT PANSI_STRING DestinationString,
-    IN PCSZ SourceString);
 
-NTSYSAPI
+#if defined(_M_IX86)
+/** Kernel definitions for x86 **/
+
+/* Interrupt request levels */
+#define PASSIVE_LEVEL           0
+#define LOW_LEVEL               0
+#define APC_LEVEL               1
+#define DISPATCH_LEVEL          2
+#define CMCI_LEVEL              5
+#define PROFILE_LEVEL           27
+#define CLOCK1_LEVEL            28
+#define CLOCK2_LEVEL            28
+#define IPI_LEVEL               29
+#define POWER_LEVEL             30
+#define HIGH_LEVEL              31
+#define CLOCK_LEVEL             CLOCK2_LEVEL
+
+#define KIP0PCRADDRESS          0xffdff000  
+#define KI_USER_SHARED_DATA     0xffdf0000
+#define SharedUserData          ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA)
+
+#define PAGE_SIZE               0x1000
+#define PAGE_SHIFT              12L
+#define KeGetDcacheFillSize()   1L
+
+#define EFLAG_SIGN              0x8000
+#define EFLAG_ZERO              0x4000
+#define EFLAG_SELECT            (EFLAG_SIGN | EFLAG_ZERO)
+
+#define RESULT_NEGATIVE         ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
+#define RESULT_ZERO             ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
+#define RESULT_POSITIVE         ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
+
+
+typedef struct _KFLOATING_SAVE {
+  ULONG  ControlWord;
+  ULONG  StatusWord;
+  ULONG  ErrorOffset;
+  ULONG  ErrorSelector;
+  ULONG  DataOffset;
+  ULONG  DataSelector;
+  ULONG  Cr0NpxState;
+  ULONG  Spare1;
+} KFLOATING_SAVE, *PKFLOATING_SAVE;
+
+extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount;
+
+#define YieldProcessor _mm_pause
+
+FORCEINLINE
 VOID
+KeMemoryBarrier(VOID)
+{
+  volatile LONG Barrier;
+#if defined(__GNUC__)
+  __asm__ __volatile__ ("xchg %%eax, %0" : : "m" (Barrier) : "%eax");
+#elif defined(_MSC_VER)
+  __asm xchg [Barrier], eax
+#endif
+}
+
+NTHALAPI
+KIRQL
 NTAPI
-RtlInitializeBitMap(
-    IN PRTL_BITMAP BitMapHeader,
-    IN PULONG BitMapBuffer,
-    IN ULONG SizeOfBitMap);
+KeGetCurrentIrql(VOID);
 
-NTSYSAPI
+NTHALAPI
 VOID
-NTAPI
-RtlInitString(
-    IN OUT PSTRING DestinationString,
-    IN PCSZ SourceString);
+FASTCALL
+KfLowerIrql(
+  IN KIRQL  NewIrql);
+#define KeLowerIrql(a) KfLowerIrql(a)
 
-NTSYSAPI
-NTSTATUS
+NTHALAPI
+KIRQL
+FASTCALL
+KfRaiseIrql(
+  IN KIRQL  NewIrql);
+#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
+
+NTHALAPI
+KIRQL
 NTAPI
-RtlIntegerToUnicodeString(
-    IN ULONG Value,
-    IN ULONG Base OPTIONAL,
-    IN OUT PUNICODE_STRING String);
+KeRaiseIrqlToDpcLevel(VOID);
 
-NTSYSAPI
-NTSTATUS
+NTHALAPI
+KIRQL
 NTAPI
-RtlInt64ToUnicodeString(
-    IN ULONGLONG Value,
-    IN ULONG Base OPTIONAL,
-    IN OUT PUNICODE_STRING String);
+KeRaiseIrqlToSynchLevel(VOID);
 
-#ifdef _WIN64
-#define RtlIntPtrToUnicodeString(Value, Base, String) \
-    RtlInt64ToUnicodeString(Value, Base, String)
-#else
-#define RtlIntPtrToUnicodeString(Value, Base, String) \
-    RtlIntegerToUnicodeString(Value, Base, String)
-#endif
+NTHALAPI
+KIRQL
+FASTCALL
+KfAcquireSpinLock(
+  IN OUT PKSPIN_LOCK SpinLock);
+#define KeAcquireSpinLock(a,b)  *(b) = KfAcquireSpinLock(a)
 
-/* BOOLEAN
- * RtlIsZeroLuid(
- *     IN PLUID L1);
- */
-#define RtlIsZeroLuid(_L1) \
-    ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
+NTHALAPI
+VOID
+FASTCALL
+KfReleaseSpinLock(
+  IN OUT PKSPIN_LOCK SpinLock,
+  IN KIRQL NewIrql);
+#define KeReleaseSpinLock(a,b)  KfReleaseSpinLock(a,b)
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlLengthSecurityDescriptor(
-    IN PSECURITY_DESCRIPTOR SecurityDescriptor);
+NTKERNELAPI
+VOID
+FASTCALL
+KefAcquireSpinLockAtDpcLevel(
+  IN OUT PKSPIN_LOCK SpinLock);
+#define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlNumberOfClearBits(
-    IN PRTL_BITMAP BitMapHeader);
+NTKERNELAPI
+VOID
+FASTCALL
+KefReleaseSpinLockFromDpcLevel(
+  IN OUT PKSPIN_LOCK SpinLock);
+#define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
 
 NTSYSAPI
-ULONG
+PKTHREAD
 NTAPI
-RtlNumberOfSetBits(
-    IN PRTL_BITMAP BitMapHeader);
+KeGetCurrentThread(VOID);
 
-NTSYSAPI
+NTKERNELAPI
 NTSTATUS
 NTAPI
-RtlQueryRegistryValues(
-    IN ULONG RelativeTo,
-    IN PCWSTR Path,
-  IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable,
-  IN PVOID Context OPTIONAL,
-    IN PVOID Environment OPTIONAL);
+KeSaveFloatingPointState(
+  OUT PKFLOATING_SAVE  FloatSave);
 
-#define SHORT_SIZE  (sizeof(USHORT))
-#define SHORT_MASK  (SHORT_SIZE - 1)
-#define LONG_SIZE (sizeof(LONG))
-#define LONGLONG_SIZE   (sizeof(LONGLONG))
-#define LONG_MASK (LONG_SIZE - 1)
-#define LONGLONG_MASK   (LONGLONG_SIZE - 1)
-#define LOWBYTE_MASK 0x00FF
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeRestoreFloatingPointState(
+  IN PKFLOATING_SAVE  FloatSave);
 
 /* VOID
- * RtlRetrieveUlong(
- *       PULONG DestinationAddress,
- *       PULONG SourceAddress);
+ * KeFlushIoBuffers(
+ *   IN PMDL Mdl,
+ *   IN BOOLEAN ReadOperation,
+ *   IN BOOLEAN DmaOperation)
  */
-#if defined(_AMD64_)
-#define RtlRetrieveUlong(DestAddress,SrcAddress) \
-    *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
-#else
-#define RtlRetrieveUlong(DestAddress,SrcAddress) \
-    if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
-    { \
-        ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
-        ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
-        ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
-        ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
-    } \
-    else \
-    { \
-        *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
-    }
-#endif
+#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
 
-/* VOID
- * RtlRetrieveUshort(
- *       PUSHORT DestinationAddress,
- *       PUSHORT SourceAddress);
- */
-#if defined(_AMD64_)
-#define RtlRetrieveUshort(DestAddress,SrcAddress) \
-    *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
-#else
-#define RtlRetrieveUshort(DestAddress,SrcAddress) \
-    if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
-    { \
-        ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
-        ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
-    } \
-    else \
-    { \
-        *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
-    }
-#endif
+/* x86 and x64 performs a 0x2C interrupt */
+#define DbgRaiseAssertionFailure __int2c
 
-NTSYSAPI
+FORCEINLINE
 VOID
-NTAPI
-RtlSetAllBits(
-    IN PRTL_BITMAP BitMapHeader);
+_KeQueryTickCount(
+  OUT PLARGE_INTEGER CurrentCount)
+{
+  for (;;) {
+        CurrentCount->HighPart = KeTickCount.High1Time;
+        CurrentCount->LowPart = KeTickCount.LowPart;
+        if (CurrentCount->HighPart == KeTickCount.High2Time) break;
+        YieldProcessor();
+    }
+}
+#define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount)
 
-NTSYSAPI
-VOID
-NTAPI
-RtlSetBits(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG StartingIndex,
-    IN ULONG NumberToSet);
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlSetDaclSecurityDescriptor(
-    IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
-    IN BOOLEAN DaclPresent,
-    IN PACL Dacl OPTIONAL,
-    IN BOOLEAN DaclDefaulted OPTIONAL);
 
-#if defined(_AMD64_)
 
-/* VOID
- * RtlStoreUlong(
- *     IN PULONG Address,
- *     IN ULONG Value);
- */
-#define RtlStoreUlong(Address,Value) \
-    *(ULONG UNALIGNED *)(Address) = (Value)
 
-/* VOID
- * RtlStoreUlonglong(
- *     IN OUT PULONGLONG Address,
- *     ULONGLONG Value);
- */
-#define RtlStoreUlonglong(Address,Value) \
-    *(ULONGLONG UNALIGNED *)(Address) = (Value)
+#elif defined(_M_AMD64)
+/** Kernel definitions for AMD64 **/
 
-/* VOID
- * RtlStoreUshort(
- *     IN PUSHORT Address,
- *     IN USHORT Value);
- */
-#define RtlStoreUshort(Address,Value) \
-    *(USHORT UNALIGNED *)(Address) = (Value)
+/* Interrupt request levels */
+#define PASSIVE_LEVEL           0
+#define LOW_LEVEL               0
+#define APC_LEVEL               1
+#define DISPATCH_LEVEL          2
+#define CMCI_LEVEL              5
+#define CLOCK_LEVEL             13
+#define IPI_LEVEL               14
+#define DRS_LEVEL               14
+#define POWER_LEVEL             14
+#define PROFILE_LEVEL           15
+#define HIGH_LEVEL              15
+
+#define KI_USER_SHARED_DATA     0xFFFFF78000000000ULL
+#define SharedUserData          ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA)
+#define SharedInterruptTime     (KI_USER_SHARED_DATA + 0x8)
+#define SharedSystemTime        (KI_USER_SHARED_DATA + 0x14)
+#define SharedTickCount         (KI_USER_SHARED_DATA + 0x320)
 
-/* VOID
- * RtlRetrieveUshort(
- *     PUSHORT DestinationAddress,
- *    PUSHORT SourceAddress);
- */
-#define RtlRetrieveUshort(DestAddress,SrcAddress) \
-    *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
+#define PAGE_SIZE               0x1000
+#define PAGE_SHIFT              12L
 
-/* VOID
- * RtlRetrieveUlong(
- *    PULONG DestinationAddress,
- *    PULONG SourceAddress);
- */
-#define RtlRetrieveUlong(DestAddress,SrcAddress) \
-    *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
+#define EFLAG_SIGN              0x8000
+#define EFLAG_ZERO              0x4000
+#define EFLAG_SELECT            (EFLAG_SIGN | EFLAG_ZERO)
 
-#else
+#define RESULT_NEGATIVE         ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
+#define RESULT_ZERO             ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
+#define RESULT_POSITIVE         ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
 
-#define RtlStoreUlong(Address,Value)                      \
-    if ((ULONG_PTR)(Address) & LONG_MASK) { \
-        ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT]    = (UCHAR)(FIRSTBYTE(Value)); \
-        ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \
-        ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \
-        ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT]     = (UCHAR)(FOURTHBYTE(Value)); \
-    } \
-    else { \
-        *((PULONG)(Address)) = (ULONG) (Value); \
-    }
-#endif
 
-/* VOID
- * RtlStoreUlonglong(
- *     IN OUT PULONGLONG Address,
- *     ULONGLONG Value);
- */
-#if defined(_AMD64_)
-#define RtlStoreUlonglong(Address,Value) \
-    *(ULONGLONG UNALIGNED *)(Address) = (Value)
-#else
-#define RtlStoreUlonglong(Address,Value) \
-    if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \
-        RtlStoreUlong((ULONG_PTR)(Address), \
-                      (ULONGLONG)(Value) & 0xFFFFFFFF); \
-        RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \
-                      (ULONGLONG)(Value) >> 32); \
-    } else { \
-        *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
-    }
-#endif
+typedef struct _KFLOATING_SAVE {
+  ULONG Dummy;
+} KFLOATING_SAVE, *PKFLOATING_SAVE;
 
-/* VOID
- * RtlStoreUlongPtr(
- *     IN OUT PULONG_PTR Address,
- *     IN ULONG_PTR Value);
- */
-#ifdef _WIN64
-#define RtlStoreUlongPtr(Address,Value)                         \
-    RtlStoreUlonglong(Address,Value)
-#else
-#define RtlStoreUlongPtr(Address,Value)                         \
-    RtlStoreUlong(Address,Value)
-#endif
+typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
 
-/* VOID
- * RtlStoreUshort(
- *     IN PUSHORT Address,
- *     IN USHORT Value);
- */
-#if defined(_AMD64_)
-#define RtlStoreUshort(Address,Value) \
-    *(USHORT UNALIGNED *)(Address) = (Value)
-#else
-#define RtlStoreUshort(Address,Value) \
-    if ((ULONG_PTR)(Address) & SHORT_MASK) { \
-        ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
-        ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \
-    } \
-    else { \
-        *((PUSHORT) (Address)) = (USHORT)Value; \
-    }
-#endif
+#define KeQueryInterruptTime() \
+    (*(volatile ULONG64*)SharedInterruptTime)
 
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlTimeFieldsToTime(
-    IN PTIME_FIELDS TimeFields,
-    IN PLARGE_INTEGER Time);
+#define KeQuerySystemTime(CurrentCount) \
+    *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime
 
-NTSYSAPI
+#define KeQueryTickCount(CurrentCount) \
+    *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount
+
+#define KeGetDcacheFillSize() 1L
+
+#define YieldProcessor _mm_pause
+
+FORCEINLINE
+KIRQL
+KeGetCurrentIrql(VOID)
+{
+  return (KIRQL)__readcr8();
+}
+
+FORCEINLINE
 VOID
-NTAPI
-RtlTimeToTimeFields(
-    IN PLARGE_INTEGER Time,
-    IN PTIME_FIELDS TimeFields);
+KeLowerIrql(IN KIRQL NewIrql)
+{
+  //ASSERT(KeGetCurrentIrql() >= NewIrql);
+  __writecr8(NewIrql);
+}
 
-NTSYSAPI
-ULONG
-FASTCALL
-RtlUlongByteSwap(
-    IN ULONG Source);
+FORCEINLINE
+KIRQL
+KfRaiseIrql(IN KIRQL NewIrql)
+{
+  KIRQL OldIrql;
 
-NTSYSAPI
-ULONGLONG
-FASTCALL
-RtlUlonglongByteSwap(
-    IN ULONGLONG Source);
+  OldIrql = __readcr8();
+  //ASSERT(OldIrql <= NewIrql);
+  __writecr8(NewIrql);
+  return OldIrql;
+}
+#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlUnicodeStringToAnsiString(
-    IN OUT PANSI_STRING DestinationString,
-    IN PCUNICODE_STRING SourceString,
-    IN BOOLEAN AllocateDestinationString);
+FORCEINLINE
+KIRQL
+KeRaiseIrqlToDpcLevel(VOID)
+{
+  return KfRaiseIrql(DISPATCH_LEVEL);
+}
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlxUnicodeStringToAnsiSize(
-    IN PCUNICODE_STRING UnicodeString);
+FORCEINLINE
+KIRQL
+KeRaiseIrqlToSynchLevel(VOID)
+{
+  return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2
+  }
 
-#define RtlUnicodeStringToAnsiSize(String) (                  \
-    NLS_MB_CODE_PAGE_TAG ?                                    \
-    RtlxUnicodeStringToAnsiSize(String) :                     \
-    ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
-)
+FORCEINLINE
+PKTHREAD
+KeGetCurrentThread(VOID)
+{
+  return (struct _KTHREAD *)__readgsqword(0x188);
+}
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlUnicodeStringToInteger(
-    IN PCUNICODE_STRING String,
-    IN ULONG Base OPTIONAL,
-    OUT PULONG Value);
+/* VOID
+ * KeFlushIoBuffers(
+ *   IN PMDL Mdl,
+ *   IN BOOLEAN ReadOperation,
+ *   IN BOOLEAN DmaOperation)
+ */
+#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
 
-NTSYSAPI
-WCHAR
-NTAPI
-RtlUpcaseUnicodeChar(
-    IN WCHAR SourceCharacter);
+/* x86 and x64 performs a 0x2C interrupt */
+#define DbgRaiseAssertionFailure __int2c
 
-NTSYSAPI
-USHORT
-FASTCALL
-RtlUshortByteSwap(
-    IN USHORT Source);
+#elif defined(_M_IA64)
+/** Kernel definitions for IA64 **/
 
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlValidRelativeSecurityDescriptor(
-    IN PSECURITY_DESCRIPTOR SecurityDescriptorInput,
-    IN ULONG SecurityDescriptorLength,
-    IN SECURITY_INFORMATION RequiredInformation);
+/* Interrupt request levels */
+#define PASSIVE_LEVEL           0
+#define LOW_LEVEL               0
+#define APC_LEVEL               1
+#define DISPATCH_LEVEL          2
+#define CMC_LEVEL               3
+#define DEVICE_LEVEL_BASE       4
+#define PC_LEVEL                12
+#define IPI_LEVEL               14
+#define DRS_LEVEL               14
+#define CLOCK_LEVEL             13
+#define POWER_LEVEL             15
+#define PROFILE_LEVEL           15
+#define HIGH_LEVEL              15
+
+#define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000))
+extern volatile LARGE_INTEGER KeTickCount;
+
+#define PAUSE_PROCESSOR __yield();
+
+FORCEINLINE
+VOID
+KeFlushWriteBuffer(VOID)
+{
+  __mf ();
+  return;
+}
 
 NTSYSAPI
-BOOLEAN
+PKTHREAD
 NTAPI
-RtlValidSecurityDescriptor(
-    IN PSECURITY_DESCRIPTOR SecurityDescriptor);
+KeGetCurrentThread(VOID);
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlWriteRegistryValue(
-    IN ULONG RelativeTo,
-    IN PCWSTR Path,
-    IN PCWSTR ValueName,
-    IN ULONG ValueType,
-    IN PVOID ValueData,
-    IN ULONG ValueLength);
 
+#elif defined(_M_PPC)
 
-#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
-
+/* Interrupt request levels */
+#define PASSIVE_LEVEL                      0
+#define LOW_LEVEL                          0
+#define APC_LEVEL                          1
+#define DISPATCH_LEVEL                     2
+#define PROFILE_LEVEL                     27
+#define CLOCK1_LEVEL                      28
+#define CLOCK2_LEVEL                      28
+#define IPI_LEVEL                         29
+#define POWER_LEVEL                       30
+#define HIGH_LEVEL                        31
 
-#if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
-NTSYSAPI
-VOID
-FASTCALL
-RtlPrefetchMemoryNonTemporal(
-    IN PVOID Source,
-    IN SIZE_T Length);
-#endif
+//
+// Used to contain PFNs and PFN counts
+//
+typedef ULONG PFN_COUNT;
+typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
+typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
 
 
-#if (NTDDI_VERSION >= NTDDI_WINXP)
+typedef struct _KFLOATING_SAVE {
+  ULONG Dummy;
+} KFLOATING_SAVE, *PKFLOATING_SAVE;
 
+typedef struct _KPCR_TIB {
+  PVOID ExceptionList;         /* 00 */
+  PVOID StackBase;             /* 04 */
+  PVOID StackLimit;            /* 08 */
+  PVOID SubSystemTib;          /* 0C */
+  _ANONYMOUS_UNION union {
+    PVOID FiberData;           /* 10 */
+    ULONG Version;             /* 10 */
+  } DUMMYUNIONNAME;
+  PVOID ArbitraryUserPointer;  /* 14 */
+  struct _KPCR_TIB *Self;       /* 18 */
+} KPCR_TIB, *PKPCR_TIB;         /* 1C */
+
+#define PCR_MINOR_VERSION 1
+#define PCR_MAJOR_VERSION 1
+
+typedef struct _KPCR {
+  KPCR_TIB Tib;                /* 00 */
+  struct _KPCR *Self;          /* 1C */
+  struct _KPRCB *Prcb;         /* 20 */
+  KIRQL Irql;                  /* 24 */
+  ULONG IRR;                   /* 28 */
+  ULONG IrrActive;             /* 2C */
+  ULONG IDR;                   /* 30 */
+  PVOID KdVersionBlock;        /* 34 */
+  PUSHORT IDT;                 /* 38 */
+  PUSHORT GDT;                 /* 3C */
+  struct _KTSS *TSS;           /* 40 */
+  USHORT MajorVersion;         /* 44 */
+  USHORT MinorVersion;         /* 46 */
+  KAFFINITY SetMember;         /* 48 */
+  ULONG StallScaleFactor;      /* 4C */
+  UCHAR SpareUnused;           /* 50 */
+  UCHAR Number;                /* 51 */
+} KPCR, *PKPCR;                /* 54 */
+
+#define KeGetPcr()                      PCR
+
+#define YieldProcessor() __asm__ __volatile__("nop");
 
+FORCEINLINE
+ULONG
+NTAPI
+KeGetCurrentProcessorNumber(VOID)
+{
+  ULONG Number;
+  __asm__ __volatile__ (
+    "lwz %0, %c1(12)\n"
+    : "=r" (Number)
+    : "i" (FIELD_OFFSET(KPCR, Number))
+  );
+  return Number;
+}
 
-NTSYSAPI
+NTHALAPI
 VOID
-NTAPI
-RtlClearBit(
-    PRTL_BITMAP BitMapHeader,
-    ULONG BitNumber);
+FASTCALL
+KfLowerIrql(
+  IN KIRQL NewIrql);
+#define KeLowerIrql(a) KfLowerIrql(a)
 
-NTSYSAPI
-WCHAR
-NTAPI
-RtlDowncaseUnicodeChar(
-    IN WCHAR SourceCharacter);
+NTHALAPI
+KIRQL
+FASTCALL
+KfRaiseIrql(
+  IN KIRQL NewIrql);
+#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
 
-NTSYSAPI
-VOID
+NTHALAPI
+KIRQL
 NTAPI
-RtlSetBit(
-    PRTL_BITMAP BitMapHeader,
-    ULONG BitNumber);
+KeRaiseIrqlToDpcLevel(VOID);
 
-NTSYSAPI
-BOOLEAN
+NTHALAPI
+KIRQL
 NTAPI
-RtlTestBit(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG BitNumber);
+KeRaiseIrqlToSynchLevel(VOID);
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlHashUnicodeString(
-  IN CONST UNICODE_STRING *String,
-  IN BOOLEAN CaseInSensitive,
-  IN ULONG HashAlgorithm,
-  OUT PULONG HashValue);
 
 
-#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
+#elif defined(_M_MIPS)
+#error MIPS Headers are totally incorrect
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
+//
+// Used to contain PFNs and PFN counts
+//
+typedef ULONG PFN_COUNT;
+typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
+typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
 
+#define PASSIVE_LEVEL                      0
+#define APC_LEVEL                          1
+#define DISPATCH_LEVEL                     2
+#define PROFILE_LEVEL                     27
+#define IPI_LEVEL                         29
+#define HIGH_LEVEL                        31
 
+typedef struct _KPCR {
+  struct _KPRCB *Prcb;         /* 20 */
+  KIRQL Irql;                  /* 24 */
+  ULONG IRR;                   /* 28 */
+  ULONG IDR;                   /* 30 */
+} KPCR, *PKPCR;
 
-NTSYSAPI
+#define KeGetPcr()                      PCR
+
+typedef struct _KFLOATING_SAVE {
+} KFLOATING_SAVE, *PKFLOATING_SAVE;
+
+static __inline
 ULONG
 NTAPI
-RtlNumberOfSetBitsUlongPtr(
-    IN ULONG_PTR Target);
+KeGetCurrentProcessorNumber(VOID)
+{
+  return 0;
+}
 
-NTSYSAPI
-ULONGLONG
-NTAPI
-RtlIoDecodeMemIoResource (
-    IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
-    OUT PULONGLONG Alignment OPTIONAL,
-    OUT PULONGLONG MinimumAddress OPTIONAL,
-    OUT PULONGLONG MaximumAddress OPTIONAL);
+#define YieldProcessor() __asm__ __volatile__("nop");
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlIoEncodeMemIoResource(
-    IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
-    IN UCHAR Type,
-    IN ULONGLONG Length,
-    IN ULONGLONG Alignment,
-    IN ULONGLONG MinimumAddress,
-    IN ULONGLONG MaximumAddress);
+#define KeLowerIrql(a) KfLowerIrql(a)
+#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
 
-NTSYSAPI
-ULONGLONG
+NTKERNELAPI
+VOID
 NTAPI
-RtlCmDecodeMemIoResource(
-    IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor,
-    OUT PULONGLONG Start OPTIONAL);
+KfLowerIrql(
+  IN KIRQL NewIrql);
 
-NTSYSAPI
-NTSTATUS
+NTKERNELAPI
+KIRQL
 NTAPI
-RtlFindClosestEncodableLength(
-    IN ULONGLONG SourceLength,
-    OUT PULONGLONG TargetLength);
+KfRaiseIrql(
+  IN KIRQL NewIrql);
 
-NTSYSAPI
-NTSTATUS
+NTKERNELAPI
+KIRQL
 NTAPI
-RtlCmEncodeMemIoResource(
-  IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
-  IN UCHAR Type,
-  IN ULONGLONG Length,
-  IN ULONGLONG Start);
-
-
-#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
-
-#if (NTDDI_VERSION >= NTDDI_WIN7)
-
-
+KeRaiseIrqlToDpcLevel(VOID);
 
-NTSYSAPI
-NTSTATUS
+NTKERNELAPI
+KIRQL
 NTAPI
-RtlUnicodeToUTF8N(
-  OUT PCHAR UTF8StringDestination,
-  IN ULONG UTF8StringMaxByteCount,
-  OUT PULONG UTF8StringActualByteCount,
-  IN PCWCH UnicodeStringSource,
-  IN ULONG UnicodeStringByteCount);
+KeRaiseIrqlToSynchLevel(VOID);
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlUTF8ToUnicodeN(
-  OUT PWSTR UnicodeStringDestination,
-  IN ULONG UnicodeStringMaxByteCount,
-  OUT PULONG UnicodeStringActualByteCount,
-  IN PCCH UTF8StringSource,
-  IN ULONG UTF8StringByteCount);
 
-NTSYSAPI
-ULONG64
-NTAPI
-RtlGetEnabledExtendedFeatures(
-  IN ULONG64 FeatureMask);
+#elif defined(_M_ARM)
+#include <armddk.h>
+#else
+#error Unknown Architecture
+#endif
 
+/******************************************************************************
+ *                         Runtime Library Functions                          *
+ ******************************************************************************/
 
-#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
 
+#if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
 
-#if !defined(MIDL_PASS)
-/* inline funftions */
-//DECLSPEC_DEPRECATED_DDK_WINXP
-static __inline
-LARGE_INTEGER
-NTAPI_INLINE
-RtlConvertLongToLargeInteger(
-  IN LONG SignedInteger)
-{
-    LARGE_INTEGER ret;
-    ret.QuadPart = SignedInteger;
-    return ret;
-}
+#define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x }
 
-//DECLSPEC_DEPRECATED_DDK_WINXP
-static __inline
-LARGE_INTEGER
-NTAPI_INLINE
-RtlConvertUlongToLargeInteger(
-  IN ULONG UnsignedInteger)
+FORCEINLINE
+VOID
+InitializeListHead(
+  OUT PLIST_ENTRY ListHead)
 {
-    LARGE_INTEGER ret;
-    ret.QuadPart = UnsignedInteger;
-    return ret;
+  ListHead->Flink = ListHead->Blink = ListHead;
 }
 
-//DECLSPEC_DEPRECATED_DDK
-static __inline
-ULONG
-NTAPI_INLINE
-RtlEnlargedUnsignedDivide(
-    IN ULARGE_INTEGER Dividend,
-    IN ULONG Divisor,
-    IN OUT PULONG Remainder)
+BOOLEAN
+FORCEINLINE
+IsListEmpty(
+  IN CONST LIST_ENTRY * ListHead)
 {
-    if (Remainder)
-        *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
-    return (ULONG)(Dividend.QuadPart / Divisor);
+  return (BOOLEAN)(ListHead->Flink == ListHead);
 }
 
-//DECLSPEC_DEPRECATED_DDK
-static __inline
-LARGE_INTEGER
-NTAPI_INLINE
-RtlEnlargedUnsignedMultiply(
-    IN ULONG Multiplicand,
-    IN ULONG Multiplier)
+FORCEINLINE
+BOOLEAN
+RemoveEntryList(
+  IN PLIST_ENTRY  Entry)
 {
-    LARGE_INTEGER ret;
-    ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
-    return ret;
-}
+  PLIST_ENTRY OldFlink;
+  PLIST_ENTRY OldBlink;
 
-//DECLSPEC_DEPRECATED_DDK
-static __inline
-LARGE_INTEGER
-NTAPI_INLINE
-RtlEnlargedIntegerMultiply(
-    IN LONG Multiplicand,
-    IN LONG Multiplier)
-{
-    LARGE_INTEGER ret;
-    ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
-    return ret;
+  OldFlink = Entry->Flink;
+  OldBlink = Entry->Blink;
+  OldFlink->Blink = OldBlink;
+  OldBlink->Flink = OldFlink;
+  return (BOOLEAN)(OldFlink == OldBlink);
 }
 
 FORCEINLINE
-VOID
-RtlInitEmptyAnsiString(
-  OUT PANSI_STRING AnsiString,
-                       IN PCHAR Buffer,
-                       IN USHORT BufferSize)
+PLIST_ENTRY
+RemoveHeadList(
+  IN OUT PLIST_ENTRY  ListHead)
 {
-    AnsiString->Length = 0;
-    AnsiString->MaximumLength = BufferSize;
-    AnsiString->Buffer = Buffer;
+  PLIST_ENTRY Flink;
+  PLIST_ENTRY Entry;
+
+  Entry = ListHead->Flink;
+  Flink = Entry->Flink;
+  ListHead->Flink = Flink;
+  Flink->Blink = ListHead;
+  return Entry;
 }
 
 FORCEINLINE
-VOID
-RtlInitEmptyUnicodeString(
-    OUT PUNICODE_STRING UnicodeString,
-    IN PWSTR Buffer,
-    IN USHORT BufferSize)
+PLIST_ENTRY
+RemoveTailList(
+  IN OUT PLIST_ENTRY  ListHead)
 {
-    UnicodeString->Length = 0;
-    UnicodeString->MaximumLength = BufferSize;
-    UnicodeString->Buffer = Buffer;
-}
-
-#if defined(_AMD64_) || defined(_IA64_)
+  PLIST_ENTRY Blink;
+  PLIST_ENTRY Entry;
 
+  Entry = ListHead->Blink;
+  Blink = Entry->Blink;
+  ListHead->Blink = Blink;
+  Blink->Flink = ListHead;
+  return Entry;
+}
 
-static __inline
-LARGE_INTEGER
-NTAPI_INLINE
-RtlExtendedIntegerMultiply(
-  IN LARGE_INTEGER Multiplicand,
-  IN LONG Multiplier)
+FORCEINLINE
+VOID
+InsertTailList(
+  IN OUT PLIST_ENTRY ListHead,
+  IN OUT PLIST_ENTRY Entry)
 {
-    LARGE_INTEGER ret;
-    ret.QuadPart = Multiplicand.QuadPart * Multiplier;
-    return ret;
+  PLIST_ENTRY OldBlink;
+  OldBlink = ListHead->Blink;
+  Entry->Flink = ListHead;
+  Entry->Blink = OldBlink;
+  OldBlink->Flink = Entry;
+  ListHead->Blink = Entry;
 }
 
-static __inline
-LARGE_INTEGER
-NTAPI_INLINE
-RtlExtendedLargeIntegerDivide(
-  IN LARGE_INTEGER Dividend,
-  IN ULONG Divisor,
-  OUT PULONG Remainder OPTIONAL)
+FORCEINLINE
+VOID
+InsertHeadList(
+  IN OUT PLIST_ENTRY ListHead,
+  IN OUT PLIST_ENTRY Entry)
 {
-    LARGE_INTEGER ret;
-    ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor;
-    if (Remainder)
-        *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
-    return ret;
+  PLIST_ENTRY OldFlink;
+  OldFlink = ListHead->Flink;
+  Entry->Flink = OldFlink;
+  Entry->Blink = ListHead;
+  OldFlink->Blink = Entry;
+  ListHead->Flink = Entry;
 }
 
+FORCEINLINE
+VOID
+AppendTailList(
+  IN OUT PLIST_ENTRY ListHead,
+  IN OUT PLIST_ENTRY ListToAppend)
+{
+  PLIST_ENTRY ListEnd = ListHead->Blink;
 
+  ListHead->Blink->Flink = ListToAppend;
+  ListHead->Blink = ListToAppend->Blink;
+  ListToAppend->Blink->Flink = ListHead;
+  ListToAppend->Blink = ListEnd;
+}
 
-#endif /* defined(_AMD64_) || defined(_IA64_) */
-
-
-#if defined(_AMD64_)
-
-#define MultiplyHigh __mulh
-#define UnsignedMultiplyHigh __umulh
-
-//DECLSPEC_DEPRECATED_DDK
-static __inline
-LARGE_INTEGER
-NTAPI_INLINE
-RtlExtendedMagicDivide(
-    IN LARGE_INTEGER Dividend,
-    IN LARGE_INTEGER MagicDivisor,
-    IN CCHAR ShiftCount)
+FORCEINLINE
+PSINGLE_LIST_ENTRY
+PopEntryList(
+  IN OUT PSINGLE_LIST_ENTRY ListHead)
 {
-    LARGE_INTEGER ret;
-    ULONG64 ret64;
-    BOOLEAN Pos;
-    Pos = (Dividend.QuadPart >= 0);
-    ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart,
-                                 MagicDivisor.QuadPart);
-    ret64 >>= ShiftCount;
-    ret.QuadPart = Pos ? ret64 : -ret64;
-    return ret;
+  PSINGLE_LIST_ENTRY FirstEntry;
+  FirstEntry = ListHead->Next;
+  if (FirstEntry != NULL) {
+    ListHead->Next = FirstEntry->Next;
+  }
+  return FirstEntry;
 }
-#endif
 
-//DECLSPEC_DEPRECATED_DDK
-static __inline
-LARGE_INTEGER
-NTAPI_INLINE
-RtlLargeIntegerAdd(
-    IN LARGE_INTEGER Addend1,
-    IN LARGE_INTEGER Addend2)
+FORCEINLINE
+VOID
+PushEntryList(
+  IN OUT PSINGLE_LIST_ENTRY ListHead,
+  IN OUT PSINGLE_LIST_ENTRY Entry)
 {
-    LARGE_INTEGER ret;
-    ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart;
-    return ret;
+  Entry->Next = ListHead->Next;
+  ListHead->Next = Entry;
 }
 
-/* VOID
- * RtlLargeIntegerAnd(
- *     IN OUT LARGE_INTEGER Result,
- *     IN LARGE_INTEGER Source,
- *     IN LARGE_INTEGER Mask);
- */
-#define RtlLargeIntegerAnd(Result, Source, Mask) \
-    Result.QuadPart = Source.QuadPart & Mask.QuadPart
+#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */
 
-//DECLSPEC_DEPRECATED_DDK
-static __inline
-LARGE_INTEGER
-NTAPI_INLINE
-RtlLargeIntegerArithmeticShift(
-    IN LARGE_INTEGER LargeInteger,
-    IN CCHAR ShiftCount)
-{
-    LARGE_INTEGER ret;
-    ret.QuadPart = LargeInteger.QuadPart >> ShiftCount;
-    return ret;
-}
+NTSYSAPI
+VOID
+NTAPI
+RtlAssert(
+    IN PVOID FailedAssertion,
+    IN PVOID FileName,
+    IN ULONG LineNumber,
+    IN PSTR Message);
 
-/* BOOLEAN
- * RtlLargeIntegerEqualTo(
- *     IN LARGE_INTEGER  Operand1,
- *     IN LARGE_INTEGER  Operand2);
+/* VOID
+ * RtlCopyMemory(
+ *     IN VOID UNALIGNED *Destination,
+ *     IN CONST VOID UNALIGNED *Source,
+ *     IN SIZE_T Length)
  */
-#define RtlLargeIntegerEqualTo(X,Y) \
-    (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
+#define RtlCopyMemory(Destination, Source, Length) \
+    memcpy(Destination, Source, Length)
 
-FORCEINLINE
-PVOID
-RtlSecureZeroMemory(
-    OUT PVOID Pointer,
-    IN SIZE_T Size)
-{
-    volatile char* vptr = (volatile char*)Pointer;
-#if defined(_M_AMD64)
-    __stosb((PUCHAR)vptr, 0, Size);
-#else
-    char * endptr = (char *)vptr + Size;
-  while (vptr < endptr) {
-        *vptr = 0; vptr++;
-    }
-#endif
-     return Pointer;
-}
+#define RtlCopyBytes RtlCopyMemory
 
 #if defined(_M_AMD64)
-FORCEINLINE
-BOOLEAN
-RtlCheckBit(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG BitPosition)
-{
-  return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition);
-}
+NTSYSAPI
+VOID
+NTAPI
+RtlCopyMemoryNonTemporal(
+    VOID UNALIGNED *Destination,
+    CONST VOID UNALIGNED *Source,
+    SIZE_T Length);
 #else
-#define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
-#endif /* defined(_M_AMD64) */
+#define RtlCopyMemoryNonTemporal RtlCopyMemory
+#endif
 
-#define RtlLargeIntegerGreaterThan(X,Y) (                              \
-    (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
-    ((X).HighPart > (Y).HighPart)                                      \
-)
+/* BOOLEAN
+ * RtlEqualLuid(
+ *     IN PLUID Luid1,
+ *     IN PLUID Luid2)
+ */
+#define RtlEqualLuid(Luid1, Luid2) \
+    (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart))
 
-#define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) (                      \
-    (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
-    ((X).HighPart > (Y).HighPart)                                       \
-)
+/* ULONG
+ * RtlEqualMemory(
+ *     IN VOID UNALIGNED *Destination,
+ *     IN CONST VOID UNALIGNED *Source,
+ *     IN SIZE_T Length)
+ */
+#define RtlEqualMemory(Destination, Source, Length) \
+    (!memcmp(Destination, Source, Length))
 
-#define RtlLargeIntegerNotEqualTo(X,Y) (                          \
-    (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
-)
+/* VOID
+ * RtlFillMemory(
+ *     IN VOID UNALIGNED *Destination,
+ *     IN SIZE_T Length,
+ *     IN UCHAR Fill)
+ */
+#define RtlFillMemory(Destination, Length, Fill) \
+    memset(Destination, Fill, Length)
 
-#define RtlLargeIntegerLessThan(X,Y) (                                 \
-    (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
-    ((X).HighPart < (Y).HighPart)                                      \
-)
+#define RtlFillBytes RtlFillMemory
 
-#define RtlLargeIntegerLessThanOrEqualTo(X,Y) (                         \
-    (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
-    ((X).HighPart < (Y).HighPart)                                       \
-)
+NTSYSAPI
+VOID
+NTAPI
+RtlFreeUnicodeString(
+    IN OUT PUNICODE_STRING UnicodeString);
 
-#define RtlLargeIntegerGreaterThanZero(X) (       \
-    (((X).HighPart == 0) && ((X).LowPart > 0)) || \
-    ((X).HighPart > 0 )                           \
-)
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlGUIDFromString(
+    IN PUNICODE_STRING GuidString,
+    OUT GUID *Guid);
 
-#define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
+NTSYSAPI
+VOID
+NTAPI
+RtlInitUnicodeString(
+    IN OUT PUNICODE_STRING DestinationString,
+    IN PCWSTR SourceString OPTIONAL);
 
-#define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
+/* VOID
+ * RtlMoveMemory(
+ *    IN VOID UNALIGNED *Destination,
+ *    IN CONST VOID UNALIGNED *Source,
+ *    IN SIZE_T Length)
+ */
+#define RtlMoveMemory(Destination, Source, Length) \
+    memmove(Destination, Source, Length)
 
-#define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlStringFromGUID(
+    IN REFGUID Guid,
+    OUT PUNICODE_STRING GuidString);
 
-#define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
+/* VOID
+ * RtlZeroMemory(
+ *     IN VOID UNALIGNED *Destination,
+ *     IN SIZE_T Length)
+ */
+#define RtlZeroMemory(Destination, Length) \
+    memset(Destination, 0, Length)
 
-#define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
+#define RtlZeroBytes RtlZeroMemory
 
-#endif /* !defined(MIDL_PASS) */
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
-/* Byte Swap Functions */
-#if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \
-    ((defined(_M_AMD64) || defined(_M_IA64)) \
-        && (_MSC_FULL_VER > 13009175 || defined(__GNUC__)))
 
-#define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
-#define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
-#define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
 
-#endif
+NTSYSAPI
+BOOLEAN
+NTAPI
+RtlAreBitsClear(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG StartingIndex,
+    IN ULONG Length);
 
-#if DBG
+NTSYSAPI
+BOOLEAN
+NTAPI
+RtlAreBitsSet(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG StartingIndex,
+    IN ULONG Length);
 
-#define ASSERT(exp) \
-  (VOID)((!(exp)) ? \
-    RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlAnsiStringToUnicodeString(
+    IN OUT PUNICODE_STRING DestinationString,
+    IN PANSI_STRING SourceString,
+    IN BOOLEAN AllocateDestinationString);
 
-#define ASSERTMSG(msg, exp) \
-  (VOID)((!(exp)) ? \
-    RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, msg ), FALSE : TRUE)
+NTSYSAPI
+ULONG
+NTAPI
+RtlxAnsiStringToUnicodeSize(
+    IN PCANSI_STRING AnsiString);
 
-#define RTL_SOFT_ASSERT(exp) \
-  (VOID)((!(exp)) ? \
-    DbgPrint("%s(%d): Soft assertion failed\n   Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
+#define RtlAnsiStringToUnicodeSize(String) (               \
+  NLS_MB_CODE_PAGE_TAG ?                                   \
+  RtlxAnsiStringToUnicodeSize(String) :                    \
+  ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR)   \
+)
 
-#define RTL_SOFT_ASSERTMSG(msg, exp) \
-  (VOID)((!(exp)) ? \
-    DbgPrint("%s(%d): Soft assertion failed\n   Expression: %s\n   Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlAppendUnicodeStringToString(
+    IN OUT PUNICODE_STRING Destination,
+    IN PCUNICODE_STRING Source);
 
-#define RTL_VERIFY(exp) ASSERT(exp)
-#define RTL_VERIFYMSG(msg, exp) ASSERTMSG(msg, exp)
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlAppendUnicodeToString(
+    IN OUT PUNICODE_STRING Destination,
+    IN PCWSTR Source);
 
-#define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
-#define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlCheckRegistryKey(
+    IN ULONG RelativeTo,
+    IN PWSTR Path);
 
-#if defined(_MSC_VER)
+NTSYSAPI
+VOID
+NTAPI
+RtlClearAllBits(
+    IN PRTL_BITMAP BitMapHeader);
 
-#define NT_ASSERT(exp) \
-   ((!(exp)) ? \
-      (__annotation(L"Debug", L"AssertFail", L#exp), \
-       DbgRaiseAssertionFailure(), FALSE) : TRUE)
+NTSYSAPI
+VOID
+NTAPI
+RtlClearBits(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG StartingIndex,
+    IN ULONG NumberToClear);
 
-#define NT_ASSERTMSG(msg, exp) \
-   ((!(exp)) ? \
-      (__annotation(L"Debug", L"AssertFail", L##msg), \
-      DbgRaiseAssertionFailure(), FALSE) : TRUE)
+NTSYSAPI
+SIZE_T
+NTAPI
+RtlCompareMemory(
+    IN CONST VOID *Source1,
+    IN CONST VOID *Source2,
+    IN SIZE_T Length);
 
-#define NT_ASSERTMSGW(msg, exp) \
-    ((!(exp)) ? \
-        (__annotation(L"Debug", L"AssertFail", msg), \
-         DbgRaiseAssertionFailure(), FALSE) : TRUE)
+NTSYSAPI
+LONG
+NTAPI
+RtlCompareUnicodeString(
+    IN PCUNICODE_STRING String1,
+    IN PCUNICODE_STRING String2,
+    IN BOOLEAN CaseInSensitive);
 
-#else
+NTSYSAPI
+LONG
+NTAPI
+RtlCompareUnicodeStrings(
+    IN PCWCH String1,
+    IN SIZE_T String1Length,
+    IN PCWCH String2,
+    IN SIZE_T String2Length,
+    IN BOOLEAN CaseInSensitive);
 
-/* GCC doesn't support __annotation (nor PDB) */
-#define NT_ASSERT(exp) \
-   (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
+NTSYSAPI
+VOID
+NTAPI
+RtlCopyUnicodeString(
+  IN OUT PUNICODE_STRING  DestinationString,
+  IN PCUNICODE_STRING SourceString OPTIONAL);
 
-#define NT_ASSERTMSG NT_ASSERT
-#define NT_ASSERTMSGW NT_ASSERT
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlCreateRegistryKey(
+    IN ULONG RelativeTo,
+    IN PWSTR Path);
 
-#endif
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlCreateSecurityDescriptor(
+    IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
+    IN ULONG Revision);
 
-#else /* !DBG */
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlDeleteRegistryValue(
+    IN ULONG RelativeTo,
+    IN PCWSTR Path,
+    IN PCWSTR ValueName);
 
-#define ASSERT(exp) ((VOID) 0)
-#define ASSERTMSG(msg, exp) ((VOID) 0)
+NTSYSAPI
+BOOLEAN
+NTAPI
+RtlEqualUnicodeString(
+    IN CONST UNICODE_STRING *String1,
+    IN CONST UNICODE_STRING *String2,
+    IN BOOLEAN CaseInSensitive);
 
-#define RTL_SOFT_ASSERT(exp) ((VOID) 0)
-#define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
+#if !defined(_AMD64_) && !defined(_IA64_)
+NTSYSAPI
+LARGE_INTEGER
+NTAPI
+RtlExtendedIntegerMultiply(
+    IN LARGE_INTEGER Multiplicand,
+    IN LONG Multiplier);
 
-#define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
-#define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
+NTSYSAPI
+LARGE_INTEGER
+NTAPI
+RtlExtendedLargeIntegerDivide(
+  IN LARGE_INTEGER Dividend,
+  IN ULONG Divisor,
+  OUT PULONG Remainder OPTIONAL);
+#endif
 
-#define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
-#define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
+#if defined(_X86_) || defined(_IA64_)
+NTSYSAPI
+LARGE_INTEGER
+NTAPI
+RtlExtendedMagicDivide(
+    IN LARGE_INTEGER Dividend,
+    IN LARGE_INTEGER MagicDivisor,
+    IN CCHAR  ShiftCount);
+#endif
 
-#define NT_ASSERT(exp)     ((VOID)0)
-#define NT_ASSERTMSG(exp)  ((VOID)0)
-#define NT_ASSERTMSGW(exp) ((VOID)0)
+NTSYSAPI
+VOID
+NTAPI
+RtlFreeAnsiString(
+    IN PANSI_STRING AnsiString);
 
-#define NT_VERIFY(_exp)           ((_exp) ? TRUE : FALSE)
-#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
-#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
-
-#endif /* DBG */
-
-#define InitializeListHead32(ListHead) (\
-    (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
-
-#if !defined(_WINBASE_)
-
-#if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
-
-NTKERNELAPI
-VOID
-InitializeSListHead(
-  OUT PSLIST_HEADER SListHead);
-
-#else
-
-VOID
-FORCEINLINE
-InitializeSListHead(
-  OUT PSLIST_HEADER SListHead)
-{
-#if defined(_IA64_)
-    ULONG64 FeatureBits;
-#endif
-
-#if defined(_WIN64)
-  if (((ULONG_PTR)SListHead & 0xf) != 0) {
-        RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
-    }
-#endif
-    RtlZeroMemory(SListHead, sizeof(SLIST_HEADER));
-#if defined(_IA64_)
-    FeatureBits = __getReg(CV_IA64_CPUID4);
-  if ((FeatureBits & KF_16BYTE_INSTR) != 0) {
-        SListHead->Header16.HeaderType = 1;
-        SListHead->Header16.Init = 1;
-    }
-#endif
-}
-
-#endif
-
-#if defined(_WIN64)
-
-#define InterlockedPopEntrySList(Head) \
-    ExpInterlockedPopEntrySList(Head)
-
-#define InterlockedPushEntrySList(Head, Entry) \
-    ExpInterlockedPushEntrySList(Head, Entry)
-
-#define InterlockedFlushSList(Head) \
-    ExpInterlockedFlushSList(Head)
-
-#define QueryDepthSList(Head) \
-    ExQueryDepthSList(Head)
-
-#else /* !defined(_WIN64) */
-
-NTKERNELAPI
-PSLIST_ENTRY
-FASTCALL
-InterlockedPopEntrySList(
-    IN PSLIST_HEADER ListHead);
-
-NTKERNELAPI
-PSLIST_ENTRY
-FASTCALL
-InterlockedPushEntrySList(
-    IN PSLIST_HEADER ListHead,
-    IN PSLIST_ENTRY ListEntry);
-
-#define InterlockedFlushSList(ListHead) \
-    ExInterlockedFlushSList(ListHead)
+NTSYSAPI
+ULONG
+NTAPI
+RtlFindClearBits(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG NumberToFind,
+    IN ULONG HintIndex);
 
-#define QueryDepthSList(Head) \
-    ExQueryDepthSList(Head)
+NTSYSAPI
+ULONG
+NTAPI
+RtlFindClearBitsAndSet(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG NumberToFind,
+    IN ULONG HintIndex);
 
-#endif /* !defined(_WIN64) */
+NTSYSAPI
+ULONG
+NTAPI
+RtlFindFirstRunClear(
+    IN PRTL_BITMAP BitMapHeader,
+    OUT PULONG StartingIndex);
 
-#endif /* !defined(_WINBASE_) */
+NTSYSAPI
+ULONG
+NTAPI
+RtlFindClearRuns(
+    IN PRTL_BITMAP BitMapHeader,
+    OUT PRTL_BITMAP_RUN RunArray,
+    IN ULONG SizeOfRunArray,
+    IN BOOLEAN LocateLongestRuns);
 
-/******************************************************************************
- *                              Kernel Functions                              *
- ******************************************************************************/
+NTSYSAPI
+ULONG
+NTAPI
+RtlFindLastBackwardRunClear(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG FromIndex,
+    OUT PULONG StartingRunIndex);
 
-NTHALAPI
-KIRQL
+NTSYSAPI
+CCHAR
 NTAPI
-KeGetCurrentIrql(
-    VOID);
+RtlFindLeastSignificantBit(
+    IN ULONGLONG Set);
 
-NTKERNELAPI
-VOID
+NTSYSAPI
+ULONG
 NTAPI
-KeInitializeEvent(
-  OUT PRKEVENT  Event,
-  IN EVENT_TYPE  Type,
-  IN BOOLEAN  State);
+RtlFindLongestRunClear(
+    IN PRTL_BITMAP BitMapHeader,
+    OUT PULONG StartingIndex);
 
-NTKERNELAPI
-VOID
+NTSYSAPI
+CCHAR
 NTAPI
-KeClearEvent(
-  IN OUT PRKEVENT Event);
+RtlFindMostSignificantBit(
+    IN ULONGLONG Set);
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+NTSYSAPI
+ULONG
+NTAPI
+RtlFindNextForwardRunClear(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG FromIndex,
+    OUT PULONG StartingRunIndex);
 
+NTSYSAPI
+ULONG
+NTAPI
+RtlFindSetBits(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG NumberToFind,
+    IN ULONG HintIndex);
 
-#if defined(_NTDDK_) || defined(_NTIFS_)
-NTKERNELAPI
-VOID
+NTSYSAPI
+ULONG
 NTAPI
-ProbeForRead(
-  IN CONST VOID *Address, /* CONST is added */
-  IN SIZE_T Length,
-  IN ULONG Alignment);
-#endif /* defined(_NTDDK_) || defined(_NTIFS_) */
+RtlFindSetBitsAndClear(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG NumberToFind,
+    IN ULONG HintIndex);
 
-NTKERNELAPI
+NTSYSAPI
 VOID
 NTAPI
-ProbeForWrite(
-  IN PVOID Address,
-  IN SIZE_T Length,
-  IN ULONG Alignment);
-
-
-#if defined(SINGLE_GROUP_LEGACY_API)
+RtlInitAnsiString(
+    IN OUT PANSI_STRING DestinationString,
+    IN PCSZ SourceString);
 
-NTKERNELAPI
+NTSYSAPI
 VOID
 NTAPI
-KeRevertToUserAffinityThread(VOID);
+RtlInitializeBitMap(
+    IN PRTL_BITMAP BitMapHeader,
+    IN PULONG BitMapBuffer,
+    IN ULONG SizeOfBitMap);
 
-NTKERNELAPI
+NTSYSAPI
 VOID
 NTAPI
-KeSetSystemAffinityThread(
-    IN KAFFINITY Affinity);
+RtlInitString(
+    IN OUT PSTRING DestinationString,
+    IN PCSZ SourceString);
 
-NTKERNELAPI
-VOID
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeSetTargetProcessorDpc(
-  IN OUT PRKDPC Dpc,
-  IN CCHAR Number);
+RtlIntegerToUnicodeString(
+    IN ULONG Value,
+    IN ULONG Base OPTIONAL,
+    IN OUT PUNICODE_STRING String);
 
-NTKERNELAPI
-KAFFINITY
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeQueryActiveProcessors(VOID);
+RtlInt64ToUnicodeString(
+    IN ULONGLONG Value,
+    IN ULONG Base OPTIONAL,
+    IN OUT PUNICODE_STRING String);
 
+#ifdef _WIN64
+#define RtlIntPtrToUnicodeString(Value, Base, String) \
+    RtlInt64ToUnicodeString(Value, Base, String)
+#else
+#define RtlIntPtrToUnicodeString(Value, Base, String) \
+    RtlIntegerToUnicodeString(Value, Base, String)
+#endif
 
-#endif /* defined(SINGLE_GROUP_LEGACY_API) */
+/* BOOLEAN
+ * RtlIsZeroLuid(
+ *     IN PLUID L1);
+ */
+#define RtlIsZeroLuid(_L1) \
+    ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart)))
 
-#if !defined(_M_AMD64)
-NTKERNELAPI
-ULONGLONG
+NTSYSAPI
+ULONG
 NTAPI
-KeQueryInterruptTime(VOID);
+RtlLengthSecurityDescriptor(
+    IN PSECURITY_DESCRIPTOR SecurityDescriptor);
 
-NTKERNELAPI
-VOID
+NTSYSAPI
+ULONG
 NTAPI
-KeQuerySystemTime(
-  OUT PLARGE_INTEGER  CurrentTime);
-#endif /* !_M_AMD64 */
+RtlNumberOfClearBits(
+    IN PRTL_BITMAP BitMapHeader);
 
-#if !defined(_X86_)
-NTKERNELAPI
-KIRQL
+NTSYSAPI
+ULONG
 NTAPI
-KeAcquireSpinLockRaiseToDpc(
-  IN OUT PKSPIN_LOCK SpinLock);
-
-#define KeAcquireSpinLock(SpinLock, OldIrql) \
-    *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
+RtlNumberOfSetBits(
+    IN PRTL_BITMAP BitMapHeader);
 
-NTKERNELAPI
-VOID
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeAcquireSpinLockAtDpcLevel(
-  IN OUT PKSPIN_LOCK SpinLock);
+RtlQueryRegistryValues(
+    IN ULONG RelativeTo,
+    IN PCWSTR Path,
+  IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable,
+  IN PVOID Context OPTIONAL,
+    IN PVOID Environment OPTIONAL);
 
-NTKERNELAPI
-VOID
-NTAPI
-KeReleaseSpinLock(
-  IN OUT PKSPIN_LOCK SpinLock,
-  IN KIRQL NewIrql);
+#define SHORT_SIZE  (sizeof(USHORT))
+#define SHORT_MASK  (SHORT_SIZE - 1)
+#define LONG_SIZE (sizeof(LONG))
+#define LONGLONG_SIZE   (sizeof(LONGLONG))
+#define LONG_MASK (LONG_SIZE - 1)
+#define LONGLONG_MASK   (LONGLONG_SIZE - 1)
+#define LOWBYTE_MASK 0x00FF
 
-NTKERNELAPI
-VOID
-NTAPI
-KeReleaseSpinLockFromDpcLevel(
-  IN OUT PKSPIN_LOCK SpinLock);
-#endif /* !_X86_ */
+#define FIRSTBYTE(VALUE)  ((VALUE) & LOWBYTE_MASK)
+#define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK)
+#define THIRDBYTE(VALUE)  (((VALUE) >> 16) & LOWBYTE_MASK)
+#define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK)
 
-#if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK))
-NTKERNELAPI
+NTSYSAPI
 VOID
 NTAPI
-KeInitializeSpinLock(
-    IN PKSPIN_LOCK SpinLock);
-#else
-FORCEINLINE
-VOID
-KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
-{
-    /* Clear the lock */
-    *SpinLock = 0;
-}
-#endif
+RtlSetAllBits(
+    IN PRTL_BITMAP BitMapHeader);
 
-NTKERNELAPI
-DECLSPEC_NORETURN
+NTSYSAPI
 VOID
 NTAPI
-KeBugCheckEx(
-  IN ULONG  BugCheckCode,
-  IN ULONG_PTR  BugCheckParameter1,
-  IN ULONG_PTR  BugCheckParameter2,
-  IN ULONG_PTR  BugCheckParameter3,
-  IN ULONG_PTR  BugCheckParameter4);
-
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeCancelTimer(
-  IN OUT PKTIMER);
+RtlSetBits(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG StartingIndex,
+    IN ULONG NumberToSet);
 
-NTKERNELAPI
+NTSYSAPI
 NTSTATUS
 NTAPI
-KeDelayExecutionThread(
-  IN KPROCESSOR_MODE WaitMode,
-  IN BOOLEAN Alertable,
-  IN PLARGE_INTEGER Interval);
+RtlSetDaclSecurityDescriptor(
+    IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
+    IN BOOLEAN DaclPresent,
+    IN PACL Dacl OPTIONAL,
+    IN BOOLEAN DaclDefaulted OPTIONAL);
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeDeregisterBugCheckCallback(
-  IN OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
+#if defined(_AMD64_)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeEnterCriticalRegion(VOID);
+/* VOID
+ * RtlStoreUlong(
+ *     IN PULONG Address,
+ *     IN ULONG Value);
+ */
+#define RtlStoreUlong(Address,Value) \
+    *(ULONG UNALIGNED *)(Address) = (Value)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeDeviceQueue(
-  OUT PKDEVICE_QUEUE  DeviceQueue);
+/* VOID
+ * RtlStoreUlonglong(
+ *     IN OUT PULONGLONG Address,
+ *     ULONGLONG Value);
+ */
+#define RtlStoreUlonglong(Address,Value) \
+    *(ULONGLONG UNALIGNED *)(Address) = (Value)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeDpc(
-  OUT PRKDPC  Dpc,
-  IN PKDEFERRED_ROUTINE  DeferredRoutine,
-  IN PVOID  DeferredContext OPTIONAL);
+/* VOID
+ * RtlStoreUshort(
+ *     IN PUSHORT Address,
+ *     IN USHORT Value);
+ */
+#define RtlStoreUshort(Address,Value) \
+    *(USHORT UNALIGNED *)(Address) = (Value)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeMutex(
-  OUT PRKMUTEX  Mutex,
-  IN ULONG  Level);
+/* VOID
+ * RtlRetrieveUshort(
+ *     PUSHORT DestinationAddress,
+ *    PUSHORT SourceAddress);
+ */
+#define RtlRetrieveUshort(DestAddress,SrcAddress) \
+    *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeSemaphore(
-  OUT PRKSEMAPHORE  Semaphore,
-  IN LONG  Count,
-  IN LONG  Limit);
+/* VOID
+ * RtlRetrieveUlong(
+ *    PULONG DestinationAddress,
+ *    PULONG SourceAddress);
+ */
+#define RtlRetrieveUlong(DestAddress,SrcAddress) \
+    *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeTimer(
-  OUT PKTIMER  Timer);
+#else
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeTimerEx(
-  OUT PKTIMER  Timer,
-  IN TIMER_TYPE  Type);
+#define RtlStoreUlong(Address,Value)                      \
+    if ((ULONG_PTR)(Address) & LONG_MASK) { \
+        ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT]    = (UCHAR)(FIRSTBYTE(Value)); \
+        ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \
+        ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \
+        ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT]     = (UCHAR)(FOURTHBYTE(Value)); \
+    } \
+    else { \
+        *((PULONG)(Address)) = (ULONG) (Value); \
+    }
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeInsertByKeyDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue,
-  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry,
-  IN ULONG  SortKey);
+#define RtlStoreUlonglong(Address,Value) \
+    if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \
+        RtlStoreUlong((ULONG_PTR)(Address), \
+                      (ULONGLONG)(Value) & 0xFFFFFFFF); \
+        RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \
+                      (ULONGLONG)(Value) >> 32); \
+    } else { \
+        *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \
+    }
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeInsertDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue,
-  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry);
+#define RtlStoreUshort(Address,Value) \
+    if ((ULONG_PTR)(Address) & SHORT_MASK) { \
+        ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \
+        ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \
+    } \
+    else { \
+        *((PUSHORT) (Address)) = (USHORT)Value; \
+    }
 
-NTKERNELAPI
+#define RtlRetrieveUshort(DestAddress,SrcAddress) \
+    if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
+    { \
+        ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
+        ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
+    } \
+    else \
+    { \
+        *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
+    }
+
+#define RtlRetrieveUlong(DestAddress,SrcAddress) \
+    if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \
+    { \
+        ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
+        ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
+        ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
+        ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
+    } \
+    else \
+    { \
+        *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
+    }
+
+#endif /* defined(_AMD64_) */
+
+#ifdef _WIN64
+/* VOID
+ * RtlStoreUlongPtr(
+ *     IN OUT PULONG_PTR Address,
+ *     IN ULONG_PTR Value);
+ */
+#define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value)
+#else
+#define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value)
+#endif /* _WIN64 */
+
+
+NTSYSAPI
 BOOLEAN
 NTAPI
-KeInsertQueueDpc(
-  IN OUT PRKDPC  Dpc,
-  IN PVOID  SystemArgument1 OPTIONAL,
-  IN PVOID  SystemArgument2 OPTIONAL);
+RtlTimeFieldsToTime(
+    IN PTIME_FIELDS TimeFields,
+    IN PLARGE_INTEGER Time);
 
-NTKERNELAPI
+NTSYSAPI
 VOID
 NTAPI
-KeLeaveCriticalRegion(VOID);
+RtlTimeToTimeFields(
+    IN PLARGE_INTEGER Time,
+    IN PTIME_FIELDS TimeFields);
 
-NTHALAPI
-LARGE_INTEGER
-NTAPI
-KeQueryPerformanceCounter(
-  OUT PLARGE_INTEGER  PerformanceFrequency  OPTIONAL);
+NTSYSAPI
+ULONG
+FASTCALL
+RtlUlongByteSwap(
+    IN ULONG Source);
 
-NTKERNELAPI
-KPRIORITY
+NTSYSAPI
+ULONGLONG
+FASTCALL
+RtlUlonglongByteSwap(
+    IN ULONGLONG Source);
+
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeQueryPriorityThread(
-  IN PRKTHREAD  Thread);
+RtlUnicodeStringToAnsiString(
+    IN OUT PANSI_STRING DestinationString,
+    IN PCUNICODE_STRING SourceString,
+    IN BOOLEAN AllocateDestinationString);
 
-NTKERNELAPI
+NTSYSAPI
 ULONG
 NTAPI
-KeQueryTimeIncrement(VOID);
+RtlxUnicodeStringToAnsiSize(
+    IN PCUNICODE_STRING UnicodeString);
 
-NTKERNELAPI
-LONG
-NTAPI
-KeReadStateEvent(
-  IN PRKEVENT  Event);
+#define RtlUnicodeStringToAnsiSize(String) (                  \
+    NLS_MB_CODE_PAGE_TAG ?                                    \
+    RtlxUnicodeStringToAnsiSize(String) :                     \
+    ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
+)
 
-NTKERNELAPI
-LONG
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeReadStateMutex(
-  IN PRKMUTEX  Mutex);
+RtlUnicodeStringToInteger(
+    IN PCUNICODE_STRING String,
+    IN ULONG Base OPTIONAL,
+    OUT PULONG Value);
 
-NTKERNELAPI
-LONG
+NTSYSAPI
+WCHAR
 NTAPI
-KeReadStateSemaphore(
-  IN PRKSEMAPHORE  Semaphore);
+RtlUpcaseUnicodeChar(
+    IN WCHAR SourceCharacter);
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeReadStateTimer(
-  IN PKTIMER  Timer);
+NTSYSAPI
+USHORT
+FASTCALL
+RtlUshortByteSwap(
+    IN USHORT Source);
 
-NTKERNELAPI
+NTSYSAPI
 BOOLEAN
 NTAPI
-KeRegisterBugCheckCallback(
-  OUT PKBUGCHECK_CALLBACK_RECORD  CallbackRecord,
-  IN PKBUGCHECK_CALLBACK_ROUTINE  CallbackRoutine,
-  IN PVOID  Buffer,
-  IN ULONG  Length,
-  IN PUCHAR  Component);
+RtlValidRelativeSecurityDescriptor(
+    IN PSECURITY_DESCRIPTOR SecurityDescriptorInput,
+    IN ULONG SecurityDescriptorLength,
+    IN SECURITY_INFORMATION RequiredInformation);
 
-NTKERNELAPI
-LONG
+NTSYSAPI
+BOOLEAN
 NTAPI
-KeReleaseMutex(
-  IN OUT PRKMUTEX  Mutex,
-  IN BOOLEAN  Wait);
+RtlValidSecurityDescriptor(
+    IN PSECURITY_DESCRIPTOR SecurityDescriptor);
 
-NTKERNELAPI
-LONG
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeReleaseSemaphore(
-  IN OUT PRKSEMAPHORE  Semaphore,
-  IN KPRIORITY  Increment,
-  IN LONG  Adjustment,
-  IN BOOLEAN  Wait);
+RtlWriteRegistryValue(
+    IN ULONG RelativeTo,
+    IN PCWSTR Path,
+    IN PCWSTR ValueName,
+    IN ULONG ValueType,
+    IN PVOID ValueData,
+    IN ULONG ValueLength);
 
-NTKERNELAPI
-PKDEVICE_QUEUE_ENTRY
-NTAPI
-KeRemoveByKeyDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue,
-  IN ULONG  SortKey);
 
-NTKERNELAPI
-PKDEVICE_QUEUE_ENTRY
-NTAPI
-KeRemoveDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue);
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeRemoveEntryDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue,
-  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry);
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeRemoveQueueDpc(
-  IN OUT PRKDPC  Dpc);
+#if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
+NTSYSAPI
+VOID
+FASTCALL
+RtlPrefetchMemoryNonTemporal(
+    IN PVOID Source,
+    IN SIZE_T Length);
+#endif
 
-NTKERNELAPI
-LONG
-NTAPI
-KeResetEvent(
-  IN OUT PRKEVENT  Event);
 
-NTKERNELAPI
-LONG
-NTAPI
-KeSetEvent(
-  IN OUT PRKEVENT  Event,
-  IN KPRIORITY  Increment,
-  IN BOOLEAN  Wait);
+#if (NTDDI_VERSION >= NTDDI_WINXP)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeSetImportanceDpc(
-  IN OUT PRKDPC  Dpc,
-  IN KDPC_IMPORTANCE  Importance);
 
-NTKERNELAPI
-KPRIORITY
-NTAPI
-KeSetPriorityThread(
-  IN OUT PKTHREAD  Thread,
-  IN KPRIORITY  Priority);
 
-NTKERNELAPI
-BOOLEAN
+NTSYSAPI
+VOID
 NTAPI
-KeSetTimer(
-  IN OUT PKTIMER  Timer,
-  IN LARGE_INTEGER  DueTime,
-  IN PKDPC  Dpc  OPTIONAL);
+RtlClearBit(
+    PRTL_BITMAP BitMapHeader,
+    ULONG BitNumber);
 
-NTKERNELAPI
-BOOLEAN
+NTSYSAPI
+WCHAR
 NTAPI
-KeSetTimerEx(
-  IN OUT PKTIMER  Timer,
-  IN LARGE_INTEGER  DueTime,
-  IN LONG  Period  OPTIONAL,
-  IN PKDPC  Dpc  OPTIONAL);
+RtlDowncaseUnicodeChar(
+    IN WCHAR SourceCharacter);
 
-NTHALAPI
+NTSYSAPI
 VOID
 NTAPI
-KeStallExecutionProcessor(
-  IN ULONG  MicroSeconds);
+RtlSetBit(
+    PRTL_BITMAP BitMapHeader,
+    ULONG BitNumber);
 
-NTKERNELAPI
+NTSYSAPI
 BOOLEAN
 NTAPI
-KeSynchronizeExecution(
-  IN OUT PKINTERRUPT    Interrupt,
-  IN PKSYNCHRONIZE_ROUTINE  SynchronizeRoutine,
-  IN PVOID  SynchronizeContext OPTIONAL);
-
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeWaitForMultipleObjects(
-  IN ULONG  Count,
-  IN PVOID  Object[],
-  IN WAIT_TYPE  WaitType,
-  IN KWAIT_REASON  WaitReason,
-  IN KPROCESSOR_MODE  WaitMode,
-  IN BOOLEAN  Alertable,
-  IN PLARGE_INTEGER  Timeout  OPTIONAL,
-  OUT PKWAIT_BLOCK  WaitBlockArray  OPTIONAL);
-
-#define KeWaitForMutexObject KeWaitForSingleObject
+RtlTestBit(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG BitNumber);
 
-NTKERNELAPI
+NTSYSAPI
 NTSTATUS
 NTAPI
-KeWaitForSingleObject(
-  IN PVOID  Object,
-  IN KWAIT_REASON  WaitReason,
-  IN KPROCESSOR_MODE  WaitMode,
-  IN BOOLEAN  Alertable,
-  IN PLARGE_INTEGER  Timeout  OPTIONAL);
-
-#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+RtlHashUnicodeString(
+  IN CONST UNICODE_STRING *String,
+  IN BOOLEAN CaseInSensitive,
+  IN ULONG HashAlgorithm,
+  OUT PULONG HashValue);
 
-#if (NTDDI_VERSION >= NTDDI_WINXP)
 
-_DECL_HAL_KE_IMPORT
-VOID
-FASTCALL
-KeAcquireInStackQueuedSpinLock(
-  IN OUT PKSPIN_LOCK SpinLock,
-  OUT PKLOCK_QUEUE_HANDLE LockHandle);
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeAcquireInStackQueuedSpinLockAtDpcLevel(
-  IN OUT PKSPIN_LOCK  SpinLock,
-  OUT PKLOCK_QUEUE_HANDLE  LockHandle);
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 
-NTKERNELAPI
-KIRQL
-NTAPI
-KeAcquireInterruptSpinLock(
-  IN OUT PKINTERRUPT  Interrupt);
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeAreApcsDisabled(VOID);
 
-NTKERNELAPI
+NTSYSAPI
 ULONG
 NTAPI
-KeGetRecommendedSharedDataAlignment(VOID);
+RtlNumberOfSetBitsUlongPtr(
+    IN ULONG_PTR Target);
 
-NTKERNELAPI
-ULONG
+NTSYSAPI
+ULONGLONG
 NTAPI
-KeQueryRuntimeThread(
-  IN PKTHREAD Thread,
-  OUT PULONG UserTime);
-
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseInStackQueuedSpinLockFromDpcLevel(
-  IN PKLOCK_QUEUE_HANDLE  LockHandle);
+RtlIoDecodeMemIoResource (
+    IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
+    OUT PULONGLONG Alignment OPTIONAL,
+    OUT PULONGLONG MinimumAddress OPTIONAL,
+    OUT PULONGLONG MaximumAddress OPTIONAL);
 
-NTKERNELAPI
-VOID
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeReleaseInterruptSpinLock(
-  IN OUT PKINTERRUPT  Interrupt,
-  IN KIRQL  OldIrql);
+RtlIoEncodeMemIoResource(
+    IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor,
+    IN UCHAR Type,
+    IN ULONGLONG Length,
+    IN ULONGLONG Alignment,
+    IN ULONGLONG MinimumAddress,
+    IN ULONGLONG MaximumAddress);
 
-NTKERNELAPI
-PKDEVICE_QUEUE_ENTRY
+NTSYSAPI
+ULONGLONG
 NTAPI
-KeRemoveByKeyDeviceQueueIfBusy(
-  IN OUT PKDEVICE_QUEUE DeviceQueue,
-  IN ULONG SortKey);
-
-_DECL_HAL_KE_IMPORT
-VOID
-FASTCALL
-KeReleaseInStackQueuedSpinLock(
-  IN PKLOCK_QUEUE_HANDLE LockHandle);
-
-#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
-
-#if (NTDDI_VERSION >= NTDDI_WINXPSP1)
+RtlCmDecodeMemIoResource(
+    IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor,
+    OUT PULONGLONG Start OPTIONAL);
 
-NTKERNELAPI
-BOOLEAN
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeDeregisterBugCheckReasonCallback(
-  IN OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord);
+RtlFindClosestEncodableLength(
+    IN ULONGLONG SourceLength,
+    OUT PULONGLONG TargetLength);
 
-NTKERNELAPI
-BOOLEAN
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeRegisterBugCheckReasonCallback(
-  OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord,
-  IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine,
-  IN KBUGCHECK_CALLBACK_REASON Reason,
-  IN PUCHAR Component);
+RtlCmEncodeMemIoResource(
+  IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
+  IN UCHAR Type,
+  IN ULONGLONG Length,
+  IN ULONGLONG Start);
 
-#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */
 
-#if (NTDDI_VERSION >= NTDDI_WINXPSP2)
-NTKERNELAPI
-VOID
-NTAPI
-KeFlushQueuedDpcs(VOID);
-#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
+#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
 
-#if (NTDDI_VERSION >= NTDDI_WS03)
+#if (NTDDI_VERSION >= NTDDI_WIN7)
 
-NTKERNELAPI
-PVOID
-NTAPI
-KeRegisterNmiCallback(
-  IN PNMI_CALLBACK CallbackRoutine,
-  IN PVOID Context OPTIONAL);
 
-NTKERNELAPI
+
+NTSYSAPI
 NTSTATUS
 NTAPI
-KeDeregisterNmiCallback(
-  IN PVOID Handle);
+RtlUnicodeToUTF8N(
+  OUT PCHAR UTF8StringDestination,
+  IN ULONG UTF8StringMaxByteCount,
+  OUT PULONG UTF8StringActualByteCount,
+  IN PCWCH UnicodeStringSource,
+  IN ULONG UnicodeStringByteCount);
 
-NTKERNELAPI
-VOID
+NTSYSAPI
+NTSTATUS
 NTAPI
-KeInitializeThreadedDpc(
-  OUT PRKDPC Dpc,
-  IN PKDEFERRED_ROUTINE DeferredRoutine,
-  IN PVOID DeferredContext OPTIONAL);
+RtlUTF8ToUnicodeN(
+  OUT PWSTR UnicodeStringDestination,
+  IN ULONG UnicodeStringMaxByteCount,
+  OUT PULONG UnicodeStringActualByteCount,
+  IN PCCH UTF8StringSource,
+  IN ULONG UTF8StringByteCount);
 
-NTKERNELAPI
-ULONG_PTR
+NTSYSAPI
+ULONG64
 NTAPI
-KeIpiGenericCall(
-  IN PKIPI_BROADCAST_WORKER BroadcastFunction,
-  IN ULONG_PTR Context);
+RtlGetEnabledExtendedFeatures(
+  IN ULONG64 FeatureMask);
 
-NTKERNELAPI
-KIRQL
-FASTCALL
-KeAcquireSpinLockForDpc(
-  IN OUT PKSPIN_LOCK SpinLock);
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseSpinLockForDpc(
-  IN OUT PKSPIN_LOCK SpinLock,
-  IN KIRQL OldIrql);
+#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
 
-NTKERNELAPI
-BOOLEAN
-FASTCALL
-KeTestSpinLock(
-  IN PKSPIN_LOCK SpinLock);
 
+#if !defined(MIDL_PASS)
+/* inline funftions */
+//DECLSPEC_DEPRECATED_DDK_WINXP
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlConvertLongToLargeInteger(
+  IN LONG SignedInteger)
+{
+    LARGE_INTEGER ret;
+    ret.QuadPart = SignedInteger;
+    return ret;
+}
 
-#endif /* (NTDDI_VERSION >= NTDDI_WS03) */
+//DECLSPEC_DEPRECATED_DDK_WINXP
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlConvertUlongToLargeInteger(
+  IN ULONG UnsignedInteger)
+{
+    LARGE_INTEGER ret;
+    ret.QuadPart = UnsignedInteger;
+    return ret;
+}
 
-#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+//DECLSPEC_DEPRECATED_DDK_WINXP
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlLargeIntegerShiftLeft(
+  IN LARGE_INTEGER LargeInteger,
+  IN CCHAR ShiftCount)
+{
+  LARGE_INTEGER Result;
 
+  Result.QuadPart = LargeInteger.QuadPart << ShiftCount;
+  return Result;
+}
 
-NTKERNELAPI
-BOOLEAN
-FASTCALL
-KeTryToAcquireSpinLockAtDpcLevel(
-  IN OUT PKSPIN_LOCK SpinLock);
+//DECLSPEC_DEPRECATED_DDK_WINXP
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlLargeIntegerShiftRight(
+  IN LARGE_INTEGER LargeInteger,
+  IN CCHAR ShiftCount)
+{
+  LARGE_INTEGER Result;
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeAreAllApcsDisabled(VOID);
+  Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount;
+  return Result;
+}
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeAcquireGuardedMutex(
-  IN OUT PKGUARDED_MUTEX GuardedMutex);
+//DECLSPEC_DEPRECATED_DDK
+static __inline
+ULONG
+NTAPI_INLINE
+RtlEnlargedUnsignedDivide(
+    IN ULARGE_INTEGER Dividend,
+    IN ULONG Divisor,
+    IN OUT PULONG Remainder)
+{
+    if (Remainder)
+        *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
+    return (ULONG)(Dividend.QuadPart / Divisor);
+}
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeAcquireGuardedMutexUnsafe(
-  IN OUT PKGUARDED_MUTEX GuardedMutex);
+//DECLSPEC_DEPRECATED_DDK
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlLargeIntegerNegate(
+  IN LARGE_INTEGER Subtrahend)
+{
+  LARGE_INTEGER Difference;
 
-NTKERNELAPI
-VOID
-NTAPI
-KeEnterGuardedRegion(VOID);
+  Difference.QuadPart = -Subtrahend.QuadPart;
+  return Difference;
+}
 
-NTKERNELAPI
-VOID
-NTAPI
-KeLeaveGuardedRegion(VOID);
+//DECLSPEC_DEPRECATED_DDK
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlLargeIntegerSubtract(
+  IN LARGE_INTEGER Minuend,
+  IN LARGE_INTEGER Subtrahend)
+{
+  LARGE_INTEGER Difference;
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeInitializeGuardedMutex(
-  OUT PKGUARDED_MUTEX GuardedMutex);
+  Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart;
+  return Difference;
+}
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseGuardedMutexUnsafe(
-  IN OUT PKGUARDED_MUTEX GuardedMutex);
+//DECLSPEC_DEPRECATED_DDK
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlEnlargedUnsignedMultiply(
+    IN ULONG Multiplicand,
+    IN ULONG Multiplier)
+{
+    LARGE_INTEGER ret;
+    ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
+    return ret;
+}
+
+//DECLSPEC_DEPRECATED_DDK
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlEnlargedIntegerMultiply(
+    IN LONG Multiplicand,
+    IN LONG Multiplier)
+{
+    LARGE_INTEGER ret;
+    ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
+    return ret;
+}
+
+FORCEINLINE
+VOID
+RtlInitEmptyAnsiString(
+  OUT PANSI_STRING AnsiString,
+                       IN PCHAR Buffer,
+                       IN USHORT BufferSize)
+{
+    AnsiString->Length = 0;
+    AnsiString->MaximumLength = BufferSize;
+    AnsiString->Buffer = Buffer;
+}
+
+FORCEINLINE
+VOID
+RtlInitEmptyUnicodeString(
+    OUT PUNICODE_STRING UnicodeString,
+    IN PWSTR Buffer,
+    IN USHORT BufferSize)
+{
+    UnicodeString->Length = 0;
+    UnicodeString->MaximumLength = BufferSize;
+    UnicodeString->Buffer = Buffer;
+}
+
+#if defined(_AMD64_) || defined(_IA64_)
+
+
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlExtendedIntegerMultiply(
+  IN LARGE_INTEGER Multiplicand,
+  IN LONG Multiplier)
+{
+    LARGE_INTEGER ret;
+    ret.QuadPart = Multiplicand.QuadPart * Multiplier;
+    return ret;
+}
+
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlExtendedLargeIntegerDivide(
+  IN LARGE_INTEGER Dividend,
+  IN ULONG Divisor,
+  OUT PULONG Remainder OPTIONAL)
+{
+    LARGE_INTEGER ret;
+    ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor;
+    if (Remainder)
+        *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
+    return ret;
+}
+
+
+
+#endif /* defined(_AMD64_) || defined(_IA64_) */
+
+
+#if defined(_AMD64_)
+
+#define MultiplyHigh __mulh
+#define UnsignedMultiplyHigh __umulh
+
+//DECLSPEC_DEPRECATED_DDK
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlExtendedMagicDivide(
+    IN LARGE_INTEGER Dividend,
+    IN LARGE_INTEGER MagicDivisor,
+    IN CCHAR ShiftCount)
+{
+    LARGE_INTEGER ret;
+    ULONG64 ret64;
+    BOOLEAN Pos;
+    Pos = (Dividend.QuadPart >= 0);
+    ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart,
+                                 MagicDivisor.QuadPart);
+    ret64 >>= ShiftCount;
+    ret.QuadPart = Pos ? ret64 : -ret64;
+    return ret;
+}
+#endif
+
+//DECLSPEC_DEPRECATED_DDK
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlLargeIntegerAdd(
+    IN LARGE_INTEGER Addend1,
+    IN LARGE_INTEGER Addend2)
+{
+    LARGE_INTEGER ret;
+    ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart;
+    return ret;
+}
+
+/* VOID
+ * RtlLargeIntegerAnd(
+ *     IN OUT LARGE_INTEGER Result,
+ *     IN LARGE_INTEGER Source,
+ *     IN LARGE_INTEGER Mask);
+ */
+#define RtlLargeIntegerAnd(Result, Source, Mask) \
+    Result.QuadPart = Source.QuadPart & Mask.QuadPart
+
+//DECLSPEC_DEPRECATED_DDK
+static __inline
+LARGE_INTEGER
+NTAPI_INLINE
+RtlLargeIntegerArithmeticShift(
+    IN LARGE_INTEGER LargeInteger,
+    IN CCHAR ShiftCount)
+{
+    LARGE_INTEGER ret;
+    ret.QuadPart = LargeInteger.QuadPart >> ShiftCount;
+    return ret;
+}
+
+/* BOOLEAN
+ * RtlLargeIntegerEqualTo(
+ *     IN LARGE_INTEGER  Operand1,
+ *     IN LARGE_INTEGER  Operand2);
+ */
+#define RtlLargeIntegerEqualTo(X,Y) \
+    (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
+
+FORCEINLINE
+PVOID
+RtlSecureZeroMemory(
+    OUT PVOID Pointer,
+    IN SIZE_T Size)
+{
+    volatile char* vptr = (volatile char*)Pointer;
+#if defined(_M_AMD64)
+    __stosb((PUCHAR)vptr, 0, Size);
+#else
+    char * endptr = (char *)vptr + Size;
+  while (vptr < endptr) {
+        *vptr = 0; vptr++;
+    }
+#endif
+     return Pointer;
+}
+
+#if defined(_M_AMD64)
+FORCEINLINE
+BOOLEAN
+RtlCheckBit(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG BitPosition)
+{
+  return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition);
+}
+#else
+#define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
+#endif /* defined(_M_AMD64) */
+
+#define RtlLargeIntegerGreaterThan(X,Y) (                              \
+    (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
+    ((X).HighPart > (Y).HighPart)                                      \
+)
+
+#define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) (                      \
+    (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
+    ((X).HighPart > (Y).HighPart)                                       \
+)
+
+#define RtlLargeIntegerNotEqualTo(X,Y) (                          \
+    (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
+)
+
+#define RtlLargeIntegerLessThan(X,Y) (                                 \
+    (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
+    ((X).HighPart < (Y).HighPart)                                      \
+)
+
+#define RtlLargeIntegerLessThanOrEqualTo(X,Y) (                         \
+    (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
+    ((X).HighPart < (Y).HighPart)                                       \
+)
+
+#define RtlLargeIntegerGreaterThanZero(X) (       \
+    (((X).HighPart == 0) && ((X).LowPart > 0)) || \
+    ((X).HighPart > 0 )                           \
+)
+
+#define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 )
+
+#define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) )
+
+#define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) )
+
+#define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) )
+
+#define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) )
+
+#endif /* !defined(MIDL_PASS) */
+
+/* Byte Swap Functions */
+#if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \
+    ((defined(_M_AMD64) || defined(_M_IA64)) \
+        && (_MSC_FULL_VER > 13009175 || defined(__GNUC__)))
+
+#define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
+#define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
+#define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
+
+#endif
+
+#if DBG
+
+#define ASSERT(exp) \
+  (VOID)((!(exp)) ? \
+    RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
+
+#define ASSERTMSG(msg, exp) \
+  (VOID)((!(exp)) ? \
+    RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, msg ), FALSE : TRUE)
+
+#define RTL_SOFT_ASSERT(exp) \
+  (VOID)((!(exp)) ? \
+    DbgPrint("%s(%d): Soft assertion failed\n   Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
+
+#define RTL_SOFT_ASSERTMSG(msg, exp) \
+  (VOID)((!(exp)) ? \
+    DbgPrint("%s(%d): Soft assertion failed\n   Expression: %s\n   Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
+
+#define RTL_VERIFY(exp) ASSERT(exp)
+#define RTL_VERIFYMSG(msg, exp) ASSERTMSG(msg, exp)
+
+#define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
+#define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
+
+#if defined(_MSC_VER)
+
+#define NT_ASSERT(exp) \
+   ((!(exp)) ? \
+      (__annotation(L"Debug", L"AssertFail", L#exp), \
+       DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_ASSERTMSG(msg, exp) \
+   ((!(exp)) ? \
+      (__annotation(L"Debug", L"AssertFail", L##msg), \
+      DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_ASSERTMSGW(msg, exp) \
+    ((!(exp)) ? \
+        (__annotation(L"Debug", L"AssertFail", msg), \
+         DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_VERIFY     NT_ASSERT
+#define NT_VERIFYMSG  NT_ASSERTMSG
+#define NT_VERIFYMSGW NT_ASSERTMSGW
+
+#else
+
+/* GCC doesn't support __annotation (nor PDB) */
+#define NT_ASSERT(exp) \
+   (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_ASSERTMSG NT_ASSERT
+#define NT_ASSERTMSGW NT_ASSERT
+
+#endif
+
+#else /* !DBG */
+
+#define ASSERT(exp) ((VOID) 0)
+#define ASSERTMSG(msg, exp) ((VOID) 0)
+
+#define RTL_SOFT_ASSERT(exp) ((VOID) 0)
+#define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
+
+#define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
+#define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
+
+#define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
+#define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
+
+#define NT_ASSERT(exp)     ((VOID)0)
+#define NT_ASSERTMSG(msg, exp)  ((VOID)0)
+#define NT_ASSERTMSGW(msg, exp) ((VOID)0)
+
+#define NT_VERIFY(_exp)           ((_exp) ? TRUE : FALSE)
+#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
+#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
+
+#endif /* DBG */
+
+#define InitializeListHead32(ListHead) (\
+    (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
+
+#if !defined(_WINBASE_)
+
+#if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
+
+NTKERNELAPI
+VOID
+InitializeSListHead(
+  OUT PSLIST_HEADER SListHead);
+
+#else
+
+VOID
+FORCEINLINE
+InitializeSListHead(
+  OUT PSLIST_HEADER SListHead)
+{
+#if defined(_IA64_)
+    ULONG64 FeatureBits;
+#endif
+
+#if defined(_WIN64)
+  if (((ULONG_PTR)SListHead & 0xf) != 0) {
+        RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
+    }
+#endif
+    RtlZeroMemory(SListHead, sizeof(SLIST_HEADER));
+#if defined(_IA64_)
+    FeatureBits = __getReg(CV_IA64_CPUID4);
+  if ((FeatureBits & KF_16BYTE_INSTR) != 0) {
+        SListHead->Header16.HeaderType = 1;
+        SListHead->Header16.Init = 1;
+    }
+#endif
+}
+
+#endif
+
+#if defined(_WIN64)
+
+#define InterlockedPopEntrySList(Head) \
+    ExpInterlockedPopEntrySList(Head)
+
+#define InterlockedPushEntrySList(Head, Entry) \
+    ExpInterlockedPushEntrySList(Head, Entry)
+
+#define InterlockedFlushSList(Head) \
+    ExpInterlockedFlushSList(Head)
+
+#define QueryDepthSList(Head) \
+    ExQueryDepthSList(Head)
+
+#else /* !defined(_WIN64) */
+
+NTKERNELAPI
+PSLIST_ENTRY
+FASTCALL
+InterlockedPopEntrySList(
+    IN PSLIST_HEADER ListHead);
+
+NTKERNELAPI
+PSLIST_ENTRY
+FASTCALL
+InterlockedPushEntrySList(
+    IN PSLIST_HEADER ListHead,
+    IN PSLIST_ENTRY ListEntry);
+
+#define InterlockedFlushSList(ListHead) \
+    ExInterlockedFlushSList(ListHead)
+
+#define QueryDepthSList(Head) \
+    ExQueryDepthSList(Head)
+
+#endif /* !defined(_WIN64) */
+
+#endif /* !defined(_WINBASE_) */
+
+#define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset)
+#define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length)
+#define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk)       \
+    ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk)))
+#define RTL_CONTEXT_OFFSET(Context, Chunk)              \
+    RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk)
+#define RTL_CONTEXT_LENGTH(Context, Chunk)              \
+    RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk)
+#define RTL_CONTEXT_CHUNK(Context, Chunk)               \
+    RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1),    \
+                         (PCONTEXT_EX)(Context + 1),    \
+                         Chunk)
+
+BOOLEAN
+RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)(
+  IN ULONG Version);
+
+BOOLEAN
+RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)(
+  IN ULONG Version);
+
+#ifndef RtlIsNtDdiVersionAvailable
+#define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable
+#endif
+
+#ifndef RtlIsServicePackVersionInstalled
+#define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled
+#endif
+
+#define RtlInterlockedSetBits(Flags, Flag) \
+    InterlockedOr((PLONG)(Flags), Flag)
+
+#define RtlInterlockedAndBits(Flags, Flag) \
+    InterlockedAnd((PLONG)(Flags), Flag)
+
+#define RtlInterlockedClearBits(Flags, Flag) \
+    RtlInterlockedAndBits(Flags, ~(Flag))
+
+#define RtlInterlockedXorBits(Flags, Flag) \
+    InterlockedXor(Flags, Flag)
+
+#define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \
+    (VOID) RtlInterlockedSetBits(Flags, Flag)
+
+#define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \
+    (VOID) RtlInterlockedAndBits(Flags, Flag)
+
+#define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \
+    RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag))
+
+
+/******************************************************************************
+ *                              Kernel Functions                              *
+ ******************************************************************************/
+
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeEvent(
+  OUT PRKEVENT  Event,
+  IN EVENT_TYPE  Type,
+  IN BOOLEAN  State);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeClearEvent(
+  IN OUT PRKEVENT Event);
+
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
+
+
+#if defined(_NTDDK_) || defined(_NTIFS_)
+NTKERNELAPI
+VOID
+NTAPI
+ProbeForRead(
+  IN CONST VOID *Address, /* CONST is added */
+  IN SIZE_T Length,
+  IN ULONG Alignment);
+#endif /* defined(_NTDDK_) || defined(_NTIFS_) */
+
+NTKERNELAPI
+VOID
+NTAPI
+ProbeForWrite(
+  IN PVOID Address,
+  IN SIZE_T Length,
+  IN ULONG Alignment);
+
+
+#if defined(SINGLE_GROUP_LEGACY_API)
+
+NTKERNELAPI
+VOID
+NTAPI
+KeRevertToUserAffinityThread(VOID);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeSetSystemAffinityThread(
+    IN KAFFINITY Affinity);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeSetTargetProcessorDpc(
+  IN OUT PRKDPC Dpc,
+  IN CCHAR Number);
+
+NTKERNELAPI
+KAFFINITY
+NTAPI
+KeQueryActiveProcessors(VOID);
+
+
+#endif /* defined(SINGLE_GROUP_LEGACY_API) */
+
+#if !defined(_M_AMD64)
+NTKERNELAPI
+ULONGLONG
+NTAPI
+KeQueryInterruptTime(VOID);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeQuerySystemTime(
+  OUT PLARGE_INTEGER  CurrentTime);
+#endif /* !_M_AMD64 */
+
+#if !defined(_X86_)
+NTKERNELAPI
+KIRQL
+NTAPI
+KeAcquireSpinLockRaiseToDpc(
+  IN OUT PKSPIN_LOCK SpinLock);
+
+#define KeAcquireSpinLock(SpinLock, OldIrql) \
+    *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
+
+NTKERNELAPI
+VOID
+NTAPI
+KeAcquireSpinLockAtDpcLevel(
+  IN OUT PKSPIN_LOCK SpinLock);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeReleaseSpinLock(
+  IN OUT PKSPIN_LOCK SpinLock,
+  IN KIRQL NewIrql);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeReleaseSpinLockFromDpcLevel(
+  IN OUT PKSPIN_LOCK SpinLock);
+#endif /* !_X86_ */
+
+#if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK))
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeSpinLock(
+    IN PKSPIN_LOCK SpinLock);
+#else
+FORCEINLINE
+VOID
+KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
+{
+    /* Clear the lock */
+    *SpinLock = 0;
+}
+#endif
+
+NTKERNELAPI
+DECLSPEC_NORETURN
+VOID
+NTAPI
+KeBugCheckEx(
+  IN ULONG  BugCheckCode,
+  IN ULONG_PTR  BugCheckParameter1,
+  IN ULONG_PTR  BugCheckParameter2,
+  IN ULONG_PTR  BugCheckParameter3,
+  IN ULONG_PTR  BugCheckParameter4);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeCancelTimer(
+  IN OUT PKTIMER);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeDelayExecutionThread(
+  IN KPROCESSOR_MODE WaitMode,
+  IN BOOLEAN Alertable,
+  IN PLARGE_INTEGER Interval);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeDeregisterBugCheckCallback(
+  IN OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeEnterCriticalRegion(VOID);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeDeviceQueue(
+  OUT PKDEVICE_QUEUE  DeviceQueue);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeDpc(
+  OUT PRKDPC  Dpc,
+  IN PKDEFERRED_ROUTINE  DeferredRoutine,
+  IN PVOID  DeferredContext OPTIONAL);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeMutex(
+  OUT PRKMUTEX  Mutex,
+  IN ULONG  Level);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeSemaphore(
+  OUT PRKSEMAPHORE  Semaphore,
+  IN LONG  Count,
+  IN LONG  Limit);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeTimer(
+  OUT PKTIMER  Timer);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeTimerEx(
+  OUT PKTIMER  Timer,
+  IN TIMER_TYPE  Type);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeInsertByKeyDeviceQueue(
+  IN OUT PKDEVICE_QUEUE  DeviceQueue,
+  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry,
+  IN ULONG  SortKey);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeInsertDeviceQueue(
+  IN OUT PKDEVICE_QUEUE  DeviceQueue,
+  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeInsertQueueDpc(
+  IN OUT PRKDPC  Dpc,
+  IN PVOID  SystemArgument1 OPTIONAL,
+  IN PVOID  SystemArgument2 OPTIONAL);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeLeaveCriticalRegion(VOID);
+
+NTHALAPI
+LARGE_INTEGER
+NTAPI
+KeQueryPerformanceCounter(
+  OUT PLARGE_INTEGER  PerformanceFrequency  OPTIONAL);
+
+NTKERNELAPI
+KPRIORITY
+NTAPI
+KeQueryPriorityThread(
+  IN PRKTHREAD  Thread);
+
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryTimeIncrement(VOID);
+
+NTKERNELAPI
+LONG
+NTAPI
+KeReadStateEvent(
+  IN PRKEVENT  Event);
+
+NTKERNELAPI
+LONG
+NTAPI
+KeReadStateMutex(
+  IN PRKMUTEX  Mutex);
+
+NTKERNELAPI
+LONG
+NTAPI
+KeReadStateSemaphore(
+  IN PRKSEMAPHORE  Semaphore);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeReadStateTimer(
+  IN PKTIMER  Timer);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeRegisterBugCheckCallback(
+  OUT PKBUGCHECK_CALLBACK_RECORD  CallbackRecord,
+  IN PKBUGCHECK_CALLBACK_ROUTINE  CallbackRoutine,
+  IN PVOID  Buffer,
+  IN ULONG  Length,
+  IN PUCHAR  Component);
+
+NTKERNELAPI
+LONG
+NTAPI
+KeReleaseMutex(
+  IN OUT PRKMUTEX  Mutex,
+  IN BOOLEAN  Wait);
+
+NTKERNELAPI
+LONG
+NTAPI
+KeReleaseSemaphore(
+  IN OUT PRKSEMAPHORE  Semaphore,
+  IN KPRIORITY  Increment,
+  IN LONG  Adjustment,
+  IN BOOLEAN  Wait);
+
+NTKERNELAPI
+PKDEVICE_QUEUE_ENTRY
+NTAPI
+KeRemoveByKeyDeviceQueue(
+  IN OUT PKDEVICE_QUEUE  DeviceQueue,
+  IN ULONG  SortKey);
+
+NTKERNELAPI
+PKDEVICE_QUEUE_ENTRY
+NTAPI
+KeRemoveDeviceQueue(
+  IN OUT PKDEVICE_QUEUE  DeviceQueue);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeRemoveEntryDeviceQueue(
+  IN OUT PKDEVICE_QUEUE  DeviceQueue,
+  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeRemoveQueueDpc(
+  IN OUT PRKDPC  Dpc);
+
+NTKERNELAPI
+LONG
+NTAPI
+KeResetEvent(
+  IN OUT PRKEVENT  Event);
+
+NTKERNELAPI
+LONG
+NTAPI
+KeSetEvent(
+  IN OUT PRKEVENT  Event,
+  IN KPRIORITY  Increment,
+  IN BOOLEAN  Wait);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeSetImportanceDpc(
+  IN OUT PRKDPC  Dpc,
+  IN KDPC_IMPORTANCE  Importance);
+
+NTKERNELAPI
+KPRIORITY
+NTAPI
+KeSetPriorityThread(
+  IN OUT PKTHREAD  Thread,
+  IN KPRIORITY  Priority);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeSetTimer(
+  IN OUT PKTIMER  Timer,
+  IN LARGE_INTEGER  DueTime,
+  IN PKDPC  Dpc  OPTIONAL);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeSetTimerEx(
+  IN OUT PKTIMER  Timer,
+  IN LARGE_INTEGER  DueTime,
+  IN LONG  Period  OPTIONAL,
+  IN PKDPC  Dpc  OPTIONAL);
+
+NTHALAPI
+VOID
+NTAPI
+KeStallExecutionProcessor(
+  IN ULONG  MicroSeconds);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeSynchronizeExecution(
+  IN OUT PKINTERRUPT    Interrupt,
+  IN PKSYNCHRONIZE_ROUTINE  SynchronizeRoutine,
+  IN PVOID  SynchronizeContext OPTIONAL);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeWaitForMultipleObjects(
+  IN ULONG  Count,
+  IN PVOID  Object[],
+  IN WAIT_TYPE  WaitType,
+  IN KWAIT_REASON  WaitReason,
+  IN KPROCESSOR_MODE  WaitMode,
+  IN BOOLEAN  Alertable,
+  IN PLARGE_INTEGER  Timeout  OPTIONAL,
+  OUT PKWAIT_BLOCK  WaitBlockArray  OPTIONAL);
+
+#define KeWaitForMutexObject KeWaitForSingleObject
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeWaitForSingleObject(
+  IN PVOID  Object,
+  IN KWAIT_REASON  WaitReason,
+  IN KPROCESSOR_MODE  WaitMode,
+  IN BOOLEAN  Alertable,
+  IN PLARGE_INTEGER  Timeout  OPTIONAL);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+
+#if (NTDDI_VERSION >= NTDDI_WINXP)
+
+_DECL_HAL_KE_IMPORT
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLock(
+  IN OUT PKSPIN_LOCK SpinLock,
+  OUT PKLOCK_QUEUE_HANDLE LockHandle);
+
+NTKERNELAPI
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLockAtDpcLevel(
+  IN OUT PKSPIN_LOCK  SpinLock,
+  OUT PKLOCK_QUEUE_HANDLE  LockHandle);
+
+NTKERNELAPI
+KIRQL
+NTAPI
+KeAcquireInterruptSpinLock(
+  IN OUT PKINTERRUPT  Interrupt);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeAreApcsDisabled(VOID);
+
+NTKERNELAPI
+ULONG
+NTAPI
+KeGetRecommendedSharedDataAlignment(VOID);
+
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryRuntimeThread(
+  IN PKTHREAD Thread,
+  OUT PULONG UserTime);
+
+NTKERNELAPI
+VOID
+FASTCALL
+KeReleaseInStackQueuedSpinLockFromDpcLevel(
+  IN PKLOCK_QUEUE_HANDLE  LockHandle);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeReleaseInterruptSpinLock(
+  IN OUT PKINTERRUPT  Interrupt,
+  IN KIRQL  OldIrql);
+
+NTKERNELAPI
+PKDEVICE_QUEUE_ENTRY
+NTAPI
+KeRemoveByKeyDeviceQueueIfBusy(
+  IN OUT PKDEVICE_QUEUE DeviceQueue,
+  IN ULONG SortKey);
+
+_DECL_HAL_KE_IMPORT
+VOID
+FASTCALL
+KeReleaseInStackQueuedSpinLock(
+  IN PKLOCK_QUEUE_HANDLE LockHandle);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
+
+#if (NTDDI_VERSION >= NTDDI_WINXPSP1)
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeDeregisterBugCheckReasonCallback(
+  IN OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeRegisterBugCheckReasonCallback(
+  OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord,
+  IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine,
+  IN KBUGCHECK_CALLBACK_REASON Reason,
+  IN PUCHAR Component);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */
+
+#if (NTDDI_VERSION >= NTDDI_WINXPSP2)
+NTKERNELAPI
+VOID
+NTAPI
+KeFlushQueuedDpcs(VOID);
+#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
+
+#if (NTDDI_VERSION >= NTDDI_WS03)
+
+NTKERNELAPI
+PVOID
+NTAPI
+KeRegisterNmiCallback(
+  IN PNMI_CALLBACK CallbackRoutine,
+  IN PVOID Context OPTIONAL);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeDeregisterNmiCallback(
+  IN PVOID Handle);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeThreadedDpc(
+  OUT PRKDPC Dpc,
+  IN PKDEFERRED_ROUTINE DeferredRoutine,
+  IN PVOID DeferredContext OPTIONAL);
+
+NTKERNELAPI
+ULONG_PTR
+NTAPI
+KeIpiGenericCall(
+  IN PKIPI_BROADCAST_WORKER BroadcastFunction,
+  IN ULONG_PTR Context);
+
+NTKERNELAPI
+KIRQL
+FASTCALL
+KeAcquireSpinLockForDpc(
+  IN OUT PKSPIN_LOCK SpinLock);
+
+NTKERNELAPI
+VOID
+FASTCALL
+KeReleaseSpinLockForDpc(
+  IN OUT PKSPIN_LOCK SpinLock,
+  IN KIRQL OldIrql);
+
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+KeTestSpinLock(
+  IN PKSPIN_LOCK SpinLock);
+
+
+#endif /* (NTDDI_VERSION >= NTDDI_WS03) */
+
+#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+
+
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+KeTryToAcquireSpinLockAtDpcLevel(
+  IN OUT PKSPIN_LOCK SpinLock);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeAreAllApcsDisabled(VOID);
+
+NTKERNELAPI
+VOID
+FASTCALL
+KeAcquireGuardedMutex(
+  IN OUT PKGUARDED_MUTEX GuardedMutex);
+
+NTKERNELAPI
+VOID
+FASTCALL
+KeAcquireGuardedMutexUnsafe(
+  IN OUT PKGUARDED_MUTEX GuardedMutex);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeEnterGuardedRegion(VOID);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeLeaveGuardedRegion(VOID);
+
+NTKERNELAPI
+VOID
+FASTCALL
+KeInitializeGuardedMutex(
+  OUT PKGUARDED_MUTEX GuardedMutex);
+
+NTKERNELAPI
+VOID
+FASTCALL
+KeReleaseGuardedMutexUnsafe(
+  IN OUT PKGUARDED_MUTEX GuardedMutex);
 
 NTKERNELAPI
 VOID
@@ -7951,3925 +10272,5048 @@ FASTCALL
 KeReleaseGuardedMutex(
   IN OUT PKGUARDED_MUTEX GuardedMutex);
 
-NTKERNELAPI
-BOOLEAN
-FASTCALL
-KeTryToAcquireGuardedMutex(
-  IN OUT PKGUARDED_MUTEX GuardedMutex);
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+KeTryToAcquireGuardedMutex(
+  IN OUT PKGUARDED_MUTEX GuardedMutex);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
+
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+
+NTKERNELAPI
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLockForDpc(
+  IN OUT PKSPIN_LOCK SpinLock,
+  OUT PKLOCK_QUEUE_HANDLE LockHandle);
+
+NTKERNELAPI
+VOID
+FASTCALL
+KeReleaseInStackQueuedSpinLockForDpc(
+  IN PKLOCK_QUEUE_HANDLE LockHandle);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeQueryDpcWatchdogInformation(
+  OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation);
+
+#if defined(SINGLE_GROUP_LEGACY_API)
+
+NTKERNELAPI
+KAFFINITY
+NTAPI
+KeSetSystemAffinityThreadEx(
+  IN KAFFINITY Affinity);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeRevertToUserAffinityThreadEx(
+  IN KAFFINITY Affinity);
+
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryActiveProcessorCount(
+  OUT PKAFFINITY ActiveProcessors OPTIONAL);
+
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryMaximumProcessorCount(VOID);
+#endif /* SINGLE_GROUP_LEGACY_API */
+
+#endif /*  (NTDDI_VERSION >= NTDDI_VISTA) */
+
+#if (NTDDI_VERSION >= NTDDI_WS08)
+
+PVOID
+KeRegisterProcessorChangeCallback(
+  IN PPROCESSOR_CALLBACK_FUNCTION CallbackFunction,
+  IN PVOID CallbackContext OPTIONAL,
+  IN ULONG Flags);
+
+VOID
+KeDeregisterProcessorChangeCallback(
+  IN PVOID CallbackHandle);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WS08) */
+
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+
+
+ULONG64
+NTAPI
+KeQueryTotalCycleTimeProcess(
+  IN OUT PKPROCESS Process,
+  OUT PULONG64 CycleTimeStamp);
+
+ULONG64
+NTAPI
+KeQueryTotalCycleTimeThread(
+  IN OUT PKTHREAD Thread,
+  OUT PULONG64 CycleTimeStamp);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeSetTargetProcessorDpcEx(
+  IN OUT PKDPC Dpc,
+  IN PPROCESSOR_NUMBER ProcNumber);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeSetSystemGroupAffinityThread(
+  IN PGROUP_AFFINITY Affinity,
+  OUT PGROUP_AFFINITY PreviousAffinity OPTIONAL);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeRevertToUserGroupAffinityThread(
+  IN PGROUP_AFFINITY PreviousAffinity);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeSetCoalescableTimer(
+  IN OUT PKTIMER Timer,
+  IN LARGE_INTEGER DueTime,
+  IN ULONG Period,
+  IN ULONG TolerableDelay,
+  IN PKDPC Dpc OPTIONAL);
+
+NTKERNELAPI
+ULONGLONG
+NTAPI
+KeQueryUnbiasedInterruptTime(VOID);
+
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryActiveProcessorCountEx(
+  IN USHORT GroupNumber);
+
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryMaximumProcessorCountEx(
+  IN USHORT GroupNumber);
+
+NTKERNELAPI
+USHORT
+NTAPI
+KeQueryActiveGroupCount(VOID);
+
+NTKERNELAPI
+USHORT
+NTAPI
+KeQueryMaximumGroupCount(VOID);
+
+NTKERNELAPI
+KAFFINITY
+NTAPI
+KeQueryGroupAffinity(
+  IN USHORT GroupNumber);
+
+NTKERNELAPI
+ULONG
+NTAPI
+KeGetCurrentProcessorNumberEx(
+  OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeQueryNodeActiveAffinity(
+  IN USHORT NodeNumber,
+  OUT PGROUP_AFFINITY Affinity OPTIONAL,
+  OUT PUSHORT Count OPTIONAL);
+
+NTKERNELAPI
+USHORT
+NTAPI
+KeQueryNodeMaximumProcessorCount(
+  IN USHORT NodeNumber);
+
+NTKERNELAPI
+USHORT
+NTAPI
+KeQueryHighestNodeNumber(VOID);
+
+NTKERNELAPI
+USHORT
+NTAPI
+KeGetCurrentNodeNumber(VOID);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeQueryLogicalProcessorRelationship(
+  IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL,
+  IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType,
+  OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL,
+  IN OUT PULONG Length);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeSaveExtendedProcessorState(
+  IN ULONG64 Mask,
+  OUT PXSTATE_SAVE XStateSave);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeRestoreExtendedProcessorState(
+  IN PXSTATE_SAVE XStateSave);
+
+NTSTATUS
+NTAPI
+KeGetProcessorNumberFromIndex(
+  IN ULONG ProcIndex,
+  OUT PPROCESSOR_NUMBER ProcNumber);
+
+ULONG
+NTAPI
+KeGetProcessorIndexFromNumber(
+  IN PPROCESSOR_NUMBER ProcNumber);
+
+#endif /*  (NTDDI_VERSION >= NTDDI_WIN7) */
+
+#if !defined(_IA64_)
+NTHALAPI
+VOID
+NTAPI
+KeFlushWriteBuffer(VOID);
+#endif
+
+/* VOID
+ * KeInitializeCallbackRecord(
+ *   IN PKBUGCHECK_CALLBACK_RECORD  CallbackRecord)
+ */
+#define KeInitializeCallbackRecord(CallbackRecord) \
+  CallbackRecord->State = BufferEmpty;
+
+#if DBG
+
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+#define PAGED_ASSERT( exp ) NT_ASSERT( exp )
+#else
+#define PAGED_ASSERT( exp ) ASSERT( exp )
+#endif
+
+#define PAGED_CODE() { \
+  if (KeGetCurrentIrql() > APC_LEVEL) { \
+    KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \
+    PAGED_ASSERT(FALSE); \
+  } \
+}
+
+#else
+
+#define PAGED_CODE()
+
+#endif /* DBG */
 
-#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
+#define PAGED_CODE_LOCKED() NOP_FUNCTION;
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
+/******************************************************************************
+ *                       Memory manager Functions                             *
+ ******************************************************************************/
+/* Alignment Macros */
+#define ALIGN_DOWN_BY(size, align) \
+    ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeAcquireInStackQueuedSpinLockForDpc(
-  IN OUT PKSPIN_LOCK SpinLock,
-  OUT PKLOCK_QUEUE_HANDLE LockHandle);
+#define ALIGN_UP_BY(size, align) \
+    (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseInStackQueuedSpinLockForDpc(
-  IN PKLOCK_QUEUE_HANDLE LockHandle);
+#define ALIGN_DOWN_POINTER_BY(ptr, align) \
+    ((PVOID)ALIGN_DOWN_BY(ptr, align))
+
+#define ALIGN_UP_POINTER_BY(ptr, align) \
+    ((PVOID)ALIGN_UP_BY(ptr, align))
+
+#define ALIGN_DOWN(size, type) \
+    ALIGN_DOWN_BY(size, sizeof(type))
+
+#define ALIGN_UP(size, type) \
+    ALIGN_UP_BY(size, sizeof(type))
+
+#define ALIGN_DOWN_POINTER(ptr, type) \
+    ALIGN_DOWN_POINTER_BY(ptr, sizeof(type))
+
+#define ALIGN_UP_POINTER(ptr, type) \
+    ALIGN_UP_POINTER_BY(ptr, sizeof(type))
+
+#ifndef FIELD_OFFSET
+#define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field))
+#endif
+
+#ifndef FIELD_SIZE
+#define FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
+#endif
+
+#define POOL_TAGGING                             1
+
+#if DBG
+#define IF_DEBUG if (TRUE)
+#else
+#define IF_DEBUG if (FALSE)
+#endif /* DBG */
+
+/* ULONG
+ * BYTE_OFFSET(
+ *   IN PVOID Va)
+ */
+#define BYTE_OFFSET(Va) \
+  ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
+
+/* ULONG
+ * BYTES_TO_PAGES(
+ *   IN ULONG Size)
+ */
+#define BYTES_TO_PAGES(Size) \
+  (((Size) + PAGE_SIZE - 1) >> PAGE_SHIFT)
+
+/* PVOID
+ * PAGE_ALIGN(
+ *   IN PVOID Va)
+ */
+#define PAGE_ALIGN(Va) \
+  ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
+
+/* ULONG_PTR
+ * ROUND_TO_PAGES(
+ *   IN ULONG_PTR Size)
+ */
+#define ROUND_TO_PAGES(Size) \
+  (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
+
+/* ULONG
+ * ADDRESS_AND_SIZE_TO_SPAN_PAGES(
+ *   IN PVOID Va,
+ *   IN ULONG Size)
+ */
+#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size) \
+  ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \
+    + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
+
+#define COMPUTE_PAGES_SPANNED(Va, Size) \
+    ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size)
+
+/*
+ * ULONG
+ * MmGetMdlByteCount(
+ *   IN PMDL  Mdl)
+ */
+#define MmGetMdlByteCount(_Mdl) \
+  ((_Mdl)->ByteCount)
+
+/*
+ * ULONG
+ * MmGetMdlByteOffset(
+ *   IN PMDL  Mdl)
+ */
+#define MmGetMdlByteOffset(_Mdl) \
+  ((_Mdl)->ByteOffset)
+
+#define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa)
+
+/*
+ * PPFN_NUMBER
+ * MmGetMdlPfnArray(
+ *   IN PMDL  Mdl)
+ */
+#define MmGetMdlPfnArray(_Mdl) \
+  ((PPFN_NUMBER) ((_Mdl) + 1))
+
+/*
+ * PVOID
+ * MmGetMdlVirtualAddress(
+ *   IN PMDL  Mdl)
+ */
+#define MmGetMdlVirtualAddress(_Mdl) \
+  ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))
+
+#define MmGetProcedureAddress(Address) (Address)
+
+/* PVOID MmGetSystemAddressForMdl(
+ *     IN PMDL Mdl);
+ */
+#define MmGetSystemAddressForMdl(Mdl) \
+  (((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
+    MDL_SOURCE_IS_NONPAGED_POOL)) ? \
+      ((Mdl)->MappedSystemVa) : \
+      (MmMapLockedPages((Mdl), KernelMode)))
+
+/* PVOID
+ * MmGetSystemAddressForMdlSafe(
+ *     IN PMDL Mdl,
+ *     IN MM_PAGE_PRIORITY Priority)
+ */
+#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority) \
+  (((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \
+    | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
+    (_Mdl)->MappedSystemVa : \
+    (PVOID) MmMapLockedPagesSpecifyCache((_Mdl), \
+      KernelMode, MmCached, NULL, FALSE, (_Priority)))
+
+/*
+ * VOID
+ * MmInitializeMdl(
+ *   IN PMDL  MemoryDescriptorList,
+ *   IN PVOID  BaseVa,
+ *   IN SIZE_T  Length)
+ */
+#define MmInitializeMdl(_MemoryDescriptorList, \
+                        _BaseVa, \
+                        _Length) \
+{ \
+  (_MemoryDescriptorList)->Next = (PMDL) NULL; \
+  (_MemoryDescriptorList)->Size = (CSHORT) (sizeof(MDL) + \
+    (sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(_BaseVa, _Length))); \
+  (_MemoryDescriptorList)->MdlFlags = 0; \
+  (_MemoryDescriptorList)->StartVa = (PVOID) PAGE_ALIGN(_BaseVa); \
+  (_MemoryDescriptorList)->ByteOffset = BYTE_OFFSET(_BaseVa); \
+  (_MemoryDescriptorList)->ByteCount = (ULONG) _Length; \
+}
+
+/*
+ * VOID
+ * MmPrepareMdlForReuse(
+ *   IN PMDL  Mdl)
+ */
+#define MmPrepareMdlForReuse(_Mdl) \
+{ \
+  if (((_Mdl)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) { \
+    ASSERT(((_Mdl)->MdlFlags & MDL_PARTIAL) != 0); \
+    MmUnmapLockedPages((_Mdl)->MappedSystemVa, (_Mdl)); \
+  } else if (((_Mdl)->MdlFlags & MDL_PARTIAL) == 0) { \
+    ASSERT(((_Mdl)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \
+  } \
+}
+
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
 NTKERNELAPI
-NTSTATUS
+PVOID
 NTAPI
-KeQueryDpcWatchdogInformation(
-  OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation);
+MmAllocateContiguousMemory(
+  IN SIZE_T  NumberOfBytes,
+  IN PHYSICAL_ADDRESS  HighestAcceptableAddress);
 
-#if defined(SINGLE_GROUP_LEGACY_API)
+NTKERNELAPI
+PVOID
+NTAPI
+MmAllocateContiguousMemorySpecifyCache(
+  IN SIZE_T  NumberOfBytes,
+  IN PHYSICAL_ADDRESS  LowestAcceptableAddress,
+  IN PHYSICAL_ADDRESS  HighestAcceptableAddress,
+  IN PHYSICAL_ADDRESS  BoundaryAddressMultiple  OPTIONAL,
+  IN MEMORY_CACHING_TYPE  CacheType);
 
 NTKERNELAPI
-KAFFINITY
+PMDL
 NTAPI
-KeSetSystemAffinityThreadEx(
-  IN KAFFINITY Affinity);
+MmAllocatePagesForMdl(
+  IN PHYSICAL_ADDRESS  LowAddress,
+  IN PHYSICAL_ADDRESS  HighAddress,
+  IN PHYSICAL_ADDRESS  SkipBytes,
+  IN SIZE_T  TotalBytes);
 
 NTKERNELAPI
 VOID
 NTAPI
-KeRevertToUserAffinityThreadEx(
-  IN KAFFINITY Affinity);
+MmBuildMdlForNonPagedPool(
+  IN OUT PMDLX  MemoryDescriptorList);
 
+//DECLSPEC_DEPRECATED_DDK
 NTKERNELAPI
-ULONG
+PMDL
 NTAPI
-KeQueryActiveProcessorCount(
-  OUT PKAFFINITY ActiveProcessors OPTIONAL);
+MmCreateMdl(
+  IN PMDL  MemoryDescriptorList  OPTIONAL,
+  IN PVOID  Base,
+  IN SIZE_T  Length);
 
 NTKERNELAPI
-ULONG
+VOID
 NTAPI
-KeQueryMaximumProcessorCount(VOID);
-#endif /* SINGLE_GROUP_LEGACY_API */
-
-#endif /*  (NTDDI_VERSION >= NTDDI_VISTA) */
-
-#if (NTDDI_VERSION >= NTDDI_WS08)
-
-PVOID
-KeRegisterProcessorChangeCallback(
-  IN PPROCESSOR_CALLBACK_FUNCTION CallbackFunction,
-  IN PVOID CallbackContext OPTIONAL,
-  IN ULONG Flags);
+MmFreeContiguousMemory(
+  IN PVOID  BaseAddress);
 
+NTKERNELAPI
 VOID
-KeDeregisterProcessorChangeCallback(
-  IN PVOID CallbackHandle);
-
-#endif /* (NTDDI_VERSION >= NTDDI_WS08) */
-
-#if (NTDDI_VERSION >= NTDDI_WIN7)
+NTAPI
+MmFreeContiguousMemorySpecifyCache(
+  IN PVOID  BaseAddress,
+  IN SIZE_T  NumberOfBytes,
+  IN MEMORY_CACHING_TYPE  CacheType);
 
+NTKERNELAPI
+VOID
+NTAPI
+MmFreePagesFromMdl(
+  IN PMDLX MemoryDescriptorList);
 
-ULONG64
+NTKERNELAPI
+PVOID
 NTAPI
-KeQueryTotalCycleTimeProcess(
-  IN OUT PKPROCESS Process,
-  OUT PULONG64 CycleTimeStamp);
+MmGetSystemRoutineAddress(
+  IN PUNICODE_STRING  SystemRoutineName);
 
-ULONG64
+NTKERNELAPI
+LOGICAL
 NTAPI
-KeQueryTotalCycleTimeThread(
-  IN OUT PKTHREAD Thread,
-  OUT PULONG64 CycleTimeStamp);
+MmIsDriverVerifying(
+  IN struct _DRIVER_OBJECT *DriverObject);
 
 NTKERNELAPI
-NTSTATUS
+PVOID
 NTAPI
-KeSetTargetProcessorDpcEx(
-  IN OUT PKDPC Dpc,
-  IN PPROCESSOR_NUMBER ProcNumber);
+MmLockPagableDataSection(
+  IN PVOID  AddressWithinSection);
 
 NTKERNELAPI
-VOID
+PVOID
 NTAPI
-KeSetSystemGroupAffinityThread(
-  IN PGROUP_AFFINITY Affinity,
-  OUT PGROUP_AFFINITY PreviousAffinity OPTIONAL);
+MmMapIoSpace(
+  IN PHYSICAL_ADDRESS  PhysicalAddress,
+  IN SIZE_T  NumberOfBytes,
+  IN MEMORY_CACHING_TYPE  CacheEnable);
 
 NTKERNELAPI
-VOID
+PVOID
 NTAPI
-KeRevertToUserGroupAffinityThread(
-  IN PGROUP_AFFINITY PreviousAffinity);
+MmMapLockedPages(
+  IN PMDL  MemoryDescriptorList,
+  IN KPROCESSOR_MODE  AccessMode);
 
 NTKERNELAPI
-BOOLEAN
+PVOID
 NTAPI
-KeSetCoalescableTimer(
-  IN OUT PKTIMER Timer,
-  IN LARGE_INTEGER DueTime,
-  IN ULONG Period,
-  IN ULONG TolerableDelay,
-  IN PKDPC Dpc OPTIONAL);
+MmMapLockedPagesSpecifyCache(
+  IN PMDLX MemoryDescriptorList,
+  IN KPROCESSOR_MODE AccessMode,
+  IN MEMORY_CACHING_TYPE CacheType,
+  IN PVOID BaseAddress OPTIONAL,
+  IN ULONG BugCheckOnFailure,
+  IN MM_PAGE_PRIORITY Priority);
 
 NTKERNELAPI
-ULONGLONG
+PVOID
 NTAPI
-KeQueryUnbiasedInterruptTime(VOID);
+MmPageEntireDriver(
+  IN PVOID  AddressWithinSection);
 
 NTKERNELAPI
-ULONG
+VOID
 NTAPI
-KeQueryActiveProcessorCountEx(
-  IN USHORT GroupNumber);
+MmProbeAndLockPages(
+  IN OUT PMDL  MemoryDescriptorList,
+  IN KPROCESSOR_MODE  AccessMode,
+  IN LOCK_OPERATION  Operation);
 
 NTKERNELAPI
-ULONG
+MM_SYSTEMSIZE
 NTAPI
-KeQueryMaximumProcessorCountEx(
-  IN USHORT GroupNumber);
+MmQuerySystemSize(VOID);
 
 NTKERNELAPI
-USHORT
+VOID
 NTAPI
-KeQueryActiveGroupCount(VOID);
+MmResetDriverPaging(
+  IN PVOID  AddressWithinSection);
 
 NTKERNELAPI
-USHORT
+SIZE_T
 NTAPI
-KeQueryMaximumGroupCount(VOID);
+MmSizeOfMdl(
+  IN PVOID  Base,
+  IN SIZE_T  Length);
 
 NTKERNELAPI
-KAFFINITY
+VOID
 NTAPI
-KeQueryGroupAffinity(
-  IN USHORT GroupNumber);
+MmUnlockPagableImageSection(
+  IN PVOID  ImageSectionHandle);
 
 NTKERNELAPI
-ULONG
+VOID
 NTAPI
-KeGetCurrentProcessorNumberEx(
-  OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL);
+MmUnlockPages(
+  IN OUT PMDL  MemoryDescriptorList);
 
 NTKERNELAPI
 VOID
 NTAPI
-KeQueryNodeActiveAffinity(
-  IN USHORT NodeNumber,
-  OUT PGROUP_AFFINITY Affinity OPTIONAL,
-  OUT PUSHORT Count OPTIONAL);
+MmUnmapIoSpace(
+  IN PVOID  BaseAddress,
+  IN SIZE_T  NumberOfBytes);
 
 NTKERNELAPI
-USHORT
+VOID
 NTAPI
-KeQueryNodeMaximumProcessorCount(
-  IN USHORT NodeNumber);
+MmProbeAndLockProcessPages(
+  IN OUT PMDL  MemoryDescriptorList,
+  IN PEPROCESS  Process,
+  IN KPROCESSOR_MODE  AccessMode,
+  IN LOCK_OPERATION  Operation);
 
 NTKERNELAPI
-USHORT
+VOID
 NTAPI
-KeQueryHighestNodeNumber(VOID);
+MmUnmapLockedPages(
+  IN PVOID  BaseAddress,
+  IN PMDL  MemoryDescriptorList);
 
 NTKERNELAPI
-USHORT
+PVOID
 NTAPI
-KeGetCurrentNodeNumber(VOID);
+MmAllocateContiguousMemorySpecifyCacheNode(
+  IN SIZE_T NumberOfBytes,
+  IN PHYSICAL_ADDRESS LowestAcceptableAddress,
+  IN PHYSICAL_ADDRESS HighestAcceptableAddress,
+  IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL,
+  IN MEMORY_CACHING_TYPE CacheType,
+  IN NODE_REQUIREMENT PreferredNode);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+
+#if (NTDDI_VERSION >= NTDDI_WINXP)
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-KeQueryLogicalProcessorRelationship(
-  IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL,
-  IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType,
-  OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL,
-  IN OUT PULONG Length);
+MmAdvanceMdl(
+  IN OUT PMDL  Mdl,
+  IN ULONG  NumberOfBytes);
 
 NTKERNELAPI
-NTSTATUS
+PVOID
 NTAPI
-KeSaveExtendedProcessorState(
-  IN ULONG64 Mask,
-  OUT PXSTATE_SAVE XStateSave);
+MmAllocateMappingAddress(
+  IN SIZE_T  NumberOfBytes,
+  IN ULONG  PoolTag);
 
 NTKERNELAPI
 VOID
 NTAPI
-KeRestoreExtendedProcessorState(
-  IN PXSTATE_SAVE XStateSave);
+MmFreeMappingAddress(
+  IN PVOID  BaseAddress,
+  IN ULONG  PoolTag);
 
+NTKERNELAPI
 NTSTATUS
 NTAPI
-KeGetProcessorNumberFromIndex(
-  IN ULONG ProcIndex,
-  OUT PPROCESSOR_NUMBER ProcNumber);
+MmIsVerifierEnabled(
+  OUT PULONG  VerifierFlags);
 
-ULONG
+NTKERNELAPI
+PVOID
 NTAPI
-KeGetProcessorIndexFromNumber(
-  IN PPROCESSOR_NUMBER ProcNumber);
+MmMapLockedPagesWithReservedMapping(
+  IN PVOID  MappingAddress,
+  IN ULONG  PoolTag,
+  IN PMDL  MemoryDescriptorList,
+  IN MEMORY_CACHING_TYPE  CacheType);
 
-#endif /*  (NTDDI_VERSION >= NTDDI_WIN7) */
+NTKERNELAPI
+NTSTATUS
+NTAPI
+MmProtectMdlSystemAddress(
+  IN PMDL  MemoryDescriptorList,
+  IN ULONG  NewProtect);
 
-#if !defined(_IA64_)
-NTHALAPI
+NTKERNELAPI
 VOID
 NTAPI
-KeFlushWriteBuffer(VOID);
-#endif
+MmUnmapReservedMapping(
+  IN PVOID  BaseAddress,
+  IN ULONG  PoolTag,
+  IN PMDL  MemoryDescriptorList);
 
-/* VOID
- * KeInitializeCallbackRecord(
- *   IN PKBUGCHECK_CALLBACK_RECORD  CallbackRecord)
- */
-#define KeInitializeCallbackRecord(CallbackRecord) \
-  CallbackRecord->State = BufferEmpty;
+NTKERNELAPI
+NTSTATUS
+NTAPI
+MmAddVerifierThunks(
+  IN PVOID ThunkBuffer,
+  IN ULONG ThunkBufferSize);
 
-#if DBG
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
-#define PAGED_ASSERT( exp ) NT_ASSERT( exp )
-#else
-#define PAGED_ASSERT( exp ) ASSERT( exp )
+#if (NTDDI_VERSION >= NTDDI_WS03)
+NTKERNELAPI
+LOGICAL
+NTAPI
+MmIsIoSpaceActive(
+  IN PHYSICAL_ADDRESS StartAddress,
+  IN SIZE_T NumberOfBytes);
 #endif
 
-#define PAGED_CODE() { \
-  if (KeGetCurrentIrql() > APC_LEVEL) { \
-    KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \
-    PAGED_ASSERT(FALSE); \
-  } \
-}
-
-#else
-
-#define PAGED_CODE()
-
-#endif /* DBG */
-
-#define PAGED_CODE_LOCKED() NOP_FUNCTION;
-
-/******************************************************************************
- *                       Memory manager Functions                             *
- ******************************************************************************/
-/* Alignment Macros */
-#define ALIGN_DOWN_BY(size, align) \
-    ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
-
-#define ALIGN_UP_BY(size, align) \
-    (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
-
-#define ALIGN_DOWN_POINTER_BY(ptr, align) \
-    ((PVOID)ALIGN_DOWN_BY(ptr, align))
-
-#define ALIGN_UP_POINTER_BY(ptr, align) \
-    ((PVOID)ALIGN_UP_BY(ptr, align))
-
-#define ALIGN_DOWN(size, type) \
-    ALIGN_DOWN_BY(size, sizeof(type))
+#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+NTKERNELAPI
+PMDL
+NTAPI
+MmAllocatePagesForMdlEx(
+  IN PHYSICAL_ADDRESS LowAddress,
+  IN PHYSICAL_ADDRESS HighAddress,
+  IN PHYSICAL_ADDRESS SkipBytes,
+  IN SIZE_T TotalBytes,
+  IN MEMORY_CACHING_TYPE CacheType,
+  IN ULONG Flags);
+#endif
 
-#define ALIGN_UP(size, type) \
-    ALIGN_UP_BY(size, sizeof(type))
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 
-#define ALIGN_DOWN_POINTER(ptr, type) \
-    ALIGN_DOWN_POINTER_BY(ptr, sizeof(type))
+NTKERNELAPI
+LOGICAL
+NTAPI
+MmIsDriverVerifyingByAddress(
+  IN PVOID AddressWithinSection);
+#endif
 
-#define ALIGN_UP_POINTER(ptr, type) \
-    ALIGN_UP_POINTER_BY(ptr, sizeof(type))
+/******************************************************************************
+ *                            Security Manager Functions                      *
+ ******************************************************************************/
 
-/* ULONG
- * BYTE_OFFSET(
- *   IN PVOID Va)
- */
-#define BYTE_OFFSET(Va) \
-  ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
-/* ULONG
- * BYTES_TO_PAGES(
- *   IN ULONG Size)
- */
-#define BYTES_TO_PAGES(Size) \
-  (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0))
+NTKERNELAPI
+BOOLEAN
+NTAPI
+SeAccessCheck(
+  IN PSECURITY_DESCRIPTOR  SecurityDescriptor,
+  IN PSECURITY_SUBJECT_CONTEXT  SubjectSecurityContext,
+  IN BOOLEAN  SubjectContextLocked,
+  IN ACCESS_MASK  DesiredAccess,
+  IN ACCESS_MASK  PreviouslyGrantedAccess,
+  OUT PPRIVILEGE_SET  *Privileges  OPTIONAL,
+  IN PGENERIC_MAPPING  GenericMapping,
+  IN KPROCESSOR_MODE  AccessMode,
+  OUT PACCESS_MASK  GrantedAccess,
+  OUT PNTSTATUS  AccessStatus);
 
-/* PVOID
- * PAGE_ALIGN(
- *   IN PVOID Va)
- */
-#define PAGE_ALIGN(Va) \
-  ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
+NTKERNELAPI
+NTSTATUS
+NTAPI
+SeAssignSecurity(
+  IN PSECURITY_DESCRIPTOR  ParentDescriptor  OPTIONAL,
+  IN PSECURITY_DESCRIPTOR  ExplicitDescriptor  OPTIONAL,
+  OUT PSECURITY_DESCRIPTOR  *NewDescriptor,
+  IN BOOLEAN  IsDirectoryObject,
+  IN PSECURITY_SUBJECT_CONTEXT  SubjectContext,
+  IN PGENERIC_MAPPING  GenericMapping,
+  IN POOL_TYPE  PoolType);
 
-/* ULONG_PTR
- * ROUND_TO_PAGES(
- *   IN ULONG_PTR Size)
- */
-#define ROUND_TO_PAGES(Size) \
-  (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
+NTKERNELAPI
+NTSTATUS
+NTAPI
+SeAssignSecurityEx(
+  IN PSECURITY_DESCRIPTOR  ParentDescriptor  OPTIONAL,
+  IN PSECURITY_DESCRIPTOR  ExplicitDescriptor  OPTIONAL,
+  OUT PSECURITY_DESCRIPTOR  *NewDescriptor,
+  IN GUID  *ObjectType  OPTIONAL,
+  IN BOOLEAN  IsDirectoryObject,
+  IN ULONG  AutoInheritFlags,
+  IN PSECURITY_SUBJECT_CONTEXT  SubjectContext,
+  IN PGENERIC_MAPPING  GenericMapping,
+  IN POOL_TYPE  PoolType);
 
-/* ULONG
- * ADDRESS_AND_SIZE_TO_SPAN_PAGES(
- *   IN PVOID Va,
- *   IN ULONG Size)
- */
-#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size) \
-  ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \
-    + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
+NTKERNELAPI
+NTSTATUS
+NTAPI
+SeDeassignSecurity(
+  IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor);
 
-#define COMPUTE_PAGES_SPANNED(Va, Size) \
-    ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size)
+NTKERNELAPI
+BOOLEAN
+NTAPI
+SeValidSecurityDescriptor(
+  IN ULONG Length,
+  IN PSECURITY_DESCRIPTOR SecurityDescriptor);
 
-/*
- * ULONG
- * MmGetMdlByteCount(
- *   IN PMDL  Mdl)
- */
-#define MmGetMdlByteCount(_Mdl) \
-  ((_Mdl)->ByteCount)
+NTKERNELAPI
+ULONG
+NTAPI
+SeObjectCreateSaclAccessBits(
+  IN PSECURITY_DESCRIPTOR SecurityDescriptor);
 
-/*
- * ULONG
- * MmGetMdlByteOffset(
- *   IN PMDL  Mdl)
- */
-#define MmGetMdlByteOffset(_Mdl) \
-  ((_Mdl)->ByteOffset)
+NTKERNELAPI
+VOID
+NTAPI
+SeReleaseSubjectContext(
+  IN OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
 
-#define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa)
+NTKERNELAPI
+VOID
+NTAPI
+SeUnlockSubjectContext(
+  IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
 
-/*
- * PPFN_NUMBER
- * MmGetMdlPfnArray(
- *   IN PMDL  Mdl)
- */
-#define MmGetMdlPfnArray(_Mdl) \
-  ((PPFN_NUMBER) ((_Mdl) + 1))
+NTKERNELAPI
+VOID
+NTAPI
+SeCaptureSubjectContext(
+  OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
 
-/*
- * PVOID
- * MmGetMdlVirtualAddress(
- *   IN PMDL  Mdl)
- */
-#define MmGetMdlVirtualAddress(_Mdl) \
-  ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))
+NTKERNELAPI
+VOID
+NTAPI
+SeLockSubjectContext(
+  IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
 
-#define MmGetProcedureAddress(Address) (Address)
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
 
-/* PVOID MmGetSystemAddressForMdl(
- *     IN PMDL Mdl);
- */
-#define MmGetSystemAddressForMdl(Mdl) \
-  (((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
-    MDL_SOURCE_IS_NONPAGED_POOL)) ? \
-      ((Mdl)->MappedSystemVa) : \
-      (MmMapLockedPages((Mdl), KernelMode)))
+#if (NTDDI_VERSION >= NTDDI_WS03SP1)
 
-/* PVOID
- * MmGetSystemAddressForMdlSafe(
- *     IN PMDL Mdl,
- *     IN MM_PAGE_PRIORITY Priority)
- */
-#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority) \
-  (((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \
-    | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
-    (_Mdl)->MappedSystemVa : \
-    (PVOID) MmMapLockedPagesSpecifyCache((_Mdl), \
-      KernelMode, MmCached, NULL, FALSE, (_Priority)))
+NTSTATUS
+NTAPI
+SeSetAuditParameter(
+  IN OUT PSE_ADT_PARAMETER_ARRAY AuditParameters,
+  IN SE_ADT_PARAMETER_TYPE Type,
+  IN ULONG Index,
+  IN PVOID Data);
 
-/*
- * VOID
- * MmInitializeMdl(
- *   IN PMDL  MemoryDescriptorList,
- *   IN PVOID  BaseVa,
- *   IN SIZE_T  Length)
- */
-#define MmInitializeMdl(_MemoryDescriptorList, \
-                        _BaseVa, \
-                        _Length) \
-{ \
-  (_MemoryDescriptorList)->Next = (PMDL) NULL; \
-  (_MemoryDescriptorList)->Size = (CSHORT) (sizeof(MDL) + \
-    (sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(_BaseVa, _Length))); \
-  (_MemoryDescriptorList)->MdlFlags = 0; \
-  (_MemoryDescriptorList)->StartVa = (PVOID) PAGE_ALIGN(_BaseVa); \
-  (_MemoryDescriptorList)->ByteOffset = BYTE_OFFSET(_BaseVa); \
-  (_MemoryDescriptorList)->ByteCount = (ULONG) _Length; \
-}
+NTSTATUS
+NTAPI
+SeReportSecurityEvent(
+  IN ULONG Flags,
+  IN PUNICODE_STRING SourceName,
+  IN PSID UserSid OPTIONAL,
+  IN PSE_ADT_PARAMETER_ARRAY AuditParameters);
 
-/*
- * VOID
- * MmPrepareMdlForReuse(
- *   IN PMDL  Mdl)
- */
-#define MmPrepareMdlForReuse(_Mdl) \
-{ \
-  if (((_Mdl)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) { \
-    ASSERT(((_Mdl)->MdlFlags & MDL_PARTIAL) != 0); \
-    MmUnmapLockedPages((_Mdl)->MappedSystemVa, (_Mdl)); \
-  } else if (((_Mdl)->MdlFlags & MDL_PARTIAL) == 0) { \
-    ASSERT(((_Mdl)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \
-  } \
-}
+#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 
 NTKERNELAPI
-PVOID
+ULONG
 NTAPI
-MmAllocateContiguousMemory(
-  IN SIZE_T  NumberOfBytes,
-  IN PHYSICAL_ADDRESS  HighestAcceptableAddress);
+SeComputeAutoInheritByObjectType(
+  IN PVOID ObjectType,
+  IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
+  IN PSECURITY_DESCRIPTOR ParentSecurityDescriptor OPTIONAL);
 
-NTKERNELAPI
-PVOID
+#ifdef SE_NTFS_WORLD_CACHE
+VOID
 NTAPI
-MmAllocateContiguousMemorySpecifyCache(
-  IN SIZE_T  NumberOfBytes,
-  IN PHYSICAL_ADDRESS  LowestAcceptableAddress,
-  IN PHYSICAL_ADDRESS  HighestAcceptableAddress,
-  IN PHYSICAL_ADDRESS  BoundaryAddressMultiple  OPTIONAL,
-  IN MEMORY_CACHING_TYPE  CacheType);
+SeGetWorldRights(
+  IN PSECURITY_DESCRIPTOR SecurityDescriptor,
+  IN PGENERIC_MAPPING GenericMapping,
+  OUT PACCESS_MASK GrantedAccess);
+#endif /* SE_NTFS_WORLD_CACHE */
+
+#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
+/******************************************************************************
+ *                         Configuration Manager Functions                    *
+ ******************************************************************************/
 
+#if (NTDDI_VERSION >= NTDDI_WINXP)
 NTKERNELAPI
-PMDL
+NTSTATUS
 NTAPI
-MmAllocatePagesForMdl(
-  IN PHYSICAL_ADDRESS  LowAddress,
-  IN PHYSICAL_ADDRESS  HighAddress,
-  IN PHYSICAL_ADDRESS  SkipBytes,
-  IN SIZE_T  TotalBytes);
+CmRegisterCallback(
+  IN PEX_CALLBACK_FUNCTION  Function,
+  IN PVOID  Context  OPTIONAL,
+  OUT PLARGE_INTEGER  Cookie);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-MmBuildMdlForNonPagedPool(
-  IN OUT PMDLX  MemoryDescriptorList);
+CmUnRegisterCallback(
+  IN LARGE_INTEGER  Cookie);
+#endif
+
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 
-//DECLSPEC_DEPRECATED_DDK
 NTKERNELAPI
-PMDL
+NTSTATUS
 NTAPI
-MmCreateMdl(
-  IN PMDL  MemoryDescriptorList  OPTIONAL,
-  IN PVOID  Base,
-  IN SIZE_T  Length);
+CmRegisterCallbackEx(
+  PEX_CALLBACK_FUNCTION Function,
+  PCUNICODE_STRING Altitude,
+  PVOID Driver,
+  PVOID Context,
+  PLARGE_INTEGER Cookie,
+  PVOID Reserved);
 
 NTKERNELAPI
 VOID
 NTAPI
-MmFreeContiguousMemory(
-  IN PVOID  BaseAddress);
+CmGetCallbackVersion(
+  OUT PULONG Major OPTIONAL,
+  OUT PULONG Minor OPTIONAL);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-MmFreeContiguousMemorySpecifyCache(
-  IN PVOID  BaseAddress,
-  IN SIZE_T  NumberOfBytes,
-  IN MEMORY_CACHING_TYPE  CacheType);
+CmSetCallbackObjectContext(
+  IN OUT PVOID Object,
+  IN PLARGE_INTEGER Cookie,
+  IN PVOID NewContext,
+  OUT PVOID *OldContext OPTIONAL);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-MmFreePagesFromMdl(
-  IN PMDLX MemoryDescriptorList);
+CmCallbackGetKeyObjectID(
+  IN PLARGE_INTEGER Cookie,
+  IN PVOID Object,
+  OUT PULONG_PTR ObjectID OPTIONAL,
+  OUT PCUNICODE_STRING *ObjectName OPTIONAL);
 
 NTKERNELAPI
 PVOID
 NTAPI
-MmGetSystemRoutineAddress(
-  IN PUNICODE_STRING  SystemRoutineName);
+CmGetBoundTransaction(
+  IN PLARGE_INTEGER Cookie,
+  IN PVOID Object);
 
-NTKERNELAPI
-LOGICAL
+#endif // NTDDI_VERSION >= NTDDI_VISTA
+
+
+/******************************************************************************
+ *                         I/O Manager Functions                              *
+ ******************************************************************************/
+
+
+/*
+ * NTSTATUS
+ * IoAcquireRemoveLock(
+ *   IN PIO_REMOVE_LOCK  RemoveLock,
+ *   IN OPTIONAL PVOID  Tag)
+ */
+#if DBG
+#define IoAcquireRemoveLock(RemoveLock, Tag) \
+  IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK))
+#else
+#define IoAcquireRemoveLock(RemoveLock, Tag) \
+  IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK))
+#endif
+
+/*
+ * VOID
+ * IoAdjustPagingPathCount(
+ *   IN PLONG  Count,
+ *   IN BOOLEAN  Increment)
+ */
+#define IoAdjustPagingPathCount(_Count, \
+                                _Increment) \
+{ \
+  if (_Increment) \
+    { \
+      InterlockedIncrement(_Count); \
+    } \
+  else \
+    { \
+      InterlockedDecrement(_Count); \
+    } \
+}
+
+#if !defined(_M_AMD64)
+NTHALAPI
+VOID
 NTAPI
-MmIsDriverVerifying(
-  IN struct _DRIVER_OBJECT *DriverObject);
+READ_PORT_BUFFER_UCHAR(
+  IN PUCHAR Port,
+  IN PUCHAR Buffer,
+  IN ULONG Count);
 
-NTKERNELAPI
-PVOID
+NTHALAPI
+VOID
 NTAPI
-MmLockPagableDataSection(
-  IN PVOID  AddressWithinSection);
+READ_PORT_BUFFER_ULONG(
+  IN PULONG Port,
+  IN PULONG Buffer,
+  IN ULONG Count);
 
-NTKERNELAPI
-PVOID
+NTHALAPI
+VOID
 NTAPI
-MmMapIoSpace(
-  IN PHYSICAL_ADDRESS  PhysicalAddress,
-  IN SIZE_T  NumberOfBytes,
-  IN MEMORY_CACHING_TYPE  CacheEnable);
+READ_PORT_BUFFER_USHORT(
+  IN PUSHORT Port,
+  IN PUSHORT Buffer,
+  IN ULONG Count);
 
-NTKERNELAPI
-PVOID
+NTHALAPI
+UCHAR
 NTAPI
-MmMapLockedPages(
-  IN PMDL  MemoryDescriptorList,
-  IN KPROCESSOR_MODE  AccessMode);
+READ_PORT_UCHAR(
+  IN PUCHAR Port);
 
-NTKERNELAPI
-PVOID
+NTHALAPI
+ULONG
 NTAPI
-MmMapLockedPagesSpecifyCache(
-  IN PMDLX MemoryDescriptorList,
-  IN KPROCESSOR_MODE AccessMode,
-  IN MEMORY_CACHING_TYPE CacheType,
-  IN PVOID BaseAddress OPTIONAL,
-  IN ULONG BugCheckOnFailure,
-  IN MM_PAGE_PRIORITY Priority);
+READ_PORT_ULONG(
+  IN PULONG Port);
 
-NTKERNELAPI
-PVOID
+NTHALAPI
+USHORT
 NTAPI
-MmPageEntireDriver(
-  IN PVOID  AddressWithinSection);
+READ_PORT_USHORT(
+  IN PUSHORT Port);
 
 NTKERNELAPI
 VOID
 NTAPI
-MmProbeAndLockPages(
-  IN OUT PMDL  MemoryDescriptorList,
-  IN KPROCESSOR_MODE  AccessMode,
-  IN LOCK_OPERATION  Operation);
+READ_REGISTER_BUFFER_UCHAR(
+  IN PUCHAR Register,
+  IN PUCHAR Buffer,
+  IN ULONG Count);
 
 NTKERNELAPI
-MM_SYSTEMSIZE
+VOID
 NTAPI
-MmQuerySystemSize(VOID);
+READ_REGISTER_BUFFER_ULONG(
+  IN PULONG Register,
+  IN PULONG Buffer,
+  IN ULONG Count);
 
 NTKERNELAPI
 VOID
 NTAPI
-MmResetDriverPaging(
-  IN PVOID  AddressWithinSection);
+READ_REGISTER_BUFFER_USHORT(
+  IN PUSHORT Register,
+  IN PUSHORT Buffer,
+  IN ULONG Count);
 
 NTKERNELAPI
-SIZE_T
+UCHAR
 NTAPI
-MmSizeOfMdl(
-  IN PVOID  Base,
-  IN SIZE_T  Length);
+READ_REGISTER_UCHAR(
+  IN PUCHAR Register);
 
 NTKERNELAPI
-VOID
+ULONG
 NTAPI
-MmUnlockPagableImageSection(
-  IN PVOID  ImageSectionHandle);
+READ_REGISTER_ULONG(
+  IN PULONG Register);
 
 NTKERNELAPI
-VOID
+USHORT
 NTAPI
-MmUnlockPages(
-  IN OUT PMDL  MemoryDescriptorList);
+READ_REGISTER_USHORT(
+  IN PUSHORT Register);
 
-NTKERNELAPI
+NTHALAPI
 VOID
 NTAPI
-MmUnmapIoSpace(
-  IN PVOID  BaseAddress,
-  IN SIZE_T  NumberOfBytes);
+WRITE_PORT_BUFFER_UCHAR(
+  IN PUCHAR Port,
+  IN PUCHAR Buffer,
+  IN ULONG Count);
 
-NTKERNELAPI
+NTHALAPI
 VOID
 NTAPI
-MmProbeAndLockProcessPages(
-  IN OUT PMDL  MemoryDescriptorList,
-  IN PEPROCESS  Process,
-  IN KPROCESSOR_MODE  AccessMode,
-  IN LOCK_OPERATION  Operation);
+WRITE_PORT_BUFFER_ULONG(
+  IN PULONG Port,
+  IN PULONG Buffer,
+  IN ULONG Count);
 
-NTKERNELAPI
+NTHALAPI
 VOID
 NTAPI
-MmUnmapLockedPages(
-  IN PVOID  BaseAddress,
-  IN PMDL  MemoryDescriptorList);
-
-
-
-#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+WRITE_PORT_BUFFER_USHORT(
+  IN PUSHORT Port,
+  IN PUSHORT Buffer,
+  IN ULONG Count);
 
-#if (NTDDI_VERSION >= NTDDI_WINXP)
+NTHALAPI
+VOID
+NTAPI
+WRITE_PORT_UCHAR(
+  IN PUCHAR Port,
+  IN UCHAR Value);
 
-NTKERNELAPI
-NTSTATUS
+NTHALAPI
+VOID
 NTAPI
-MmAdvanceMdl(
-  IN OUT PMDL  Mdl,
-  IN ULONG  NumberOfBytes);
+WRITE_PORT_ULONG(
+  IN PULONG Port,
+  IN ULONG Value);
 
-NTKERNELAPI
-PVOID
+NTHALAPI
+VOID
 NTAPI
-MmAllocateMappingAddress(
-  IN SIZE_T  NumberOfBytes,
-  IN ULONG  PoolTag);
+WRITE_PORT_USHORT(
+  IN PUSHORT Port,
+  IN USHORT Value);
 
 NTKERNELAPI
 VOID
 NTAPI
-MmFreeMappingAddress(
-  IN PVOID  BaseAddress,
-  IN ULONG  PoolTag);
+WRITE_REGISTER_BUFFER_UCHAR(
+  IN PUCHAR Register,
+  IN PUCHAR Buffer,
+  IN ULONG Count);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-MmIsVerifierEnabled(
-  OUT PULONG  VerifierFlags);
+WRITE_REGISTER_BUFFER_ULONG(
+  IN PULONG  Register,
+  IN PULONG  Buffer,
+  IN ULONG  Count);
 
 NTKERNELAPI
-PVOID
+VOID
 NTAPI
-MmMapLockedPagesWithReservedMapping(
-  IN PVOID  MappingAddress,
-  IN ULONG  PoolTag,
-  IN PMDL  MemoryDescriptorList,
-  IN MEMORY_CACHING_TYPE  CacheType);
+WRITE_REGISTER_BUFFER_USHORT(
+  IN PUSHORT Register,
+  IN PUSHORT Buffer,
+  IN ULONG Count);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-MmProtectMdlSystemAddress(
-  IN PMDL  MemoryDescriptorList,
-  IN ULONG  NewProtect);
+WRITE_REGISTER_UCHAR(
+  IN PUCHAR Register,
+  IN UCHAR Value);
 
 NTKERNELAPI
 VOID
 NTAPI
-MmUnmapReservedMapping(
-  IN PVOID  BaseAddress,
-  IN ULONG  PoolTag,
-  IN PMDL  MemoryDescriptorList);
-
-#endif
+WRITE_REGISTER_ULONG(
+  IN PULONG Register,
+  IN ULONG Value);
 
-#if (NTDDI_VERSION >= NTDDI_WS03SP1)
 NTKERNELAPI
-PMDL
+VOID
 NTAPI
-MmAllocatePagesForMdlEx(
-  IN PHYSICAL_ADDRESS LowAddress,
-  IN PHYSICAL_ADDRESS HighAddress,
-  IN PHYSICAL_ADDRESS SkipBytes,
-  IN SIZE_T TotalBytes,
-  IN MEMORY_CACHING_TYPE CacheType,
-  IN ULONG Flags);
-#endif
+WRITE_REGISTER_USHORT(
+  IN PUSHORT  Register,
+  IN USHORT  Value);
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
+#else
 
-NTKERNELAPI
-LOGICAL
-NTAPI
-MmIsDriverVerifyingByAddress(
-  IN PVOID AddressWithinSection);
-#endif
+FORCEINLINE
+VOID
+READ_PORT_BUFFER_UCHAR(
+  IN PUCHAR Port,
+  IN PUCHAR Buffer,
+  IN ULONG Count)
+{
+    __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
 
-/******************************************************************************
- *                            Security Manager Functions                      *
- ******************************************************************************/
+FORCEINLINE
+VOID
+READ_PORT_BUFFER_ULONG(
+  IN PULONG  Port,
+  IN PULONG  Buffer,
+  IN ULONG  Count)
+{
+    __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+FORCEINLINE
+VOID
+READ_PORT_BUFFER_USHORT(
+  IN PUSHORT Port,
+  IN PUSHORT Buffer,
+  IN ULONG Count)
+{
+    __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-SeAccessCheck(
-  IN PSECURITY_DESCRIPTOR  SecurityDescriptor,
-  IN PSECURITY_SUBJECT_CONTEXT  SubjectSecurityContext,
-  IN BOOLEAN  SubjectContextLocked,
-  IN ACCESS_MASK  DesiredAccess,
-  IN ACCESS_MASK  PreviouslyGrantedAccess,
-  OUT PPRIVILEGE_SET  *Privileges  OPTIONAL,
-  IN PGENERIC_MAPPING  GenericMapping,
-  IN KPROCESSOR_MODE  AccessMode,
-  OUT PACCESS_MASK  GrantedAccess,
-  OUT PNTSTATUS  AccessStatus);
+FORCEINLINE
+UCHAR
+READ_PORT_UCHAR(
+  IN PUCHAR Port)
+{
+    return __inbyte((USHORT)(ULONG_PTR)Port);
+}
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-SeAssignSecurity(
-  IN PSECURITY_DESCRIPTOR  ParentDescriptor  OPTIONAL,
-  IN PSECURITY_DESCRIPTOR  ExplicitDescriptor  OPTIONAL,
-  OUT PSECURITY_DESCRIPTOR  *NewDescriptor,
-  IN BOOLEAN  IsDirectoryObject,
-  IN PSECURITY_SUBJECT_CONTEXT  SubjectContext,
-  IN PGENERIC_MAPPING  GenericMapping,
-  IN POOL_TYPE  PoolType);
+FORCEINLINE
+ULONG
+READ_PORT_ULONG(
+  IN PULONG Port)
+{
+    return __indword((USHORT)(ULONG_PTR)Port);
+}
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-SeAssignSecurityEx(
-  IN PSECURITY_DESCRIPTOR  ParentDescriptor  OPTIONAL,
-  IN PSECURITY_DESCRIPTOR  ExplicitDescriptor  OPTIONAL,
-  OUT PSECURITY_DESCRIPTOR  *NewDescriptor,
-  IN GUID  *ObjectType  OPTIONAL,
-  IN BOOLEAN  IsDirectoryObject,
-  IN ULONG  AutoInheritFlags,
-  IN PSECURITY_SUBJECT_CONTEXT  SubjectContext,
-  IN PGENERIC_MAPPING  GenericMapping,
-  IN POOL_TYPE  PoolType);
+FORCEINLINE
+USHORT
+READ_PORT_USHORT(
+  IN PUSHORT Port)
+{
+    return __inword((USHORT)(ULONG_PTR)Port);
+}
+
+FORCEINLINE
+VOID
+READ_REGISTER_BUFFER_UCHAR(
+  IN PUCHAR Register,
+  IN PUCHAR Buffer,
+  IN ULONG Count)
+{
+    __movsb(Register, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+READ_REGISTER_BUFFER_ULONG(
+  IN PULONG  Register,
+  IN PULONG  Buffer,
+  IN ULONG  Count)
+{
+    __movsd(Register, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+READ_REGISTER_BUFFER_USHORT(
+  IN PUSHORT  Register,
+  IN PUSHORT  Buffer,
+  IN ULONG  Count)
+{
+    __movsw(Register, Buffer, Count);
+}
+
+FORCEINLINE
+UCHAR
+READ_REGISTER_UCHAR(
+  IN volatile UCHAR *Register)
+{
+    return *Register;
+}
+
+FORCEINLINE
+ULONG
+READ_REGISTER_ULONG(
+  IN volatile ULONG *Register)
+{
+    return *Register;
+}
+
+FORCEINLINE
+USHORT
+READ_REGISTER_USHORT(
+  IN volatile USHORT *Register)
+{
+    return *Register;
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_BUFFER_UCHAR(
+  IN PUCHAR Port,
+  IN PUCHAR Buffer,
+  IN ULONG Count)
+{
+    __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_BUFFER_ULONG(
+  IN PULONG Port,
+  IN PULONG Buffer,
+  IN ULONG Count)
+{
+    __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_BUFFER_USHORT(
+  IN PUSHORT Port,
+  IN PUSHORT Buffer,
+  IN ULONG Count)
+{
+    __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_UCHAR(
+  IN PUCHAR Port,
+  IN UCHAR Value)
+{
+    __outbyte((USHORT)(ULONG_PTR)Port, Value);
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_ULONG(
+  IN PULONG Port,
+  IN ULONG Value)
+{
+    __outdword((USHORT)(ULONG_PTR)Port, Value);
+}
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-SeDeassignSecurity(
-  IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor);
+FORCEINLINE
+VOID
+WRITE_PORT_USHORT(
+  IN PUSHORT Port,
+  IN USHORT Value)
+{
+    __outword((USHORT)(ULONG_PTR)Port, Value);
+}
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-SeValidSecurityDescriptor(
-  IN ULONG Length,
-  IN PSECURITY_DESCRIPTOR SecurityDescriptor);
+FORCEINLINE
+VOID
+WRITE_REGISTER_BUFFER_UCHAR(
+  IN PUCHAR Register,
+  IN PUCHAR Buffer,
+  IN ULONG Count)
+{
+    LONG Synch;
+    __movsb(Register, Buffer, Count);
+    InterlockedOr(&Synch, 1);
+}
 
-NTKERNELAPI
-ULONG
-NTAPI
-SeObjectCreateSaclAccessBits(
-  IN PSECURITY_DESCRIPTOR SecurityDescriptor);
+FORCEINLINE
+VOID
+WRITE_REGISTER_BUFFER_ULONG(
+  IN PULONG Register,
+  IN PULONG Buffer,
+  IN ULONG Count)
+{
+    LONG Synch;
+    __movsd(Register, Buffer, Count);
+    InterlockedOr(&Synch, 1);
+}
 
-NTKERNELAPI
+FORCEINLINE
 VOID
-NTAPI
-SeReleaseSubjectContext(
-  IN OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
+WRITE_REGISTER_BUFFER_USHORT(
+  IN PUSHORT Register,
+  IN PUSHORT Buffer,
+  IN ULONG Count)
+{
+    LONG Synch;
+    __movsw(Register, Buffer, Count);
+    InterlockedOr(&Synch, 1);
+}
 
-NTKERNELAPI
+FORCEINLINE
 VOID
-NTAPI
-SeUnlockSubjectContext(
-  IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
+WRITE_REGISTER_UCHAR(
+  IN volatile UCHAR *Register,
+  IN UCHAR Value)
+{
+    LONG Synch;
+    *Register = Value;
+    InterlockedOr(&Synch, 1);
+}
 
-NTKERNELAPI
+FORCEINLINE
 VOID
-NTAPI
-SeCaptureSubjectContext(
-  OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
+WRITE_REGISTER_ULONG(
+  IN volatile ULONG *Register,
+  IN ULONG Value)
+{
+    LONG Synch;
+    *Register = Value;
+    InterlockedOr(&Synch, 1);
+}
 
-NTKERNELAPI
+FORCEINLINE
 VOID
-NTAPI
-SeLockSubjectContext(
-  IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
+WRITE_REGISTER_USHORT(
+  IN volatile USHORT *Register,
+  IN USHORT Value)
+{
+    LONG Sync;
+    *Register = Value;
+    InterlockedOr(&Sync, 1);
+}
+#endif
 
-#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && \
+   (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
 
-#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+#define DMA_MACROS_DEFINED
 
+FORCEINLINE
 NTSTATUS
-NTAPI
-SeSetAuditParameter(
-  IN OUT PSE_ADT_PARAMETER_ARRAY AuditParameters,
-  IN SE_ADT_PARAMETER_TYPE Type,
-  IN ULONG Index,
-  IN PVOID Data);
+IoAllocateAdapterChannel(
+    IN PDMA_ADAPTER DmaAdapter,
+    IN PDEVICE_OBJECT DeviceObject,
+    IN ULONG NumberOfMapRegisters,
+    IN PDRIVER_CONTROL ExecutionRoutine,
+    IN PVOID Context)
+{
+    PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
+    AllocateAdapterChannel =
+        *(DmaAdapter)->DmaOperations->AllocateAdapterChannel;
+    ASSERT(AllocateAdapterChannel);
+    return AllocateAdapterChannel(DmaAdapter,
+                                  DeviceObject,
+                                  NumberOfMapRegisters,
+                                  ExecutionRoutine,
+                                  Context );
+}
 
-NTSTATUS
+FORCEINLINE
+BOOLEAN
 NTAPI
-SeReportSecurityEvent(
-  IN ULONG Flags,
-  IN PUNICODE_STRING SourceName,
-  IN PSID UserSid OPTIONAL,
-  IN PSE_ADT_PARAMETER_ARRAY AuditParameters);
-
-#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
-
-#if (NTDDI_VERSION >= NTDDI_VISTA)
+IoFlushAdapterBuffers(
+    IN PDMA_ADAPTER DmaAdapter,
+    IN PMDL Mdl,
+    IN PVOID MapRegisterBase,
+    IN PVOID CurrentVa,
+    IN ULONG Length,
+    IN BOOLEAN WriteToDevice)
+{
+    PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
+    FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers;
+    ASSERT(FlushAdapterBuffers);
+    return FlushAdapterBuffers(DmaAdapter,
+                               Mdl,
+                               MapRegisterBase,
+                               CurrentVa,
+                               Length,
+                               WriteToDevice);
+}
 
-NTKERNELAPI
-ULONG
+FORCEINLINE
+VOID
 NTAPI
-SeComputeAutoInheritByObjectType(
-  IN PVOID ObjectType,
-  IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
-  IN PSECURITY_DESCRIPTOR ParentSecurityDescriptor OPTIONAL);
+IoFreeAdapterChannel(
+    IN PDMA_ADAPTER DmaAdapter)
+{
+    PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
+    FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel;
+    ASSERT(FreeAdapterChannel);
+    FreeAdapterChannel(DmaAdapter);
+}
 
-#ifdef SE_NTFS_WORLD_CACHE
+FORCEINLINE
 VOID
 NTAPI
-SeGetWorldRights(
-  IN PSECURITY_DESCRIPTOR SecurityDescriptor,
-  IN PGENERIC_MAPPING GenericMapping,
-  OUT PACCESS_MASK GrantedAccess);
-#endif /* SE_NTFS_WORLD_CACHE */
-
-#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
-/******************************************************************************
- *                         Configuration Manager Functions                    *
- ******************************************************************************/
+IoFreeMapRegisters(
+    IN PDMA_ADAPTER DmaAdapter,
+    IN PVOID MapRegisterBase,
+    IN ULONG NumberOfMapRegisters)
+{
+    PFREE_MAP_REGISTERS FreeMapRegisters;
+    FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters;
+    ASSERT(FreeMapRegisters);
+    FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters);
+}
 
-#if (NTDDI_VERSION >= NTDDI_WINXP)
-NTKERNELAPI
-NTSTATUS
+FORCEINLINE
+PHYSICAL_ADDRESS
 NTAPI
-CmRegisterCallback(
-  IN PEX_CALLBACK_FUNCTION  Function,
-  IN PVOID  Context  OPTIONAL,
-  OUT PLARGE_INTEGER  Cookie);
+IoMapTransfer(
+    IN PDMA_ADAPTER DmaAdapter,
+    IN PMDL Mdl,
+    IN PVOID MapRegisterBase,
+    IN PVOID CurrentVa,
+    IN OUT PULONG Length,
+    IN BOOLEAN WriteToDevice)
+{
+    PMAP_TRANSFER MapTransfer;
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-CmUnRegisterCallback(
-  IN LARGE_INTEGER  Cookie);
+    MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer;
+    ASSERT(MapTransfer);
+    return MapTransfer(DmaAdapter,
+                       Mdl,
+                       MapRegisterBase,
+                       CurrentVa,
+                       Length,
+                       WriteToDevice);
+}
 #endif
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
-
-NTKERNELAPI
-NTSTATUS
-NTAPI
-CmRegisterCallbackEx(
-  PEX_CALLBACK_FUNCTION Function,
-  PCUNICODE_STRING Altitude,
-  PVOID Driver,
-  PVOID Context,
-  PLARGE_INTEGER Cookie,
-  PVOID Reserved);
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
 NTKERNELAPI
 VOID
 NTAPI
-CmGetCallbackVersion(
-  OUT PULONG Major OPTIONAL,
-  OUT PULONG Minor OPTIONAL);
+IoAcquireCancelSpinLock(
+  OUT PKIRQL  Irql);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-CmSetCallbackObjectContext(
-  IN OUT PVOID Object,
-  IN PLARGE_INTEGER Cookie,
-  IN PVOID NewContext,
-  OUT PVOID *OldContext OPTIONAL);
-
+IoAcquireRemoveLockEx(
+  IN PIO_REMOVE_LOCK  RemoveLock,
+  IN PVOID  Tag  OPTIONAL,
+  IN PCSTR  File,
+  IN ULONG  Line,
+  IN ULONG  RemlockSize);
 NTKERNELAPI
 NTSTATUS
 NTAPI
-CmCallbackGetKeyObjectID(
-  IN PLARGE_INTEGER Cookie,
-  IN PVOID Object,
-  OUT PULONG_PTR ObjectID OPTIONAL,
-  OUT PCUNICODE_STRING *ObjectName OPTIONAL);
+IoAllocateDriverObjectExtension(
+  IN PDRIVER_OBJECT  DriverObject,
+  IN PVOID  ClientIdentificationAddress,
+  IN ULONG  DriverObjectExtensionSize,
+  OUT PVOID  *DriverObjectExtension);
 
 NTKERNELAPI
 PVOID
 NTAPI
-CmGetBoundTransaction(
-  IN PLARGE_INTEGER Cookie,
-  IN PVOID Object);
-
-#endif // NTDDI_VERSION >= NTDDI_VISTA
-
-
-/******************************************************************************
- *                         I/O Manager Functions                              *
- ******************************************************************************/
+IoAllocateErrorLogEntry(
+  IN PVOID  IoObject,
+  IN UCHAR  EntrySize);
 
-#if !defined(_M_AMD64)
-NTHALAPI
-VOID
+NTKERNELAPI
+PIRP
 NTAPI
-READ_PORT_BUFFER_UCHAR(
-  IN PUCHAR Port,
-  IN PUCHAR Buffer,
-  IN ULONG Count);
+IoAllocateIrp(
+  IN CCHAR  StackSize,
+  IN BOOLEAN  ChargeQuota);
 
-NTHALAPI
-VOID
+NTKERNELAPI
+PMDL
 NTAPI
-READ_PORT_BUFFER_ULONG(
-  IN PULONG Port,
-  IN PULONG Buffer,
-  IN ULONG Count);
+IoAllocateMdl(
+  IN PVOID  VirtualAddress OPTIONAL,
+  IN ULONG  Length,
+  IN BOOLEAN  SecondaryBuffer,
+  IN BOOLEAN  ChargeQuota,
+  IN OUT PIRP  Irp  OPTIONAL);
 
-NTHALAPI
-VOID
+NTKERNELAPI
+PIO_WORKITEM
 NTAPI
-READ_PORT_BUFFER_USHORT(
-  IN PUSHORT Port,
-  IN PUSHORT Buffer,
-  IN ULONG Count);
+IoAllocateWorkItem(
+  IN PDEVICE_OBJECT  DeviceObject);
 
-NTHALAPI
-UCHAR
+NTKERNELAPI
+NTSTATUS
 NTAPI
-READ_PORT_UCHAR(
-  IN PUCHAR Port);
+IoAttachDevice(
+  IN PDEVICE_OBJECT  SourceDevice,
+  IN PUNICODE_STRING  TargetDevice,
+  OUT PDEVICE_OBJECT  *AttachedDevice);
 
-NTHALAPI
-ULONG
+NTKERNELAPI
+PDEVICE_OBJECT
 NTAPI
-READ_PORT_ULONG(
-  IN PULONG Port);
+IoAttachDeviceToDeviceStack(
+  IN PDEVICE_OBJECT  SourceDevice,
+  IN PDEVICE_OBJECT  TargetDevice);
 
-NTHALAPI
-USHORT
+NTKERNELAPI
+PIRP
 NTAPI
-READ_PORT_USHORT(
-  IN PUSHORT Port);
+IoBuildAsynchronousFsdRequest(
+  IN ULONG  MajorFunction,
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN OUT PVOID  Buffer  OPTIONAL,
+  IN ULONG  Length  OPTIONAL,
+  IN PLARGE_INTEGER  StartingOffset  OPTIONAL,
+  IN PIO_STATUS_BLOCK  IoStatusBlock  OPTIONAL);
 
 NTKERNELAPI
-VOID
+PIRP
 NTAPI
-READ_REGISTER_BUFFER_UCHAR(
-  IN PUCHAR Register,
-  IN PUCHAR Buffer,
-  IN ULONG Count);
+IoBuildDeviceIoControlRequest(
+  IN ULONG  IoControlCode,
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN PVOID  InputBuffer  OPTIONAL,
+  IN ULONG  InputBufferLength,
+  OUT PVOID  OutputBuffer  OPTIONAL,
+  IN ULONG  OutputBufferLength,
+  IN BOOLEAN  InternalDeviceIoControl,
+  IN PKEVENT  Event,
+  OUT PIO_STATUS_BLOCK  IoStatusBlock);
 
 NTKERNELAPI
 VOID
 NTAPI
-READ_REGISTER_BUFFER_ULONG(
-  IN PULONG Register,
-  IN PULONG Buffer,
-  IN ULONG Count);
+IoBuildPartialMdl(
+  IN PMDL  SourceMdl,
+  IN OUT PMDL  TargetMdl,
+  IN PVOID  VirtualAddress,
+  IN ULONG  Length);
 
 NTKERNELAPI
-VOID
+PIRP
 NTAPI
-READ_REGISTER_BUFFER_USHORT(
-  IN PUSHORT Register,
-  IN PUSHORT Buffer,
-  IN ULONG Count);
+IoBuildSynchronousFsdRequest(
+  IN ULONG  MajorFunction,
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN OUT PVOID  Buffer  OPTIONAL,
+  IN ULONG  Length  OPTIONAL,
+  IN PLARGE_INTEGER  StartingOffset  OPTIONAL,
+  IN PKEVENT  Event,
+  OUT PIO_STATUS_BLOCK  IoStatusBlock);
 
 NTKERNELAPI
-UCHAR
-NTAPI
-READ_REGISTER_UCHAR(
-  IN PUCHAR Register);
+NTSTATUS
+FASTCALL
+IofCallDriver(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN OUT PIRP  Irp);
+#define IoCallDriver IofCallDriver
 
 NTKERNELAPI
-ULONG
-NTAPI
-READ_REGISTER_ULONG(
-  IN PULONG Register);
+VOID
+FASTCALL
+IofCompleteRequest(
+  IN PIRP Irp,
+  IN CCHAR PriorityBoost);
+#define IoCompleteRequest IofCompleteRequest
 
 NTKERNELAPI
-USHORT
+BOOLEAN
 NTAPI
-READ_REGISTER_USHORT(
-  IN PUSHORT Register);
+IoCancelIrp(
+  IN PIRP  Irp);
 
-NTHALAPI
-VOID
+NTKERNELAPI
+NTSTATUS
 NTAPI
-WRITE_PORT_BUFFER_UCHAR(
-  IN PUCHAR Port,
-  IN PUCHAR Buffer,
-  IN ULONG Count);
+IoCheckShareAccess(
+  IN ACCESS_MASK  DesiredAccess,
+  IN ULONG  DesiredShareAccess,
+  IN OUT PFILE_OBJECT  FileObject,
+  IN OUT PSHARE_ACCESS  ShareAccess,
+  IN BOOLEAN  Update);
 
-NTHALAPI
+NTKERNELAPI
 VOID
+FASTCALL
+IofCompleteRequest(
+  IN PIRP  Irp,
+  IN CCHAR  PriorityBoost);
+
+NTKERNELAPI
+NTSTATUS
 NTAPI
-WRITE_PORT_BUFFER_ULONG(
-  IN PULONG Port,
-  IN PULONG Buffer,
-  IN ULONG Count);
+IoConnectInterrupt(
+  OUT PKINTERRUPT  *InterruptObject,
+  IN PKSERVICE_ROUTINE  ServiceRoutine,
+  IN PVOID  ServiceContext OPTIONAL,
+  IN PKSPIN_LOCK  SpinLock  OPTIONAL,
+  IN ULONG  Vector,
+  IN KIRQL  Irql,
+  IN KIRQL  SynchronizeIrql,
+  IN KINTERRUPT_MODE    InterruptMode,
+  IN BOOLEAN  ShareVector,
+  IN KAFFINITY  ProcessorEnableMask,
+  IN BOOLEAN  FloatingSave);
 
-NTHALAPI
-VOID
+NTKERNELAPI
+NTSTATUS
 NTAPI
-WRITE_PORT_BUFFER_USHORT(
-  IN PUSHORT Port,
-  IN PUSHORT Buffer,
-  IN ULONG Count);
+IoCreateDevice(
+  IN PDRIVER_OBJECT  DriverObject,
+  IN ULONG  DeviceExtensionSize,
+  IN PUNICODE_STRING  DeviceName  OPTIONAL,
+  IN DEVICE_TYPE  DeviceType,
+  IN ULONG  DeviceCharacteristics,
+  IN BOOLEAN  Exclusive,
+  OUT PDEVICE_OBJECT  *DeviceObject);
 
-NTHALAPI
-VOID
+NTKERNELAPI
+NTSTATUS
 NTAPI
-WRITE_PORT_UCHAR(
-  IN PUCHAR Port,
-  IN UCHAR Value);
+IoCreateFile(
+  OUT PHANDLE FileHandle,
+  IN ACCESS_MASK DesiredAccess,
+  IN POBJECT_ATTRIBUTES ObjectAttributes,
+  OUT PIO_STATUS_BLOCK IoStatusBlock,
+  IN PLARGE_INTEGER AllocationSize OPTIONAL,
+  IN ULONG FileAttributes,
+  IN ULONG ShareAccess,
+  IN ULONG Disposition,
+  IN ULONG CreateOptions,
+  IN PVOID EaBuffer OPTIONAL,
+  IN ULONG EaLength,
+  IN CREATE_FILE_TYPE CreateFileType,
+  IN PVOID InternalParameters OPTIONAL,
+  IN ULONG Options);
 
-NTHALAPI
-VOID
+NTKERNELAPI
+PKEVENT
 NTAPI
-WRITE_PORT_ULONG(
-  IN PULONG Port,
-  IN ULONG Value);
+IoCreateNotificationEvent(
+  IN PUNICODE_STRING  EventName,
+  OUT PHANDLE  EventHandle);
 
-NTHALAPI
-VOID
+NTKERNELAPI
+NTSTATUS
 NTAPI
-WRITE_PORT_USHORT(
-  IN PUSHORT Port,
-  IN USHORT Value);
+IoCreateSymbolicLink(
+  IN PUNICODE_STRING  SymbolicLinkName,
+  IN PUNICODE_STRING  DeviceName);
 
 NTKERNELAPI
-VOID
+PKEVENT
 NTAPI
-WRITE_REGISTER_BUFFER_UCHAR(
-  IN PUCHAR Register,
-  IN PUCHAR Buffer,
-  IN ULONG Count);
+IoCreateSynchronizationEvent(
+  IN PUNICODE_STRING  EventName,
+  OUT PHANDLE  EventHandle);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-WRITE_REGISTER_BUFFER_ULONG(
-  IN PULONG  Register,
-  IN PULONG  Buffer,
-  IN ULONG  Count);
+IoCreateUnprotectedSymbolicLink(
+  IN PUNICODE_STRING  SymbolicLinkName,
+  IN PUNICODE_STRING  DeviceName);
 
 NTKERNELAPI
 VOID
 NTAPI
-WRITE_REGISTER_BUFFER_USHORT(
-  IN PUSHORT Register,
-  IN PUSHORT Buffer,
-  IN ULONG Count);
+IoDeleteDevice(
+  IN PDEVICE_OBJECT  DeviceObject);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-WRITE_REGISTER_UCHAR(
-  IN PUCHAR Register,
-  IN UCHAR Value);
+IoDeleteSymbolicLink(
+  IN PUNICODE_STRING  SymbolicLinkName);
 
 NTKERNELAPI
 VOID
 NTAPI
-WRITE_REGISTER_ULONG(
-  IN PULONG Register,
-  IN ULONG Value);
+IoDetachDevice(
+  IN OUT PDEVICE_OBJECT  TargetDevice);
 
 NTKERNELAPI
 VOID
 NTAPI
-WRITE_REGISTER_USHORT(
-  IN PUSHORT  Register,
-  IN USHORT  Value);
-
-#else
+IoDisconnectInterrupt(
+  IN PKINTERRUPT  InterruptObject);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-READ_PORT_BUFFER_UCHAR(
-  IN PUCHAR Port,
-  IN PUCHAR Buffer,
-  IN ULONG Count)
-{
-    __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
-}
+NTAPI
+IoFreeIrp(
+  IN PIRP Irp);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-READ_PORT_BUFFER_ULONG(
-  IN PULONG  Port,
-  IN PULONG  Buffer,
-  IN ULONG  Count)
-{
-    __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
-}
+NTAPI
+IoFreeMdl(
+  IN PMDL Mdl);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-READ_PORT_BUFFER_USHORT(
-  IN PUSHORT Port,
-  IN PUSHORT Buffer,
-  IN ULONG Count)
-{
-    __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
-}
-
-FORCEINLINE
-UCHAR
-READ_PORT_UCHAR(
-  IN PUCHAR Port)
-{
-    return __inbyte((USHORT)(ULONG_PTR)Port);
-}
+NTAPI
+IoFreeWorkItem(
+  IN PIO_WORKITEM IoWorkItem);
 
-FORCEINLINE
-ULONG
-READ_PORT_ULONG(
-  IN PULONG Port)
-{
-    return __indword((USHORT)(ULONG_PTR)Port);
-}
+NTKERNELAPI
+PDEVICE_OBJECT
+NTAPI
+IoGetAttachedDevice(
+  IN PDEVICE_OBJECT DeviceObject);
 
-FORCEINLINE
-USHORT
-READ_PORT_USHORT(
-  IN PUSHORT Port)
-{
-    return __inword((USHORT)(ULONG_PTR)Port);
-}
+NTKERNELAPI
+PDEVICE_OBJECT
+NTAPI
+IoGetAttachedDeviceReference(
+  IN PDEVICE_OBJECT  DeviceObject);
 
-FORCEINLINE
-VOID
-READ_REGISTER_BUFFER_UCHAR(
-  IN PUCHAR Register,
-  IN PUCHAR Buffer,
-  IN ULONG Count)
-{
-    __movsb(Register, Buffer, Count);
-}
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoGetBootDiskInformation(
+  IN OUT PBOOTDISK_INFORMATION  BootDiskInformation,
+  IN ULONG  Size);
 
-FORCEINLINE
-VOID
-READ_REGISTER_BUFFER_ULONG(
-  IN PULONG  Register,
-  IN PULONG  Buffer,
-  IN ULONG  Count)
-{
-    __movsd(Register, Buffer, Count);
-}
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoGetDeviceInterfaceAlias(
+  IN PUNICODE_STRING  SymbolicLinkName,
+  IN CONST GUID  *AliasInterfaceClassGuid,
+  OUT PUNICODE_STRING  AliasSymbolicLinkName);
 
-FORCEINLINE
-VOID
-READ_REGISTER_BUFFER_USHORT(
-  IN PUSHORT  Register,
-  IN PUSHORT  Buffer,
-  IN ULONG  Count)
-{
-    __movsw(Register, Buffer, Count);
-}
+NTKERNELAPI
+PEPROCESS
+NTAPI
+IoGetCurrentProcess(VOID);
 
-FORCEINLINE
-UCHAR
-READ_REGISTER_UCHAR(
-  IN volatile UCHAR *Register)
-{
-    return *Register;
-}
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoGetDeviceInterfaces(
+  IN CONST GUID  *InterfaceClassGuid,
+  IN PDEVICE_OBJECT  PhysicalDeviceObject  OPTIONAL,
+  IN ULONG  Flags,
+  OUT PWSTR  *SymbolicLinkList);
 
-FORCEINLINE
-ULONG
-READ_REGISTER_ULONG(
-  IN volatile ULONG *Register)
-{
-    return *Register;
-}
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoGetDeviceObjectPointer(
+  IN PUNICODE_STRING  ObjectName,
+  IN ACCESS_MASK  DesiredAccess,
+  OUT PFILE_OBJECT  *FileObject,
+  OUT PDEVICE_OBJECT  *DeviceObject);
 
-FORCEINLINE
-USHORT
-READ_REGISTER_USHORT(
-  IN volatile USHORT *Register)
-{
-    return *Register;
-}
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoGetDeviceProperty(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN DEVICE_REGISTRY_PROPERTY  DeviceProperty,
+  IN ULONG  BufferLength,
+  OUT PVOID  PropertyBuffer,
+  OUT PULONG  ResultLength);
 
-FORCEINLINE
-VOID
-WRITE_PORT_BUFFER_UCHAR(
-  IN PUCHAR Port,
-  IN PUCHAR Buffer,
-  IN ULONG Count)
-{
-    __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
-}
+NTKERNELAPI
+PDMA_ADAPTER
+NTAPI
+IoGetDmaAdapter(
+  IN PDEVICE_OBJECT  PhysicalDeviceObject OPTIONAL,
+  IN PDEVICE_DESCRIPTION  DeviceDescription,
+  IN OUT PULONG  NumberOfMapRegisters);
 
-FORCEINLINE
-VOID
-WRITE_PORT_BUFFER_ULONG(
-  IN PULONG Port,
-  IN PULONG Buffer,
-  IN ULONG Count)
-{
-    __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
-}
+NTKERNELAPI
+PVOID
+NTAPI
+IoGetDriverObjectExtension(
+  IN PDRIVER_OBJECT  DriverObject,
+  IN PVOID  ClientIdentificationAddress);
 
-FORCEINLINE
-VOID
-WRITE_PORT_BUFFER_USHORT(
-  IN PUSHORT Port,
-  IN PUSHORT Buffer,
-  IN ULONG Count)
-{
-    __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
-}
+NTKERNELAPI
+PVOID
+NTAPI
+IoGetInitialStack(VOID);
 
-FORCEINLINE
-VOID
-WRITE_PORT_UCHAR(
-  IN PUCHAR Port,
-  IN UCHAR Value)
-{
-    __outbyte((USHORT)(ULONG_PTR)Port, Value);
-}
+NTKERNELAPI
+PDEVICE_OBJECT
+NTAPI
+IoGetRelatedDeviceObject(
+  IN PFILE_OBJECT  FileObject);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-WRITE_PORT_ULONG(
-  IN PULONG Port,
-  IN ULONG Value)
-{
-    __outdword((USHORT)(ULONG_PTR)Port, Value);
-}
+NTAPI
+IoQueueWorkItem(
+  IN PIO_WORKITEM  IoWorkItem,
+  IN PIO_WORKITEM_ROUTINE  WorkerRoutine,
+  IN WORK_QUEUE_TYPE  QueueType,
+  IN PVOID  Context OPTIONAL);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-WRITE_PORT_USHORT(
-  IN PUSHORT Port,
-  IN USHORT Value)
-{
-    __outword((USHORT)(ULONG_PTR)Port, Value);
-}
+NTAPI
+IoInitializeIrp(
+  IN OUT PIRP  Irp,
+  IN USHORT  PacketSize,
+  IN CCHAR  StackSize);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-WRITE_REGISTER_BUFFER_UCHAR(
-  IN PUCHAR Register,
-  IN PUCHAR Buffer,
-  IN ULONG Count)
-{
-    LONG Synch;
-    __movsb(Register, Buffer, Count);
-    InterlockedOr(&Synch, 1);
-}
+NTAPI
+IoInitializeRemoveLockEx(
+  IN  PIO_REMOVE_LOCK Lock,
+  IN  ULONG   AllocateTag,
+  IN  ULONG   MaxLockedMinutes,
+  IN  ULONG   HighWatermark,
+  IN  ULONG   RemlockSize);
 
-FORCEINLINE
-VOID
-WRITE_REGISTER_BUFFER_ULONG(
-  IN PULONG Register,
-  IN PULONG Buffer,
-  IN ULONG Count)
-{
-    LONG Synch;
-    __movsd(Register, Buffer, Count);
-    InterlockedOr(&Synch, 1);
-}
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoInitializeTimer(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN PIO_TIMER_ROUTINE  TimerRoutine,
+  IN PVOID  Context OPTIONAL);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-WRITE_REGISTER_BUFFER_USHORT(
-  IN PUSHORT Register,
-  IN PUSHORT Buffer,
-  IN ULONG Count)
-{
-    LONG Synch;
-    __movsw(Register, Buffer, Count);
-    InterlockedOr(&Synch, 1);
-}
+NTAPI
+IoInvalidateDeviceRelations(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN DEVICE_RELATION_TYPE  Type);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-WRITE_REGISTER_UCHAR(
-  IN volatile UCHAR *Register,
-  IN UCHAR Value)
-{
-    LONG Synch;
-    *Register = Value;
-    InterlockedOr(&Synch, 1);
-}
+NTAPI
+IoInvalidateDeviceState(
+  IN PDEVICE_OBJECT  PhysicalDeviceObject);
 
-FORCEINLINE
-VOID
-WRITE_REGISTER_ULONG(
-  IN volatile ULONG *Register,
-  IN ULONG Value)
-{
-    LONG Synch;
-    *Register = Value;
-    InterlockedOr(&Synch, 1);
-}
+NTKERNELAPI
+BOOLEAN
+NTAPI
+IoIsWdmVersionAvailable(
+  IN UCHAR  MajorVersion,
+  IN UCHAR  MinorVersion);
 
-FORCEINLINE
-VOID
-WRITE_REGISTER_USHORT(
-  IN volatile USHORT *Register,
-  IN USHORT Value)
-{
-    LONG Sync;
-    *Register = Value;
-    InterlockedOr(&Sync, 1);
-}
-#endif
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoOpenDeviceInterfaceRegistryKey(
+  IN PUNICODE_STRING  SymbolicLinkName,
+  IN ACCESS_MASK  DesiredAccess,
+  OUT PHANDLE  DeviceInterfaceKey);
 
-#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && \
-   (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoOpenDeviceRegistryKey(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN ULONG  DevInstKeyType,
+  IN ACCESS_MASK  DesiredAccess,
+  OUT PHANDLE  DevInstRegKey);
 
-#define DMA_MACROS_DEFINED
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoRegisterDeviceInterface(
+  IN PDEVICE_OBJECT  PhysicalDeviceObject,
+  IN CONST GUID  *InterfaceClassGuid,
+  IN PUNICODE_STRING  ReferenceString  OPTIONAL,
+  OUT PUNICODE_STRING  SymbolicLinkName);
 
-FORCEINLINE
+NTKERNELAPI
 NTSTATUS
-IoAllocateAdapterChannel(
-    IN PDMA_ADAPTER DmaAdapter,
-    IN PDEVICE_OBJECT DeviceObject,
-    IN ULONG NumberOfMapRegisters,
-    IN PDRIVER_CONTROL ExecutionRoutine,
-    IN PVOID Context)
-{
-    PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
-    AllocateAdapterChannel =
-        *(DmaAdapter)->DmaOperations->AllocateAdapterChannel;
-    ASSERT(AllocateAdapterChannel);
-    return AllocateAdapterChannel(DmaAdapter,
-                                  DeviceObject,
-                                  NumberOfMapRegisters,
-                                  ExecutionRoutine,
-                                  Context );
-}
+NTAPI
+IoRegisterPlugPlayNotification(
+  IN IO_NOTIFICATION_EVENT_CATEGORY  EventCategory,
+  IN ULONG  EventCategoryFlags,
+  IN PVOID  EventCategoryData  OPTIONAL,
+  IN PDRIVER_OBJECT  DriverObject,
+  IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE  CallbackRoutine,
+  IN OUT PVOID  Context OPTIONAL,
+  OUT PVOID  *NotificationEntry);
 
-FORCEINLINE
-BOOLEAN
+NTKERNELAPI
+NTSTATUS
 NTAPI
-IoFlushAdapterBuffers(
-    IN PDMA_ADAPTER DmaAdapter,
-    IN PMDL Mdl,
-    IN PVOID MapRegisterBase,
-    IN PVOID CurrentVa,
-    IN ULONG Length,
-    IN BOOLEAN WriteToDevice)
-{
-    PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
-    FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers;
-    ASSERT(FlushAdapterBuffers);
-    return FlushAdapterBuffers(DmaAdapter,
-                               Mdl,
-                               MapRegisterBase,
-                               CurrentVa,
-                               Length,
-                               WriteToDevice);
-}
+IoRegisterShutdownNotification(
+  IN PDEVICE_OBJECT  DeviceObject);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
 NTAPI
-IoFreeAdapterChannel(
-    IN PDMA_ADAPTER DmaAdapter)
-{
-    PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
-    FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel;
-    ASSERT(FreeAdapterChannel);
-    FreeAdapterChannel(DmaAdapter);
-}
+IoReleaseCancelSpinLock(
+  IN KIRQL  Irql);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
 NTAPI
-IoFreeMapRegisters(
-    IN PDMA_ADAPTER DmaAdapter,
-    IN PVOID MapRegisterBase,
-    IN ULONG NumberOfMapRegisters)
-{
-    PFREE_MAP_REGISTERS FreeMapRegisters;
-    FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters;
-    ASSERT(FreeMapRegisters);
-    FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters);
-}
+IoReleaseRemoveLockAndWaitEx(
+  IN PIO_REMOVE_LOCK  RemoveLock,
+  IN PVOID  Tag OPTIONAL,
+  IN ULONG  RemlockSize);
 
-FORCEINLINE
-PHYSICAL_ADDRESS
+NTKERNELAPI
+VOID
 NTAPI
-IoMapTransfer(
-    IN PDMA_ADAPTER DmaAdapter,
-    IN PMDL Mdl,
-    IN PVOID MapRegisterBase,
-    IN PVOID CurrentVa,
-    IN OUT PULONG Length,
-    IN BOOLEAN WriteToDevice)
-{
-    PMAP_TRANSFER MapTransfer;
-
-    MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer;
-    ASSERT(MapTransfer);
-    return MapTransfer(DmaAdapter,
-                       Mdl,
-                       MapRegisterBase,
-                       CurrentVa,
-                       Length,
-                       WriteToDevice);
-}
-#endif
-
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+IoReleaseRemoveLockEx(
+  IN PIO_REMOVE_LOCK  RemoveLock,
+  IN PVOID  Tag OPTIONAL,
+  IN ULONG  RemlockSize);
 
 NTKERNELAPI
 VOID
 NTAPI
-IoAcquireCancelSpinLock(
-  OUT PKIRQL  Irql);
+IoRemoveShareAccess(
+  IN PFILE_OBJECT  FileObject,
+  IN OUT PSHARE_ACCESS  ShareAccess);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoAcquireRemoveLockEx(
-  IN PIO_REMOVE_LOCK  RemoveLock,
-  IN PVOID  Tag  OPTIONAL,
-  IN PCSTR  File,
-  IN ULONG  Line,
-  IN ULONG  RemlockSize);
-#endif
+IoReportTargetDeviceChange(
+  IN PDEVICE_OBJECT  PhysicalDeviceObject,
+  IN PVOID  NotificationStructure);
 
-/*
- * NTSTATUS
- * IoAcquireRemoveLock(
- *   IN PIO_REMOVE_LOCK  RemoveLock,
- *   IN OPTIONAL PVOID  Tag)
- */
-#if DBG
-#define IoAcquireRemoveLock(RemoveLock, Tag) \
-  IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK))
-#else
-#define IoAcquireRemoveLock(RemoveLock, Tag) \
-  IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK))
-#endif
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoReportTargetDeviceChangeAsynchronous(
+  IN PDEVICE_OBJECT  PhysicalDeviceObject,
+  IN PVOID  NotificationStructure,
+  IN PDEVICE_CHANGE_COMPLETE_CALLBACK  Callback  OPTIONAL,
+  IN PVOID  Context  OPTIONAL);
 
-/*
- * VOID
- * IoAdjustPagingPathCount(
- *   IN PLONG  Count,
- *   IN BOOLEAN  Increment)
- */
-#define IoAdjustPagingPathCount(_Count, \
-                                _Increment) \
-{ \
-  if (_Increment) \
-    { \
-      InterlockedIncrement(_Count); \
-    } \
-  else \
-    { \
-      InterlockedDecrement(_Count); \
-    } \
-}
+NTKERNELAPI
+VOID
+NTAPI
+IoRequestDeviceEject(
+  IN PDEVICE_OBJECT  PhysicalDeviceObject);
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+NTKERNELAPI
+VOID
+NTAPI
+IoReuseIrp(
+  IN OUT PIRP  Irp,
+  IN NTSTATUS  Status);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoAllocateDriverObjectExtension(
-  IN PDRIVER_OBJECT  DriverObject,
-  IN PVOID  ClientIdentificationAddress,
-  IN ULONG  DriverObjectExtensionSize,
-  OUT PVOID  *DriverObjectExtension);
+IoSetDeviceInterfaceState(
+  IN PUNICODE_STRING  SymbolicLinkName,
+  IN BOOLEAN  Enable);
 
 NTKERNELAPI
-PVOID
+VOID
 NTAPI
-IoAllocateErrorLogEntry(
-  IN PVOID  IoObject,
-  IN UCHAR  EntrySize);
+IoSetShareAccess(
+  IN ACCESS_MASK  DesiredAccess,
+  IN ULONG  DesiredShareAccess,
+  IN OUT PFILE_OBJECT  FileObject,
+  OUT PSHARE_ACCESS  ShareAccess);
 
 NTKERNELAPI
-PIRP
+VOID
 NTAPI
-IoAllocateIrp(
-  IN CCHAR  StackSize,
-  IN BOOLEAN  ChargeQuota);
+IoStartNextPacket(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN BOOLEAN  Cancelable);
 
 NTKERNELAPI
-PMDL
+VOID
 NTAPI
-IoAllocateMdl(
-  IN PVOID  VirtualAddress OPTIONAL,
-  IN ULONG  Length,
-  IN BOOLEAN  SecondaryBuffer,
-  IN BOOLEAN  ChargeQuota,
-  IN OUT PIRP  Irp  OPTIONAL);
+IoStartNextPacketByKey(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN BOOLEAN  Cancelable,
+  IN ULONG  Key);
 
 NTKERNELAPI
-PIO_WORKITEM
+VOID
 NTAPI
-IoAllocateWorkItem(
-  IN PDEVICE_OBJECT  DeviceObject);
+IoStartPacket(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN PIRP  Irp,
+  IN PULONG  Key  OPTIONAL,
+  IN PDRIVER_CANCEL  CancelFunction  OPTIONAL);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-IoAttachDevice(
-  IN PDEVICE_OBJECT  SourceDevice,
-  IN PUNICODE_STRING  TargetDevice,
-  OUT PDEVICE_OBJECT  *AttachedDevice);
+IoStartTimer(
+  IN PDEVICE_OBJECT  DeviceObject);
 
 NTKERNELAPI
-PDEVICE_OBJECT
+VOID
 NTAPI
-IoAttachDeviceToDeviceStack(
-  IN PDEVICE_OBJECT  SourceDevice,
-  IN PDEVICE_OBJECT  TargetDevice);
+IoStopTimer(
+  IN PDEVICE_OBJECT  DeviceObject);
 
 NTKERNELAPI
-PIRP
+NTSTATUS
 NTAPI
-IoBuildAsynchronousFsdRequest(
-  IN ULONG  MajorFunction,
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN OUT PVOID  Buffer  OPTIONAL,
-  IN ULONG  Length  OPTIONAL,
-  IN PLARGE_INTEGER  StartingOffset  OPTIONAL,
-  IN PIO_STATUS_BLOCK  IoStatusBlock  OPTIONAL);
+IoUnregisterPlugPlayNotification(
+  IN PVOID  NotificationEntry);
 
 NTKERNELAPI
-PIRP
+VOID
 NTAPI
-IoBuildDeviceIoControlRequest(
-  IN ULONG  IoControlCode,
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN PVOID  InputBuffer  OPTIONAL,
-  IN ULONG  InputBufferLength,
-  OUT PVOID  OutputBuffer  OPTIONAL,
-  IN ULONG  OutputBufferLength,
-  IN BOOLEAN  InternalDeviceIoControl,
-  IN PKEVENT  Event,
-  OUT PIO_STATUS_BLOCK  IoStatusBlock);
+IoUnregisterShutdownNotification(
+  IN PDEVICE_OBJECT  DeviceObject);
 
 NTKERNELAPI
 VOID
 NTAPI
-IoBuildPartialMdl(
-  IN PMDL  SourceMdl,
-  IN OUT PMDL  TargetMdl,
-  IN PVOID  VirtualAddress,
-  IN ULONG  Length);
+IoUpdateShareAccess(
+  IN PFILE_OBJECT  FileObject,
+  IN OUT PSHARE_ACCESS  ShareAccess);
 
 NTKERNELAPI
-PIRP
+NTSTATUS
 NTAPI
-IoBuildSynchronousFsdRequest(
-  IN ULONG  MajorFunction,
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN OUT PVOID  Buffer  OPTIONAL,
-  IN ULONG  Length  OPTIONAL,
-  IN PLARGE_INTEGER  StartingOffset  OPTIONAL,
-  IN PKEVENT  Event,
-  OUT PIO_STATUS_BLOCK  IoStatusBlock);
+IoWMIAllocateInstanceIds(
+  IN GUID  *Guid,
+  IN ULONG  InstanceCount,
+  OUT ULONG  *FirstInstanceId);
 
 NTKERNELAPI
 NTSTATUS
-FASTCALL
-IofCallDriver(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN OUT PIRP  Irp);
-#define IoCallDriver IofCallDriver
+NTAPI
+IoWMIQuerySingleInstanceMultiple(
+  IN PVOID  *DataBlockObjectList,
+  IN PUNICODE_STRING  InstanceNames,
+  IN ULONG  ObjectCount,
+  IN OUT ULONG  *InOutBufferSize,
+  OUT PVOID  OutBuffer);
 
 NTKERNELAPI
-VOID
-FASTCALL
-IofCompleteRequest(
-  IN PIRP Irp,
-  IN CCHAR PriorityBoost);
-#define IoCompleteRequest IofCompleteRequest
+NTSTATUS
+NTAPI
+IoWMIRegistrationControl(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN ULONG  Action);
 
 NTKERNELAPI
-BOOLEAN
+NTSTATUS
 NTAPI
-IoCancelIrp(
-  IN PIRP  Irp);
+IoWMISuggestInstanceName(
+  IN PDEVICE_OBJECT  PhysicalDeviceObject OPTIONAL,
+  IN PUNICODE_STRING  SymbolicLinkName OPTIONAL,
+  IN BOOLEAN  CombineNames,
+  OUT PUNICODE_STRING  SuggestedInstanceName);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoCheckShareAccess(
-  IN ACCESS_MASK  DesiredAccess,
-  IN ULONG  DesiredShareAccess,
-  IN OUT PFILE_OBJECT  FileObject,
-  IN OUT PSHARE_ACCESS  ShareAccess,
-  IN BOOLEAN  Update);
+IoWMIWriteEvent(
+  IN OUT PVOID WnodeEventItem);
 
 NTKERNELAPI
 VOID
-FASTCALL
-IofCompleteRequest(
-  IN PIRP  Irp,
-  IN CCHAR  PriorityBoost);
+NTAPI
+IoWriteErrorLogEntry(
+  IN PVOID  ElEntry);
 
 NTKERNELAPI
-NTSTATUS
+PIRP
 NTAPI
-IoConnectInterrupt(
-  OUT PKINTERRUPT  *InterruptObject,
-  IN PKSERVICE_ROUTINE  ServiceRoutine,
-  IN PVOID  ServiceContext OPTIONAL,
-  IN PKSPIN_LOCK  SpinLock  OPTIONAL,
-  IN ULONG  Vector,
-  IN KIRQL  Irql,
-  IN KIRQL  SynchronizeIrql,
-  IN KINTERRUPT_MODE    InterruptMode,
-  IN BOOLEAN  ShareVector,
-  IN KAFFINITY  ProcessorEnableMask,
-  IN BOOLEAN  FloatingSave);
+IoGetTopLevelIrp(VOID);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoCreateDevice(
-  IN PDRIVER_OBJECT  DriverObject,
-  IN ULONG  DeviceExtensionSize,
-  IN PUNICODE_STRING  DeviceName  OPTIONAL,
-  IN DEVICE_TYPE  DeviceType,
-  IN ULONG  DeviceCharacteristics,
-  IN BOOLEAN  Exclusive,
-  OUT PDEVICE_OBJECT  *DeviceObject);
+IoRegisterLastChanceShutdownNotification(
+  IN PDEVICE_OBJECT DeviceObject);
+
+NTKERNELAPI
+VOID
+NTAPI
+IoSetTopLevelIrp(
+  IN PIRP Irp OPTIONAL);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+
+
+#if (NTDDI_VERSION >= NTDDI_WINXP)
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoCreateFile(
-  OUT PHANDLE FileHandle,
-  IN ACCESS_MASK DesiredAccess,
-  IN POBJECT_ATTRIBUTES ObjectAttributes,
-  OUT PIO_STATUS_BLOCK IoStatusBlock,
-  IN PLARGE_INTEGER AllocationSize OPTIONAL,
-  IN ULONG FileAttributes,
-  IN ULONG ShareAccess,
-  IN ULONG Disposition,
-  IN ULONG CreateOptions,
-  IN PVOID EaBuffer OPTIONAL,
-  IN ULONG EaLength,
-  IN CREATE_FILE_TYPE CreateFileType,
-  IN PVOID InternalParameters OPTIONAL,
-  IN ULONG Options);
+IoCsqInitialize(
+  IN PIO_CSQ Csq,
+  IN PIO_CSQ_INSERT_IRP CsqInsertIrp,
+  IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
+  IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
+  IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
+  IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
+  IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
 
 NTKERNELAPI
-PKEVENT
+VOID
 NTAPI
-IoCreateNotificationEvent(
-  IN PUNICODE_STRING  EventName,
-  OUT PHANDLE  EventHandle);
+IoCsqInsertIrp(
+  IN PIO_CSQ Csq,
+  IN PIRP Irp,
+  IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL);
 
 NTKERNELAPI
-NTSTATUS
+PIRP
 NTAPI
-IoCreateSymbolicLink(
-  IN PUNICODE_STRING  SymbolicLinkName,
-  IN PUNICODE_STRING  DeviceName);
+IoCsqRemoveIrp(
+  IN PIO_CSQ Csq,
+  IN PIO_CSQ_IRP_CONTEXT Context);
 
 NTKERNELAPI
-PKEVENT
+PIRP
 NTAPI
-IoCreateSynchronizationEvent(
-  IN PUNICODE_STRING  EventName,
-  OUT PHANDLE  EventHandle);
+IoCsqRemoveNextIrp(
+  IN PIO_CSQ  Csq,
+  IN PVOID PeekContext OPTIONAL);
 
 NTKERNELAPI
-NTSTATUS
+BOOLEAN
 NTAPI
-IoCreateUnprotectedSymbolicLink(
-  IN PUNICODE_STRING  SymbolicLinkName,
-  IN PUNICODE_STRING  DeviceName);
+IoForwardIrpSynchronously(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN PIRP  Irp);
+
+#define IoForwardAndCatchIrp IoForwardIrpSynchronously
 
 NTKERNELAPI
 VOID
 NTAPI
-IoDeleteDevice(
-  IN PDEVICE_OBJECT  DeviceObject);
+IoFreeErrorLogEntry(
+  PVOID  ElEntry);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoDeleteSymbolicLink(
-  IN PUNICODE_STRING  SymbolicLinkName);
+IoSetCompletionRoutineEx(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN PIRP  Irp,
+  IN PIO_COMPLETION_ROUTINE  CompletionRoutine,
+  IN PVOID  Context,
+  IN BOOLEAN  InvokeOnSuccess,
+  IN BOOLEAN  InvokeOnError,
+  IN BOOLEAN  InvokeOnCancel);
 
-NTKERNELAPI
 VOID
 NTAPI
-IoDetachDevice(
-  IN OUT PDEVICE_OBJECT  TargetDevice);
+IoSetStartIoAttributes(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN BOOLEAN  DeferredStartIo,
+  IN BOOLEAN  NonCancelable);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-IoDisconnectInterrupt(
-  IN PKINTERRUPT  InterruptObject);
+IoWMIDeviceObjectToInstanceName(
+  IN PVOID  DataBlockObject,
+  IN PDEVICE_OBJECT  DeviceObject,
+  OUT PUNICODE_STRING  InstanceName);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-IoFreeIrp(
-  IN PIRP Irp);
+IoWMIExecuteMethod(
+  IN PVOID  DataBlockObject,
+  IN PUNICODE_STRING  InstanceName,
+  IN ULONG  MethodId,
+  IN ULONG  InBufferSize,
+  IN OUT PULONG  OutBufferSize,
+  IN OUT  PUCHAR  InOutBuffer);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-IoFreeMdl(
-  IN PMDL Mdl);
+IoWMIHandleToInstanceName(
+  IN PVOID  DataBlockObject,
+  IN HANDLE  FileHandle,
+  OUT PUNICODE_STRING  InstanceName);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-IoFreeWorkItem(
-  IN PIO_WORKITEM IoWorkItem);
+IoWMIOpenBlock(
+  IN GUID  *DataBlockGuid,
+  IN ULONG  DesiredAccess,
+  OUT PVOID  *DataBlockObject);
 
 NTKERNELAPI
-PDEVICE_OBJECT
+NTSTATUS
 NTAPI
-IoGetAttachedDevice(
-  IN PDEVICE_OBJECT DeviceObject);
+IoWMIQueryAllData(
+  IN PVOID  DataBlockObject,
+  IN OUT ULONG  *InOutBufferSize,
+  OUT PVOID  OutBuffer);
 
 NTKERNELAPI
-PDEVICE_OBJECT
+NTSTATUS
 NTAPI
-IoGetAttachedDeviceReference(
-  IN PDEVICE_OBJECT  DeviceObject);
+IoWMIQueryAllDataMultiple(
+  IN PVOID  *DataBlockObjectList,
+  IN ULONG  ObjectCount,
+  IN OUT ULONG  *InOutBufferSize,
+  OUT PVOID  OutBuffer);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoGetBootDiskInformation(
-  IN OUT PBOOTDISK_INFORMATION  BootDiskInformation,
-  IN ULONG  Size);
+IoWMIQuerySingleInstance(
+  IN PVOID  DataBlockObject,
+  IN PUNICODE_STRING  InstanceName,
+  IN OUT ULONG  *InOutBufferSize,
+  OUT PVOID OutBuffer);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoGetDeviceInterfaceAlias(
-  IN PUNICODE_STRING  SymbolicLinkName,
-  IN CONST GUID  *AliasInterfaceClassGuid,
-  OUT PUNICODE_STRING  AliasSymbolicLinkName);
+IoWMISetNotificationCallback(
+  IN OUT PVOID  Object,
+  IN WMI_NOTIFICATION_CALLBACK  Callback,
+  IN PVOID  Context OPTIONAL);
 
 NTKERNELAPI
-PEPROCESS
+NTSTATUS
 NTAPI
-IoGetCurrentProcess(VOID);
+IoWMISetSingleInstance(
+  IN PVOID  DataBlockObject,
+  IN PUNICODE_STRING  InstanceName,
+  IN ULONG  Version,
+  IN ULONG  ValueBufferSize,
+  IN PVOID  ValueBuffer);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoGetDeviceInterfaces(
-  IN CONST GUID  *InterfaceClassGuid,
-  IN PDEVICE_OBJECT  PhysicalDeviceObject  OPTIONAL,
-  IN ULONG  Flags,
-  OUT PWSTR  *SymbolicLinkList);
+IoWMISetSingleItem(
+  IN PVOID  DataBlockObject,
+  IN PUNICODE_STRING  InstanceName,
+  IN ULONG  DataItemId,
+  IN ULONG  Version,
+  IN ULONG  ValueBufferSize,
+  IN PVOID  ValueBuffer);
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
 
+#if (NTDDI_VERSION >= NTDDI_WINXPSP1)
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoGetDeviceObjectPointer(
-  IN PUNICODE_STRING  ObjectName,
-  IN ACCESS_MASK  DesiredAccess,
-  OUT PFILE_OBJECT  *FileObject,
-  OUT PDEVICE_OBJECT  *DeviceObject);
+IoValidateDeviceIoControlAccess(
+  IN PIRP Irp,
+  IN ULONG RequiredAccess);
+#endif
+
+#if (NTDDI_VERSION >= NTDDI_WS03)
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoGetDeviceProperty(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN DEVICE_REGISTRY_PROPERTY  DeviceProperty,
-  IN ULONG  BufferLength,
-  OUT PVOID  PropertyBuffer,
-  OUT PULONG  ResultLength);
+IoCsqInitializeEx(
+  IN PIO_CSQ Csq,
+  IN PIO_CSQ_INSERT_IRP_EX CsqInsertIrp,
+  IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
+  IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
+  IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
+  IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
+  IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
 
 NTKERNELAPI
-PDMA_ADAPTER
+NTSTATUS
 NTAPI
-IoGetDmaAdapter(
-  IN PDEVICE_OBJECT  PhysicalDeviceObject OPTIONAL,
-  IN PDEVICE_DESCRIPTION  DeviceDescription,
-  IN OUT PULONG  NumberOfMapRegisters);
+IoCsqInsertIrpEx(
+  IN PIO_CSQ Csq,
+  IN PIRP Irp,
+  IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL,
+  IN PVOID InsertContext OPTIONAL);
+#endif /* (NTDDI_VERSION >= NTDDI_WS03) */
+
+
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 
 NTKERNELAPI
-PVOID
+NTSTATUS
 NTAPI
-IoGetDriverObjectExtension(
-  IN PDRIVER_OBJECT  DriverObject,
-  IN PVOID  ClientIdentificationAddress);
+IoGetBootDiskInformationLite(
+  OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation);
 
 NTKERNELAPI
-PVOID
+NTSTATUS
 NTAPI
-IoGetInitialStack(VOID);
+IoCheckShareAccessEx(
+  IN ACCESS_MASK DesiredAccess,
+  IN ULONG DesiredShareAccess,
+  IN OUT PFILE_OBJECT FileObject,
+  IN OUT PSHARE_ACCESS ShareAccess,
+  IN BOOLEAN Update,
+  IN PBOOLEAN WritePermission);
 
 NTKERNELAPI
-PDEVICE_OBJECT
+NTSTATUS
 NTAPI
-IoGetRelatedDeviceObject(
-  IN PFILE_OBJECT  FileObject);
+IoConnectInterruptEx(
+  IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters);
 
 NTKERNELAPI
 VOID
 NTAPI
-IoQueueWorkItem(
-  IN PIO_WORKITEM  IoWorkItem,
-  IN PIO_WORKITEM_ROUTINE  WorkerRoutine,
-  IN WORK_QUEUE_TYPE  QueueType,
-  IN PVOID  Context OPTIONAL);
+IoDisconnectInterruptEx(
+  IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters);
+
+LOGICAL
+NTAPI
+IoWithinStackLimits(
+  IN ULONG_PTR RegionStart,
+  IN SIZE_T RegionSize);
 
 NTKERNELAPI
 VOID
 NTAPI
-IoInitializeIrp(
-  IN OUT PIRP  Irp,
-  IN USHORT  PacketSize,
-  IN CCHAR  StackSize);
+IoSetShareAccessEx(
+  IN ACCESS_MASK DesiredAccess,
+  IN ULONG DesiredShareAccess,
+  IN OUT PFILE_OBJECT FileObject,
+  OUT PSHARE_ACCESS ShareAccess,
+  IN PBOOLEAN WritePermission);
+
+ULONG
+NTAPI
+IoSizeofWorkItem(VOID);
 
-NTKERNELAPI
 VOID
 NTAPI
-IoInitializeRemoveLockEx(
-  IN  PIO_REMOVE_LOCK Lock,
-  IN  ULONG   AllocateTag,
-  IN  ULONG   MaxLockedMinutes,
-  IN  ULONG   HighWatermark,
-  IN  ULONG   RemlockSize);
+IoInitializeWorkItem(
+  IN PVOID IoObject,
+  IN PIO_WORKITEM IoWorkItem);
+
+VOID
+NTAPI
+IoUninitializeWorkItem(
+  IN PIO_WORKITEM IoWorkItem);
+
+VOID
+NTAPI
+IoQueueWorkItemEx(
+  IN PIO_WORKITEM IoWorkItem,
+  IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine,
+  IN WORK_QUEUE_TYPE QueueType,
+  IN PVOID Context OPTIONAL);
+
+IO_PRIORITY_HINT
+NTAPI
+IoGetIoPriorityHint(
+  IN PIRP Irp);
 
-NTKERNELAPI
 NTSTATUS
 NTAPI
-IoInitializeTimer(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN PIO_TIMER_ROUTINE  TimerRoutine,
-  IN PVOID  Context OPTIONAL);
+IoSetIoPriorityHint(
+  IN PIRP Irp,
+  IN IO_PRIORITY_HINT PriorityHint);
 
-NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-IoInvalidateDeviceRelations(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN DEVICE_RELATION_TYPE  Type);
+IoAllocateSfioStreamIdentifier(
+  IN PFILE_OBJECT FileObject,
+  IN ULONG Length,
+  IN PVOID Signature,
+  OUT PVOID *StreamIdentifier);
 
-NTKERNELAPI
-VOID
+PVOID
 NTAPI
-IoInvalidateDeviceState(
-  IN PDEVICE_OBJECT  PhysicalDeviceObject);
+IoGetSfioStreamIdentifier(
+  IN PFILE_OBJECT FileObject,
+  IN PVOID Signature);
 
-NTKERNELAPI
-BOOLEAN
+NTSTATUS
 NTAPI
-IoIsWdmVersionAvailable(
-  IN UCHAR  MajorVersion,
-  IN UCHAR  MinorVersion);
+IoFreeSfioStreamIdentifier(
+  IN PFILE_OBJECT FileObject,
+  IN PVOID Signature);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoOpenDeviceInterfaceRegistryKey(
-  IN PUNICODE_STRING  SymbolicLinkName,
-  IN ACCESS_MASK  DesiredAccess,
-  OUT PHANDLE  DeviceInterfaceKey);
+IoRequestDeviceEjectEx(
+  IN PDEVICE_OBJECT PhysicalDeviceObject,
+  IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL,
+  IN PVOID Context OPTIONAL,
+  IN PDRIVER_OBJECT DriverObject OPTIONAL);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoOpenDeviceRegistryKey(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN ULONG  DevInstKeyType,
-  IN ACCESS_MASK  DesiredAccess,
-  OUT PHANDLE  DevInstRegKey);
+IoSetDevicePropertyData(
+  IN PDEVICE_OBJECT     Pdo,
+  IN CONST DEVPROPKEY   *PropertyKey,
+  IN LCID               Lcid,
+  IN ULONG              Flags,
+  IN DEVPROPTYPE        Type,
+  IN ULONG              Size,
+  IN PVOID          Data OPTIONAL);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoRegisterDeviceInterface(
-  IN PDEVICE_OBJECT  PhysicalDeviceObject,
-  IN CONST GUID  *InterfaceClassGuid,
-  IN PUNICODE_STRING  ReferenceString  OPTIONAL,
-  OUT PUNICODE_STRING  SymbolicLinkName);
+IoGetDevicePropertyData(
+  PDEVICE_OBJECT Pdo,
+  CONST DEVPROPKEY *PropertyKey,
+  LCID Lcid,
+  ULONG Flags,
+  ULONG Size,
+  PVOID Data,
+  PULONG RequiredSize,
+  PDEVPROPTYPE Type);
+
+#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
 
+#define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b)
+
+#if (NTDDI_VERSION >= NTDDI_WS08)
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoRegisterPlugPlayNotification(
-  IN IO_NOTIFICATION_EVENT_CATEGORY  EventCategory,
-  IN ULONG  EventCategoryFlags,
-  IN PVOID  EventCategoryData  OPTIONAL,
-  IN PDRIVER_OBJECT  DriverObject,
-  IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE  CallbackRoutine,
-  IN OUT PVOID  Context OPTIONAL,
-  OUT PVOID  *NotificationEntry);
+IoReplacePartitionUnit(
+  IN PDEVICE_OBJECT TargetPdo,
+  IN PDEVICE_OBJECT SparePdo,
+  IN ULONG Flags);
+#endif
+
+#if (NTDDI_VERSION >= NTDDI_WIN7)
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoRegisterShutdownNotification(
-  IN PDEVICE_OBJECT  DeviceObject);
+IoGetAffinityInterrupt(
+  IN PKINTERRUPT InterruptObject,
+  OUT PGROUP_AFFINITY GroupAffinity);
 
-NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-IoReleaseCancelSpinLock(
-  IN KIRQL  Irql);
+IoGetContainerInformation(
+  IN IO_CONTAINER_INFORMATION_CLASS InformationClass,
+  IN PVOID ContainerObject OPTIONAL,
+  IN OUT PVOID Buffer OPTIONAL,
+  IN ULONG BufferLength);
 
-NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-IoReleaseRemoveLockAndWaitEx(
-  IN PIO_REMOVE_LOCK  RemoveLock,
-  IN PVOID  Tag OPTIONAL,
-  IN ULONG  RemlockSize);
+IoRegisterContainerNotification(
+  IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass,
+  IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction,
+  IN PVOID NotificationInformation OPTIONAL,
+  IN ULONG NotificationInformationLength,
+  OUT PVOID CallbackRegistration);
 
-NTKERNELAPI
 VOID
 NTAPI
-IoReleaseRemoveLockEx(
-  IN PIO_REMOVE_LOCK  RemoveLock,
-  IN PVOID  Tag OPTIONAL,
-  IN ULONG  RemlockSize);
+IoUnregisterContainerNotification(
+  IN PVOID CallbackRegistration);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-IoRemoveShareAccess(
-  IN PFILE_OBJECT  FileObject,
-  IN OUT PSHARE_ACCESS  ShareAccess);
+IoUnregisterPlugPlayNotificationEx(
+  IN PVOID NotificationEntry);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoReportTargetDeviceChange(
-  IN PDEVICE_OBJECT  PhysicalDeviceObject,
-  IN PVOID  NotificationStructure);
+IoGetDeviceNumaNode(
+  IN PDEVICE_OBJECT Pdo,
+  OUT PUSHORT NodeNumber);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
 
+#if defined(_WIN64)
 NTKERNELAPI
-NTSTATUS
+ULONG
 NTAPI
-IoReportTargetDeviceChangeAsynchronous(
-  IN PDEVICE_OBJECT  PhysicalDeviceObject,
-  IN PVOID  NotificationStructure,
-  IN PDEVICE_CHANGE_COMPLETE_CALLBACK  Callback  OPTIONAL,
-  IN PVOID  Context  OPTIONAL);
+IoWMIDeviceObjectToProviderId(
+  IN PDEVICE_OBJECT DeviceObject);
+#else
+#define IoWMIDeviceObjectToProviderId(DeviceObject) ((ULONG)(DeviceObject))
+#endif
+
+/*
+ * USHORT
+ * IoSizeOfIrp(
+ *   IN CCHAR  StackSize)
+ */
+#define IoSizeOfIrp(_StackSize) \
+  ((USHORT) (sizeof(IRP) + ((_StackSize) * (sizeof(IO_STACK_LOCATION)))))
+
+FORCEINLINE
+VOID
+IoSkipCurrentIrpStackLocation (
+  IN OUT PIRP Irp)
+{
+  ASSERT(Irp->CurrentLocation <= Irp->StackCount);
+  Irp->CurrentLocation++;
+  Irp->Tail.Overlay.CurrentStackLocation++;
+}
+
+FORCEINLINE
+VOID
+IoSetNextIrpStackLocation (
+  IN OUT PIRP Irp)
+{
+  ASSERT(Irp->CurrentLocation > 0);
+  Irp->CurrentLocation--;
+  Irp->Tail.Overlay.CurrentStackLocation--;
+}
+
+FORCEINLINE
+PIO_STACK_LOCATION
+IoGetNextIrpStackLocation(
+  IN PIRP Irp)
+{
+  ASSERT(Irp->CurrentLocation > 0);
+  return ((Irp)->Tail.Overlay.CurrentStackLocation - 1 );
+}
+
+FORCEINLINE
+VOID
+IoSetCompletionRoutine(
+  IN PIRP Irp,
+  IN PIO_COMPLETION_ROUTINE CompletionRoutine OPTIONAL,
+  IN PVOID Context OPTIONAL,
+  IN BOOLEAN InvokeOnSuccess,
+  IN BOOLEAN InvokeOnError,
+  IN BOOLEAN InvokeOnCancel)
+{
+  PIO_STACK_LOCATION irpSp;
+  ASSERT( (InvokeOnSuccess || InvokeOnError || InvokeOnCancel) ? (CompletionRoutine != NULL) : TRUE );
+  irpSp = IoGetNextIrpStackLocation(Irp);
+  irpSp->CompletionRoutine = CompletionRoutine;
+  irpSp->Context = Context;
+  irpSp->Control = 0;
+
+  if (InvokeOnSuccess) {
+    irpSp->Control = SL_INVOKE_ON_SUCCESS;
+  }
+
+  if (InvokeOnError) {
+    irpSp->Control |= SL_INVOKE_ON_ERROR;
+  }
+
+  if (InvokeOnCancel) {
+    irpSp->Control |= SL_INVOKE_ON_CANCEL;
+  }
+}
+
+/*
+ * PDRIVER_CANCEL
+ * IoSetCancelRoutine(
+ *   IN PIRP  Irp,
+ *   IN PDRIVER_CANCEL  CancelRoutine)
+ */
+#define IoSetCancelRoutine(_Irp, \
+                           _CancelRoutine) \
+  ((PDRIVER_CANCEL) (ULONG_PTR) InterlockedExchangePointer( \
+    (PVOID *) &(_Irp)->CancelRoutine, (PVOID) (ULONG_PTR) (_CancelRoutine)))
+
+/*
+ * VOID
+ * IoRequestDpc(
+ *   IN PDEVICE_OBJECT  DeviceObject,
+ *   IN PIRP  Irp,
+ *   IN PVOID  Context);
+ */
+#define IoRequestDpc(DeviceObject, Irp, Context)( \
+  KeInsertQueueDpc(&(DeviceObject)->Dpc, (Irp), (Context)))
+
+/*
+ * VOID
+ * IoReleaseRemoveLock(
+ *   IN PIO_REMOVE_LOCK  RemoveLock,
+ *   IN PVOID  Tag)
+ */
+#define IoReleaseRemoveLock(_RemoveLock, \
+                            _Tag) \
+  IoReleaseRemoveLockEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
+
+/*
+ * VOID
+ * IoReleaseRemoveLockAndWait(
+ *   IN PIO_REMOVE_LOCK  RemoveLock,
+ *   IN PVOID  Tag)
+ */
+#define IoReleaseRemoveLockAndWait(_RemoveLock, \
+                                   _Tag) \
+  IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
 
+#if defined(_WIN64)
 NTKERNELAPI
+BOOLEAN
+IoIs32bitProcess(
+  IN PIRP  Irp  OPTIONAL);
+#endif
+
+#define PLUGPLAY_REGKEY_DEVICE                            1
+#define PLUGPLAY_REGKEY_DRIVER                            2
+#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE                 4
+
+FORCEINLINE
+PIO_STACK_LOCATION
+IoGetCurrentIrpStackLocation(
+  IN PIRP Irp)
+{
+  ASSERT(Irp->CurrentLocation <= Irp->StackCount + 1);
+  return Irp->Tail.Overlay.CurrentStackLocation;
+}
+
+FORCEINLINE
 VOID
-NTAPI
-IoRequestDeviceEject(
-  IN PDEVICE_OBJECT  PhysicalDeviceObject);
+IoMarkIrpPending(
+  IN OUT PIRP Irp)
+{
+  IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED;
+}
+
+/*
+ * BOOLEAN
+ * IoIsErrorUserInduced(
+ *   IN NTSTATUS  Status);
+ */
+#define IoIsErrorUserInduced(Status) \
+   ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \
+   ((Status) == STATUS_IO_TIMEOUT) || \
+   ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
+   ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
+   ((Status) == STATUS_VERIFY_REQUIRED) || \
+   ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
+   ((Status) == STATUS_WRONG_VOLUME)))
+
+/* VOID
+ * IoInitializeRemoveLock(
+ *   IN PIO_REMOVE_LOCK  Lock,
+ *   IN ULONG  AllocateTag,
+ *   IN ULONG  MaxLockedMinutes,
+ *   IN ULONG  HighWatermark)
+ */
+#define IoInitializeRemoveLock( \
+  Lock, AllocateTag, MaxLockedMinutes, HighWatermark) \
+  IoInitializeRemoveLockEx(Lock, AllocateTag, MaxLockedMinutes, \
+    HighWatermark, sizeof(IO_REMOVE_LOCK))
 
-NTKERNELAPI
 VOID
-NTAPI
-IoReuseIrp(
-  IN OUT PIRP  Irp,
-  IN NTSTATUS  Status);
+FORCEINLINE
+IoInitializeDpcRequest(
+  IN PDEVICE_OBJECT DeviceObject,
+  IN PIO_DPC_ROUTINE DpcRoutine)
+{
+  KeInitializeDpc( &DeviceObject->Dpc,
+                   (PKDEFERRED_ROUTINE) DpcRoutine,
+                   DeviceObject );
+}
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-IoSetDeviceInterfaceState(
-  IN PUNICODE_STRING  SymbolicLinkName,
-  IN BOOLEAN  Enable);
+#define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
 
-NTKERNELAPI
-VOID
-NTAPI
-IoSetShareAccess(
-  IN ACCESS_MASK  DesiredAccess,
-  IN ULONG  DesiredShareAccess,
-  IN OUT PFILE_OBJECT  FileObject,
-  OUT PSHARE_ACCESS  ShareAccess);
+/*
+ * ULONG
+ * IoGetFunctionCodeFromCtlCode(
+ *   IN ULONG  ControlCode)
+ */
+#define IoGetFunctionCodeFromCtlCode(_ControlCode) \
+  (((_ControlCode) >> 2) & 0x00000FFF)
 
-NTKERNELAPI
+FORCEINLINE
 VOID
-NTAPI
-IoStartNextPacket(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN BOOLEAN  Cancelable);
+IoCopyCurrentIrpStackLocationToNext(
+  IN OUT PIRP Irp)
+{
+  PIO_STACK_LOCATION irpSp;
+  PIO_STACK_LOCATION nextIrpSp;
+  irpSp = IoGetCurrentIrpStackLocation(Irp);
+  nextIrpSp = IoGetNextIrpStackLocation(Irp);
+  RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine));
+  nextIrpSp->Control = 0;
+}
 
 NTKERNELAPI
 VOID
 NTAPI
-IoStartNextPacketByKey(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN BOOLEAN  Cancelable,
-  IN ULONG  Key);
+IoGetStackLimits(
+  OUT PULONG_PTR  LowLimit,
+  OUT PULONG_PTR  HighLimit);
 
-NTKERNELAPI
-VOID
-NTAPI
-IoStartPacket(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN PIRP  Irp,
-  IN PULONG  Key  OPTIONAL,
-  IN PDRIVER_CANCEL  CancelFunction  OPTIONAL);
+FORCEINLINE
+ULONG_PTR
+IoGetRemainingStackSize(VOID)
+{
+  ULONG_PTR End, Begin;
+  ULONG_PTR Result;
 
-NTKERNELAPI
-VOID
-NTAPI
-IoStartTimer(
-  IN PDEVICE_OBJECT  DeviceObject);
+  IoGetStackLimits(&Begin, &End);
+  Result = (ULONG_PTR)(&End) - Begin;
+  return Result;
+}
 
-NTKERNELAPI
+#if (NTDDI_VERSION >= NTDDI_WS03)
 VOID
-NTAPI
-IoStopTimer(
-  IN PDEVICE_OBJECT  DeviceObject);
+FORCEINLINE
+IoInitializeThreadedDpcRequest(
+  IN PDEVICE_OBJECT DeviceObject,
+  IN PIO_DPC_ROUTINE DpcRoutine)
+{
+  KeInitializeThreadedDpc(&DeviceObject->Dpc,
+                          (PKDEFERRED_ROUTINE) DpcRoutine,
+                          DeviceObject );
+}
+#endif
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-IoUnregisterPlugPlayNotification(
-  IN PVOID  NotificationEntry);
+/******************************************************************************
+ *                     Power Management Support Functions                     *
+ ******************************************************************************/
 
-NTKERNELAPI
-VOID
-NTAPI
-IoUnregisterShutdownNotification(
-  IN PDEVICE_OBJECT  DeviceObject);
+#define PoSetDeviceBusy(IdlePointer) ((void)(*(IdlePointer) = 0))
 
-NTKERNELAPI
-VOID
-NTAPI
-IoUpdateShareAccess(
-  IN PFILE_OBJECT  FileObject,
-  IN OUT PSHARE_ACCESS  ShareAccess);
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoWMIAllocateInstanceIds(
-  IN GUID  *Guid,
-  IN ULONG  InstanceCount,
-  OUT ULONG  *FirstInstanceId);
+PoCallDriver(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN OUT struct _IRP  *Irp);
 
 NTKERNELAPI
-NTSTATUS
+PULONG
 NTAPI
-IoWMIQuerySingleInstanceMultiple(
-  IN PVOID  *DataBlockObjectList,
-  IN PUNICODE_STRING  InstanceNames,
-  IN ULONG  ObjectCount,
-  IN OUT ULONG  *InOutBufferSize,
-  OUT PVOID  OutBuffer);
+PoRegisterDeviceForIdleDetection(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN ULONG  ConservationIdleTime,
+  IN ULONG  PerformanceIdleTime,
+  IN DEVICE_POWER_STATE  State);
 
 NTKERNELAPI
-NTSTATUS
+PVOID
 NTAPI
-IoWMIRegistrationControl(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN ULONG  Action);
+PoRegisterSystemState(
+  IN OUT PVOID StateHandle OPTIONAL,
+  IN EXECUTION_STATE Flags);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoWMISuggestInstanceName(
-  IN PDEVICE_OBJECT  PhysicalDeviceObject OPTIONAL,
-  IN PUNICODE_STRING  SymbolicLinkName OPTIONAL,
-  IN BOOLEAN  CombineNames,
-  OUT PUNICODE_STRING  SuggestedInstanceName);
+PoRequestPowerIrp(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN UCHAR  MinorFunction,
+  IN POWER_STATE  PowerState,
+  IN PREQUEST_POWER_COMPLETE  CompletionFunction OPTIONAL,
+  IN PVOID  Context OPTIONAL,
+  OUT struct _IRP  **Irp OPTIONAL);
 
 NTKERNELAPI
-NTSTATUS
+POWER_STATE
 NTAPI
-IoWMIWriteEvent(
-  IN OUT PVOID WnodeEventItem);
+PoSetPowerState(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN POWER_STATE_TYPE  Type,
+  IN POWER_STATE  State);
 
 NTKERNELAPI
 VOID
 NTAPI
-IoWriteErrorLogEntry(
-  IN PVOID  ElEntry);
+PoSetSystemState(
+  IN EXECUTION_STATE  Flags);
 
 NTKERNELAPI
-PIRP
+VOID
 NTAPI
-IoGetTopLevelIrp(VOID);
+PoStartNextPowerIrp(
+  IN OUT struct _IRP *Irp);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-IoRegisterLastChanceShutdownNotification(
-  IN PDEVICE_OBJECT DeviceObject);
+PoUnregisterSystemState(
+  IN OUT PVOID StateHandle);
 
 NTKERNELAPI
-VOID
+NTSTATUS
 NTAPI
-IoSetTopLevelIrp(
-  IN PIRP Irp OPTIONAL);
+PoRequestShutdownEvent(
+  OUT PVOID *Event);
 
 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
 
-
-#if (NTDDI_VERSION >= NTDDI_WINXP)
-
-NTKERNELAPI
-NTSTATUS
-NTAPI
-IoCsqInitialize(
-  IN PIO_CSQ Csq,
-  IN PIO_CSQ_INSERT_IRP CsqInsertIrp,
-  IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
-  IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
-  IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
-  IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
-  IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 
 NTKERNELAPI
 VOID
 NTAPI
-IoCsqInsertIrp(
-  IN PIO_CSQ Csq,
-  IN PIRP Irp,
-  IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL);
+PoSetSystemWake(
+  IN OUT struct _IRP *Irp);
 
 NTKERNELAPI
-PIRP
+BOOLEAN
 NTAPI
-IoCsqRemoveIrp(
-  IN PIO_CSQ Csq,
-  IN PIO_CSQ_IRP_CONTEXT Context);
+PoGetSystemWake(
+  IN struct _IRP *Irp);
 
 NTKERNELAPI
-PIRP
+NTSTATUS
 NTAPI
-IoCsqRemoveNextIrp(
-  IN PIO_CSQ  Csq,
-  IN PVOID PeekContext OPTIONAL);
+PoRegisterPowerSettingCallback(
+  IN PDEVICE_OBJECT DeviceObject OPTIONAL,
+  IN LPCGUID SettingGuid,
+  IN PPOWER_SETTING_CALLBACK Callback,
+  IN PVOID Context OPTIONAL,
+  OUT PVOID *Handle OPTIONAL);
 
 NTKERNELAPI
-BOOLEAN
+NTSTATUS
 NTAPI
-IoForwardIrpSynchronously(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN PIRP  Irp);
+PoUnregisterPowerSettingCallback(
+  IN OUT PVOID Handle);
 
-#define IoForwardAndCatchIrp IoForwardIrpSynchronously
+#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
 
+#if (NTDDI_VERSION >= NTDDI_VISTASP1)
 NTKERNELAPI
 VOID
 NTAPI
-IoFreeErrorLogEntry(
-  PVOID  ElEntry);
+PoSetDeviceBusyEx(
+  IN OUT PULONG IdlePointer);
+#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-IoSetCompletionRoutineEx(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN PIRP  Irp,
-  IN PIO_COMPLETION_ROUTINE  CompletionRoutine,
-  IN PVOID  Context,
-  IN BOOLEAN  InvokeOnSuccess,
-  IN BOOLEAN  InvokeOnError,
-  IN BOOLEAN  InvokeOnCancel);
+#if (NTDDI_VERSION >= NTDDI_WIN7)
 
+NTKERNELAPI
 VOID
 NTAPI
-IoSetStartIoAttributes(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN BOOLEAN  DeferredStartIo,
-  IN BOOLEAN  NonCancelable);
+PoStartDeviceBusy(
+  IN OUT PULONG IdlePointer);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-IoWMIDeviceObjectToInstanceName(
-  IN PVOID  DataBlockObject,
-  IN PDEVICE_OBJECT  DeviceObject,
-  OUT PUNICODE_STRING  InstanceName);
+PoEndDeviceBusy(
+  IN OUT PULONG IdlePointer);
 
 NTKERNELAPI
-NTSTATUS
+BOOLEAN
 NTAPI
-IoWMIExecuteMethod(
-  IN PVOID  DataBlockObject,
-  IN PUNICODE_STRING  InstanceName,
-  IN ULONG  MethodId,
-  IN ULONG  InBufferSize,
-  IN OUT PULONG  OutBufferSize,
-  IN OUT  PUCHAR  InOutBuffer);
+PoQueryWatchdogTime(
+  IN PDEVICE_OBJECT Pdo,
+  OUT PULONG SecondsRemaining);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-IoWMIHandleToInstanceName(
-  IN PVOID  DataBlockObject,
-  IN HANDLE  FileHandle,
-  OUT PUNICODE_STRING  InstanceName);
+PoDeletePowerRequest(
+  IN OUT PVOID PowerRequest);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoWMIOpenBlock(
-  IN GUID  *DataBlockGuid,
-  IN ULONG  DesiredAccess,
-  OUT PVOID  *DataBlockObject);
+PoSetPowerRequest(
+  IN OUT PVOID PowerRequest,
+  IN POWER_REQUEST_TYPE Type);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoWMIQueryAllData(
-  IN PVOID  DataBlockObject,
-  IN OUT ULONG  *InOutBufferSize,
-  OUT PVOID  OutBuffer);
+PoClearPowerRequest(
+  IN OUT PVOID PowerRequest,
+  IN POWER_REQUEST_TYPE Type);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-IoWMIQueryAllDataMultiple(
-  IN PVOID  *DataBlockObjectList,
-  IN ULONG  ObjectCount,
-  IN OUT ULONG  *InOutBufferSize,
-  OUT PVOID  OutBuffer);
+PoCreatePowerRequest(
+  OUT PVOID *PowerRequest,
+  IN PDEVICE_OBJECT DeviceObject,
+  IN PCOUNTED_REASON_CONTEXT Context);
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-IoWMIQuerySingleInstance(
-  IN PVOID  DataBlockObject,
-  IN PUNICODE_STRING  InstanceName,
-  IN OUT ULONG  *InOutBufferSize,
-  OUT PVOID OutBuffer);
+#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
+
+/******************************************************************************
+ *                          Executive Functions                               *
+ ******************************************************************************/
+
+#define ExInterlockedIncrementLong(Addend,Lock) Exfi386InterlockedIncrementLong(Addend)
+#define ExInterlockedDecrementLong(Addend,Lock) Exfi386InterlockedDecrementLong(Addend)
+#define ExInterlockedExchangeUlong(Target, Value, Lock) Exfi386InterlockedExchangeUlong(Target, Value)
+
+#define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
+#define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
+#define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
+#define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
+
+#define ExInitializeSListHead InitializeSListHead
+
+#if defined(_NTHAL_) && defined(_X86_)
 
 NTKERNELAPI
-NTSTATUS
-NTAPI
-IoWMISetNotificationCallback(
-  IN OUT PVOID  Object,
-  IN WMI_NOTIFICATION_CALLBACK  Callback,
-  IN PVOID  Context OPTIONAL);
+VOID
+FASTCALL
+ExiAcquireFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
 
 NTKERNELAPI
-NTSTATUS
-NTAPI
-IoWMISetSingleInstance(
-  IN PVOID  DataBlockObject,
-  IN PUNICODE_STRING  InstanceName,
-  IN ULONG  Version,
-  IN ULONG  ValueBufferSize,
-  IN PVOID  ValueBuffer);
+VOID
+FASTCALL
+ExiReleaseFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
 
 NTKERNELAPI
-NTSTATUS
-NTAPI
-IoWMISetSingleItem(
-  IN PVOID  DataBlockObject,
-  IN PUNICODE_STRING  InstanceName,
-  IN ULONG  DataItemId,
-  IN ULONG  Version,
-  IN ULONG  ValueBufferSize,
-  IN PVOID  ValueBuffer);
+BOOLEAN
+FASTCALL
+ExiTryToAcquireFastMutex(
+    IN OUT PFAST_MUTEX FastMutex);
 
-#endif
+#define ExAcquireFastMutex ExiAcquireFastMutex
+#define ExReleaseFastMutex ExiReleaseFastMutex
+#define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex
 
-#if defined(_WIN64)
-NTKERNELAPI
-ULONG
-NTAPI
-IoWMIDeviceObjectToProviderId(
-  IN PDEVICE_OBJECT DeviceObject);
 #else
-#define IoWMIDeviceObjectToProviderId(DeviceObject) ((ULONG)(DeviceObject))
-#endif
 
-/*
- * USHORT
- * IoSizeOfIrp(
- *   IN CCHAR  StackSize)
- */
-#define IoSizeOfIrp(_StackSize) \
-  ((USHORT) (sizeof(IRP) + ((_StackSize) * (sizeof(IO_STACK_LOCATION)))))
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-IoSkipCurrentIrpStackLocation (
-  IN OUT PIRP Irp)
-{
-  ASSERT(Irp->CurrentLocation <= Irp->StackCount);
-  Irp->CurrentLocation++;
-  Irp->Tail.Overlay.CurrentStackLocation++;
-}
+FASTCALL
+ExAcquireFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
 
-FORCEINLINE
+NTKERNELAPI
 VOID
-IoSetNextIrpStackLocation (
-  IN OUT PIRP Irp)
-{
-  ASSERT(Irp->CurrentLocation > 0);
-  Irp->CurrentLocation--;
-  Irp->Tail.Overlay.CurrentStackLocation--;
-}
+FASTCALL
+ExReleaseFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
+
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+ExTryToAcquireFastMutex(
+  IN OUT PFAST_MUTEX FastMutex);
 
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+
+#endif /* defined(_NTHAL_) && defined(_X86_) */
+
+#if defined(_X86_)
+#define ExInterlockedAddUlong ExfInterlockedAddUlong
+#define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList
+#define ExInterlockedInsertTailList ExfInterlockedInsertTailList
+#define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList
+#define ExInterlockedPopEntryList ExfInterlockedPopEntryList
+#define ExInterlockedPushEntryList ExfInterlockedPushEntryList
+#endif /* defined(_X86_) */
+
+#if defined(_WIN64)
+
+#if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || \
+    defined(_NTHAL_) || defined(_NTOSP_)
+NTKERNELAPI
+USHORT
+ExQueryDepthSList(IN PSLIST_HEADER ListHead);
+#else
 FORCEINLINE
-PIO_STACK_LOCATION
-IoGetNextIrpStackLocation(
-  IN PIRP Irp)
+USHORT
+ExQueryDepthSList(IN PSLIST_HEADER ListHead)
 {
-  ASSERT(Irp->CurrentLocation > 0);
-  return ((Irp)->Tail.Overlay.CurrentStackLocation - 1 );
+    return (USHORT)(ListHead->Alignment & 0xffff);
 }
+#endif
 
-FORCEINLINE
-VOID
-IoSetCompletionRoutine(
-  IN PIRP Irp,
-  IN PIO_COMPLETION_ROUTINE CompletionRoutine OPTIONAL,
-  IN PVOID Context OPTIONAL,
-  IN BOOLEAN InvokeOnSuccess,
-  IN BOOLEAN InvokeOnError,
-  IN BOOLEAN InvokeOnCancel)
-{
-  PIO_STACK_LOCATION irpSp;
-  ASSERT( (InvokeOnSuccess || InvokeOnError || InvokeOnCancel) ? (CompletionRoutine != NULL) : TRUE );
-  irpSp = IoGetNextIrpStackLocation(Irp);
-  irpSp->CompletionRoutine = CompletionRoutine;
-  irpSp->Context = Context;
-  irpSp->Control = 0;
+NTKERNELAPI
+PSLIST_ENTRY
+ExpInterlockedFlushSList(
+    PSLIST_HEADER ListHead);
 
-  if (InvokeOnSuccess) {
-    irpSp->Control = SL_INVOKE_ON_SUCCESS;
-  }
+NTKERNELAPI
+PSLIST_ENTRY
+ExpInterlockedPopEntrySList(
+    PSLIST_HEADER ListHead);
 
-  if (InvokeOnError) {
-    irpSp->Control |= SL_INVOKE_ON_ERROR;
-  }
+NTKERNELAPI
+PSLIST_ENTRY
+ExpInterlockedPushEntrySList(
+    PSLIST_HEADER ListHead,
+    PSLIST_ENTRY ListEntry);
 
-  if (InvokeOnCancel) {
-    irpSp->Control |= SL_INVOKE_ON_CANCEL;
-  }
-}
+#define ExInterlockedFlushSList(Head) \
+    ExpInterlockedFlushSList(Head)
+#define ExInterlockedPopEntrySList(Head, Lock) \
+    ExpInterlockedPopEntrySList(Head)
+#define ExInterlockedPushEntrySList(Head, Entry, Lock) \
+    ExpInterlockedPushEntrySList(Head, Entry)
 
-/*
- * PDRIVER_CANCEL
- * IoSetCancelRoutine(
- *   IN PIRP  Irp,
- *   IN PDRIVER_CANCEL  CancelRoutine)
- */
-#define IoSetCancelRoutine(_Irp, \
-                           _CancelRoutine) \
-  ((PDRIVER_CANCEL) (ULONG_PTR) InterlockedExchangePointer( \
-    (PVOID *) &(_Irp)->CancelRoutine, (PVOID) (ULONG_PTR) (_CancelRoutine)))
+#else /* !defined(_WIN64) */
+
+#define ExQueryDepthSList(listhead) (listhead)->Depth
+
+NTKERNELAPI
+PSINGLE_LIST_ENTRY
+FASTCALL
+ExInterlockedFlushSList(
+  IN OUT PSLIST_HEADER ListHead);
+
+#endif /* !defined(_WIN64) */
+
+#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
 
-/*
- * VOID
- * IoRequestDpc(
- *   IN PDEVICE_OBJECT  DeviceObject,
- *   IN PIRP  Irp,
- *   IN PVOID  Context);
- */
-#define IoRequestDpc(DeviceObject, Irp, Context)( \
-  KeInsertQueueDpc(&(DeviceObject)->Dpc, (Irp), (Context)))
+NTKERNELAPI
+PSINGLE_LIST_ENTRY 
+FASTCALL
+ExInterlockedPopEntrySList(
+    IN PSLIST_HEADER ListHead,
+    IN PKSPIN_LOCK Lock);
 
-/*
- * VOID
- * IoReleaseRemoveLock(
- *   IN PIO_REMOVE_LOCK  RemoveLock,
- *   IN PVOID  Tag)
- */
-#define IoReleaseRemoveLock(_RemoveLock, \
-                            _Tag) \
-  IoReleaseRemoveLockEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
+NTKERNELAPI
+PSINGLE_LIST_ENTRY 
+FASTCALL
+ExInterlockedPushEntrySList(
+    IN PSLIST_HEADER ListHead,
+    IN PSINGLE_LIST_ENTRY ListEntry,
+    IN PKSPIN_LOCK Lock);
 
-/*
- * VOID
- * IoReleaseRemoveLockAndWait(
- *   IN PIO_REMOVE_LOCK  RemoveLock,
- *   IN PVOID  Tag)
- */
-#define IoReleaseRemoveLockAndWait(_RemoveLock, \
-                                   _Tag) \
-  IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
+NTKERNELAPI
+PVOID
+NTAPI
+ExAllocateFromPagedLookasideList(
+  IN OUT PPAGED_LOOKASIDE_LIST Lookaside);
 
-#if defined(_WIN64)
 NTKERNELAPI
-BOOLEAN
-IoIs32bitProcess(
-  IN PIRP  Irp  OPTIONAL);
-#endif
+VOID
+NTAPI
+ExFreeToPagedLookasideList(
+  IN OUT PPAGED_LOOKASIDE_LIST Lookaside,
+  IN PVOID Entry);
 
-#define PLUGPLAY_REGKEY_DEVICE                            1
-#define PLUGPLAY_REGKEY_DRIVER                            2
-#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE                 4
+#else /* !_WIN2K_COMPAT_SLIST_USAGE */
 
-FORCEINLINE
-PIO_STACK_LOCATION
-IoGetCurrentIrpStackLocation(
-  IN PIRP Irp)
+#if !defined(_WIN64)
+#define ExInterlockedPopEntrySList(_ListHead, _Lock) \
+    InterlockedPopEntrySList(_ListHead)
+#define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \
+    InterlockedPushEntrySList(_ListHead, _ListEntry)
+#endif
+
+static __inline
+PVOID
+ExAllocateFromPagedLookasideList(
+  IN OUT PPAGED_LOOKASIDE_LIST Lookaside)
 {
-  ASSERT(Irp->CurrentLocation <= Irp->StackCount + 1);
-  return Irp->Tail.Overlay.CurrentStackLocation;
+  PVOID Entry;
+
+  Lookaside->L.TotalAllocates++;
+  Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
+  if (Entry == NULL) {
+    Lookaside->L.AllocateMisses++;
+    Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
+                                    Lookaside->L.Size,
+                                    Lookaside->L.Tag);
+  }
+  return Entry;
 }
 
-FORCEINLINE
+static __inline
 VOID
-IoMarkIrpPending(
-  IN OUT PIRP Irp)
+ExFreeToPagedLookasideList(
+  IN OUT PPAGED_LOOKASIDE_LIST Lookaside,
+  IN PVOID Entry)
 {
-  IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED;
+  Lookaside->L.TotalFrees++;
+  if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
+    Lookaside->L.FreeMisses++;
+    (Lookaside->L.Free)(Entry);
+  } else {
+    InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
+  }
 }
 
-/*
- * BOOLEAN
- * IoIsErrorUserInduced(
- *   IN NTSTATUS  Status);
- */
-#define IoIsErrorUserInduced(Status) \
-   ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \
-   ((Status) == STATUS_IO_TIMEOUT) || \
-   ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
-   ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
-   ((Status) == STATUS_VERIFY_REQUIRED) || \
-   ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
-   ((Status) == STATUS_WRONG_VOLUME)))
+#endif /* _WIN2K_COMPAT_SLIST_USAGE */
 
-/* VOID
- * IoInitializeRemoveLock(
- *   IN PIO_REMOVE_LOCK  Lock,
- *   IN ULONG  AllocateTag,
- *   IN ULONG  MaxLockedMinutes,
- *   IN ULONG  HighWatermark)
- */
-#define IoInitializeRemoveLock( \
-  Lock, AllocateTag, MaxLockedMinutes, HighWatermark) \
-  IoInitializeRemoveLockEx(Lock, AllocateTag, MaxLockedMinutes, \
-    HighWatermark, sizeof(IO_REMOVE_LOCK))
 
-VOID
-FORCEINLINE
-IoInitializeDpcRequest(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIO_DPC_ROUTINE DpcRoutine)
-{
-  KeInitializeDpc( &DeviceObject->Dpc,
-                   (PKDEFERRED_ROUTINE) DpcRoutine,
-                   DeviceObject );
-}
+/* ERESOURCE_THREAD
+ * ExGetCurrentResourceThread(
+ *     VOID);
+ */
+#define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread())
 
-#define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
+#define ExReleaseResource(R) (ExReleaseResourceLite(R))
 
-/*
- * ULONG
- * IoGetFunctionCodeFromCtlCode(
- *   IN ULONG  ControlCode)
+/* VOID
+ * ExInitializeWorkItem(
+ *     IN PWORK_QUEUE_ITEM Item,
+ *     IN PWORKER_THREAD_ROUTINE Routine,
+ *     IN PVOID Context)
  */
-#define IoGetFunctionCodeFromCtlCode(_ControlCode) \
-  (((_ControlCode) >> 2) & 0x00000FFF)
+#define ExInitializeWorkItem(Item, Routine, Context) \
+{ \
+  (Item)->WorkerRoutine = Routine; \
+  (Item)->Parameter = Context; \
+  (Item)->List.Flink = NULL; \
+}
 
 FORCEINLINE
 VOID
-IoCopyCurrentIrpStackLocationToNext(
-  IN OUT PIRP Irp)
+ExInitializeFastMutex(
+  OUT PFAST_MUTEX FastMutex)
 {
-  PIO_STACK_LOCATION irpSp;
-  PIO_STACK_LOCATION nextIrpSp;
-  irpSp = IoGetCurrentIrpStackLocation(Irp);
-  nextIrpSp = IoGetNextIrpStackLocation(Irp);
-  RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine));
-  nextIrpSp->Control = 0;
+  FastMutex->Count = FM_LOCK_BIT;
+  FastMutex->Owner = NULL;
+  FastMutex->Contention = 0;
+  KeInitializeEvent(&FastMutex->Event, SynchronizationEvent, FALSE);
+  return;
 }
 
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
+
 NTKERNELAPI
 VOID
-NTAPI
-IoGetStackLimits(
-  OUT PULONG_PTR  LowLimit,
-  OUT PULONG_PTR  HighLimit);
-
-FORCEINLINE
-ULONG_PTR
-IoGetRemainingStackSize(VOID)
-{
-  ULONG_PTR End, Begin;
-  ULONG_PTR Result;
-
-  IoGetStackLimits(&Begin, &End);
-  Result = (ULONG_PTR)(&End) - Begin;
-  return Result;
-}
+FASTCALL
+ExAcquireFastMutexUnsafe(
+    IN OUT PFAST_MUTEX FastMutex);
 
-#if (NTDDI_VERSION >= NTDDI_WS03)
+NTKERNELAPI
 VOID
-FORCEINLINE
-IoInitializeThreadedDpcRequest(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIO_DPC_ROUTINE DpcRoutine)
-{
-  KeInitializeThreadedDpc(&DeviceObject->Dpc,
-                          (PKDEFERRED_ROUTINE) DpcRoutine,
-                          DeviceObject );
-}
-#endif
-
-/******************************************************************************
- *                     Power Management Support Functions                     *
- ******************************************************************************/
+FASTCALL
+ExReleaseFastMutexUnsafe(
+    IN OUT PFAST_MUTEX FastMutex);
 
-#define PoSetDeviceBusy(IdlePointer) ((void)(*(IdlePointer) = 0))
+NTKERNELAPI
+BOOLEAN
+NTAPI
+ExAcquireResourceExclusiveLite(
+  IN OUT PERESOURCE Resource,
+    IN BOOLEAN Wait);
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+NTKERNELAPI
+BOOLEAN
+NTAPI
+ExAcquireResourceSharedLite(
+  IN OUT PERESOURCE Resource,
+    IN BOOLEAN Wait);
 
 NTKERNELAPI
-NTSTATUS
+BOOLEAN
 NTAPI
-PoCallDriver(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN OUT struct _IRP  *Irp);
+ExAcquireSharedStarveExclusive(
+  IN OUT PERESOURCE Resource,
+    IN BOOLEAN Wait);
 
 NTKERNELAPI
-PULONG
+BOOLEAN
 NTAPI
-PoRegisterDeviceForIdleDetection(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN ULONG  ConservationIdleTime,
-  IN ULONG  PerformanceIdleTime,
-  IN DEVICE_POWER_STATE  State);
+ExAcquireSharedWaitForExclusive(
+  IN OUT PERESOURCE Resource,
+    IN BOOLEAN Wait);
 
 NTKERNELAPI
 PVOID
 NTAPI
-PoRegisterSystemState(
-  IN OUT PVOID StateHandle OPTIONAL,
-  IN EXECUTION_STATE Flags);
+ExAllocatePool(
+    IN POOL_TYPE PoolType,
+    IN SIZE_T NumberOfBytes);
 
 NTKERNELAPI
-NTSTATUS
+PVOID
 NTAPI
-PoRequestPowerIrp(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN UCHAR  MinorFunction,
-  IN POWER_STATE  PowerState,
-  IN PREQUEST_POWER_COMPLETE  CompletionFunction OPTIONAL,
-  IN PVOID  Context OPTIONAL,
-  OUT struct _IRP  **Irp OPTIONAL);
+ExAllocatePoolWithQuota(
+    IN POOL_TYPE PoolType,
+    IN SIZE_T NumberOfBytes);
 
 NTKERNELAPI
-POWER_STATE
+PVOID
 NTAPI
-PoSetPowerState(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN POWER_STATE_TYPE  Type,
-  IN POWER_STATE  State);
+ExAllocatePoolWithQuotaTag(
+  IN POOL_TYPE  PoolType,
+  IN SIZE_T  NumberOfBytes,
+  IN ULONG  Tag);
+
+#ifndef POOL_TAGGING
+#define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b)
+#endif
 
 NTKERNELAPI
-VOID
+PVOID
 NTAPI
-PoSetSystemState(
-  IN EXECUTION_STATE  Flags);
+ExAllocatePoolWithTag(
+    IN POOL_TYPE PoolType,
+    IN SIZE_T NumberOfBytes,
+    IN ULONG Tag);
+
+#ifndef POOL_TAGGING
+#define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b)
+#endif
 
 NTKERNELAPI
-VOID
+PVOID
 NTAPI
-PoStartNextPowerIrp(
-  IN OUT struct _IRP *Irp);
+ExAllocatePoolWithTagPriority(
+    IN POOL_TYPE PoolType,
+    IN SIZE_T NumberOfBytes,
+    IN ULONG Tag,
+    IN EX_POOL_PRIORITY Priority);
 
 NTKERNELAPI
 VOID
 NTAPI
-PoUnregisterSystemState(
-  IN OUT PVOID StateHandle);
+ExConvertExclusiveToSharedLite(
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-PoRequestShutdownEvent(
-  OUT PVOID *Event);
-
-#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
-
-#if (NTDDI_VERSION >= NTDDI_VISTA)
+ExCreateCallback(
+    OUT PCALLBACK_OBJECT *CallbackObject,
+    IN POBJECT_ATTRIBUTES ObjectAttributes,
+    IN BOOLEAN Create,
+    IN BOOLEAN AllowMultipleCallbacks);
 
 NTKERNELAPI
 VOID
 NTAPI
-PoSetSystemWake(
-  IN OUT struct _IRP *Irp);
+ExDeleteNPagedLookasideList(
+  IN OUT PNPAGED_LOOKASIDE_LIST Lookaside);
 
 NTKERNELAPI
-BOOLEAN
+VOID
 NTAPI
-PoGetSystemWake(
-  IN struct _IRP *Irp);
+ExDeletePagedLookasideList(
+    IN PPAGED_LOOKASIDE_LIST Lookaside);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-PoRegisterPowerSettingCallback(
-  IN PDEVICE_OBJECT DeviceObject OPTIONAL,
-  IN LPCGUID SettingGuid,
-  IN PPOWER_SETTING_CALLBACK Callback,
-  IN PVOID Context OPTIONAL,
-  OUT PVOID *Handle OPTIONAL);
+ExDeleteResourceLite(
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-PoUnregisterPowerSettingCallback(
-  IN OUT PVOID Handle);
-
-#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
+ExFreePool(
+    IN PVOID P);
 
-#if (NTDDI_VERSION >= NTDDI_VISTASP1)
 NTKERNELAPI
 VOID
 NTAPI
-PoSetDeviceBusyEx(
-  IN OUT PULONG IdlePointer);
-#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */
-
-#if (NTDDI_VERSION >= NTDDI_WIN7)
+ExFreePoolWithTag(
+    IN PVOID P,
+    IN ULONG Tag);
 
 NTKERNELAPI
-VOID
+ULONG
 NTAPI
-PoStartDeviceBusy(
-  IN OUT PULONG IdlePointer);
+ExGetExclusiveWaiterCount(
+    IN PERESOURCE Resource);
 
 NTKERNELAPI
-VOID
+KPROCESSOR_MODE
 NTAPI
-PoEndDeviceBusy(
-  IN OUT PULONG IdlePointer);
+ExGetPreviousMode(VOID);
 
 NTKERNELAPI
-BOOLEAN
+ULONG
 NTAPI
-PoQueryWatchdogTime(
-  IN PDEVICE_OBJECT Pdo,
-  OUT PULONG SecondsRemaining);
+ExGetSharedWaiterCount(
+    IN PERESOURCE Resource);
 
 NTKERNELAPI
 VOID
 NTAPI
-PoDeletePowerRequest(
-  IN OUT PVOID PowerRequest);
+ExInitializeNPagedLookasideList(
+    IN PNPAGED_LOOKASIDE_LIST Lookaside,
+    IN PALLOCATE_FUNCTION Allocate OPTIONAL,
+    IN PFREE_FUNCTION Free OPTIONAL,
+    IN ULONG Flags,
+    IN SIZE_T Size,
+    IN ULONG Tag,
+    IN USHORT Depth);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-PoSetPowerRequest(
-  IN OUT PVOID PowerRequest,
-  IN POWER_REQUEST_TYPE Type);
+ExInitializePagedLookasideList(
+    IN PPAGED_LOOKASIDE_LIST Lookaside,
+    IN PALLOCATE_FUNCTION Allocate OPTIONAL,
+    IN PFREE_FUNCTION Free OPTIONAL,
+    IN ULONG Flags,
+    IN SIZE_T Size,
+    IN ULONG Tag,
+    IN USHORT Depth);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-PoClearPowerRequest(
-  IN OUT PVOID PowerRequest,
-  IN POWER_REQUEST_TYPE Type);
+ExInitializeResourceLite(
+  OUT PERESOURCE Resource);
 
 NTKERNELAPI
-NTSTATUS
+LARGE_INTEGER
 NTAPI
-PoCreatePowerRequest(
-  OUT PVOID *PowerRequest,
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PCOUNTED_REASON_CONTEXT Context);
-
-#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
-
-/******************************************************************************
- *                          Executive Functions                               *
- ******************************************************************************/
-
-#define ExInterlockedIncrementLong(Addend,Lock) Exfi386InterlockedIncrementLong(Addend)
-#define ExInterlockedDecrementLong(Addend,Lock) Exfi386InterlockedDecrementLong(Addend)
-#define ExInterlockedExchangeUlong(Target, Value, Lock) Exfi386InterlockedExchangeUlong(Target, Value)
-
-#define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
-#define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
-#define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
-#define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
-
-#define ExInitializeSListHead InitializeSListHead
-
-#if defined(_X86_)
-#if defined(_NTHAL_)
-#define ExAcquireFastMutex ExiAcquireFastMutex
-#define ExReleaseFastMutex ExiReleaseFastMutex
-#define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex
-#endif
-#define ExInterlockedAddUlong ExfInterlockedAddUlong
-#define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList
-#define ExInterlockedInsertTailList ExfInterlockedInsertTailList
-#define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList
-#define ExInterlockedPopEntryList ExfInterlockedPopEntryList
-#define ExInterlockedPushEntryList ExfInterlockedPushEntryList
-#endif /* defined(_X86_) */
+ExInterlockedAddLargeInteger(
+    IN PLARGE_INTEGER Addend,
+    IN LARGE_INTEGER Increment,
+    IN PKSPIN_LOCK Lock);
 
 #if defined(_WIN64)
-
-#if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || \
-    defined(_NTHAL_) || defined(_NTOSP_)
-NTKERNELAPI
-USHORT
-ExQueryDepthSList(IN PSLIST_HEADER ListHead);
+#define ExInterlockedAddLargeStatistic(Addend, Increment) \
+    (VOID)InterlockedAdd64(&(Addend)->QuadPart, Increment)
 #else
-FORCEINLINE
-USHORT
-ExQueryDepthSList(IN PSLIST_HEADER ListHead)
-{
-    return (USHORT)(ListHead->Alignment & 0xffff);
-}
+#define ExInterlockedAddLargeStatistic(Addend, Increment) \
+    _InterlockedAddLargeStatistic((PLONGLONG)&(Addend)->QuadPart, Increment)
 #endif
 
 NTKERNELAPI
-PSLIST_ENTRY
-ExpInterlockedFlushSList(
-    PSLIST_HEADER ListHead);
-
-NTKERNELAPI
-PSLIST_ENTRY
-ExpInterlockedPopEntrySList(
-    PSLIST_HEADER ListHead);
-
-NTKERNELAPI
-PSLIST_ENTRY
-ExpInterlockedPushEntrySList(
-    PSLIST_HEADER ListHead,
-    PSLIST_ENTRY ListEntry);
-
-#define ExInterlockedFlushSList(Head) \
-    ExpInterlockedFlushSList(Head)
-#define ExInterlockedPopEntrySList(Head, Lock) \
-    ExpInterlockedPopEntrySList(Head)
-#define ExInterlockedPushEntrySList(Head, Entry, Lock) \
-    ExpInterlockedPushEntrySList(Head, Entry)
-
-#else /* !defined(_WIN64) */
-
-#define ExQueryDepthSList(listhead) (listhead)->Depth
-
-NTKERNELAPI
-PSINGLE_LIST_ENTRY
+ULONG
 FASTCALL
-ExInterlockedFlushSList(
-  IN OUT PSLIST_HEADER ListHead);
+ExInterlockedAddUlong(
+    IN PULONG Addend,
+    IN ULONG Increment,
+  IN OUT PKSPIN_LOCK Lock);
 
-#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
+#if defined(_AMD64_) || defined(_IA64_)
 
-NTKERNELAPI
-PSINGLE_LIST_ENTRY 
-FASTCALL
-ExInterlockedPopEntrySList(
-    IN PSLIST_HEADER ListHead,
-    IN PKSPIN_LOCK Lock);
+#define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
+    InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand))
+
+#elif defined(_X86_)
 
 NTKERNELAPI
-PSINGLE_LIST_ENTRY 
+LONGLONG
 FASTCALL
-ExInterlockedPushEntrySList(
-    IN PSLIST_HEADER ListHead,
-    IN PSINGLE_LIST_ENTRY ListEntry,
-    IN PKSPIN_LOCK Lock);
-#else
-#define ExInterlockedPopEntrySList(_ListHead, _Lock) \
-    InterlockedPopEntrySList(_ListHead)
-#define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \
-    InterlockedPushEntrySList(_ListHead, _ListEntry)
-#endif // _WIN2K_COMPAT_SLIST_USAGE
-
-#endif // !defined(_WIN64)
-
-/* ERESOURCE_THREAD
- * ExGetCurrentResourceThread(
- *     VOID);
- */
-#define ExGetCurrentResourceThread() ((ERESOURCE_THREAD)PsGetCurrentThread())
-
-#define ExReleaseResource(R) (ExReleaseResourceLite(R))
+ExfInterlockedCompareExchange64(
+    IN OUT LONGLONG volatile *Destination,
+    IN PLONGLONG Exchange,
+    IN PLONGLONG Comperand);
 
-/* VOID
- * ExInitializeWorkItem(
- *     IN PWORK_QUEUE_ITEM Item,
- *     IN PWORKER_THREAD_ROUTINE Routine,
- *     IN PVOID Context)
- */
-#define ExInitializeWorkItem(Item, Routine, Context) \
-{ \
-  (Item)->WorkerRoutine = Routine; \
-  (Item)->Parameter = Context; \
-  (Item)->List.Flink = NULL; \
-}
+#define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
+    ExfInterlockedCompareExchange64(Destination, Exchange, Comperand)
 
-FORCEINLINE
-VOID
-ExInitializeFastMutex(
-  OUT PFAST_MUTEX FastMutex)
-{
-  FastMutex->Count = FM_LOCK_BIT;
-  FastMutex->Owner = NULL;
-  FastMutex->Contention = 0;
-  KeInitializeEvent(&FastMutex->Event, SynchronizationEvent, FALSE);
-  return;
-}
+#else
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+NTKERNELAPI
+LONGLONG
+FASTCALL
+ExInterlockedCompareExchange64(
+    IN OUT LONGLONG volatile *Destination,
+    IN PLONGLONG Exchange,
+    IN PLONGLONG Comparand,
+    IN PKSPIN_LOCK Lock);
+
+#endif /* defined(_AMD64_) || defined(_IA64_) */
 
 NTKERNELAPI
-VOID
+PLIST_ENTRY
 FASTCALL
-ExAcquireFastMutex(
-    IN OUT PFAST_MUTEX FastMutex);
+ExInterlockedInsertHeadList(
+  IN OUT PLIST_ENTRY ListHead,
+  IN OUT PLIST_ENTRY ListEntry,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
-VOID
+PLIST_ENTRY
 FASTCALL
-ExReleaseFastMutex(
-    IN OUT PFAST_MUTEX FastMutex);
+ExInterlockedInsertTailList(
+  IN OUT PLIST_ENTRY ListHead,
+  IN OUT PLIST_ENTRY ListEntry,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
-BOOLEAN
+PSINGLE_LIST_ENTRY
 FASTCALL
-ExTryToAcquireFastMutex(
-    IN OUT PFAST_MUTEX FastMutex);
+ExInterlockedPopEntryList(
+  IN OUT PSINGLE_LIST_ENTRY ListHead,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
-VOID
+PSINGLE_LIST_ENTRY
 FASTCALL
-ExAcquireFastMutexUnsafe(
-    IN OUT PFAST_MUTEX FastMutex);
+ExInterlockedPushEntryList(
+  IN OUT PSINGLE_LIST_ENTRY ListHead,
+  IN OUT PSINGLE_LIST_ENTRY ListEntry,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
-VOID
+PLIST_ENTRY
 FASTCALL
-ExReleaseFastMutexUnsafe(
-    IN OUT PFAST_MUTEX FastMutex);
+ExInterlockedRemoveHeadList(
+  IN OUT PLIST_ENTRY ListHead,
+  IN OUT PKSPIN_LOCK Lock);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
-ExAcquireResourceExclusiveLite(
-  IN OUT PERESOURCE Resource,
-    IN BOOLEAN Wait);
+ExIsProcessorFeaturePresent(
+    IN ULONG ProcessorFeature);
 
 NTKERNELAPI
 BOOLEAN
 NTAPI
-ExAcquireResourceSharedLite(
-  IN OUT PERESOURCE Resource,
-    IN BOOLEAN Wait);
+ExIsResourceAcquiredExclusiveLite(
+    IN PERESOURCE Resource);
 
 NTKERNELAPI
-BOOLEAN
+ULONG
 NTAPI
-ExAcquireSharedStarveExclusive(
-  IN OUT PERESOURCE Resource,
-    IN BOOLEAN Wait);
+ExIsResourceAcquiredSharedLite(
+    IN PERESOURCE Resource);
+
+#define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite
 
 NTKERNELAPI
-BOOLEAN
+VOID
 NTAPI
-ExAcquireSharedWaitForExclusive(
-  IN OUT PERESOURCE Resource,
-    IN BOOLEAN Wait);
+ExLocalTimeToSystemTime(
+    IN PLARGE_INTEGER LocalTime,
+    OUT PLARGE_INTEGER SystemTime);
 
 NTKERNELAPI
-PVOID
+VOID
 NTAPI
-ExAllocatePool(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes);
-
-#ifdef POOL_TAGGING
-#define ExAllocatePool(p,n) ExAllocatePoolWithTag(p,n,' kdD')
-#endif /* POOL_TAGGING */
+ExNotifyCallback(
+    IN PCALLBACK_OBJECT CallbackObject,
+  IN PVOID Argument1 OPTIONAL,
+  IN PVOID Argument2 OPTIONAL);
 
 NTKERNELAPI
-PVOID
+VOID
 NTAPI
-ExAllocatePoolWithQuota(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes);
-
-#ifdef POOL_TAGGING
-#define ExAllocatePoolWithQuota(p,n) ExAllocatePoolWithQuotaTag(p,n,' kdD')
-#endif /* POOL_TAGGING */
+ExQueueWorkItem(
+  IN OUT PWORK_QUEUE_ITEM WorkItem,
+    IN WORK_QUEUE_TYPE QueueType);
 
 NTKERNELAPI
-PVOID
+DECLSPEC_NORETURN
+VOID
 NTAPI
-ExAllocatePoolWithQuotaTag(
-  IN POOL_TYPE  PoolType,
-  IN SIZE_T  NumberOfBytes,
-  IN ULONG  Tag);
-
-#ifndef POOL_TAGGING
-#define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b)
-#endif
+ExRaiseStatus(
+    IN NTSTATUS Status);
 
 NTKERNELAPI
 PVOID
 NTAPI
-ExAllocatePoolWithTag(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes,
-    IN ULONG Tag);
+ExRegisterCallback(
+    IN PCALLBACK_OBJECT CallbackObject,
+    IN PCALLBACK_FUNCTION CallbackFunction,
+  IN PVOID CallbackContext OPTIONAL);
 
 NTKERNELAPI
-PVOID
+NTSTATUS
 NTAPI
-ExAllocatePoolWithTagPriority(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes,
-    IN ULONG Tag,
-    IN EX_POOL_PRIORITY Priority);
+ExReinitializeResourceLite(
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 VOID
 NTAPI
-ExConvertExclusiveToSharedLite(
+ExReleaseResourceForThreadLite(
+  IN OUT PERESOURCE Resource,
+    IN ERESOURCE_THREAD ResourceThreadId);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExReleaseResourceLite(
   IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-ExCreateCallback(
-    OUT PCALLBACK_OBJECT *CallbackObject,
-    IN POBJECT_ATTRIBUTES ObjectAttributes,
-    IN BOOLEAN Create,
-    IN BOOLEAN AllowMultipleCallbacks);
+ExSetResourceOwnerPointer(
+  IN OUT PERESOURCE Resource,
+    IN PVOID OwnerPointer);
 
 NTKERNELAPI
-VOID
+ULONG
 NTAPI
-ExDeleteNPagedLookasideList(
-  IN OUT PNPAGED_LOOKASIDE_LIST Lookaside);
+ExSetTimerResolution(
+    IN ULONG DesiredTime,
+    IN BOOLEAN SetResolution);
 
 NTKERNELAPI
 VOID
 NTAPI
-ExDeletePagedLookasideList(
-    IN PPAGED_LOOKASIDE_LIST Lookaside);
+ExSystemTimeToLocalTime(
+    IN PLARGE_INTEGER SystemTime,
+    OUT PLARGE_INTEGER LocalTime);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-ExDeleteResourceLite(
-  IN OUT PERESOURCE Resource);
+ExUnregisterCallback(
+  IN OUT PVOID CbRegistration);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+
+#if (NTDDI_VERSION >= NTDDI_WINXP)
+
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+ExAcquireRundownProtection(
+    IN OUT PEX_RUNDOWN_REF RunRef);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExInitializeRundownProtection(
+    OUT PEX_RUNDOWN_REF RunRef);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExReInitializeRundownProtection(
+  IN OUT PEX_RUNDOWN_REF RunRef);
+
+NTKERNELAPI
+VOID
+FASTCALL
+ExReleaseRundownProtection(
+    IN OUT PEX_RUNDOWN_REF RunRef);
 
 NTKERNELAPI
 VOID
+FASTCALL
+ExRundownCompleted(
+    OUT PEX_RUNDOWN_REF RunRef);
+
+NTKERNELAPI
+BOOLEAN
 NTAPI
-ExFreePool(
-    IN PVOID P);
+ExVerifySuite(
+    IN SUITE_TYPE SuiteType);
 
-#ifdef POOL_TAGGING
-#define ExFreePool(P) ExFreePoolWithTag(P, 0)
-#endif
+NTKERNELAPI
+VOID
+FASTCALL
+ExWaitForRundownProtectionRelease(
+    IN OUT PEX_RUNDOWN_REF RunRef);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
+
+#if (NTDDI_VERSION >= NTDDI_WINXPSP2)
+
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+ExAcquireRundownProtectionEx(
+    IN OUT PEX_RUNDOWN_REF RunRef,
+    IN ULONG Count);
 
 NTKERNELAPI
 VOID
+FASTCALL
+ExReleaseRundownProtectionEx(
+    IN OUT PEX_RUNDOWN_REF RunRef,
+    IN ULONG Count);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
+
+#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+
+NTKERNELAPI
+PEX_RUNDOWN_REF_CACHE_AWARE
 NTAPI
-ExFreePoolWithTag(
-    IN PVOID P,
-    IN ULONG Tag);
+ExAllocateCacheAwareRundownProtection(
+    IN POOL_TYPE PoolType,
+    IN ULONG PoolTag);
 
 NTKERNELAPI
-ULONG
+SIZE_T
 NTAPI
-ExGetExclusiveWaiterCount(
-    IN PERESOURCE Resource);
+ExSizeOfRundownProtectionCacheAware(VOID);
 
 NTKERNELAPI
-KPROCESSOR_MODE
+PVOID
 NTAPI
-ExGetPreviousMode(VOID);
+ExEnterCriticalRegionAndAcquireResourceShared(
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
-ULONG
+PVOID
 NTAPI
-ExGetSharedWaiterCount(
-    IN PERESOURCE Resource);
+ExEnterCriticalRegionAndAcquireResourceExclusive(
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
-VOID
+PVOID
 NTAPI
-ExInitializeNPagedLookasideList(
-    IN PNPAGED_LOOKASIDE_LIST Lookaside,
-    IN PALLOCATE_FUNCTION Allocate OPTIONAL,
-    IN PFREE_FUNCTION Free OPTIONAL,
-    IN ULONG Flags,
-    IN SIZE_T Size,
-    IN ULONG Tag,
-    IN USHORT Depth);
+ExEnterCriticalRegionAndAcquireSharedWaitForExclusive(
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
 VOID
-NTAPI
-ExInitializePagedLookasideList(
-    IN PPAGED_LOOKASIDE_LIST Lookaside,
-    IN PALLOCATE_FUNCTION Allocate OPTIONAL,
-    IN PFREE_FUNCTION Free OPTIONAL,
-    IN ULONG Flags,
-    IN SIZE_T Size,
-    IN ULONG Tag,
-    IN USHORT Depth);
+FASTCALL
+ExReleaseResourceAndLeaveCriticalRegion(
+  IN OUT PERESOURCE Resource);
 
 NTKERNELAPI
-NTSTATUS
+VOID
 NTAPI
-ExInitializeResourceLite(
-  OUT PERESOURCE Resource);
+ExInitializeRundownProtectionCacheAware(
+  OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
+  IN SIZE_T RunRefSize);
 
 NTKERNELAPI
-LARGE_INTEGER
+VOID
 NTAPI
-ExInterlockedAddLargeInteger(
-    IN PLARGE_INTEGER Addend,
-    IN LARGE_INTEGER Increment,
-    IN PKSPIN_LOCK Lock);
-
-#if defined(_WIN64)
-#define ExInterlockedAddLargeStatistic(Addend, Increment) \
-    (VOID)InterlockedAdd64(&(Addend)->QuadPart, Increment)
-#else
-#define ExInterlockedAddLargeStatistic(Addend, Increment) \
-    _InterlockedAddLargeStatistic((PLONGLONG)&(Addend)->QuadPart, Increment)
-#endif
+ExFreeCacheAwareRundownProtection(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
 
 NTKERNELAPI
-ULONG
+BOOLEAN
 FASTCALL
-ExInterlockedAddUlong(
-    IN PULONG Addend,
-    IN ULONG Increment,
-  IN OUT PKSPIN_LOCK Lock);
-
-#if defined(_AMD64_) || defined(_IA64_)
-
-#define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
-    InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand))
-
-#elif defined(_X86_)
+ExAcquireRundownProtectionCacheAware(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
 
 NTKERNELAPI
-LONGLONG
+VOID
 FASTCALL
-ExfInterlockedCompareExchange64(
-    IN OUT LONGLONG volatile *Destination,
-    IN PLONGLONG Exchange,
-    IN PLONGLONG Comperand);
-
-#define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \
-    ExfInterlockedCompareExchange64(Destination, Exchange, Comperand)
-
-#else
+ExReleaseRundownProtectionCacheAware(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
 
 NTKERNELAPI
-LONGLONG
+BOOLEAN
 FASTCALL
-ExInterlockedCompareExchange64(
-    IN OUT LONGLONG volatile *Destination,
-    IN PLONGLONG Exchange,
-    IN PLONGLONG Comparand,
-    IN PKSPIN_LOCK Lock);
-
-#endif /* defined(_AMD64_) || defined(_IA64_) */
+ExAcquireRundownProtectionCacheAwareEx(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
+  IN ULONG Count);
 
 NTKERNELAPI
-PLIST_ENTRY
+VOID
 FASTCALL
-ExInterlockedInsertHeadList(
-  IN OUT PLIST_ENTRY ListHead,
-  IN OUT PLIST_ENTRY ListEntry,
-  IN OUT PKSPIN_LOCK Lock);
+ExReleaseRundownProtectionCacheAwareEx(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef,
+  IN ULONG Count);
 
 NTKERNELAPI
-PLIST_ENTRY
+VOID
 FASTCALL
-ExInterlockedInsertTailList(
-  IN OUT PLIST_ENTRY ListHead,
-  IN OUT PLIST_ENTRY ListEntry,
-  IN OUT PKSPIN_LOCK Lock);
+ExWaitForRundownProtectionReleaseCacheAware(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef);
 
 NTKERNELAPI
-PSINGLE_LIST_ENTRY
+VOID
 FASTCALL
-ExInterlockedPopEntryList(
-  IN OUT PSINGLE_LIST_ENTRY ListHead,
-  IN OUT PKSPIN_LOCK Lock);
+ExReInitializeRundownProtectionCacheAware(
+  IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware);
 
 NTKERNELAPI
-PSINGLE_LIST_ENTRY
+VOID
 FASTCALL
-ExInterlockedPushEntryList(
-  IN OUT PSINGLE_LIST_ENTRY ListHead,
-  IN OUT PSINGLE_LIST_ENTR