[FREELDR] Include ntddk.h instead of winddk.h
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 11 Mar 2010 14:49:41 +0000 (14:49 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 11 Mar 2010 14:49:41 +0000 (14:49 +0000)
[RAMDISK] Add missing DO_XIP definition (not in WDK/DDK)
[FASTFAT] Remove duplicate VOLUME_IS_DIRTY definition
[HAL] Add case stubs for missing HAL_QUERY_INFORMATION_CLASS members
[NDK] Fix DbgPrompt prototype
[NTDDK]
- Move from winddk.h: _KUSER_SHARED_DATA (updated), pHalIoAssignDriveLetters, PHAL_RESET_DISPLAY_PARAMETERS, HAL_DISPATCH, HalDispatchTable, PCREATE_PROCESS_NOTIFY_ROUTINE, PCREATE_THREAD_NOTIFY_ROUTINE, IMAGE_INFO, PLOAD_IMAGE_NOTIFY_ROUTINE, BUS_DATA_TYPE (updated), PROCESSINFOCLASS (updated), THREADINFOCLASS (updated), DISK_SIGNATURE, PTIMER_APC_ROUTINE, Exfi386InterlockedIncrementLong, Exfi386InterlockedDecrementLong, Exfi386InterlockedExchangeUlong
- Add pHalGetAcpiTable, PCI_ERROR_HANDLER_CALLBACK, pHalSetPciErrorHandlerCallback
[WDM] Add _DECL_HAL_KE_IMPORT, Reorder sections (types before functions)

svn path=/branches/header-work/; revision=46097

boot/freeldr/freeldr/include/ntoskrnl.h
drivers/filesystems/fastfat/fsctl.c
drivers/storage/class/ramdisk/ramdisk.c
hal/halx86/generic/sysinfo.c
include/ddk/ntddk.h
include/ddk/ntifs.h
include/ddk/wdm.h
include/ddk/winddk.h
include/ndk/rtlfuncs.h

index fee926d..f2e9e46 100644 (file)
@@ -1,18 +1,16 @@
 #include <ntdef.h>
 #undef _NTHAL_
-#undef DECLSPEC_IMPORT
-#define DECLSPEC_IMPORT
+//#undef DECLSPEC_IMPORT
+//#define DECLSPEC_IMPORT
 #undef NTSYSAPI
 #define NTSYSAPI
 
-#include <wdm.h>
-
-typedef GUID UUID;
-
 /* Windows Device Driver Kit */
-#include <winddk.h>
+#include <ntddk.h>
 #include <ndk/haltypes.h>
 
+//typedef GUID UUID;
+
 /* Disk stuff */
 typedef PVOID PLOADER_PARAMETER_BLOCK;
 #include <ntdddisk.h>
index 8b47aa8..c76f04f 100644 (file)
@@ -33,8 +33,6 @@
 #define  CACHEPAGESIZE(pDeviceExt) ((pDeviceExt)->FatInfo.BytesPerCluster > PAGE_SIZE ? \
                                     (pDeviceExt)->FatInfo.BytesPerCluster : PAGE_SIZE)
 
-#define VOLUME_IS_DIRTY 0x00000001
-
 static NTSTATUS
 VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
                   PBOOLEAN RecognizedFS,
index c56c791..1ebe196 100644 (file)
@@ -28,6 +28,8 @@
 #define NDEBUG
 #include <debug.h>
 
+#define DO_XIP   0x00020000
+
 /* GLOBALS ********************************************************************/
 
 #define RAMDISK_SESSION_SIZE \
index db12f00..d3a72c5 100644 (file)
@@ -49,6 +49,12 @@ HaliQuerySystemInformation(IN HAL_QUERY_INFORMATION_CLASS InformationClass,
                REPORT_THIS_CASE(HalPartitionIpiInterface);
                REPORT_THIS_CASE(HalPlatformInformation);
                REPORT_THIS_CASE(HalQueryProfileSourceList);
+               REPORT_THIS_CASE(HalInitLogInformation);
+               REPORT_THIS_CASE(HalFrequencyInformation);
+               REPORT_THIS_CASE(HalProcessorBrandString);
+               REPORT_THIS_CASE(HalHypervisorInformation);
+               REPORT_THIS_CASE(HalPlatformTimerInformation);
+               REPORT_THIS_CASE(HalAcpiAuditInformation);
        }
 #undef REPORT_THIS_CASE
 
index 288658a..cbc9edf 100644 (file)
 extern "C" {
 #endif
 
+struct _LOADER_PARAMETER_BLOCK;
+struct _CREATE_DISK;
+struct _DRIVE_LAYOUT_INFORMATION_EX;
+struct _SET_PARTITION_INFORMATION_EX;
+
 //
 // GUID and UUID
 //
@@ -611,6 +616,121 @@ VOID
 (DDKAPI *pKdCheckPowerButton)(
   VOID);
 
+typedef struct _KUSER_SHARED_DATA
+{
+    ULONG TickCountLowDeprecated;
+    ULONG TickCountMultiplier;
+    volatile KSYSTEM_TIME InterruptTime;
+    volatile KSYSTEM_TIME SystemTime;
+    volatile KSYSTEM_TIME TimeZoneBias;
+    USHORT ImageNumberLow;
+    USHORT ImageNumberHigh;
+    WCHAR NtSystemRoot[260];
+    ULONG MaxStackTraceDepth;
+    ULONG CryptoExponent;
+    ULONG TimeZoneId;
+    ULONG LargePageMinimum;
+    ULONG Reserved2[7];
+    NT_PRODUCT_TYPE NtProductType;
+    BOOLEAN ProductTypeIsValid;
+    ULONG NtMajorVersion;
+    ULONG NtMinorVersion;
+    BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
+    ULONG Reserved1;
+    ULONG Reserved3;
+    volatile ULONG TimeSlip;
+    ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
+    ULONG AltArchitecturePad[1];
+    LARGE_INTEGER SystemExpirationDate;
+    ULONG SuiteMask;
+    BOOLEAN KdDebuggerEnabled;
+#if (NTDDI_VERSION >= NTDDI_WINXPSP2)
+    UCHAR NXSupportPolicy;
+#endif
+    volatile ULONG ActiveConsoleId;
+    volatile ULONG DismountCount;
+    ULONG ComPlusPackage;
+    ULONG LastSystemRITEventTickCount;
+    ULONG NumberOfPhysicalPages;
+    BOOLEAN SafeBootMode;
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+    union {
+        UCHAR TscQpcData;
+        struct {
+            UCHAR TscQpcEnabled:1;
+            UCHAR TscQpcSpareFlag:1;
+            UCHAR TscQpcShift:6;
+        } DUMMYSTRUCTNAME;
+    } DUMMYUNIONNAME;
+    UCHAR TscQpcPad[2];
+#endif
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+    union {
+        ULONG SharedDataFlags;
+        struct {
+            ULONG DbgErrorPortPresent:1;
+            ULONG DbgElevationEnabled:1;
+            ULONG DbgVirtEnabled:1;
+            ULONG DbgInstallerDetectEnabled:1;
+            ULONG DbgSystemDllRelocated:1;
+            ULONG DbgDynProcessorEnabled:1;
+            ULONG DbgSEHValidationEnabled:1;
+            ULONG SpareBits:25;
+        } DUMMYSTRUCTNAME2;
+    } DUMMYUNIONNAME2;
+#else
+    ULONG TraceLogging;
+#endif
+    ULONG DataFlagsPad[1];
+    ULONGLONG TestRetInstruction;
+    ULONG SystemCall;
+    ULONG SystemCallReturn;
+    ULONGLONG SystemCallPad[3];
+    _ANONYMOUS_UNION union {
+        volatile KSYSTEM_TIME TickCount;
+        volatile ULONG64 TickCountQuad;
+        _ANONYMOUS_STRUCT struct {
+            ULONG ReservedTickCountOverlay[3];
+            ULONG TickCountPad[1];
+        } DUMMYSTRUCTNAME;
+    } DUMMYUNIONNAME3;
+    ULONG Cookie;
+    ULONG CookiePad[1];
+#if (NTDDI_VERSION >= NTDDI_WS03)
+    LONGLONG ConsoleSessionForegroundProcessId;
+    ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
+#endif
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+    USHORT UserModeGlobalLogger[16];
+#else
+    USHORT UserModeGlobalLogger[8];
+    ULONG HeapTracingPid[2];
+    ULONG CritSecTracingPid[2];
+#endif
+    ULONG ImageFileExecutionOptions;
+#if (NTDDI_VERSION >= NTDDI_VISTASP1)
+    ULONG LangGenerationCount;
+#else
+    /* 4 bytes padding */
+#endif
+    ULONGLONG Reserved5;
+    volatile ULONG64 InterruptTimeBias;
+#endif
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+    volatile ULONG64 TscQpcBias;
+    volatile ULONG ActiveProcessorCount;
+    volatile USHORT ActiveGroupCount;
+    USHORT Reserved4;
+    volatile ULONG AitSamplingValue;
+    volatile ULONG AppCompatFlag;
+    ULONGLONG SystemDllNativeRelocation;
+    ULONG SystemDllWowRelocation;
+    ULONG XStatePad[1];
+    XSTATE_CONFIGURATION XState;
+#endif
+} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
+
 #ifdef _X86_
 
 #define SIZE_OF_80387_REGISTERS   80
@@ -886,6 +1006,29 @@ ExRaiseDatatypeMisalignment(
 
 #endif
 
+#ifdef _X86_
+
+NTKERNELAPI
+INTERLOCKED_RESULT
+FASTCALL
+Exfi386InterlockedIncrementLong(
+  IN OUT LONG volatile *Addend);
+
+NTKERNELAPI
+INTERLOCKED_RESULT
+FASTCALL
+Exfi386InterlockedDecrementLong(
+  IN PLONG  Addend);
+
+NTKERNELAPI
+ULONG
+FASTCALL
+Exfi386InterlockedExchangeUlong(
+  IN PULONG  Target,
+  IN ULONG  Value);
+
+#endif /* _X86_ */
+
 #ifndef _ARC_DDK_
 #define _ARC_DDK_
 typedef enum _CONFIGURATION_TYPE {
@@ -1030,6 +1173,111 @@ typedef struct _PCIBUSDATA {
   PVOID Reserved[4];
 } PCIBUSDATA, *PPCIBUSDATA;
 
+typedef enum _BUS_DATA_TYPE {
+  ConfigurationSpaceUndefined = -1,
+  Cmos,
+  EisaConfiguration,
+  Pos,
+  CbusConfiguration,
+  PCIConfiguration,
+  VMEConfiguration,
+  NuBusConfiguration,
+  PCMCIAConfiguration,
+  MPIConfiguration,
+  MPSAConfiguration,
+  PNPISAConfiguration,
+  SgiInternalConfiguration,
+  MaximumBusDataType
+} BUS_DATA_TYPE, *PBUS_DATA_TYPE;
+
+typedef
+PVOID
+(NTAPI *pHalGetAcpiTable)(
+  IN ULONG Signature,
+  IN PCSTR OemId OPTIONAL,
+  IN PCSTR OemTableId OPTIONAL);
+
+typedef
+VOID
+(NTAPI *PCI_ERROR_HANDLER_CALLBACK)(
+  VOID);
+
+typedef
+VOID
+(NTAPI *pHalSetPciErrorHandlerCallback)(
+  IN PCI_ERROR_HANDLER_CALLBACK Callback);
+
+#if 1 /* Not present in WDK 7600 */
+typedef VOID
+(FASTCALL *pHalIoAssignDriveLetters)(
+  IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
+  IN PSTRING NtDeviceName,
+  OUT PUCHAR NtSystemPath,
+  OUT PSTRING NtSystemPathString);
+#endif
+
+typedef struct {
+  ULONG Version;
+  pHalQuerySystemInformation HalQuerySystemInformation;
+  pHalSetSystemInformation HalSetSystemInformation;
+  pHalQueryBusSlots HalQueryBusSlots;
+  ULONG Spare1;
+  pHalExamineMBR HalExamineMBR;
+#if 1 /* Not present in WDK 7600 */
+  pHalIoAssignDriveLetters HalIoAssignDriveLetters;
+#endif
+  pHalIoReadPartitionTable HalIoReadPartitionTable;
+  pHalIoSetPartitionInformation HalIoSetPartitionInformation;
+  pHalIoWritePartitionTable HalIoWritePartitionTable;
+  pHalHandlerForBus HalReferenceHandlerForBus;
+  pHalReferenceBusHandler HalReferenceBusHandler;
+  pHalReferenceBusHandler HalDereferenceBusHandler;
+  pHalInitPnpDriver HalInitPnpDriver;
+  pHalInitPowerManagement HalInitPowerManagement;
+  pHalGetDmaAdapter HalGetDmaAdapter;
+  pHalGetInterruptTranslator HalGetInterruptTranslator;
+  pHalStartMirroring HalStartMirroring;
+  pHalEndMirroring HalEndMirroring;
+  pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
+  pHalEndOfBoot HalEndOfBoot;
+  pHalMirrorVerify HalMirrorVerify;
+  pHalGetAcpiTable HalGetCachedAcpiTable;
+  pHalSetPciErrorHandlerCallback  HalSetPciErrorHandlerCallback;
+#if defined(_IA64_)
+  pHalGetErrorCapList HalGetErrorCapList;
+  pHalInjectError HalInjectError;
+#endif
+} HAL_DISPATCH, *PHAL_DISPATCH;
+
+/* GCC/MSVC and WDK compatible declaration */
+extern NTKERNELAPI HAL_DISPATCH HalDispatchTable;
+
+#if defined(_NTOSKRNL_) || defined(_BLDR_)
+#define HALDISPATCH (&HalDispatchTable)
+#else
+/* This is a WDK compatibility definition */
+#define HalDispatchTable (&HalDispatchTable)
+#define HALDISPATCH HalDispatchTable
+#endif
+
+#define HAL_DISPATCH_VERSION            3 // FIXME: when to use 4?
+#define HalDispatchTableVersion         HALDISPATCH->Version
+#define HalQuerySystemInformation       HALDISPATCH->HalQuerySystemInformation
+#define HalSetSystemInformation         HALDISPATCH->HalSetSystemInformation
+#define HalQueryBusSlots                HALDISPATCH->HalQueryBusSlots
+#define HalReferenceHandlerForBus       HALDISPATCH->HalReferenceHandlerForBus
+#define HalReferenceBusHandler          HALDISPATCH->HalReferenceBusHandler
+#define HalDereferenceBusHandler        HALDISPATCH->HalDereferenceBusHandler
+#define HalInitPnpDriver                HALDISPATCH->HalInitPnpDriver
+#define HalInitPowerManagement          HALDISPATCH->HalInitPowerManagement
+#define HalGetDmaAdapter                HALDISPATCH->HalGetDmaAdapter
+#define HalGetInterruptTranslator       HALDISPATCH->HalGetInterruptTranslator
+#define HalStartMirroring               HALDISPATCH->HalStartMirroring
+#define HalEndMirroring                 HALDISPATCH->HalEndMirroring
+#define HalMirrorPhysicalMemory         HALDISPATCH->HalMirrorPhysicalMemory
+#define HalEndOfBoot                    HALDISPATCH->HalEndOfBoot
+#define HalMirrorVerify                 HALDISPATCH->HalMirrorVerify
+
 /* Hardware Abstraction Layer Functions */
 
 #if !defined(NO_LEGACY_DRIVERS)
@@ -1094,6 +1342,12 @@ NTAPI
 HalPutDmaAdapter(
   IN PADAPTER_OBJECT DmaAdapter);
 
+typedef
+BOOLEAN
+(DDKAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
+  ULONG Columns,
+  ULONG Rows);
+
 NTHALAPI
 VOID
 NTAPI
@@ -1155,6 +1409,19 @@ HalExamineMBR(
   OUT PVOID *Buffer);
 #endif
 
+typedef struct _DISK_SIGNATURE {
+  ULONG  PartitionStyle;
+  _ANONYMOUS_UNION union {
+    struct {
+      ULONG  Signature;
+      ULONG  CheckSum;
+    } Mbr;
+    struct {
+      GUID  DiskId;
+    } Gpt;
+  } DUMMYUNIONNAME;
+} DISK_SIGNATURE, *PDISK_SIGNATURE;
+
 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) 
 // nothing here
 #else
@@ -1449,7 +1716,7 @@ NTSTATUS
 NTAPI
 IoCreateDisk(
   IN PDEVICE_OBJECT DeviceObject,
-  IN PCREATE_DISK Disk OPTIONAL);
+  IN struct _CREATE_DISK* Disk OPTIONAL);
 
 NTKERNELAPI
 NTSTATUS
@@ -1715,6 +1982,99 @@ MmUnmapVideoDisplay(
 
 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
 
+typedef enum _PROCESSINFOCLASS {
+  ProcessBasicInformation,
+  ProcessQuotaLimits,
+  ProcessIoCounters,
+  ProcessVmCounters,
+  ProcessTimes,
+  ProcessBasePriority,
+  ProcessRaisePriority,
+  ProcessDebugPort,
+  ProcessExceptionPort,
+  ProcessAccessToken,
+  ProcessLdtInformation,
+  ProcessLdtSize,
+  ProcessDefaultHardErrorMode,
+  ProcessIoPortHandlers,
+  ProcessPooledUsageAndLimits,
+  ProcessWorkingSetWatch,
+  ProcessUserModeIOPL,
+  ProcessEnableAlignmentFaultFixup,
+  ProcessPriorityClass,
+  ProcessWx86Information,
+  ProcessHandleCount,
+  ProcessAffinityMask,
+  ProcessPriorityBoost,
+  ProcessDeviceMap,
+  ProcessSessionInformation,
+  ProcessForegroundInformation,
+  ProcessWow64Information,
+  ProcessImageFileName,
+  ProcessLUIDDeviceMapsEnabled,
+  ProcessBreakOnTermination,
+  ProcessDebugObjectHandle,
+  ProcessDebugFlags,
+  ProcessHandleTracing,
+  ProcessIoPriority,
+  ProcessExecuteFlags,
+  ProcessTlsInformation,
+  ProcessCookie,
+  ProcessImageInformation,
+  ProcessCycleTime,
+  ProcessPagePriority,
+  ProcessInstrumentationCallback,
+  ProcessThreadStackAllocation,
+  ProcessWorkingSetWatchEx,
+  ProcessImageFileNameWin32,
+  ProcessImageFileMapping,
+  ProcessAffinityUpdateMode,
+  ProcessMemoryAllocationMode,
+  ProcessGroupInformation,
+  ProcessTokenVirtualizationEnabled,
+  ProcessConsoleHostProcess,
+  ProcessWindowInformation,
+  MaxProcessInfoClass
+} PROCESSINFOCLASS;
+
+typedef enum _THREADINFOCLASS {
+  ThreadBasicInformation,
+  ThreadTimes,
+  ThreadPriority,
+  ThreadBasePriority,
+  ThreadAffinityMask,
+  ThreadImpersonationToken,
+  ThreadDescriptorTableEntry,
+  ThreadEnableAlignmentFaultFixup,
+  ThreadEventPair_Reusable,
+  ThreadQuerySetWin32StartAddress,
+  ThreadZeroTlsCell,
+  ThreadPerformanceCount,
+  ThreadAmILastThread,
+  ThreadIdealProcessor,
+  ThreadPriorityBoost,
+  ThreadSetTlsArrayAddress,
+  ThreadIsIoPending,
+  ThreadHideFromDebugger,
+  ThreadBreakOnTermination,
+  ThreadSwitchLegacyState,
+  ThreadIsTerminated,
+  ThreadLastSystemCall,
+  ThreadIoPriority,
+  ThreadCycleTime,
+  ThreadPagePriority,
+  ThreadActualBasePriority,
+  ThreadTebInformation,
+  ThreadCSwitchMon,
+  ThreadCSwitchPmu,
+  ThreadWow64Context,
+  ThreadGroupInformation,
+  ThreadUmsInformation,
+  ThreadCounterProfiling,
+  ThreadIdealProcessorEx,
+  MaxThreadInfoClass
+} THREADINFOCLASS;
+
 /* NtXxx Functions */
 
 NTSYSCALLAPI
@@ -1736,6 +2096,42 @@ NtQueryInformationProcess(
   IN ULONG ProcessInformationLength,
   OUT PULONG ReturnLength OPTIONAL);
 
+/** Process manager types **/
+
+typedef struct _IMAGE_INFO {
+  _ANONYMOUS_UNION union {
+    ULONG  Properties;
+    _ANONYMOUS_STRUCT struct {
+      ULONG  ImageAddressingMode  : 8;
+      ULONG  SystemModeImage      : 1;
+      ULONG  ImageMappedToAllPids : 1;
+      ULONG  Reserved             : 22;
+    } DUMMYSTRUCTNAME;
+  } DUMMYUNIONNAME;
+  PVOID  ImageBase;
+  ULONG  ImageSelector;
+  SIZE_T  ImageSize;
+  ULONG  ImageSectionNumber;
+} IMAGE_INFO, *PIMAGE_INFO;
+
+typedef VOID
+(DDKAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
+  IN HANDLE ParentId,
+  IN HANDLE ProcessId,
+  IN BOOLEAN Create);
+
+typedef VOID
+(DDKAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
+  IN HANDLE ProcessId,
+  IN HANDLE ThreadId,
+  IN BOOLEAN Create);
+
+typedef VOID
+(DDKAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
+  IN PUNICODE_STRING FullImageName,
+  IN HANDLE ProcessId,
+  IN PIMAGE_INFO ImageInfo);
+
 /** Process manager routines **/
 
 #if (NTDDI_VERSION >= NTDDI_WIN2K)
@@ -2008,6 +2404,12 @@ SeSinglePrivilegeCheck(
   IN KPROCESSOR_MODE PreviousMode);
 #endif
 
+typedef VOID
+(DDKAPI *PTIMER_APC_ROUTINE)(
+  IN PVOID TimerContext,
+  IN ULONG TimerLowValue,
+  IN LONG TimerHighValue);
+
 /* ZwXxx Functions */
 
 #if (NTDDI_VERSION >= NTDDI_WIN2K)
index 0c1e007..095e2e6 100644 (file)
@@ -4891,7 +4891,7 @@ KeAcquireSpinLockRaiseToSynch(
 
 #if (NTDDI_VERSION >= NTDDI_WINXP)
 
-NTHALAPI
+_DECL_HAL_KE_IMPORT
 KIRQL
 FASTCALL
 KeAcquireQueuedSpinLock(
@@ -4904,7 +4904,7 @@ KeReleaseQueuedSpinLock(
   IN OUT KSPIN_LOCK_QUEUE_NUMBER Number,
   IN KIRQL OldIrql);
 
-NTHALAPI // FIXME: _DECL_HAL_KE_IMPORT
+_DECL_HAL_KE_IMPORT
 LOGICAL
 FASTCALL
 KeTryToAcquireQueuedSpinLock(
@@ -7928,21 +7928,6 @@ IoVerifyVolume (
     IN BOOLEAN          AllowRawMount
 );
 
-NTKERNELAPI
-KIRQL
-FASTCALL
-KeAcquireQueuedSpinLock (
-    IN KSPIN_LOCK_QUEUE_NUMBER Number
-);
-
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseQueuedSpinLock (
-    IN KSPIN_LOCK_QUEUE_NUMBER Number,
-    IN KIRQL OldIrql
-);
-
 NTKERNELAPI
 BOOLEAN
 NTAPI
index b025b7c..d6f0af1 100644 (file)
@@ -62,6 +62,14 @@ extern "C" {
 #define NTKERNELAPI
 #endif
 
+#if defined(_X86_) && !defined(_NTHAL_)
+#define _DECL_HAL_KE_IMPORT  DECLSPEC_IMPORT
+#elif defined(_X86_)
+#define _DECL_HAL_KE_IMPORT
+#else
+#define _DECL_HAL_KE_IMPORT NTKERNELAPI
+#endif
+
 #if defined(_WIN64)
 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
 #else
@@ -310,6 +318,134 @@ InterlockedAdd64(
 #endif /* !__INTERLOCKED_DECLARED */
 
 
+/******************************************************************************
+ *                           Runtime Library Types                            *
+ ******************************************************************************/
+
+#define RTL_REGISTRY_ABSOLUTE             0
+#define RTL_REGISTRY_SERVICES             1
+#define RTL_REGISTRY_CONTROL              2
+#define RTL_REGISTRY_WINDOWS_NT           3
+#define RTL_REGISTRY_DEVICEMAP            4
+#define RTL_REGISTRY_USER                 5
+#define RTL_REGISTRY_MAXIMUM              6
+#define RTL_REGISTRY_HANDLE               0x40000000
+#define RTL_REGISTRY_OPTIONAL             0x80000000
+
+/* RTL_QUERY_REGISTRY_TABLE.Flags */
+#define RTL_QUERY_REGISTRY_SUBKEY         0x00000001
+#define RTL_QUERY_REGISTRY_TOPKEY         0x00000002
+#define RTL_QUERY_REGISTRY_REQUIRED       0x00000004
+#define RTL_QUERY_REGISTRY_NOVALUE        0x00000008
+#define RTL_QUERY_REGISTRY_NOEXPAND       0x00000010
+#define RTL_QUERY_REGISTRY_DIRECT         0x00000020
+#define RTL_QUERY_REGISTRY_DELETE         0x00000040
+
+#define HASH_STRING_ALGORITHM_DEFAULT     0
+#define HASH_STRING_ALGORITHM_X65599      1
+#define HASH_STRING_ALGORITHM_INVALID     0xffffffff
+
+typedef struct _RTL_BITMAP {
+    ULONG SizeOfBitMap;
+    PULONG Buffer;
+} RTL_BITMAP, *PRTL_BITMAP;
+
+typedef struct _RTL_BITMAP_RUN {
+    ULONG StartingIndex;
+    ULONG NumberOfBits;
+} RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
+
+typedef NTSTATUS
+(DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)(
+    IN PWSTR ValueName,
+    IN ULONG ValueType,
+    IN PVOID ValueData,
+    IN ULONG ValueLength,
+    IN PVOID Context,
+    IN PVOID EntryContext);
+
+typedef struct _RTL_QUERY_REGISTRY_TABLE {
+    PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
+    ULONG Flags;
+    PCWSTR Name;
+    PVOID EntryContext;
+    ULONG DefaultType;
+    PVOID DefaultData;
+    ULONG DefaultLength;
+} RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
+
+typedef struct _TIME_FIELDS {
+    CSHORT Year;
+    CSHORT Month;
+    CSHORT Day;
+    CSHORT Hour;
+    CSHORT Minute;
+    CSHORT Second;
+    CSHORT Milliseconds;
+    CSHORT Weekday;
+} TIME_FIELDS, *PTIME_FIELDS;
+
+/* Slist Header */
+#ifndef _SLIST_HEADER_
+#define _SLIST_HEADER_
+
+#if defined(_WIN64)
+typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
+typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
+       PSLIST_ENTRY Next;
+} SLIST_ENTRY;
+typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
+    struct {
+        ULONGLONG Alignment;
+        ULONGLONG Region;
+    } DUMMYSTRUCTNAME;
+    struct {
+        ULONGLONG Depth:16;
+        ULONGLONG Sequence:9;
+        ULONGLONG NextEntry:39;
+        ULONGLONG HeaderType:1;
+        ULONGLONG Init:1;
+        ULONGLONG Reserved:59;
+        ULONGLONG Region:3;
+    } Header8;
+    struct {
+        ULONGLONG Depth:16;
+        ULONGLONG Sequence:48;
+        ULONGLONG HeaderType:1;
+        ULONGLONG Init:1;
+        ULONGLONG Reserved:2;
+        ULONGLONG NextEntry:60;
+    } Header16;
+} SLIST_HEADER, *PSLIST_HEADER;
+#else
+#define SLIST_ENTRY SINGLE_LIST_ENTRY
+#define _SLIST_ENTRY _SINGLE_LIST_ENTRY
+#define PSLIST_ENTRY PSINGLE_LIST_ENTRY
+typedef union _SLIST_HEADER {
+    ULONGLONG Alignment;
+    struct {
+        SLIST_ENTRY Next;
+        USHORT Depth;
+        USHORT Sequence;
+    } DUMMYSTRUCTNAME;
+} SLIST_HEADER, *PSLIST_HEADER;
+#endif
+
+#endif /* _SLIST_HEADER_ */
+
+
+/* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
+#if defined(_NTSYSTEM_) || defined(__GNUC__)
+#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;
+
+
 /******************************************************************************
  *                              Kernel Types                                  *
  ******************************************************************************/
@@ -1085,3275 +1221,4273 @@ typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
 
 #endif // _AMD64_
 
+#if defined(_IA64_)
+extern volatile LARGE_INTEGER KeTickCount;
+#elif defined(_X86_)
+extern volatile KSYSTEM_TIME KeTickCount;
+#endif
+
 
 /******************************************************************************
- *                              Kernel Functions                              *
+ *                         Memory manager Types                               *
  ******************************************************************************/
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeEvent(
-  OUT PRKEVENT  Event,
-  IN EVENT_TYPE  Type,
-  IN BOOLEAN  State);
-
-NTKERNELAPI
-VOID
-NTAPI
-KeClearEvent(
-  IN OUT PRKEVENT Event);
+#define PAGE_SIZE                         0x1000
+#define PAGE_SHIFT                        12L
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+#define MM_DONT_ZERO_ALLOCATION                 0x00000001
+#define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY        0x00000002
+#define MM_ALLOCATE_FULLY_REQUIRED              0x00000004
+#define MM_ALLOCATE_NO_WAIT                     0x00000008
+#define MM_ALLOCATE_PREFER_CONTIGUOUS           0x00000010
+#define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS   0x00000020
 
-#if defined(SINGLE_GROUP_LEGACY_API)
-NTKERNELAPI
-VOID
-NTAPI
-KeRevertToUserAffinityThread(VOID);
+#define MDL_MAPPED_TO_SYSTEM_VA     0x0001
+#define MDL_PAGES_LOCKED            0x0002
+#define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
+#define MDL_ALLOCATED_FIXED_SIZE    0x0008
+#define MDL_PARTIAL                 0x0010
+#define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
+#define MDL_IO_PAGE_READ            0x0040
+#define MDL_WRITE_OPERATION         0x0080
+#define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
+#define MDL_FREE_EXTRA_PTES         0x0200
+#define MDL_DESCRIBES_AWE           0x0400
+#define MDL_IO_SPACE                0x0800
+#define MDL_NETWORK_HEADER          0x1000
+#define MDL_MAPPING_CAN_FAIL        0x2000
+#define MDL_ALLOCATED_MUST_SUCCEED  0x4000
+#define MDL_INTERNAL                0x8000
 
-NTKERNELAPI
-VOID
-NTAPI
-KeSetSystemAffinityThread(
-    IN KAFFINITY Affinity);
+#define MDL_MAPPING_FLAGS ( \
+  MDL_MAPPED_TO_SYSTEM_VA     | \
+  MDL_PAGES_LOCKED            | \
+  MDL_SOURCE_IS_NONPAGED_POOL | \
+  MDL_PARTIAL_HAS_BEEN_MAPPED | \
+  MDL_PARENT_MAPPED_SYSTEM_VA | \
+  MDL_SYSTEM_VA               | \
+  MDL_IO_SPACE)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeSetTargetProcessorDpc(
-  IN OUT PRKDPC Dpc,
-  IN CCHAR Number);
+#define FLUSH_MULTIPLE_MAXIMUM 32
 
-NTKERNELAPI
-KAFFINITY
-NTAPI
-KeQueryActiveProcessors(
-  VOID);
-#endif
+/* Section access rights */
+#define SECTION_QUERY                0x0001
+#define SECTION_MAP_WRITE            0x0002
+#define SECTION_MAP_READ             0x0004
+#define SECTION_MAP_EXECUTE          0x0008
+#define SECTION_EXTEND_SIZE          0x0010
+#define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
 
-#if !defined(_M_AMD64)
-NTKERNELAPI
-ULONGLONG
-NTAPI
-KeQueryInterruptTime(
-  VOID);
+#define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\
+                            SECTION_MAP_WRITE |      \
+                            SECTION_MAP_READ |       \
+                            SECTION_MAP_EXECUTE |    \
+                            SECTION_EXTEND_SIZE)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeQuerySystemTime(
-  OUT PLARGE_INTEGER  CurrentTime);
-#endif /* !_M_AMD64 */
+#define SESSION_QUERY_ACCESS  0x0001
+#define SESSION_MODIFY_ACCESS 0x0002
 
-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);
+#define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |  \
+                            SESSION_QUERY_ACCESS |             \
+                            SESSION_MODIFY_ACCESS)
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeCancelTimer(
-  IN OUT PKTIMER);
+#define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeDelayExecutionThread(
-  IN KPROCESSOR_MODE WaitMode,
-  IN BOOLEAN Alertable,
-  IN PLARGE_INTEGER Interval);
+#define PAGE_NOACCESS          0x01
+#define PAGE_READONLY          0x02
+#define PAGE_READWRITE         0x04
+#define PAGE_WRITECOPY         0x08
+#define PAGE_EXECUTE           0x10
+#define PAGE_EXECUTE_READ      0x20
+#define PAGE_EXECUTE_READWRITE 0x40
+#define PAGE_EXECUTE_WRITECOPY 0x80
+#define PAGE_GUARD            0x100
+#define PAGE_NOCACHE          0x200
+#define PAGE_WRITECOMBINE     0x400
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeDeregisterBugCheckCallback(
-  IN OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
+#define MEM_COMMIT           0x1000
+#define MEM_RESERVE          0x2000
+#define MEM_DECOMMIT         0x4000
+#define MEM_RELEASE          0x8000
+#define MEM_FREE            0x10000
+#define MEM_PRIVATE         0x20000
+#define MEM_MAPPED          0x40000
+#define MEM_RESET           0x80000
+#define MEM_TOP_DOWN       0x100000
+#define MEM_LARGE_PAGES  0x20000000
+#define MEM_4MB_PAGES    0x80000000
 
-NTKERNELAPI
-VOID
-NTAPI
-KeEnterCriticalRegion(VOID);
+#define SEC_RESERVE       0x4000000
+#define SEC_COMMIT        0x8000000
+#define SEC_LARGE_PAGES  0x80000000
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeDeviceQueue(
-  OUT PKDEVICE_QUEUE  DeviceQueue);
+/* Section map options */
+typedef enum _SECTION_INHERIT {
+    ViewShare = 1,
+    ViewUnmap = 2
+} SECTION_INHERIT;
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeDpc(
-  OUT PRKDPC  Dpc,
-  IN PKDEFERRED_ROUTINE  DeferredRoutine,
-  IN PVOID  DeferredContext OPTIONAL);
+typedef ULONG PFN_COUNT;
+typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
+typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeMutex(
-  OUT PRKMUTEX  Mutex,
-  IN ULONG  Level);
+typedef struct _MDL {
+    struct _MDL *Next;
+    CSHORT Size;
+    CSHORT MdlFlags;
+    struct _EPROCESS *Process;
+    PVOID MappedSystemVa;
+    PVOID StartVa;
+    ULONG ByteCount;
+    ULONG ByteOffset;
+} MDL, *PMDL;
+typedef MDL *PMDLX;
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeSemaphore(
-  OUT PRKSEMAPHORE  Semaphore,
-  IN LONG  Count,
-  IN LONG  Limit);
+typedef enum _MEMORY_CACHING_TYPE_ORIG {
+  MmFrameBufferCached = 2
+} MEMORY_CACHING_TYPE_ORIG;
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeTimer(
-  OUT PKTIMER  Timer);
+typedef enum _MEMORY_CACHING_TYPE {
+  MmNonCached = FALSE,
+  MmCached = TRUE,
+  MmWriteCombined = MmFrameBufferCached,
+  MmHardwareCoherentCached,
+  MmNonCachedUnordered,
+  MmUSWCCached,
+  MmMaximumCacheType
+} MEMORY_CACHING_TYPE;
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeTimerEx(
-  OUT PKTIMER  Timer,
-  IN TIMER_TYPE  Type);
+typedef enum _MM_PAGE_PRIORITY {
+  LowPagePriority,
+  NormalPagePriority = 16,
+  HighPagePriority = 32
+} MM_PAGE_PRIORITY;
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeInsertByKeyDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue,
-  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry,
-  IN ULONG  SortKey);
+typedef enum _LOCK_OPERATION {
+  IoReadAccess,
+  IoWriteAccess,
+  IoModifyAccess
+} LOCK_OPERATION;
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeInsertDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue,
-  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry);
+typedef enum _MM_SYSTEM_SIZE {
+  MmSmallSystem,
+  MmMediumSystem,
+  MmLargeSystem
+} MM_SYSTEMSIZE;
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeInsertQueueDpc(
-  IN OUT PRKDPC  Dpc,
-  IN PVOID  SystemArgument1 OPTIONAL,
-  IN PVOID  SystemArgument2 OPTIONAL);
 
-NTKERNELAPI
-VOID
-NTAPI
-KeLeaveCriticalRegion(VOID);
+/******************************************************************************
+ *                            Executive Types                                 *
+ ******************************************************************************/
 
-NTHALAPI
-LARGE_INTEGER
-NTAPI
-KeQueryPerformanceCounter(
-  OUT PLARGE_INTEGER  PerformanceFrequency  OPTIONAL);
+#define EX_RUNDOWN_ACTIVE                 0x1
+#define EX_RUNDOWN_COUNT_SHIFT            0x1
+#define EX_RUNDOWN_COUNT_INC              (1 << EX_RUNDOWN_COUNT_SHIFT)
 
-NTKERNELAPI
-KPRIORITY
-NTAPI
-KeQueryPriorityThread(
-  IN PRKTHREAD  Thread);
+#ifdef _WIN64
+#define PORT_MAXIMUM_MESSAGE_LENGTH 512
+#else
+#define PORT_MAXIMUM_MESSAGE_LENGTH 256
+#endif
 
-NTKERNELAPI
-ULONG
-NTAPI
-KeQueryTimeIncrement(
-  VOID);
+typedef struct _FAST_MUTEX {
+  volatile LONG Count;
+  PKTHREAD Owner;
+  ULONG Contention;
+  KEVENT Event;
+  ULONG OldIrql;
+} FAST_MUTEX, *PFAST_MUTEX;
 
-NTKERNELAPI
-LONG
-NTAPI
-KeReadStateEvent(
-  IN PRKEVENT  Event);
+typedef enum _SUITE_TYPE {
+    SmallBusiness,
+    Enterprise,
+    BackOffice,
+    CommunicationServer,
+    TerminalServer,
+    SmallBusinessRestricted,
+    EmbeddedNT,
+    DataCenter,
+    SingleUserTS,
+    Personal,
+    Blade,
+    EmbeddedRestricted,
+    SecurityAppliance,
+    StorageServer,
+    ComputeServer,
+    WHServer,
+    MaxSuiteType
+} SUITE_TYPE;
 
-NTKERNELAPI
-LONG
-NTAPI
-KeReadStateMutex(
-  IN PRKMUTEX  Mutex);
+typedef enum _EX_POOL_PRIORITY {
+    LowPoolPriority,
+    LowPoolPrioritySpecialPoolOverrun = 8,
+    LowPoolPrioritySpecialPoolUnderrun = 9,
+    NormalPoolPriority = 16,
+    NormalPoolPrioritySpecialPoolOverrun = 24,
+    NormalPoolPrioritySpecialPoolUnderrun = 25,
+    HighPoolPriority = 32,
+    HighPoolPrioritySpecialPoolOverrun = 40,
+    HighPoolPrioritySpecialPoolUnderrun = 41
+} EX_POOL_PRIORITY;
 
+#if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
+#define LOOKASIDE_ALIGN
+#else
+#define LOOKASIDE_ALIGN /* FIXME: DECLSPEC_CACHEALIGN */
+#endif
 
-NTKERNELAPI
-LONG
-NTAPI
-KeReadStateSemaphore(
-  IN PRKSEMAPHORE  Semaphore);
+typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX;
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeReadStateTimer(
-  IN PKTIMER  Timer);
+typedef PVOID
+(DDKAPI *PALLOCATE_FUNCTION)(
+    IN POOL_TYPE PoolType,
+    IN SIZE_T NumberOfBytes,
+    IN ULONG Tag);
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeRegisterBugCheckCallback(
-  OUT PKBUGCHECK_CALLBACK_RECORD  CallbackRecord,
-  IN PKBUGCHECK_CALLBACK_ROUTINE  CallbackRoutine,
-  IN PVOID  Buffer,
-  IN ULONG  Length,
-  IN PUCHAR  Component);
+typedef PVOID
+(DDKAPI *PALLOCATE_FUNCTION_EX)(
+    IN POOL_TYPE PoolType,
+    IN SIZE_T NumberOfBytes,
+    IN ULONG Tag,
+    IN OUT PLOOKASIDE_LIST_EX Lookaside);
 
-NTKERNELAPI
-LONG
-NTAPI
-KeReleaseMutex(
-  IN OUT PRKMUTEX  Mutex,
-  IN BOOLEAN  Wait);
+typedef VOID
+(DDKAPI *PFREE_FUNCTION)(
+    IN PVOID Buffer);
 
-NTKERNELAPI
-LONG
-NTAPI
-KeReleaseSemaphore(
-  IN OUT PRKSEMAPHORE  Semaphore,
-  IN KPRIORITY  Increment,
-  IN LONG  Adjustment,
-  IN BOOLEAN  Wait);
+typedef VOID
+(DDKAPI *PFREE_FUNCTION_EX)(
+    IN PVOID Buffer,
+    IN OUT PLOOKASIDE_LIST_EX Lookaside);
 
-NTKERNELAPI
-PKDEVICE_QUEUE_ENTRY
-NTAPI
-KeRemoveByKeyDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue,
-  IN ULONG  SortKey);
+typedef VOID
+(DDKAPI *PCALLBACK_FUNCTION)(
+  IN PVOID  CallbackContext,
+  IN PVOID  Argument1,
+  IN PVOID  Argument2);
 
-NTKERNELAPI
-PKDEVICE_QUEUE_ENTRY
-NTAPI
-KeRemoveDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue);
+#define GENERAL_LOOKASIDE_LAYOUT                \
+    union {                                     \
+        SLIST_HEADER ListHead;                  \
+        SINGLE_LIST_ENTRY SingleListHead;       \
+    } DUMMYUNIONNAME;                           \
+    USHORT Depth;                               \
+    USHORT MaximumDepth;                        \
+    ULONG TotalAllocates;                       \
+    union {                                     \
+        ULONG AllocateMisses;                   \
+        ULONG AllocateHits;                     \
+    } DUMMYUNIONNAME2;                          \
+                                                \
+    ULONG TotalFrees;                           \
+    union {                                     \
+        ULONG FreeMisses;                       \
+        ULONG FreeHits;                         \
+    } DUMMYUNIONNAME3;                          \
+                                                \
+    POOL_TYPE Type;                             \
+    ULONG Tag;                                  \
+    ULONG Size;                                 \
+    union {                                     \
+        PALLOCATE_FUNCTION_EX AllocateEx;       \
+        PALLOCATE_FUNCTION Allocate;            \
+    } DUMMYUNIONNAME4;                          \
+                                                \
+    union {                                     \
+        PFREE_FUNCTION_EX FreeEx;               \
+        PFREE_FUNCTION Free;                    \
+    } DUMMYUNIONNAME5;                          \
+                                                \
+    LIST_ENTRY ListEntry;                       \
+    ULONG LastTotalAllocates;                   \
+    union {                                     \
+        ULONG LastAllocateMisses;               \
+        ULONG LastAllocateHits;                 \
+    } DUMMYUNIONNAME6;                          \
+    ULONG Future[2];
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeRemoveEntryDeviceQueue(
-  IN OUT PKDEVICE_QUEUE  DeviceQueue,
-  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry);
+typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE {
+    GENERAL_LOOKASIDE_LAYOUT
+} GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeRemoveQueueDpc(
-  IN OUT PRKDPC  Dpc);
+typedef struct _GENERAL_LOOKASIDE_POOL {
+    GENERAL_LOOKASIDE_LAYOUT
+} GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
 
-NTKERNELAPI
-LONG
-NTAPI
-KeResetEvent(
-  IN OUT PRKEVENT  Event);
+typedef struct _PAGED_LOOKASIDE_LIST {
+    GENERAL_LOOKASIDE L;
+#if !defined(_AMD64_) && !defined(_IA64_)
+    FAST_MUTEX Lock__ObsoleteButDoNotDelete;
+#endif
+} PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
 
-NTKERNELAPI
-LONG
-NTAPI
-KeSetEvent(
-  IN OUT PRKEVENT  Event,
-  IN KPRIORITY  Increment,
-  IN BOOLEAN  Wait);
+typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST {
+    GENERAL_LOOKASIDE L;
+#if !defined(_AMD64_) && !defined(_IA64_)
+    KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
+#endif
+} NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
 
-NTKERNELAPI
-VOID
-NTAPI
-KeSetImportanceDpc(
-  IN OUT PRKDPC  Dpc,
-  IN KDPC_IMPORTANCE  Importance);
+typedef struct _LOOKASIDE_LIST_EX {
+    GENERAL_LOOKASIDE_POOL L;
+} LOOKASIDE_LIST_EX;
 
-NTKERNELAPI
-KPRIORITY
-NTAPI
-KeSetPriorityThread(
-  IN OUT PKTHREAD  Thread,
-  IN KPRIORITY  Priority);
+typedef struct _EX_RUNDOWN_REF {
+    __GNU_EXTENSION union {
+        volatile ULONG_PTR Count;
+        volatile PVOID Ptr;
+    };
+} EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeSetTimer(
-  IN OUT PKTIMER  Timer,
-  IN LARGE_INTEGER  DueTime,
-  IN PKDPC  Dpc  OPTIONAL);
+typedef struct _EX_RUNDOWN_REF_CACHE_AWARE  *PEX_RUNDOWN_REF_CACHE_AWARE;
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeSetTimerEx(
-  IN OUT PKTIMER  Timer,
-  IN LARGE_INTEGER  DueTime,
-  IN LONG  Period  OPTIONAL,
-  IN PKDPC  Dpc  OPTIONAL);
+typedef VOID
+(DDKAPI *PWORKER_THREAD_ROUTINE)(
+  IN PVOID Parameter);
 
-NTHALAPI
-VOID
-NTAPI
-KeStallExecutionProcessor(
-  IN ULONG  MicroSeconds);
+typedef struct _WORK_QUEUE_ITEM {
+  LIST_ENTRY  List;
+  PWORKER_THREAD_ROUTINE  WorkerRoutine;
+  volatile PVOID  Parameter;
+} WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
 
-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);
+/******************************************************************************
+ *                            Security Manager Types                          *
+ ******************************************************************************/
 
-#define KeWaitForMutexObject KeWaitForSingleObject
+/* Simple types */
+typedef PVOID PSECURITY_DESCRIPTOR;
+typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
+typedef ULONG ACCESS_MASK, *PACCESS_MASK;
+typedef PVOID PACCESS_TOKEN;
+typedef PVOID PSID;
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeWaitForSingleObject(
-  IN PVOID  Object,
-  IN KWAIT_REASON  WaitReason,
-  IN KPROCESSOR_MODE  WaitMode,
-  IN BOOLEAN  Alertable,
-  IN PLARGE_INTEGER  Timeout  OPTIONAL);
+#define DELETE                           0x00010000L
+#define READ_CONTROL                     0x00020000L
+#define WRITE_DAC                        0x00040000L
+#define WRITE_OWNER                      0x00080000L
+#define SYNCHRONIZE                      0x00100000L
+#define STANDARD_RIGHTS_REQUIRED         0x000F0000L
+#define STANDARD_RIGHTS_READ             READ_CONTROL
+#define STANDARD_RIGHTS_WRITE            READ_CONTROL
+#define STANDARD_RIGHTS_EXECUTE          READ_CONTROL
+#define STANDARD_RIGHTS_ALL              0x001F0000L
+#define SPECIFIC_RIGHTS_ALL              0x0000FFFFL
+#define ACCESS_SYSTEM_SECURITY           0x01000000L
+#define MAXIMUM_ALLOWED                  0x02000000L
+#define GENERIC_READ                     0x80000000L
+#define GENERIC_WRITE                    0x40000000L
+#define GENERIC_EXECUTE                  0x20000000L
+#define GENERIC_ALL                      0x10000000L
 
-#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+typedef struct _GENERIC_MAPPING {
+    ACCESS_MASK GenericRead;
+    ACCESS_MASK GenericWrite;
+    ACCESS_MASK GenericExecute;
+    ACCESS_MASK GenericAll;
+} GENERIC_MAPPING, *PGENERIC_MAPPING;
 
-#if (NTDDI_VERSION >= NTDDI_WINXP)
+#define ACL_REVISION                      2
+#define ACL_REVISION_DS                   4
 
-// _DECL_HAL_KE_IMPORT
-VOID
-FASTCALL
-KeAcquireInStackQueuedSpinLock(
-  IN OUT PKSPIN_LOCK SpinLock,
-  OUT PKLOCK_QUEUE_HANDLE LockHandle);
+#define ACL_REVISION1                     1
+#define ACL_REVISION2                     2
+#define ACL_REVISION3                     3
+#define ACL_REVISION4                     4
+#define MIN_ACL_REVISION                  ACL_REVISION2
+#define MAX_ACL_REVISION                  ACL_REVISION4
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeAcquireInStackQueuedSpinLockAtDpcLevel(
-  IN OUT PKSPIN_LOCK  SpinLock,
-  OUT PKLOCK_QUEUE_HANDLE  LockHandle);
+typedef struct _ACL {
+    UCHAR AclRevision;
+    UCHAR Sbz1;
+    USHORT AclSize;
+    USHORT AceCount;
+    USHORT Sbz2;
+} ACL, *PACL;
 
-NTKERNELAPI
-KIRQL
-NTAPI
-KeAcquireInterruptSpinLock(
-  IN OUT PKINTERRUPT  Interrupt);
+/* Current security descriptor revision value */
+#define SECURITY_DESCRIPTOR_REVISION     (1)
+#define SECURITY_DESCRIPTOR_REVISION1    (1)
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeAreApcsDisabled(VOID);
+/* Privilege attributes */
+#define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
+#define SE_PRIVILEGE_ENABLED            (0x00000002L)
+#define SE_PRIVILEGE_REMOVED            (0X00000004L)
+#define SE_PRIVILEGE_USED_FOR_ACCESS    (0x80000000L)
 
-NTKERNELAPI
-ULONG
-NTAPI
-KeGetRecommendedSharedDataAlignment(VOID);
+#define SE_PRIVILEGE_VALID_ATTRIBUTES   (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \
+                                         SE_PRIVILEGE_ENABLED            | \
+                                         SE_PRIVILEGE_REMOVED            | \
+                                         SE_PRIVILEGE_USED_FOR_ACCESS)
 
-NTKERNELAPI
-ULONG
-NTAPI
-KeQueryRuntimeThread(
-  IN PKTHREAD Thread,
-  OUT PULONG UserTime);
+#include <pshpack4.h>
+typedef struct _LUID_AND_ATTRIBUTES {
+    LUID Luid;
+    ULONG Attributes;
+} LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
+#include <poppack.h>
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseInStackQueuedSpinLockFromDpcLevel(
-  IN PKLOCK_QUEUE_HANDLE  LockHandle);
+typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
+typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
 
-NTKERNELAPI
-VOID
-NTAPI
-KeReleaseInterruptSpinLock(
-  IN OUT PKINTERRUPT  Interrupt,
-  IN KIRQL  OldIrql);
+/* Privilege sets */
+#define PRIVILEGE_SET_ALL_NECESSARY (1)
 
-NTKERNELAPI
-PKDEVICE_QUEUE_ENTRY
-NTAPI
-KeRemoveByKeyDeviceQueueIfBusy(
-  IN OUT PKDEVICE_QUEUE DeviceQueue,
-  IN ULONG SortKey);
+typedef struct _PRIVILEGE_SET {
+    ULONG PrivilegeCount;
+    ULONG Control;
+    LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
+} PRIVILEGE_SET,*PPRIVILEGE_SET;
 
-//_DECL_HAL_KE_IMPORT
-VOID
-FASTCALL
-KeReleaseInStackQueuedSpinLock(
-  IN PKLOCK_QUEUE_HANDLE LockHandle);
+typedef enum _SECURITY_IMPERSONATION_LEVEL {
+    SecurityAnonymous,
+    SecurityIdentification,
+    SecurityImpersonation,
+    SecurityDelegation
+} SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
 
-#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
+#define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
+#define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
+#define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
+#define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL))
 
-#if (NTDDI_VERSION >= NTDDI_WINXPSP1)
+#define SECURITY_DYNAMIC_TRACKING (TRUE)
+#define SECURITY_STATIC_TRACKING (FALSE)
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeDeregisterBugCheckReasonCallback(
-  IN OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord);
+typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE;
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeRegisterBugCheckReasonCallback(
-  OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord,
-  IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine,
-  IN KBUGCHECK_CALLBACK_REASON Reason,
-  IN PUCHAR Component);
+typedef struct _SECURITY_QUALITY_OF_SERVICE {
+    ULONG Length;
+    SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
+    SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
+    BOOLEAN EffectiveOnly;
+} SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
 
-#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */
+typedef struct _SE_IMPERSONATION_STATE {
+    PACCESS_TOKEN Token;
+    BOOLEAN CopyOnOpen;
+    BOOLEAN EffectiveOnly;
+    SECURITY_IMPERSONATION_LEVEL Level;
+} SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
 
-#if (NTDDI_VERSION >= NTDDI_WINXPSP2)
+#define OWNER_SECURITY_INFORMATION       (0x00000001L)
+#define GROUP_SECURITY_INFORMATION       (0x00000002L)
+#define DACL_SECURITY_INFORMATION        (0x00000004L)
+#define SACL_SECURITY_INFORMATION        (0x00000008L)
+#define LABEL_SECURITY_INFORMATION       (0x00000010L)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeFlushQueuedDpcs(
-  VOID);
+#define PROTECTED_DACL_SECURITY_INFORMATION     (0x80000000L)
+#define PROTECTED_SACL_SECURITY_INFORMATION     (0x40000000L)
+#define UNPROTECTED_DACL_SECURITY_INFORMATION   (0x20000000L)
+#define UNPROTECTED_SACL_SECURITY_INFORMATION   (0x10000000L)
 
-#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
+typedef enum _SECURITY_OPERATION_CODE {
+  SetSecurityDescriptor,
+  QuerySecurityDescriptor,
+  DeleteSecurityDescriptor,
+  AssignSecurityDescriptor
+} SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
 
-#if (NTDDI_VERSION >= NTDDI_WS03)
+#define INITIAL_PRIVILEGE_COUNT           3
 
-NTKERNELAPI
-PVOID
-NTAPI
-KeRegisterNmiCallback(
-  IN PNMI_CALLBACK CallbackRoutine,
-  IN PVOID Context OPTIONAL);
+typedef struct _INITIAL_PRIVILEGE_SET {
+  ULONG  PrivilegeCount;
+  ULONG  Control;
+  LUID_AND_ATTRIBUTES  Privilege[INITIAL_PRIVILEGE_COUNT];
+} INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeDeregisterNmiCallback(
-  IN PVOID Handle);
+#define SE_MIN_WELL_KNOWN_PRIVILEGE         2
+#define SE_CREATE_TOKEN_PRIVILEGE           2
+#define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE     3
+#define SE_LOCK_MEMORY_PRIVILEGE            4
+#define SE_INCREASE_QUOTA_PRIVILEGE         5
+#define SE_MACHINE_ACCOUNT_PRIVILEGE        6
+#define SE_TCB_PRIVILEGE                    7
+#define SE_SECURITY_PRIVILEGE               8
+#define SE_TAKE_OWNERSHIP_PRIVILEGE         9
+#define SE_LOAD_DRIVER_PRIVILEGE            10
+#define SE_SYSTEM_PROFILE_PRIVILEGE         11
+#define SE_SYSTEMTIME_PRIVILEGE             12
+#define SE_PROF_SINGLE_PROCESS_PRIVILEGE    13
+#define SE_INC_BASE_PRIORITY_PRIVILEGE      14
+#define SE_CREATE_PAGEFILE_PRIVILEGE        15
+#define SE_CREATE_PERMANENT_PRIVILEGE       16
+#define SE_BACKUP_PRIVILEGE                 17
+#define SE_RESTORE_PRIVILEGE                18
+#define SE_SHUTDOWN_PRIVILEGE               19
+#define SE_DEBUG_PRIVILEGE                  20
+#define SE_AUDIT_PRIVILEGE                  21
+#define SE_SYSTEM_ENVIRONMENT_PRIVILEGE     22
+#define SE_CHANGE_NOTIFY_PRIVILEGE          23
+#define SE_REMOTE_SHUTDOWN_PRIVILEGE        24
+#define SE_UNDOCK_PRIVILEGE                 25
+#define SE_SYNC_AGENT_PRIVILEGE             26
+#define SE_ENABLE_DELEGATION_PRIVILEGE      27
+#define SE_MANAGE_VOLUME_PRIVILEGE          28
+#define SE_IMPERSONATE_PRIVILEGE            29
+#define SE_CREATE_GLOBAL_PRIVILEGE          30
+#define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31
+#define SE_RELABEL_PRIVILEGE                32
+#define SE_INC_WORKING_SET_PRIVILEGE        33
+#define SE_TIME_ZONE_PRIVILEGE              34
+#define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE   35
+#define SE_MAX_WELL_KNOWN_PRIVILEGE         SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
 
-NTKERNELAPI
-VOID
-NTAPI
-KeInitializeThreadedDpc(
-  OUT PRKDPC Dpc,
-  IN PKDEFERRED_ROUTINE DeferredRoutine,
-  IN PVOID DeferredContext OPTIONAL);
+typedef struct _SECURITY_SUBJECT_CONTEXT {
+  PACCESS_TOKEN  ClientToken;
+  SECURITY_IMPERSONATION_LEVEL  ImpersonationLevel;
+  PACCESS_TOKEN  PrimaryToken;
+  PVOID  ProcessAuditId;
+} SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
 
-NTKERNELAPI
-ULONG_PTR
-NTAPI
-KeIpiGenericCall(
-  IN PKIPI_BROADCAST_WORKER BroadcastFunction,
-  IN ULONG_PTR Context);
+typedef struct _ACCESS_STATE {
+  LUID  OperationID;
+  BOOLEAN  SecurityEvaluated;
+  BOOLEAN  GenerateAudit;
+  BOOLEAN  GenerateOnClose;
+  BOOLEAN  PrivilegesAllocated;
+  ULONG  Flags;
+  ACCESS_MASK  RemainingDesiredAccess;
+  ACCESS_MASK  PreviouslyGrantedAccess;
+  ACCESS_MASK  OriginalDesiredAccess;
+  SECURITY_SUBJECT_CONTEXT  SubjectSecurityContext;
+  PSECURITY_DESCRIPTOR  SecurityDescriptor;
+  PVOID  AuxData;
+  union {
+    INITIAL_PRIVILEGE_SET  InitialPrivilegeSet;
+    PRIVILEGE_SET  PrivilegeSet;
+  } Privileges;
 
-NTKERNELAPI
-KIRQL
-FASTCALL
-KeAcquireSpinLockForDpc(
-  IN OUT PKSPIN_LOCK SpinLock);
+  BOOLEAN  AuditPrivileges;
+  UNICODE_STRING  ObjectName;
+  UNICODE_STRING  ObjectTypeName;
+} ACCESS_STATE, *PACCESS_STATE;
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseSpinLockForDpc(
-  IN OUT PKSPIN_LOCK SpinLock,
-  IN KIRQL OldIrql);
 
-#endif /* (NTDDI_VERSION >= NTDDI_WS03) */
+#ifndef _NTLSA_IFS_
 
-#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+#ifndef _NTLSA_AUDIT_
+#define _NTLSA_AUDIT_
 
-NTKERNELAPI
-BOOLEAN
-FASTCALL
-KeTryToAcquireSpinLockAtDpcLevel(
-  IN OUT PKSPIN_LOCK SpinLock);
+#define SE_MAX_AUDIT_PARAMETERS 32
+#define SE_MAX_GENERIC_AUDIT_PARAMETERS 28
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeAreAllApcsDisabled(
-  VOID);
+#define SE_ADT_OBJECT_ONLY 0x1
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeAcquireGuardedMutex(
-    IN OUT PKGUARDED_MUTEX GuardedMutex
-);
-
-NTKERNELAPI
-VOID
-FASTCALL
-KeAcquireGuardedMutexUnsafe(
-    IN OUT PKGUARDED_MUTEX GuardedMutex
-);
+#define SE_ADT_PARAMETERS_SELF_RELATIVE    0x00000001
+#define SE_ADT_PARAMETERS_SEND_TO_LSA      0x00000002
+#define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT  0x00000004
+#define SE_ADT_PARAMETER_GENERIC_AUDIT     0x00000008
+#define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010
 
-NTKERNELAPI
-VOID
-NTAPI
-KeEnterGuardedRegion(
-    VOID
-);
+#define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \
+  ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \
+    (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) )
 
-NTKERNELAPI
-VOID
-NTAPI
-KeLeaveGuardedRegion(
-    VOID
-);
+typedef enum _SE_ADT_PARAMETER_TYPE {
+  SeAdtParmTypeNone = 0,
+  SeAdtParmTypeString,
+  SeAdtParmTypeFileSpec,
+  SeAdtParmTypeUlong,
+  SeAdtParmTypeSid,
+  SeAdtParmTypeLogonId,
+  SeAdtParmTypeNoLogonId,
+  SeAdtParmTypeAccessMask,
+  SeAdtParmTypePrivs,
+  SeAdtParmTypeObjectTypes,
+  SeAdtParmTypeHexUlong,
+  SeAdtParmTypePtr,
+  SeAdtParmTypeTime,
+  SeAdtParmTypeGuid,
+  SeAdtParmTypeLuid,
+  SeAdtParmTypeHexInt64,
+  SeAdtParmTypeStringList,
+  SeAdtParmTypeSidList,
+  SeAdtParmTypeDuration,
+  SeAdtParmTypeUserAccountControl,
+  SeAdtParmTypeNoUac,
+  SeAdtParmTypeMessage,
+  SeAdtParmTypeDateTime,
+  SeAdtParmTypeSockAddr,
+  SeAdtParmTypeSD,
+  SeAdtParmTypeLogonHours,
+  SeAdtParmTypeLogonIdNoSid,
+  SeAdtParmTypeUlongNoConv,
+  SeAdtParmTypeSockAddrNoPort,
+  SeAdtParmTypeAccessReason
+} SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE;
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeInitializeGuardedMutex(
-    OUT PKGUARDED_MUTEX GuardedMutex
-);
+typedef struct _SE_ADT_OBJECT_TYPE {
+  GUID ObjectType;
+  USHORT Flags;
+  USHORT Level;
+  ACCESS_MASK AccessMask;
+} SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE;
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseGuardedMutexUnsafe(
-    IN OUT PKGUARDED_MUTEX GuardedMutex
-);
+typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY {
+  SE_ADT_PARAMETER_TYPE Type;
+  ULONG Length;
+  ULONG_PTR Data[2];
+  PVOID Address;
+} SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY;
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseGuardedMutex(
-    IN OUT PKGUARDED_MUTEX GuardedMutex
-);
+typedef struct _SE_ADT_ACCESS_REASON {
+  ACCESS_MASK AccessMask;
+  ULONG  AccessReasons[32];
+  ULONG  ObjectTypeIndex;
+  ULONG AccessGranted;
+  PSECURITY_DESCRIPTOR SecurityDescriptor;
+} SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON;
 
-NTKERNELAPI
-BOOLEAN
-FASTCALL
-KeTryToAcquireGuardedMutex(
-    IN OUT PKGUARDED_MUTEX GuardedMutex
-);
+typedef struct _SE_ADT_PARAMETER_ARRAY {
+  ULONG CategoryId;
+  ULONG AuditId;
+  ULONG ParameterCount;
+  ULONG Length;
+  USHORT FlatSubCategoryId;
+  USHORT Type;
+  ULONG Flags;
+  SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ];
+} SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY;
 
-#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
+#endif /* !_NTLSA_AUDIT_ */
+#endif /* !_NTLSA_IFS_ */
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeAcquireInStackQueuedSpinLockForDpc(
-  IN OUT PKSPIN_LOCK SpinLock,
-  OUT PKLOCK_QUEUE_HANDLE LockHandle);
+/******************************************************************************
+ *                            Power Management Support Types                  *
+ ******************************************************************************/
 
-NTKERNELAPI
-VOID
-FASTCALL
-KeReleaseInStackQueuedSpinLockForDpc(
-  IN PKLOCK_QUEUE_HANDLE LockHandle);
+#ifndef _PO_DDK_
+#define _PO_DDK_
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeQueryDpcWatchdogInformation(
-  OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation);
+/* Power States/Levels */
+typedef enum _SYSTEM_POWER_STATE {
+    PowerSystemUnspecified,
+    PowerSystemWorking,
+    PowerSystemSleeping1,
+    PowerSystemSleeping2,
+    PowerSystemSleeping3,
+    PowerSystemHibernate,
+    PowerSystemShutdown,
+    PowerSystemMaximum
+} SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
 
-#if defined(SINGLE_GROUP_LEGACY_API)
-NTKERNELAPI
-KAFFINITY
-NTAPI
-KeSetSystemAffinityThreadEx(
-  IN KAFFINITY Affinity);
+#define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
 
-NTKERNELAPI
-ULONG
-NTAPI
-KeQueryActiveProcessorCount(
-  OUT PKAFFINITY ActiveProcessors OPTIONAL);
+typedef enum _POWER_INFORMATION_LEVEL {
+    SystemPowerPolicyAc,
+    SystemPowerPolicyDc,
+    VerifySystemPolicyAc,
+    VerifySystemPolicyDc,
+    SystemPowerCapabilities,
+    SystemBatteryState,
+    SystemPowerStateHandler,
+    ProcessorStateHandler,
+    SystemPowerPolicyCurrent,
+    AdministratorPowerPolicy,
+    SystemReserveHiberFile,
+    ProcessorInformation,
+    SystemPowerInformation,
+    ProcessorStateHandler2,
+    LastWakeTime,
+    LastSleepTime,
+    SystemExecutionState,
+    SystemPowerStateNotifyHandler,
+    ProcessorPowerPolicyAc,
+    ProcessorPowerPolicyDc,
+    VerifyProcessorPowerPolicyAc,
+    VerifyProcessorPowerPolicyDc,
+    ProcessorPowerPolicyCurrent,
+    SystemPowerStateLogging,
+    SystemPowerLoggingEntry,
+    SetPowerSettingValue,
+    NotifyUserPowerSetting,
+    PowerInformationLevelUnused0,
+    PowerInformationLevelUnused1,
+    SystemVideoState,
+    TraceApplicationPowerMessage,
+    TraceApplicationPowerMessageEnd,
+    ProcessorPerfStates,
+    ProcessorIdleStates,
+    ProcessorCap,
+    SystemWakeSource,
+    SystemHiberFileInformation,
+    TraceServicePowerMessage,
+    ProcessorLoad,
+    PowerShutdownNotification,
+    MonitorCapabilities,
+    SessionPowerInit,
+    SessionDisplayState,
+    PowerRequestCreate,
+    PowerRequestAction,
+    GetPowerRequestList,
+    ProcessorInformationEx,
+    NotifyUserModeLegacyPowerEvent,
+    GroupPark,
+    ProcessorIdleDomains,
+    WakeTimerList,
+    SystemHiberFileSize,
+    PowerInformationLevelMaximum
+} POWER_INFORMATION_LEVEL;
 
-NTKERNELAPI
-ULONG
-NTAPI
-KeQueryMaximumProcessorCount(
-  VOID);
-#endif
+typedef enum {
+    PowerActionNone,
+    PowerActionReserved,
+    PowerActionSleep,
+    PowerActionHibernate,
+    PowerActionShutdown,
+    PowerActionShutdownReset,
+    PowerActionShutdownOff,
+    PowerActionWarmEject
+} POWER_ACTION, *PPOWER_ACTION;
 
-#endif /*  (NTDDI_VERSION >= NTDDI_VISTA) */
+typedef enum _DEVICE_POWER_STATE {
+    PowerDeviceUnspecified,
+    PowerDeviceD0,
+    PowerDeviceD1,
+    PowerDeviceD2,
+    PowerDeviceD3,
+    PowerDeviceMaximum
+} DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
 
-#if (NTDDI_VERSION >= NTDDI_WS08)
+typedef union _POWER_STATE {
+  SYSTEM_POWER_STATE  SystemState;
+  DEVICE_POWER_STATE  DeviceState;
+} POWER_STATE, *PPOWER_STATE;
 
-PVOID
-KeRegisterProcessorChangeCallback(
-  IN PPROCESSOR_CALLBACK_FUNCTION CallbackFunction,
-  IN PVOID CallbackContext OPTIONAL,
-  IN ULONG Flags);
+typedef enum _POWER_STATE_TYPE {
+  SystemPowerState = 0,
+  DevicePowerState
+} POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
 
-VOID
-KeDeregisterProcessorChangeCallback(
-  IN PVOID CallbackHandle);
-
-#endif /* (NTDDI_VERSION >= NTDDI_WS08) */
-
-#if (NTDDI_VERSION >= NTDDI_WIN7)
+#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_) */
 
-ULONG64
-NTAPI
-KeQueryTotalCycleTimeProcess(
-  IN OUT PKPROCESS Process,
-  OUT PULONG64 CycleTimeStamp);
+#endif /* !_PO_DDK_ */
 
-ULONG64
-NTAPI
-KeQueryTotalCycleTimeThread(
-  IN OUT PKTHREAD Thread,
-  OUT PULONG64 CycleTimeStamp);
+typedef VOID
+(DDKAPI *PREQUEST_POWER_COMPLETE)(
+  IN struct _DEVICE_OBJECT *DeviceObject,
+  IN UCHAR MinorFunction,
+  IN POWER_STATE PowerState,
+  IN PVOID Context,
+  IN struct _IO_STATUS_BLOCK *IoStatus);
 
-NTKERNELAPI
+typedef
 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);
+(DDKAPI POWER_SETTING_CALLBACK)(
+  IN LPCGUID SettingGuid,
+  IN PVOID Value,
+  IN ULONG ValueLength,
+  IN OUT PVOID Context OPTIONAL);
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-KeSetCoalescableTimer(
-  IN OUT PKTIMER Timer,
-  IN LARGE_INTEGER DueTime,
-  IN ULONG Period,
-  IN ULONG TolerableDelay,
-  IN PKDPC Dpc OPTIONAL);
+typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK;
 
-NTKERNELAPI
-ULONGLONG
-NTAPI
-KeQueryUnbiasedInterruptTime(
-  VOID);
 
-NTKERNELAPI
-ULONG
-NTAPI
-KeQueryActiveProcessorCountEx(
-  IN USHORT GroupNumber);
+/******************************************************************************
+ *                            Configuration Manager Types                     *
+ ******************************************************************************/
 
-NTKERNELAPI
-ULONG
-NTAPI
-KeQueryMaximumProcessorCountEx(
-  IN USHORT GroupNumber);
+/* Resource list definitions */
+typedef int CM_RESOURCE_TYPE;
 
-NTKERNELAPI
-USHORT
-NTAPI
-KeQueryActiveGroupCount(
-  VOID);
+#define CmResourceTypeNull              0
+#define CmResourceTypePort              1
+#define CmResourceTypeInterrupt         2
+#define CmResourceTypeMemory            3
+#define CmResourceTypeDma               4
+#define CmResourceTypeDeviceSpecific    5
+#define CmResourceTypeBusNumber         6
+#define CmResourceTypeNonArbitrated      128
+#define CmResourceTypeConfigData         128
+#define CmResourceTypeDevicePrivate      129
+#define CmResourceTypePcCardConfig       130
+#define CmResourceTypeMfCardConfig       131
 
-NTKERNELAPI
-USHORT
-NTAPI
-KeQueryMaximumGroupCount(
-  VOID);
+/* KEY_VALUE_Xxx.Type */
+#define REG_NONE                           0
+#define REG_SZ                             1
+#define REG_EXPAND_SZ                      2
+#define REG_BINARY                         3
+#define REG_DWORD                          4
+#define REG_DWORD_LITTLE_ENDIAN            4
+#define REG_DWORD_BIG_ENDIAN               5
+#define REG_LINK                           6
+#define REG_MULTI_SZ                       7
+#define REG_RESOURCE_LIST                  8
+#define REG_FULL_RESOURCE_DESCRIPTOR       9
+#define REG_RESOURCE_REQUIREMENTS_LIST    10
+#define REG_QWORD                         11
+#define REG_QWORD_LITTLE_ENDIAN           11
 
-NTKERNELAPI
-KAFFINITY
-NTAPI
-KeQueryGroupAffinity 
-  IN USHORT GroupNumber);
+/* Registry Access Rights */
+#define KEY_QUERY_VALUE         (0x0001)
+#define KEY_SET_VALUE           (0x0002)
+#define KEY_CREATE_SUB_KEY      (0x0004)
+#define KEY_ENUMERATE_SUB_KEYS  (0x0008)
+#define KEY_NOTIFY              (0x0010)
+#define KEY_CREATE_LINK         (0x0020)
+#define KEY_WOW64_32KEY         (0x0200)
+#define KEY_WOW64_64KEY         (0x0100)
+#define KEY_WOW64_RES           (0x0300)
 
-NTKERNELAPI
-ULONG
-NTAPI
-KeGetCurrentProcessorNumberEx(
-  OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL);
+#define KEY_READ                ((STANDARD_RIGHTS_READ       |\
+                                  KEY_QUERY_VALUE            |\
+                                  KEY_ENUMERATE_SUB_KEYS     |\
+                                  KEY_NOTIFY)                 \
+                                  &                           \
+                                 (~SYNCHRONIZE))
 
-NTKERNELAPI
-VOID
-NTAPI
-KeQueryNodeActiveAffinity(
-  IN USHORT NodeNumber,
-  OUT PGROUP_AFFINITY Affinity OPTIONAL,
-  OUT PUSHORT Count OPTIONAL);
+#define KEY_WRITE               ((STANDARD_RIGHTS_WRITE      |\
+                                  KEY_SET_VALUE              |\
+                                  KEY_CREATE_SUB_KEY)         \
+                                  &                           \
+                                 (~SYNCHRONIZE))
 
-NTKERNELAPI
-USHORT
-NTAPI
-KeQueryNodeMaximumProcessorCount(
-  IN USHORT NodeNumber);
+#define KEY_EXECUTE             ((KEY_READ)                   \
+                                  &                           \
+                                 (~SYNCHRONIZE))
 
-NTKERNELAPI
-USHORT
-NTAPI
-KeQueryHighestNodeNumber(
-  VOID);
+#define KEY_ALL_ACCESS          ((STANDARD_RIGHTS_ALL        |\
+                                  KEY_QUERY_VALUE            |\
+                                  KEY_SET_VALUE              |\
+                                  KEY_CREATE_SUB_KEY         |\
+                                  KEY_ENUMERATE_SUB_KEYS     |\
+                                  KEY_NOTIFY                 |\
+                                  KEY_CREATE_LINK)            \
+                                  &                           \
+                                 (~SYNCHRONIZE))
 
-NTKERNELAPI
-USHORT
-NTAPI
-KeGetCurrentNodeNumber(
-  VOID);
+/* Registry Open/Create Options */
+#define REG_OPTION_RESERVED         (0x00000000L)
+#define REG_OPTION_NON_VOLATILE     (0x00000000L)
+#define REG_OPTION_VOLATILE         (0x00000001L)
+#define REG_OPTION_CREATE_LINK      (0x00000002L)
+#define REG_OPTION_BACKUP_RESTORE   (0x00000004L)
+#define REG_OPTION_OPEN_LINK        (0x00000008L)
 
-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);
+#define REG_LEGAL_OPTION            \
+                (REG_OPTION_RESERVED            |\
+                 REG_OPTION_NON_VOLATILE        |\
+                 REG_OPTION_VOLATILE            |\
+                 REG_OPTION_CREATE_LINK         |\
+                 REG_OPTION_BACKUP_RESTORE      |\
+                 REG_OPTION_OPEN_LINK)
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeSaveExtendedProcessorState(
-  IN ULONG64 Mask,
-  OUT PXSTATE_SAVE XStateSave);
+/* Key creation/open disposition */
+#define REG_CREATED_NEW_KEY         (0x00000001L)
+#define REG_OPENED_EXISTING_KEY     (0x00000002L)
 
-NTKERNELAPI
-VOID
-NTAPI
-KeRestoreExtendedProcessorState(
-  IN PXSTATE_SAVE XStateSave);
+/* Key restore & hive load flags */
+#define REG_WHOLE_HIVE_VOLATILE         (0x00000001L)
+#define REG_REFRESH_HIVE                (0x00000002L)
+#define REG_NO_LAZY_FLUSH               (0x00000004L)
+#define REG_FORCE_RESTORE               (0x00000008L)
+#define REG_APP_HIVE                    (0x00000010L)
+#define REG_PROCESS_PRIVATE             (0x00000020L)
+#define REG_START_JOURNAL               (0x00000040L)
+#define REG_HIVE_EXACT_FILE_GROWTH      (0x00000080L)
+#define REG_HIVE_NO_RM                  (0x00000100L)
+#define REG_HIVE_SINGLE_LOG             (0x00000200L)
 
-#endif /*  (NTDDI_VERSION >= NTDDI_WIN7) */
+/* Unload Flags */
+#define REG_FORCE_UNLOAD            1
 
-#if defined(_X86_)
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeSaveFloatingPointState(
-  OUT PKFLOATING_SAVE  FloatSave);
+/* Notify Filter Values */
+#define REG_NOTIFY_CHANGE_NAME          (0x00000001L)
+#define REG_NOTIFY_CHANGE_ATTRIBUTES    (0x00000002L)
+#define REG_NOTIFY_CHANGE_LAST_SET      (0x00000004L)
+#define REG_NOTIFY_CHANGE_SECURITY      (0x00000008L)
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-KeRestoreFloatingPointState(
-  IN PKFLOATING_SAVE  FloatSave);
-#endif
+#define REG_LEGAL_CHANGE_FILTER                 \
+                (REG_NOTIFY_CHANGE_NAME          |\
+                 REG_NOTIFY_CHANGE_ATTRIBUTES    |\
+                 REG_NOTIFY_CHANGE_LAST_SET      |\
+                 REG_NOTIFY_CHANGE_SECURITY)
 
-#if defined(_IA64_)
-FORCEINLINE
-VOID
-KeFlushWriteBuffer(VOID)
-{
-  __mf ();
-  return;
-}
+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;
+  UCHAR ShareDisposition;
+  USHORT Flags;
+  union {
+    struct {
+      PHYSICAL_ADDRESS Start;
+      ULONG Length;
+    } Generic;
+    struct {
+      PHYSICAL_ADDRESS Start;
+      ULONG Length;
+    } Port;
+    struct {
+#if defined(NT_PROCESSOR_GROUPS)
+      USHORT Level;
+      USHORT Group;
 #else
-NTHALAPI
-VOID
-NTAPI
-KeFlushWriteBuffer(VOID);
+      ULONG Level;
 #endif
-
-/*
- * VOID
- * KeFlushIoBuffers(
- *   IN PMDL  Mdl,
- *   IN BOOLEAN  ReadOperation,
- *   IN BOOLEAN  DmaOperation)
- */
-#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
-
-#define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
-#define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
-#define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
-#define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
-
-#if (NTDDI_VERSION >= NTDDI_WS03)
-NTKERNELAPI
-BOOLEAN
-FASTCALL
-KeTestSpinLock(
-    IN PKSPIN_LOCK SpinLock
-);
+      ULONG Vector;
+      KAFFINITY Affinity;
+    } Interrupt;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    struct {
+      __GNU_EXTENSION union {
+        struct {
+#if defined(NT_PROCESSOR_GROUPS)
+          USHORT Group;
+#else
+          USHORT Reserved;
 #endif
-
-NTHALAPI
-KIRQL
-NTAPI
-KeGetCurrentIrql(
-    VOID);
-
-#if defined(_M_AMD64)
-FORCEINLINE
-PKTHREAD
-KeGetCurrentThread (
-  VOID)
-{
-    return (struct _KTHREAD *)__readgsqword(0x188);
-}
+          USHORT MessageCount;
+          ULONG Vector;
+          KAFFINITY Affinity;
+        } Raw;
+        struct {
+#if defined(NT_PROCESSOR_GROUPS)
+          USHORT Level;
+          USHORT Group;
+#else
+          ULONG Level;
 #endif
-
-#if defined(_M_IX86) || defined(_M_IA64)
-NTSYSAPI
-PKTHREAD
-NTAPI
-KeGetCurrentThread(
-  VOID);
+          ULONG Vector;
+          KAFFINITY Affinity;
+        } Translated;
+      } DUMMYUNIONNAME;
+    } MessageInterrupt;
 #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 )
+    struct {
+      PHYSICAL_ADDRESS Start;
+      ULONG Length;
+    } Memory;
+    struct {
+      ULONG Channel;
+      ULONG Port;
+      ULONG Reserved1;
+    } Dma;
+    struct {
+      ULONG Data[3];
+    } DevicePrivate;
+    struct {
+      ULONG Start;
+      ULONG Length;
+      ULONG Reserved;
+    } BusNumber;
+    struct {
+      ULONG DataSize;
+      ULONG Reserved1;
+      ULONG Reserved2;
+    } DeviceSpecificData;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    struct {
+      PHYSICAL_ADDRESS Start;
+      ULONG Length40;
+    } Memory40;
+    struct {
+      PHYSICAL_ADDRESS Start;
+      ULONG Length48;
+    } Memory48;
+    struct {
+      PHYSICAL_ADDRESS Start;
+      ULONG Length64;
+    } Memory64;
 #endif
+  } u;
+} CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
+#include <poppack.h>
 
-#define PAGED_CODE() { \
-  if (KeGetCurrentIrql() > APC_LEVEL) { \
-    KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \
-    PAGED_ASSERT(FALSE); \
-  } \
-}
+/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
+#define CmResourceTypeNull                0
+#define CmResourceTypePort                1
+#define CmResourceTypeInterrupt           2
+#define CmResourceTypeMemory              3
+#define CmResourceTypeDma                 4
+#define CmResourceTypeDeviceSpecific      5
+#define CmResourceTypeBusNumber           6
+#define CmResourceTypeMemoryLarge         7
+#define CmResourceTypeNonArbitrated     128
+#define CmResourceTypeConfigData        128
+#define CmResourceTypeDevicePrivate     129
+#define CmResourceTypePcCardConfig      130
+#define CmResourceTypeMfCardConfig      131
 
-#else
+/* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
+typedef enum _CM_SHARE_DISPOSITION {
+  CmResourceShareUndetermined,
+  CmResourceShareDeviceExclusive,
+  CmResourceShareDriverExclusive,
+  CmResourceShareShared
+} CM_SHARE_DISPOSITION;
 
-#define PAGED_CODE()
+/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
+#define CM_RESOURCE_PORT_MEMORY           0x0000
+#define CM_RESOURCE_PORT_IO               0x0001
+#define CM_RESOURCE_PORT_10_BIT_DECODE    0x0004
+#define CM_RESOURCE_PORT_12_BIT_DECODE    0x0008
+#define CM_RESOURCE_PORT_16_BIT_DECODE    0x0010
+#define CM_RESOURCE_PORT_POSITIVE_DECODE  0x0020
+#define CM_RESOURCE_PORT_PASSIVE_DECODE   0x0040
+#define CM_RESOURCE_PORT_WINDOW_DECODE    0x0080
+#define CM_RESOURCE_PORT_BAR              0x0100
 
-#endif
+/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
+#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
+#define CM_RESOURCE_INTERRUPT_LATCHED         0x0001
+#define CM_RESOURCE_INTERRUPT_MESSAGE         0x0002
+#define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004
 
-#define PAGED_CODE_LOCKED() NOP_FUNCTION;
+/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
+#define CM_RESOURCE_MEMORY_READ_WRITE                    0x0000
+#define CM_RESOURCE_MEMORY_READ_ONLY                     0x0001
+#define CM_RESOURCE_MEMORY_WRITE_ONLY                    0x0002
+#define CM_RESOURCE_MEMORY_WRITEABILITY_MASK             0x0003
+#define CM_RESOURCE_MEMORY_PREFETCHABLE                  0x0004
+#define CM_RESOURCE_MEMORY_COMBINEDWRITE                 0x0008
+#define CM_RESOURCE_MEMORY_24                            0x0010
+#define CM_RESOURCE_MEMORY_CACHEABLE                     0x0020
+#define CM_RESOURCE_MEMORY_WINDOW_DECODE                 0x0040
+#define CM_RESOURCE_MEMORY_BAR                           0x0080
+#define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100
 
+/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
+#define CM_RESOURCE_DMA_8                 0x0000
+#define CM_RESOURCE_DMA_16                0x0001
+#define CM_RESOURCE_DMA_32                0x0002
+#define CM_RESOURCE_DMA_8_AND_16          0x0004
+#define CM_RESOURCE_DMA_BUS_MASTER        0x0008
+#define CM_RESOURCE_DMA_TYPE_A            0x0010
+#define CM_RESOURCE_DMA_TYPE_B            0x0020
+#define CM_RESOURCE_DMA_TYPE_F            0x0040
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+typedef struct _CM_PARTIAL_RESOURCE_LIST {
+  USHORT  Version;
+  USHORT  Revision;
+  ULONG  Count;
+  CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
+} CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
 
-NTKERNELAPI
-VOID
-NTAPI
-ProbeForRead(
-  IN CONST VOID *Address, /* CONST is added */
-  IN SIZE_T Length,
-  IN ULONG Alignment);
+typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
+  INTERFACE_TYPE  InterfaceType;
+  ULONG  BusNumber;
+  CM_PARTIAL_RESOURCE_LIST  PartialResourceList;
+} CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
 
-NTKERNELAPI
-VOID
-NTAPI
-ProbeForWrite(
-  IN PVOID Address,
-  IN SIZE_T Length,
-  IN ULONG Alignment);
+typedef struct _CM_RESOURCE_LIST {
+  ULONG  Count;
+  CM_FULL_RESOURCE_DESCRIPTOR  List[1];
+} CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
 
-#endif
+#include <pshpack1.h>
+typedef struct _CM_INT13_DRIVE_PARAMETER {
+  USHORT  DriveSelect;
+  ULONG  MaxCylinders;
+  USHORT  SectorsPerTrack;
+  USHORT  MaxHeads;
+  USHORT  NumberDrives;
+} CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
 
-#if defined(_X86_) || defined(_AMD64_)
+typedef struct _CM_PNP_BIOS_DEVICE_NODE {
+  USHORT Size;
+  UCHAR Node;
+  ULONG ProductId;
+  UCHAR DeviceType[3];
+  USHORT DeviceAttributes;
+} CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
 
-/* x86 and x64 performs a 0x2C interrupt */
-#define DbgRaiseAssertionFailure __int2c
+typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
+  UCHAR Signature[4];
+  UCHAR Revision;
+  UCHAR Length;
+  USHORT ControlField;
+  UCHAR Checksum;
+  ULONG EventFlagAddress;
+  USHORT RealModeEntryOffset;
+  USHORT RealModeEntrySegment;
+  USHORT ProtectedModeEntryOffset;
+  ULONG ProtectedModeCodeBaseAddress;
+  ULONG OemDeviceId;
+  USHORT RealModeDataBaseAddress;
+  ULONG ProtectedModeDataBaseAddress;
+} CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
+#include <poppack.h>
 
-#elif defined(_ARM_)
+typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA {
+    ULONG BytesPerSector;
+    ULONG NumberOfCylinders;
+    ULONG SectorsPerTrack;
+    ULONG NumberOfHeads;
+} CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
 
-//
-// TODO
-//
+typedef struct _CM_KEYBOARD_DEVICE_DATA {
+  USHORT  Version;
+  USHORT  Revision;
+  UCHAR  Type;
+  UCHAR  Subtype;
+  USHORT  KeyboardFlags;
+} CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
 
-#else
-#error Unsupported Architecture
-#endif
+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;
 
-/******************************************************************************
- *                         Memory manager Types                               *
- ******************************************************************************/
+#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
 
-#define PAGE_SIZE                         0x1000
-#define PAGE_SHIFT                        12L
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
 
-#define MM_DONT_ZERO_ALLOCATION                 0x00000001
-#define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY        0x00000002
-#define MM_ALLOCATE_FULLY_REQUIRED              0x00000004
-#define MM_ALLOCATE_NO_WAIT                     0x00000008
-#define MM_ALLOCATE_PREFER_CONTIGUOUS           0x00000010
-#define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS   0x00000020
+typedef struct _CM_SCSI_DEVICE_DATA {
+  USHORT  Version;
+  USHORT  Revision;
+  UCHAR  HostIdentifier;
+} CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
 
-#define MDL_MAPPED_TO_SYSTEM_VA     0x0001
-#define MDL_PAGES_LOCKED            0x0002
-#define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
-#define MDL_ALLOCATED_FIXED_SIZE    0x0008
-#define MDL_PARTIAL                 0x0010
-#define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
-#define MDL_IO_PAGE_READ            0x0040
-#define MDL_WRITE_OPERATION         0x0080
-#define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
-#define MDL_FREE_EXTRA_PTES         0x0200
-#define MDL_DESCRIBES_AWE           0x0400
-#define MDL_IO_SPACE                0x0800
-#define MDL_NETWORK_HEADER          0x1000
-#define MDL_MAPPING_CAN_FAIL        0x2000
-#define MDL_ALLOCATED_MUST_SUCCEED  0x4000
-#define MDL_INTERNAL                0x8000
+typedef struct _CM_SERIAL_DEVICE_DATA {
+  USHORT  Version;
+  USHORT  Revision;
+  ULONG  BaudClock;
+} CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
 
-#define MDL_MAPPING_FLAGS ( \
-  MDL_MAPPED_TO_SYSTEM_VA     | \
-  MDL_PAGES_LOCKED            | \
-  MDL_SOURCE_IS_NONPAGED_POOL | \
-  MDL_PARTIAL_HAS_BEEN_MAPPED | \
-  MDL_PARENT_MAPPED_SYSTEM_VA | \
-  MDL_SYSTEM_VA               | \
-  MDL_IO_SPACE)
+typedef enum _KEY_INFORMATION_CLASS {
+  KeyBasicInformation,
+  KeyNodeInformation,
+  KeyFullInformation,
+  KeyNameInformation,
+  KeyCachedInformation,
+  KeyFlagsInformation
+} KEY_INFORMATION_CLASS;
 
-#define FLUSH_MULTIPLE_MAXIMUM 32
+typedef struct _KEY_BASIC_INFORMATION {
+  LARGE_INTEGER  LastWriteTime;
+  ULONG  TitleIndex;
+  ULONG  NameLength;
+  WCHAR  Name[1];
+} KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
 
-/* Section access rights */
-#define SECTION_QUERY                0x0001
-#define SECTION_MAP_WRITE            0x0002
-#define SECTION_MAP_READ             0x0004
-#define SECTION_MAP_EXECUTE          0x0008
-#define SECTION_EXTEND_SIZE          0x0010
-#define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
+typedef struct _KEY_FULL_INFORMATION {
+  LARGE_INTEGER  LastWriteTime;
+  ULONG  TitleIndex;
+  ULONG  ClassOffset;
+  ULONG  ClassLength;
+  ULONG  SubKeys;
+  ULONG  MaxNameLen;
+  ULONG  MaxClassLen;
+  ULONG  Values;
+  ULONG  MaxValueNameLen;
+  ULONG  MaxValueDataLen;
+  WCHAR  Class[1];
+} KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
 
-#define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\
-                            SECTION_MAP_WRITE |      \
-                            SECTION_MAP_READ |       \
-                            SECTION_MAP_EXECUTE |    \
-                            SECTION_EXTEND_SIZE)
+typedef struct _KEY_NODE_INFORMATION {
+  LARGE_INTEGER  LastWriteTime;
+  ULONG  TitleIndex;
+  ULONG  ClassOffset;
+  ULONG  ClassLength;
+  ULONG  NameLength;
+  WCHAR  Name[1];
+} KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
 
-#define SESSION_QUERY_ACCESS  0x0001
-#define SESSION_MODIFY_ACCESS 0x0002
+typedef struct _KEY_VALUE_BASIC_INFORMATION {
+  ULONG  TitleIndex;
+  ULONG  Type;
+  ULONG  NameLength;
+  WCHAR  Name[1];
+} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
 
-#define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |  \
-                            SESSION_QUERY_ACCESS |             \
-                            SESSION_MODIFY_ACCESS)
+typedef struct _KEY_VALUE_FULL_INFORMATION {
+  ULONG  TitleIndex;
+  ULONG  Type;
+  ULONG  DataOffset;
+  ULONG  DataLength;
+  ULONG  NameLength;
+  WCHAR  Name[1];
+} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
 
-#define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
+typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
+  ULONG  TitleIndex;
+  ULONG  Type;
+  ULONG  DataLength;
+  UCHAR  Data[1];
+} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
 
-#define PAGE_NOACCESS          0x01
-#define PAGE_READONLY          0x02
-#define PAGE_READWRITE         0x04
-#define PAGE_WRITECOPY         0x08
-#define PAGE_EXECUTE           0x10
-#define PAGE_EXECUTE_READ      0x20
-#define PAGE_EXECUTE_READWRITE 0x40
-#define PAGE_EXECUTE_WRITECOPY 0x80
-#define PAGE_GUARD            0x100
-#define PAGE_NOCACHE          0x200
-#define PAGE_WRITECOMBINE     0x400
+typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
+  ULONG  Type;
+  ULONG  DataLength;
+  UCHAR  Data[1];
+} KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
 
-#define MEM_COMMIT           0x1000
-#define MEM_RESERVE          0x2000
-#define MEM_DECOMMIT         0x4000
-#define MEM_RELEASE          0x8000
-#define MEM_FREE            0x10000
-#define MEM_PRIVATE         0x20000
-#define MEM_MAPPED          0x40000
-#define MEM_RESET           0x80000
-#define MEM_TOP_DOWN       0x100000
-#define MEM_LARGE_PAGES  0x20000000
-#define MEM_4MB_PAGES    0x80000000
+typedef struct _KEY_VALUE_ENTRY {
+  PUNICODE_STRING  ValueName;
+  ULONG  DataLength;
+  ULONG  DataOffset;
+  ULONG  Type;
+} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
 
-#define SEC_RESERVE       0x4000000
-#define SEC_COMMIT        0x8000000
-#define SEC_LARGE_PAGES  0x80000000
+typedef enum _KEY_VALUE_INFORMATION_CLASS {
+  KeyValueBasicInformation,
+  KeyValueFullInformation,
+  KeyValuePartialInformation,
+  KeyValueFullInformationAlign64,
+  KeyValuePartialInformationAlign64
+} KEY_VALUE_INFORMATION_CLASS;
 
-/* Section map options */
-typedef enum _SECTION_INHERIT {
-    ViewShare = 1,
-    ViewUnmap = 2
-} SECTION_INHERIT;
-
-typedef ULONG PFN_COUNT;
-typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
-typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
-
-typedef struct _MDL {
-    struct _MDL *Next;
-    CSHORT Size;
-    CSHORT MdlFlags;
-    struct _EPROCESS *Process;
-    PVOID MappedSystemVa;
-    PVOID StartVa;
-    ULONG ByteCount;
-    ULONG ByteOffset;
-} MDL, *PMDL;
-typedef MDL *PMDLX;
+typedef struct _KEY_WRITE_TIME_INFORMATION {
+  LARGE_INTEGER  LastWriteTime;
+} KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
 
-typedef enum _MEMORY_CACHING_TYPE_ORIG {
-  MmFrameBufferCached = 2
-} MEMORY_CACHING_TYPE_ORIG;
+typedef enum _KEY_SET_INFORMATION_CLASS {
+  KeyWriteTimeInformation,
+  KeyWow64FlagsInformation,
+  KeyControlFlagsInformation,
+  KeySetVirtualizationInformation,
+  KeySetDebugInformation,
+  KeySetHandleTagsInformation,
+  MaxKeySetInfoClass
+} KEY_SET_INFORMATION_CLASS;
 
-typedef enum _MEMORY_CACHING_TYPE {
-  MmNonCached = FALSE,
-  MmCached = TRUE,
-  MmWriteCombined = MmFrameBufferCached,
-  MmHardwareCoherentCached,
-  MmNonCachedUnordered,
-  MmUSWCCached,
-  MmMaximumCacheType
-} MEMORY_CACHING_TYPE;
+typedef enum _REG_NOTIFY_CLASS {
+  RegNtDeleteKey,
+  RegNtPreDeleteKey = RegNtDeleteKey,
+  RegNtSetValueKey,
+  RegNtPreSetValueKey = RegNtSetValueKey,
+  RegNtDeleteValueKey,
+  RegNtPreDeleteValueKey = RegNtDeleteValueKey,
+  RegNtSetInformationKey,
+  RegNtPreSetInformationKey = RegNtSetInformationKey,
+  RegNtRenameKey,
+  RegNtPreRenameKey = RegNtRenameKey,
+  RegNtEnumerateKey,
+  RegNtPreEnumerateKey = RegNtEnumerateKey,
+  RegNtEnumerateValueKey,
+  RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
+  RegNtQueryKey,
+  RegNtPreQueryKey = RegNtQueryKey,
+  RegNtQueryValueKey,
+  RegNtPreQueryValueKey = RegNtQueryValueKey,
+  RegNtQueryMultipleValueKey,
+  RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
+  RegNtPreCreateKey,
+  RegNtPostCreateKey,
+  RegNtPreOpenKey,
+  RegNtPostOpenKey,
+  RegNtKeyHandleClose,
+  RegNtPreKeyHandleClose = RegNtKeyHandleClose,
+  RegNtPostDeleteKey,
+  RegNtPostSetValueKey,
+  RegNtPostDeleteValueKey,
+  RegNtPostSetInformationKey,
+  RegNtPostRenameKey,
+  RegNtPostEnumerateKey,
+  RegNtPostEnumerateValueKey,
+  RegNtPostQueryKey,
+  RegNtPostQueryValueKey,
+  RegNtPostQueryMultipleValueKey,
+  RegNtPostKeyHandleClose,
+  RegNtPreCreateKeyEx,
+  RegNtPostCreateKeyEx,
+  RegNtPreOpenKeyEx,
+  RegNtPostOpenKeyEx,
+  RegNtPreFlushKey,
+  RegNtPostFlushKey,
+  RegNtPreLoadKey,
+  RegNtPostLoadKey,
+  RegNtPreUnLoadKey,
+  RegNtPostUnLoadKey,
+  RegNtPreQueryKeySecurity,
+  RegNtPostQueryKeySecurity,
+  RegNtPreSetKeySecurity,
+  RegNtPostSetKeySecurity,
+  RegNtCallbackObjectContextCleanup,
+  RegNtPreRestoreKey,
+  RegNtPostRestoreKey,
+  RegNtPreSaveKey,
+  RegNtPostSaveKey,
+  RegNtPreReplaceKey,
+  RegNtPostReplaceKey,
+  MaxRegNtNotifyClass
+} REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
 
-typedef enum _MM_PAGE_PRIORITY {
-  LowPagePriority,
-  NormalPagePriority = 16,
-  HighPagePriority = 32
-} MM_PAGE_PRIORITY;
+typedef NTSTATUS
+(NTAPI *PEX_CALLBACK_FUNCTION)(
+    IN PVOID CallbackContext,
+    IN PVOID Argument1,
+    IN PVOID Argument2
+);
 
-typedef enum _LOCK_OPERATION {
-  IoReadAccess,
-  IoWriteAccess,
-  IoModifyAccess
-} LOCK_OPERATION;
+typedef struct _REG_DELETE_KEY_INFORMATION {
+  PVOID Object;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+, REG_FLUSH_KEY_INFORMATION, *PREG_FLUSH_KEY_INFORMATION
+#endif
+;
 
-typedef enum _MM_SYSTEM_SIZE {
-  MmSmallSystem,
-  MmMediumSystem,
-  MmLargeSystem
-} MM_SYSTEMSIZE;
+typedef struct _REG_SET_VALUE_KEY_INFORMATION {
+  PVOID Object;
+  PUNICODE_STRING ValueName;
+  ULONG TitleIndex;
+  ULONG Type;
+  PVOID Data;
+  ULONG DataSize;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
 
+typedef struct _REG_DELETE_VALUE_KEY_INFORMATION {
+  PVOID Object;
+  PUNICODE_STRING ValueName;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
 
-/******************************************************************************
- *                       Memory manager Functions                             *
- ******************************************************************************/
+typedef struct _REG_SET_INFORMATION_KEY_INFORMATION {
+  PVOID Object;
+  KEY_SET_INFORMATION_CLASS KeySetInformationClass;
+  PVOID KeySetInformation;
+  ULONG KeySetInformationLength;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
 
-/*
- * Alignment Macros
- */
-#define ALIGN_DOWN_BY(size, align) \
-    ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
+typedef struct _REG_ENUMERATE_KEY_INFORMATION {
+  PVOID Object;
+  ULONG Index;
+  KEY_INFORMATION_CLASS KeyInformationClass;
+  PVOID KeyInformation;
+  ULONG Length;
+  PULONG ResultLength;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
 
-#define ALIGN_UP_BY(size, align) \
-    (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
+typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION {
+  PVOID Object;
+  ULONG Index;
+  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
+  PVOID KeyValueInformation;
+  ULONG Length;
+  PULONG ResultLength;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
 
-#define ALIGN_DOWN_POINTER_BY(ptr, align) \
-    ((PVOID)ALIGN_DOWN_BY(ptr, align))
+typedef struct _REG_QUERY_KEY_INFORMATION {
+  PVOID Object;
+  KEY_INFORMATION_CLASS KeyInformationClass;
+  PVOID KeyInformation;
+  ULONG Length;
+  PULONG ResultLength;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
 
-#define ALIGN_UP_POINTER_BY(ptr, align) \
-    ((PVOID)ALIGN_UP_BY(ptr, align))
+typedef struct _REG_QUERY_VALUE_KEY_INFORMATION {
+  PVOID Object;
+  PUNICODE_STRING ValueName;
+  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
+  PVOID KeyValueInformation;
+  ULONG Length;
+  PULONG ResultLength;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
 
-#define ALIGN_DOWN(size, type) \
-    ALIGN_DOWN_BY(size, sizeof(type))
+typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION {
+  PVOID Object;
+  PKEY_VALUE_ENTRY ValueEntries;
+  ULONG EntryCount;
+  PVOID ValueBuffer;
+  PULONG BufferLength;
+  PULONG RequiredBufferLength;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
 
-#define ALIGN_UP(size, type) \
-    ALIGN_UP_BY(size, sizeof(type))
+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;;
 
-#define ALIGN_DOWN_POINTER(ptr, type) \
-    ALIGN_DOWN_POINTER_BY(ptr, sizeof(type))
+typedef struct _REG_POST_CREATE_KEY_INFORMATION {
+  PUNICODE_STRING CompleteName;
+  PVOID Object;
+  NTSTATUS Status;
+} REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
 
-#define ALIGN_UP_POINTER(ptr, type) \
-    ALIGN_UP_POINTER_BY(ptr, sizeof(type))
+typedef struct _REG_POST_OPERATION_INFORMATION {
+  PVOID Object;
+  NTSTATUS Status;
+  PVOID PreInformation;
+  NTSTATUS ReturnStatus;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
 
-/* ULONG
- * BYTE_OFFSET(
- *   IN PVOID  Va)
- */
-#define BYTE_OFFSET(Va) \
-  ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
+typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION {
+  PVOID Object;
+  PVOID CallContext;
+  PVOID ObjectContext;
+  PVOID Reserved;
+} REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
 
-/* ULONG
- * BYTES_TO_PAGES(
- *   IN ULONG  Size)
- */
-#define BYTES_TO_PAGES(Size) \
-  (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0))
+/******************************************************************************
+ *                         I/O Manager Types                                  *
+ ******************************************************************************/
 
-/* PVOID
- * PAGE_ALIGN(
- *   IN PVOID  Va)
- */
-#define PAGE_ALIGN(Va) \
-  ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
+ /* 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
 
-/* ULONG_PTR
- * ROUND_TO_PAGES(
- *   IN ULONG_PTR  Size)
- */
-#define ROUND_TO_PAGES(Size) \
-  (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
+/* 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
 
-/*
- * ULONG
- * MmGetMdlByteCount(
- *   IN PMDL  Mdl)
- */
-#define MmGetMdlByteCount(_Mdl) \
-  ((_Mdl)->ByteCount)
+/* PCI_COMMON_CONFIG.HeaderType */
+#define PCI_MULTIFUNCTION                 0x80
+#define PCI_DEVICE_TYPE                   0x00
+#define PCI_BRIDGE_TYPE                   0x01
+#define PCI_CARDBUS_BRIDGE_TYPE           0x02
 
-/*
- * ULONG
- * MmGetMdlByteOffset(
- *   IN PMDL  Mdl)
- */
-#define MmGetMdlByteOffset(_Mdl) \
-  ((_Mdl)->ByteOffset)
+#define PCI_CONFIGURATION_TYPE(PciData) \
+  (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
 
-/*
- * PPFN_NUMBER
- * MmGetMdlPfnArray(
- *   IN PMDL  Mdl)
- */
-#define MmGetMdlPfnArray(_Mdl) \
-  ((PPFN_NUMBER) ((_Mdl) + 1))
+#define PCI_MULTIFUNCTION_DEVICE(PciData) \
+  ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
 
-/*
- * PVOID
- * MmGetMdlVirtualAddress(
- *   IN PMDL  Mdl)
- */
-#define MmGetMdlVirtualAddress(_Mdl) \
-  ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))
+/* 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 MmGetProcedureAddress(Address) (Address)
+/* PCI device subclasses for class 0 */
+#define PCI_SUBCLASS_PRE_20_NON_VGA         0x00
+#define PCI_SUBCLASS_PRE_20_VGA             0x01
 
-/* 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)))
+/* 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
 
-/* 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)))
+/* 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
 
-/*
- * 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; \
-}
+/* 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
 
-/*
- * 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); \
-  } \
-}
+/* 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
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+/* 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
 
-NTKERNELAPI
-PVOID
-NTAPI
-MmAllocateContiguousMemory(
-  IN SIZE_T  NumberOfBytes,
-  IN PHYSICAL_ADDRESS  HighestAcceptableAddress);
+/* 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
 
-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);
+/* 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
 
-NTKERNELAPI
-PMDL
-NTAPI
-MmAllocatePagesForMdl(
-  IN PHYSICAL_ADDRESS  LowAddress,
-  IN PHYSICAL_ADDRESS  HighAddress,
-  IN PHYSICAL_ADDRESS  SkipBytes,
-  IN SIZE_T  TotalBytes);
+#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))
 
-NTKERNELAPI
-VOID
-NTAPI
-MmBuildMdlForNonPagedPool(
-  IN OUT PMDLX  MemoryDescriptorList);
+#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
 
-//DECLSPEC_DEPRECATED_DDK
-NTKERNELAPI
-PMDL
-NTAPI
-MmCreateMdl(
-  IN PMDL  MemoryDescriptorList  OPTIONAL,
-  IN PVOID  Base,
-  IN SIZE_T  Length);
+#define PCI_TYPE_32BIT 0
+#define PCI_TYPE_20BIT 2
+#define PCI_TYPE_64BIT 4
 
-NTKERNELAPI
-VOID
-NTAPI
-MmFreeContiguousMemory(
-  IN PVOID  BaseAddress);
+#define POOL_COLD_ALLOCATION                256
+#define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE    8
+#define POOL_RAISE_IF_ALLOCATION_FAILURE    16
 
-NTKERNELAPI
-VOID
-NTAPI
-MmFreeContiguousMemorySpecifyCache(
-  IN PVOID  BaseAddress,
-  IN SIZE_T  NumberOfBytes,
-  IN MEMORY_CACHING_TYPE  CacheType);
+#define PCI_TYPE0_ADDRESSES               6
+#define PCI_TYPE1_ADDRESSES               2
+#define PCI_TYPE2_ADDRESSES               5
 
-NTKERNELAPI
-VOID
-NTAPI
-MmFreePagesFromMdl(
-  IN PMDLX MemoryDescriptorList);
+#define IO_TYPE_ADAPTER                 1
+#define IO_TYPE_CONTROLLER              2
+#define IO_TYPE_DEVICE                  3
+#define IO_TYPE_DRIVER                  4
+#define IO_TYPE_FILE                    5
+#define IO_TYPE_IRP                     6
+#define IO_TYPE_MASTER_ADAPTER          7
+#define IO_TYPE_OPEN_PACKET             8
+#define IO_TYPE_TIMER                   9
+#define IO_TYPE_VPB                     10
+#define IO_TYPE_ERROR_LOG               11
+#define IO_TYPE_ERROR_MESSAGE           12
+#define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
 
-NTKERNELAPI
-PVOID
-NTAPI
-MmGetSystemRoutineAddress(
-  IN PUNICODE_STRING  SystemRoutineName);
+#define IO_TYPE_CSQ_IRP_CONTEXT 1
+#define IO_TYPE_CSQ 2
+#define IO_TYPE_CSQ_EX 3
 
-NTKERNELAPI
-LOGICAL
-NTAPI
-MmIsDriverVerifying(
-  IN struct _DRIVER_OBJECT *DriverObject);
+/* IO_RESOURCE_DESCRIPTOR.Option */
+#define IO_RESOURCE_PREFERRED             0x01
+#define IO_RESOURCE_DEFAULT               0x02
+#define IO_RESOURCE_ALTERNATIVE           0x08
 
-NTKERNELAPI
-PVOID
-NTAPI
-MmLockPagableDataSection(
-  IN PVOID  AddressWithinSection);
+/* 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
 
-NTKERNELAPI
-PVOID
-NTAPI
-MmMapIoSpace(
-  IN PHYSICAL_ADDRESS  PhysicalAddress,
-  IN SIZE_T  NumberOfBytes,
-  IN MEMORY_CACHING_TYPE  CacheEnable);
+/* 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
 
-NTKERNELAPI
-PVOID
-NTAPI
-MmMapLockedPages(
-  IN PMDL  MemoryDescriptorList,
-  IN KPROCESSOR_MODE  AccessMode);
+/* 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
 
-NTKERNELAPI
-PVOID
-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);
+/* DEVICE_OBJECT.DeviceType */
+#define DEVICE_TYPE ULONG
 
-NTKERNELAPI
-PVOID
-NTAPI
-MmPageEntireDriver(
-  IN PVOID  AddressWithinSection);
+#define FILE_DEVICE_BEEP                  0x00000001
+#define FILE_DEVICE_CD_ROM                0x00000002
+#define FILE_DEVICE_CD_ROM_FILE_SYSTEM    0x00000003
+#define FILE_DEVICE_CONTROLLER            0x00000004
+#define FILE_DEVICE_DATALINK              0x00000005
+#define FILE_DEVICE_DFS                   0x00000006
+#define FILE_DEVICE_DISK                  0x00000007
+#define FILE_DEVICE_DISK_FILE_SYSTEM      0x00000008
+#define FILE_DEVICE_FILE_SYSTEM           0x00000009
+#define FILE_DEVICE_INPORT_PORT           0x0000000a
+#define FILE_DEVICE_KEYBOARD              0x0000000b
+#define FILE_DEVICE_MAILSLOT              0x0000000c
+#define FILE_DEVICE_MIDI_IN               0x0000000d
+#define FILE_DEVICE_MIDI_OUT              0x0000000e
+#define FILE_DEVICE_MOUSE                 0x0000000f
+#define FILE_DEVICE_MULTI_UNC_PROVIDER    0x00000010
+#define FILE_DEVICE_NAMED_PIPE            0x00000011
+#define FILE_DEVICE_NETWORK               0x00000012
+#define FILE_DEVICE_NETWORK_BROWSER       0x00000013
+#define FILE_DEVICE_NETWORK_FILE_SYSTEM   0x00000014
+#define FILE_DEVICE_NULL                  0x00000015
+#define FILE_DEVICE_PARALLEL_PORT         0x00000016
+#define FILE_DEVICE_PHYSICAL_NETCARD      0x00000017
+#define FILE_DEVICE_PRINTER               0x00000018
+#define FILE_DEVICE_SCANNER               0x00000019
+#define FILE_DEVICE_SERIAL_MOUSE_PORT     0x0000001a
+#define FILE_DEVICE_SERIAL_PORT           0x0000001b
+#define FILE_DEVICE_SCREEN                0x0000001c
+#define FILE_DEVICE_SOUND                 0x0000001d
+#define FILE_DEVICE_STREAMS               0x0000001e
+#define FILE_DEVICE_TAPE                  0x0000001f
+#define FILE_DEVICE_TAPE_FILE_SYSTEM      0x00000020
+#define FILE_DEVICE_TRANSPORT             0x00000021
+#define FILE_DEVICE_UNKNOWN               0x00000022
+#define FILE_DEVICE_VIDEO                 0x00000023
+#define FILE_DEVICE_VIRTUAL_DISK          0x00000024
+#define FILE_DEVICE_WAVE_IN               0x00000025
+#define FILE_DEVICE_WAVE_OUT              0x00000026
+#define FILE_DEVICE_8042_PORT             0x00000027
+#define FILE_DEVICE_NETWORK_REDIRECTOR    0x00000028
+#define FILE_DEVICE_BATTERY               0x00000029
+#define FILE_DEVICE_BUS_EXTENDER          0x0000002a
+#define FILE_DEVICE_MODEM                 0x0000002b
+#define FILE_DEVICE_VDM                   0x0000002c
+#define FILE_DEVICE_MASS_STORAGE          0x0000002d
+#define FILE_DEVICE_SMB                   0x0000002e
+#define FILE_DEVICE_KS                    0x0000002f
+#define FILE_DEVICE_CHANGER               0x00000030
+#define FILE_DEVICE_SMARTCARD             0x00000031
+#define FILE_DEVICE_ACPI                  0x00000032
+#define FILE_DEVICE_DVD                   0x00000033
+#define FILE_DEVICE_FULLSCREEN_VIDEO      0x00000034
+#define FILE_DEVICE_DFS_FILE_SYSTEM       0x00000035
+#define FILE_DEVICE_DFS_VOLUME            0x00000036
+#define FILE_DEVICE_SERENUM               0x00000037
+#define FILE_DEVICE_TERMSRV               0x00000038
+#define FILE_DEVICE_KSEC                  0x00000039
+#define FILE_DEVICE_FIPS                  0x0000003A
+#define FILE_DEVICE_INFINIBAND            0x0000003B
+#define FILE_DEVICE_VMBUS                 0x0000003E
+#define FILE_DEVICE_CRYPT_PROVIDER        0x0000003F
+#define FILE_DEVICE_WPD                   0x00000040
+#define FILE_DEVICE_BLUETOOTH             0x00000041
+#define FILE_DEVICE_MT_COMPOSITE          0x00000042
+#define FILE_DEVICE_MT_TRANSPORT          0x00000043
+#define FILE_DEVICE_BIOMETRIC             0x00000044
+#define FILE_DEVICE_PMI                   0x00000045
 
-NTKERNELAPI
-VOID
-NTAPI
-MmProbeAndLockPages(
-  IN OUT PMDL  MemoryDescriptorList,
-  IN KPROCESSOR_MODE  AccessMode,
-  IN LOCK_OPERATION  Operation);
+#define MAXIMUM_VOLUME_LABEL_LENGTH       (32 * sizeof(WCHAR))
 
-NTKERNELAPI
-MM_SYSTEMSIZE
-NTAPI
-MmQuerySystemSize(
-  VOID);
+typedef struct _OBJECT_HANDLE_INFORMATION {
+  ULONG HandleAttributes;
+  ACCESS_MASK GrantedAccess;
+} OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
 
-NTKERNELAPI
-VOID
-NTAPI
-MmResetDriverPaging(
-  IN PVOID  AddressWithinSection);
+typedef struct _CLIENT_ID {
+  HANDLE  UniqueProcess;
+  HANDLE  UniqueThread;
+} CLIENT_ID, *PCLIENT_ID;
 
-NTKERNELAPI
-SIZE_T
-NTAPI
-MmSizeOfMdl(
-  IN PVOID  Base,
-  IN SIZE_T  Length);
+typedef VOID
+(DDKAPI *PKSTART_ROUTINE)(
+  IN PVOID  StartContext);
 
-NTKERNELAPI
-VOID
-NTAPI
-MmUnlockPagableImageSection(
-  IN PVOID  ImageSectionHandle);
+typedef struct _VPB {
+  CSHORT  Type;
+  CSHORT  Size;
+  USHORT  Flags;
+  USHORT  VolumeLabelLength;
+  struct _DEVICE_OBJECT  *DeviceObject;
+  struct _DEVICE_OBJECT  *RealDevice;
+  ULONG  SerialNumber;
+  ULONG  ReferenceCount;
+  WCHAR  VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
+} VPB, *PVPB;
 
-NTKERNELAPI
-VOID
-NTAPI
-MmUnlockPages(
-  IN OUT PMDL  MemoryDescriptorList);
-
-NTKERNELAPI
-VOID
-NTAPI
-MmUnmapIoSpace(
-  IN PVOID  BaseAddress,
-  IN SIZE_T  NumberOfBytes);
+typedef enum _IO_ALLOCATION_ACTION {
+  KeepObject = 1,
+  DeallocateObject,
+  DeallocateObjectKeepRegisters
+} IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
 
-NTKERNELAPI
-VOID
-NTAPI
-MmProbeAndLockProcessPages(
-  IN OUT PMDL  MemoryDescriptorList,
-  IN PEPROCESS  Process,
-  IN KPROCESSOR_MODE  AccessMode,
-  IN LOCK_OPERATION  Operation);
+typedef IO_ALLOCATION_ACTION
+(DDKAPI *PDRIVER_CONTROL)(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN struct _IRP  *Irp,
+  IN PVOID  MapRegisterBase,
+  IN PVOID  Context);
 
-NTKERNELAPI
-VOID
-NTAPI
-MmUnmapLockedPages(
-  IN PVOID  BaseAddress,
-  IN PMDL  MemoryDescriptorList);
+typedef struct _WAIT_CONTEXT_BLOCK {
+  KDEVICE_QUEUE_ENTRY  WaitQueueEntry;
+  PDRIVER_CONTROL  DeviceRoutine;
+  PVOID  DeviceContext;
+  ULONG  NumberOfMapRegisters;
+  PVOID  DeviceObject;
+  PVOID  CurrentIrp;
+  PKDPC  BufferChainingDpc;
+} WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
 
-#endif
+typedef struct _DEVICE_OBJECT {
+  CSHORT  Type;
+  USHORT  Size;
+  LONG  ReferenceCount;
+  struct _DRIVER_OBJECT  *DriverObject;
+  struct _DEVICE_OBJECT  *NextDevice;
+  struct _DEVICE_OBJECT  *AttachedDevice;
+  struct _IRP  *CurrentIrp;
+  PIO_TIMER  Timer;
+  ULONG  Flags;
+  ULONG  Characteristics;
+  volatile PVPB  Vpb;
+  PVOID  DeviceExtension;
+  DEVICE_TYPE  DeviceType;
+  CCHAR  StackSize;
+  union {
+    LIST_ENTRY  ListEntry;
+    WAIT_CONTEXT_BLOCK  Wcb;
+  } Queue;
+  ULONG  AlignmentRequirement;
+  KDEVICE_QUEUE  DeviceQueue;
+  KDPC  Dpc;
+  ULONG  ActiveThreadCount;
+  PSECURITY_DESCRIPTOR  SecurityDescriptor;
+  KEVENT  DeviceLock;
+  USHORT  SectorSize;
+  USHORT  Spare1;
+  struct _DEVOBJ_EXTENSION  *DeviceObjectExtension;
+  PVOID  Reserved;
+} DEVICE_OBJECT, *PDEVICE_OBJECT;
 
-#if (NTDDI_VERSION >= NTDDI_WINXP)
+typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-MmAdvanceMdl(
-  IN OUT PMDL  Mdl,
-  IN ULONG  NumberOfBytes);
+typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
+  BOOLEAN  Removed;
+  BOOLEAN  Reserved[3];
+  volatile LONG  IoCount;
+  KEVENT  RemoveEvent;
+} IO_REMOVE_LOCK_COMMON_BLOCK;
 
-NTKERNELAPI
-PVOID
-NTAPI
-MmAllocateMappingAddress(
-  IN SIZE_T  NumberOfBytes,
-  IN ULONG  PoolTag);
+typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
+  LONG  Signature;
+  LONG  HighWatermark;
+  LONGLONG  MaxLockedTicks;
+  LONG  AllocateTag;
+  LIST_ENTRY  LockList;
+  KSPIN_LOCK  Spin;
+  volatile LONG  LowMemoryCount;
+  ULONG  Reserved1[4];
+  PVOID  Reserved2;
+  PIO_REMOVE_LOCK_TRACKING_BLOCK  Blocks;
+} IO_REMOVE_LOCK_DBG_BLOCK;
 
-NTKERNELAPI
-VOID
-NTAPI
-MmFreeMappingAddress(
-  IN PVOID  BaseAddress,
-  IN ULONG  PoolTag);
+typedef struct _IO_REMOVE_LOCK {
+  IO_REMOVE_LOCK_COMMON_BLOCK  Common;
+#if DBG
+  IO_REMOVE_LOCK_DBG_BLOCK  Dbg;
+#endif
+} IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-MmIsVerifierEnabled(
-  OUT PULONG  VerifierFlags);
+typedef struct _IO_WORKITEM *PIO_WORKITEM;
 
-NTKERNELAPI
-PVOID
-NTAPI
-MmMapLockedPagesWithReservedMapping(
-  IN PVOID  MappingAddress,
-  IN ULONG  PoolTag,
-  IN PMDL  MemoryDescriptorList,
-  IN MEMORY_CACHING_TYPE  CacheType);
+typedef VOID
+(DDKAPI IO_WORKITEM_ROUTINE)(
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN PVOID  Context);
+typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-MmProtectMdlSystemAddress(
-  IN PMDL  MemoryDescriptorList,
-  IN ULONG  NewProtect);
+typedef struct _SHARE_ACCESS {
+  ULONG  OpenCount;
+  ULONG  Readers;
+  ULONG  Writers;
+  ULONG  Deleters;
+  ULONG  SharedRead;
+  ULONG  SharedWrite;
+  ULONG  SharedDelete;
+} SHARE_ACCESS, *PSHARE_ACCESS;
 
-NTKERNELAPI
-VOID
-NTAPI
-MmUnmapReservedMapping(
-  IN PVOID  BaseAddress,
-  IN ULONG  PoolTag,
-  IN PMDL  MemoryDescriptorList);
+/* While MS WDK uses inheritance in C++, we cannot do this with gcc, as
+   inheritance, even from a struct renders the type non-POD. So we use
+   this hack */
+#define PCI_COMMON_HEADER_LAYOUT \
+  USHORT  VendorID; \
+  USHORT  DeviceID; \
+  USHORT  Command; \
+  USHORT  Status; \
+  UCHAR   RevisionID; \
+  UCHAR   ProgIf; \
+  UCHAR   SubClass; \
+  UCHAR   BaseClass; \
+  UCHAR   CacheLineSize; \
+  UCHAR   LatencyTimer; \
+  UCHAR   HeaderType; \
+  UCHAR   BIST; \
+  union { \
+    struct _PCI_HEADER_TYPE_0 { \
+      ULONG   BaseAddresses[PCI_TYPE0_ADDRESSES]; \
+      ULONG   CIS; \
+      USHORT  SubVendorID; \
+      USHORT  SubSystemID; \
+      ULONG   ROMBaseAddress; \
+      UCHAR   CapabilitiesPtr; \
+      UCHAR   Reserved1[3]; \
+      ULONG   Reserved2; \
+      UCHAR   InterruptLine; \
+      UCHAR   InterruptPin; \
+      UCHAR   MinimumGrant; \
+      UCHAR   MaximumLatency; \
+    } type0; \
+    struct _PCI_HEADER_TYPE_1 { \
+      ULONG   BaseAddresses[PCI_TYPE1_ADDRESSES]; \
+      UCHAR   PrimaryBus; \
+      UCHAR   SecondaryBus; \
+      UCHAR   SubordinateBus; \
+      UCHAR   SecondaryLatency; \
+      UCHAR   IOBase; \
+      UCHAR   IOLimit; \
+      USHORT  SecondaryStatus; \
+      USHORT  MemoryBase; \
+      USHORT  MemoryLimit; \
+      USHORT  PrefetchBase; \
+      USHORT  PrefetchLimit; \
+      ULONG   PrefetchBaseUpper32; \
+      ULONG   PrefetchLimitUpper32; \
+      USHORT  IOBaseUpper16; \
+      USHORT  IOLimitUpper16; \
+      UCHAR   CapabilitiesPtr; \
+      UCHAR   Reserved1[3]; \
+      ULONG   ROMBaseAddress; \
+      UCHAR   InterruptLine; \
+      UCHAR   InterruptPin; \
+      USHORT  BridgeControl; \
+    } type1; \
+    struct _PCI_HEADER_TYPE_2 { \
+      ULONG   SocketRegistersBaseAddress; \
+      UCHAR   CapabilitiesPtr; \
+      UCHAR   Reserved; \
+      USHORT  SecondaryStatus; \
+      UCHAR   PrimaryBus; \
+      UCHAR   SecondaryBus; \
+      UCHAR   SubordinateBus; \
+      UCHAR   SecondaryLatency; \
+      struct  { \
+        ULONG   Base; \
+        ULONG   Limit; \
+      } Range[PCI_TYPE2_ADDRESSES-1]; \
+      UCHAR   InterruptLine; \
+      UCHAR   InterruptPin; \
+      USHORT  BridgeControl; \
+    } type2; \
+  } u;
 
-#endif
+typedef struct _PCI_COMMON_HEADER {
+  PCI_COMMON_HEADER_LAYOUT
+} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
 
-#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);
+#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
 
-/******************************************************************************
- *                            Security Manager Types                          *
- ******************************************************************************/
-
-/* Simple types */
-typedef PVOID PSECURITY_DESCRIPTOR;
-typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
-typedef ULONG ACCESS_MASK, *PACCESS_MASK;
-typedef PVOID PACCESS_TOKEN;
-typedef PVOID PSID;
-
-#define DELETE                           0x00010000L
-#define READ_CONTROL                     0x00020000L
-#define WRITE_DAC                        0x00040000L
-#define WRITE_OWNER                      0x00080000L
-#define SYNCHRONIZE                      0x00100000L
-#define STANDARD_RIGHTS_REQUIRED         0x000F0000L
-#define STANDARD_RIGHTS_READ             READ_CONTROL
-#define STANDARD_RIGHTS_WRITE            READ_CONTROL
-#define STANDARD_RIGHTS_EXECUTE          READ_CONTROL
-#define STANDARD_RIGHTS_ALL              0x001F0000L
-#define SPECIFIC_RIGHTS_ALL              0x0000FFFFL
-#define ACCESS_SYSTEM_SECURITY           0x01000000L
-#define MAXIMUM_ALLOWED                  0x02000000L
-#define GENERIC_READ                     0x80000000L
-#define GENERIC_WRITE                    0x40000000L
-#define GENERIC_EXECUTE                  0x20000000L
-#define GENERIC_ALL                      0x10000000L
+typedef enum _CREATE_FILE_TYPE {
+  CreateFileTypeNone,
+  CreateFileTypeNamedPipe,
+  CreateFileTypeMailslot
+} CREATE_FILE_TYPE;
 
-typedef struct _GENERIC_MAPPING {
-    ACCESS_MASK GenericRead;
-    ACCESS_MASK GenericWrite;
-    ACCESS_MASK GenericExecute;
-    ACCESS_MASK GenericAll;
-} GENERIC_MAPPING, *PGENERIC_MAPPING;
+#define IO_FORCE_ACCESS_CHECK               0x001
+#define IO_NO_PARAMETER_CHECKING            0x100
 
-#define ACL_REVISION                      2
-#define ACL_REVISION_DS                   4
+#define IO_REPARSE                      0x0
+#define IO_REMOUNT                      0x1
 
-#define ACL_REVISION1                     1
-#define ACL_REVISION2                     2
-#define ACL_REVISION3                     3
-#define ACL_REVISION4                     4
-#define MIN_ACL_REVISION                  ACL_REVISION2
-#define MAX_ACL_REVISION                  ACL_REVISION4
+typedef struct _IO_STATUS_BLOCK {
+  _ANONYMOUS_UNION union {
+    NTSTATUS  Status;
+    PVOID  Pointer;
+  } DUMMYUNIONNAME;
+  ULONG_PTR  Information;
+} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
 
-typedef struct _ACL {
-    UCHAR AclRevision;
-    UCHAR Sbz1;
-    USHORT AclSize;
-    USHORT AceCount;
-    USHORT Sbz2;
-} ACL, *PACL;
+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;
 
-/* Current security descriptor revision value */
-#define SECURITY_DESCRIPTOR_REVISION     (1)
-#define SECURITY_DESCRIPTOR_REVISION1    (1)
+typedef VOID
+(DDKAPI *PIO_APC_ROUTINE)(
+  IN PVOID ApcContext,
+  IN PIO_STATUS_BLOCK IoStatusBlock,
+  IN ULONG Reserved);
 
-/* Privilege attributes */
-#define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
-#define SE_PRIVILEGE_ENABLED            (0x00000002L)
-#define SE_PRIVILEGE_REMOVED            (0X00000004L)
-#define SE_PRIVILEGE_USED_FOR_ACCESS    (0x80000000L)
+typedef VOID
+(DDKAPI *WMI_NOTIFICATION_CALLBACK)(
+  PVOID  Wnode,
+  PVOID  Context);
 
-#define SE_PRIVILEGE_VALID_ATTRIBUTES   (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \
-                                         SE_PRIVILEGE_ENABLED            | \
-                                         SE_PRIVILEGE_REMOVED            | \
-                                         SE_PRIVILEGE_USED_FOR_ACCESS)
+#define EVENT_INCREMENT                   1
+#define IO_NO_INCREMENT                   0
+#define IO_CD_ROM_INCREMENT               1
+#define IO_DISK_INCREMENT                 1
+#define IO_KEYBOARD_INCREMENT             6
+#define IO_MAILSLOT_INCREMENT             2
+#define IO_MOUSE_INCREMENT                6
+#define IO_NAMED_PIPE_INCREMENT           2
+#define IO_NETWORK_INCREMENT              2
+#define IO_PARALLEL_INCREMENT             1
+#define IO_SERIAL_INCREMENT               2
+#define IO_SOUND_INCREMENT                8
+#define IO_VIDEO_INCREMENT                1
+#define SEMAPHORE_INCREMENT               1
 
-#include <pshpack4.h>
-typedef struct _LUID_AND_ATTRIBUTES {
-    LUID Luid;
-    ULONG Attributes;
-} LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
-#include <poppack.h>
+#define MM_MAXIMUM_DISK_IO_SIZE          (0x10000)
 
-typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
-typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
+typedef struct _BOOTDISK_INFORMATION {
+  LONGLONG  BootPartitionOffset;
+  LONGLONG  SystemPartitionOffset;
+  ULONG  BootDeviceSignature;
+  ULONG  SystemDeviceSignature;
+} BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
 
-/* Privilege sets */
-#define PRIVILEGE_SET_ALL_NECESSARY (1)
+typedef struct _BOOTDISK_INFORMATION_EX {
+  LONGLONG  BootPartitionOffset;
+  LONGLONG  SystemPartitionOffset;
+  ULONG  BootDeviceSignature;
+  ULONG  SystemDeviceSignature;
+  GUID  BootDeviceGuid;
+  GUID  SystemDeviceGuid;
+  BOOLEAN  BootDeviceIsGpt;
+  BOOLEAN  SystemDeviceIsGpt;
+} BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
 
-typedef struct _PRIVILEGE_SET {
-    ULONG PrivilegeCount;
-    ULONG Control;
-    LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
-} PRIVILEGE_SET,*PPRIVILEGE_SET;
+typedef struct _EISA_MEMORY_TYPE {
+  UCHAR  ReadWrite : 1;
+  UCHAR  Cached : 1;
+  UCHAR  Reserved0 : 1;
+  UCHAR  Type : 2;
+  UCHAR  Shared : 1;
+  UCHAR  Reserved1 : 1;
+  UCHAR  MoreEntries : 1;
+} EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
 
-typedef enum _SECURITY_IMPERSONATION_LEVEL {
-    SecurityAnonymous,
-    SecurityIdentification,
-    SecurityImpersonation,
-    SecurityDelegation
-} SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
+#include <pshpack1.h>
+typedef struct _EISA_MEMORY_CONFIGURATION {
+  EISA_MEMORY_TYPE  ConfigurationByte;
+  UCHAR  DataSize;
+  USHORT  AddressLowWord;
+  UCHAR  AddressHighByte;
+  USHORT  MemorySize;
+} EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
+#include <poppack.h>
 
-#define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
-#define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
-#define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
-#define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL))
+typedef struct _EISA_IRQ_DESCRIPTOR {
+  UCHAR  Interrupt : 4;
+  UCHAR  Reserved : 1;
+  UCHAR  LevelTriggered : 1;
+  UCHAR  Shared : 1;
+  UCHAR  MoreEntries : 1;
+} EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
 
-#define SECURITY_DYNAMIC_TRACKING (TRUE)
-#define SECURITY_STATIC_TRACKING (FALSE)
+typedef struct _EISA_IRQ_CONFIGURATION {
+  EISA_IRQ_DESCRIPTOR  ConfigurationByte;
+  UCHAR  Reserved;
+} EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
 
-typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE;
+typedef struct _DMA_CONFIGURATION_BYTE0 {
+  UCHAR Channel : 3;
+  UCHAR Reserved : 3;
+  UCHAR Shared : 1;
+  UCHAR MoreEntries : 1;
+} DMA_CONFIGURATION_BYTE0;
 
-typedef struct _SECURITY_QUALITY_OF_SERVICE {
-    ULONG Length;
-    SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
-    SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
-    BOOLEAN EffectiveOnly;
-} SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
+typedef struct _DMA_CONFIGURATION_BYTE1 {
+  UCHAR  Reserved0 : 2;
+  UCHAR  TransferSize : 2;
+  UCHAR  Timing : 2;
+  UCHAR  Reserved1 : 2;
+} DMA_CONFIGURATION_BYTE1;
 
-typedef struct _SE_IMPERSONATION_STATE {
-    PACCESS_TOKEN Token;
-    BOOLEAN CopyOnOpen;
-    BOOLEAN EffectiveOnly;
-    SECURITY_IMPERSONATION_LEVEL Level;
-} SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
+typedef struct _EISA_DMA_CONFIGURATION {
+  DMA_CONFIGURATION_BYTE0  ConfigurationByte0;
+  DMA_CONFIGURATION_BYTE1  ConfigurationByte1;
+} EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
 
-#define OWNER_SECURITY_INFORMATION       (0x00000001L)
-#define GROUP_SECURITY_INFORMATION       (0x00000002L)
-#define DACL_SECURITY_INFORMATION        (0x00000004L)
-#define SACL_SECURITY_INFORMATION        (0x00000008L)
-#define LABEL_SECURITY_INFORMATION       (0x00000010L)
+#include <pshpack1.h>
+typedef struct _EISA_PORT_DESCRIPTOR {
+  UCHAR  NumberPorts : 5;
+  UCHAR  Reserved : 1;
+  UCHAR  Shared : 1;
+  UCHAR  MoreEntries : 1;
+} EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
 
-#define PROTECTED_DACL_SECURITY_INFORMATION     (0x80000000L)
-#define PROTECTED_SACL_SECURITY_INFORMATION     (0x40000000L)
-#define UNPROTECTED_DACL_SECURITY_INFORMATION   (0x20000000L)
-#define UNPROTECTED_SACL_SECURITY_INFORMATION   (0x10000000L)
+typedef struct _EISA_PORT_CONFIGURATION {
+  EISA_PORT_DESCRIPTOR  Configuration;
+  USHORT  PortAddress;
+} EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
+#include <poppack.h>
 
-typedef enum _SECURITY_OPERATION_CODE {
-  SetSecurityDescriptor,
-  QuerySecurityDescriptor,
-  DeleteSecurityDescriptor,
-  AssignSecurityDescriptor
-} SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
+typedef struct _CM_EISA_FUNCTION_INFORMATION {
+  ULONG  CompressedId;
+  UCHAR  IdSlotFlags1;
+  UCHAR  IdSlotFlags2;
+  UCHAR  MinorRevision;
+  UCHAR  MajorRevision;
+  UCHAR  Selections[26];
+  UCHAR  FunctionFlags;
+  UCHAR  TypeString[80];
+  EISA_MEMORY_CONFIGURATION  EisaMemory[9];
+  EISA_IRQ_CONFIGURATION  EisaIrq[7];
+  EISA_DMA_CONFIGURATION  EisaDma[4];
+  EISA_PORT_CONFIGURATION  EisaPort[20];
+  UCHAR  InitializationData[60];
+} CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
 
-#define INITIAL_PRIVILEGE_COUNT           3
+/* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
 
-typedef struct _INITIAL_PRIVILEGE_SET {
-  ULONG  PrivilegeCount;
-  ULONG  Control;
-  LUID_AND_ATTRIBUTES  Privilege[INITIAL_PRIVILEGE_COUNT];
-} INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
-
-#define SE_MIN_WELL_KNOWN_PRIVILEGE         2
-#define SE_CREATE_TOKEN_PRIVILEGE           2
-#define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE     3
-#define SE_LOCK_MEMORY_PRIVILEGE            4
-#define SE_INCREASE_QUOTA_PRIVILEGE         5
-#define SE_MACHINE_ACCOUNT_PRIVILEGE        6
-#define SE_TCB_PRIVILEGE                    7
-#define SE_SECURITY_PRIVILEGE               8
-#define SE_TAKE_OWNERSHIP_PRIVILEGE         9
-#define SE_LOAD_DRIVER_PRIVILEGE            10
-#define SE_SYSTEM_PROFILE_PRIVILEGE         11
-#define SE_SYSTEMTIME_PRIVILEGE             12
-#define SE_PROF_SINGLE_PROCESS_PRIVILEGE    13
-#define SE_INC_BASE_PRIORITY_PRIVILEGE      14
-#define SE_CREATE_PAGEFILE_PRIVILEGE        15
-#define SE_CREATE_PERMANENT_PRIVILEGE       16
-#define SE_BACKUP_PRIVILEGE                 17
-#define SE_RESTORE_PRIVILEGE                18
-#define SE_SHUTDOWN_PRIVILEGE               19
-#define SE_DEBUG_PRIVILEGE                  20
-#define SE_AUDIT_PRIVILEGE                  21
-#define SE_SYSTEM_ENVIRONMENT_PRIVILEGE     22
-#define SE_CHANGE_NOTIFY_PRIVILEGE          23
-#define SE_REMOTE_SHUTDOWN_PRIVILEGE        24
-#define SE_UNDOCK_PRIVILEGE                 25
-#define SE_SYNC_AGENT_PRIVILEGE             26
-#define SE_ENABLE_DELEGATION_PRIVILEGE      27
-#define SE_MANAGE_VOLUME_PRIVILEGE          28
-#define SE_IMPERSONATE_PRIVILEGE            29
-#define SE_CREATE_GLOBAL_PRIVILEGE          30
-#define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31
-#define SE_RELABEL_PRIVILEGE                32
-#define SE_INC_WORKING_SET_PRIVILEGE        33
-#define SE_TIME_ZONE_PRIVILEGE              34
-#define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE   35
-#define SE_MAX_WELL_KNOWN_PRIVILEGE         SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
-
-typedef struct _SECURITY_SUBJECT_CONTEXT {
-  PACCESS_TOKEN  ClientToken;
-  SECURITY_IMPERSONATION_LEVEL  ImpersonationLevel;
-  PACCESS_TOKEN  PrimaryToken;
-  PVOID  ProcessAuditId;
-} SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
-
-typedef struct _ACCESS_STATE {
-  LUID  OperationID;
-  BOOLEAN  SecurityEvaluated;
-  BOOLEAN  GenerateAudit;
-  BOOLEAN  GenerateOnClose;
-  BOOLEAN  PrivilegesAllocated;
-  ULONG  Flags;
-  ACCESS_MASK  RemainingDesiredAccess;
-  ACCESS_MASK  PreviouslyGrantedAccess;
-  ACCESS_MASK  OriginalDesiredAccess;
-  SECURITY_SUBJECT_CONTEXT  SubjectSecurityContext;
-  PSECURITY_DESCRIPTOR  SecurityDescriptor;
-  PVOID  AuxData;
-  union {
-    INITIAL_PRIVILEGE_SET  InitialPrivilegeSet;
-    PRIVILEGE_SET  PrivilegeSet;
-  } Privileges;
+#define EISA_FUNCTION_ENABLED           0x80
+#define EISA_FREE_FORM_DATA             0x40
+#define EISA_HAS_PORT_INIT_ENTRY        0x20
+#define EISA_HAS_PORT_RANGE             0x10
+#define EISA_HAS_DMA_ENTRY              0x08
+#define EISA_HAS_IRQ_ENTRY              0x04
+#define EISA_HAS_MEMORY_ENTRY           0x02
+#define EISA_HAS_TYPE_ENTRY             0x01
+#define EISA_HAS_INFORMATION \
+  (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
+  + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
 
-  BOOLEAN  AuditPrivileges;
-  UNICODE_STRING  ObjectName;
-  UNICODE_STRING  ObjectTypeName;
-} ACCESS_STATE, *PACCESS_STATE;
+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;
 
+/* CM_EISA_SLOT_INFORMATION.ReturnCode */
 
-#ifndef _NTLSA_IFS_
+#define EISA_INVALID_SLOT               0x80
+#define EISA_INVALID_FUNCTION           0x81
+#define EISA_INVALID_CONFIGURATION      0x82
+#define EISA_EMPTY_SLOT                 0x83
+#define EISA_INVALID_BIOS_CALL          0x86
 
-#ifndef _NTLSA_AUDIT_
-#define _NTLSA_AUDIT_
+/*
+** Plug and Play structures
+*/
 
-#define SE_MAX_AUDIT_PARAMETERS 32
-#define SE_MAX_GENERIC_AUDIT_PARAMETERS 28
+typedef VOID
+(DDKAPI *PINTERFACE_REFERENCE)(
+  PVOID  Context);
 
-#define SE_ADT_OBJECT_ONLY 0x1
+typedef VOID
+(DDKAPI *PINTERFACE_DEREFERENCE)(
+  PVOID Context);
 
-#define SE_ADT_PARAMETERS_SELF_RELATIVE    0x00000001
-#define SE_ADT_PARAMETERS_SEND_TO_LSA      0x00000002
-#define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT  0x00000004
-#define SE_ADT_PARAMETER_GENERIC_AUDIT     0x00000008
-#define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010
+typedef BOOLEAN
+(DDKAPI *PTRANSLATE_BUS_ADDRESS)(
+  IN PVOID  Context,
+  IN PHYSICAL_ADDRESS  BusAddress,
+  IN ULONG  Length,
+  IN OUT PULONG  AddressSpace,
+  OUT PPHYSICAL_ADDRESS  TranslatedAddress);
 
-#define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \
-  ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \
-    (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) )
+typedef struct _DMA_ADAPTER*
+(DDKAPI *PGET_DMA_ADAPTER)(
+  IN PVOID  Context,
+  IN struct _DEVICE_DESCRIPTION  *DeviceDescriptor,
+  OUT PULONG  NumberOfMapRegisters);
 
-typedef enum _SE_ADT_PARAMETER_TYPE {
-  SeAdtParmTypeNone = 0,
-  SeAdtParmTypeString,
-  SeAdtParmTypeFileSpec,
-  SeAdtParmTypeUlong,
-  SeAdtParmTypeSid,
-  SeAdtParmTypeLogonId,
-  SeAdtParmTypeNoLogonId,
-  SeAdtParmTypeAccessMask,
-  SeAdtParmTypePrivs,
-  SeAdtParmTypeObjectTypes,
-  SeAdtParmTypeHexUlong,
-  SeAdtParmTypePtr,
-  SeAdtParmTypeTime,
-  SeAdtParmTypeGuid,
-  SeAdtParmTypeLuid,
-  SeAdtParmTypeHexInt64,
-  SeAdtParmTypeStringList,
-  SeAdtParmTypeSidList,
-  SeAdtParmTypeDuration,
-  SeAdtParmTypeUserAccountControl,
-  SeAdtParmTypeNoUac,
-  SeAdtParmTypeMessage,
-  SeAdtParmTypeDateTime,
-  SeAdtParmTypeSockAddr,
-  SeAdtParmTypeSD,
-  SeAdtParmTypeLogonHours,
-  SeAdtParmTypeLogonIdNoSid,
-  SeAdtParmTypeUlongNoConv,
-  SeAdtParmTypeSockAddrNoPort,
-  SeAdtParmTypeAccessReason
-} SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE;
+typedef ULONG
+(DDKAPI *PGET_SET_DEVICE_DATA)(
+  IN PVOID  Context,
+  IN ULONG  DataType,
+  IN PVOID  Buffer,
+  IN ULONG  Offset,
+  IN ULONG  Length);
 
-typedef struct _SE_ADT_OBJECT_TYPE {
-  GUID ObjectType;
-  USHORT Flags;
-  USHORT Level;
-  ACCESS_MASK AccessMask;
-} SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE;
+/* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
+#define PCI_USE_SUBSYSTEM_IDS   0x00000001
+#define PCI_USE_REVISION        0x00000002
+#define PCI_USE_VENDEV_IDS      0x00000004
+#define PCI_USE_CLASS_SUBCLASS  0x00000008
+#define PCI_USE_PROGIF          0x00000010
+#define PCI_USE_LOCAL_BUS       0x00000020
+#define PCI_USE_LOCAL_DEVICE    0x00000040
 
-typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY {
-  SE_ADT_PARAMETER_TYPE Type;
-  ULONG Length;
-  ULONG_PTR Data[2];
-  PVOID Address;
-} SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY;
+typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
+  ULONG   Size;
+  ULONG   Flags;
+  USHORT  VendorID;
+  USHORT  DeviceID;
+  UCHAR   RevisionID;
+  USHORT  SubVendorID;
+  USHORT  SubSystemID;
+  UCHAR   BaseClass;
+  UCHAR   SubClass;
+  UCHAR   ProgIf;
+} PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
 
-typedef struct _SE_ADT_ACCESS_REASON {
-  ACCESS_MASK AccessMask;
-  ULONG  AccessReasons[32];
-  ULONG  ObjectTypeIndex;
-  ULONG AccessGranted;
-  PSECURITY_DESCRIPTOR SecurityDescriptor;
-} SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON;
+typedef BOOLEAN
+(DDKAPI *PPCI_IS_DEVICE_PRESENT)(
+  IN USHORT  VendorID,
+  IN USHORT  DeviceID,
+  IN UCHAR   RevisionID,
+  IN USHORT  SubVendorID,
+  IN USHORT  SubSystemID,
+  IN ULONG   Flags);
 
-typedef struct _SE_ADT_PARAMETER_ARRAY {
-  ULONG CategoryId;
-  ULONG AuditId;
-  ULONG ParameterCount;
-  ULONG Length;
-  USHORT FlatSubCategoryId;
-  USHORT Type;
-  ULONG Flags;
-  SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ];
-} SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY;
+typedef BOOLEAN
+(DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)(
+  IN PVOID Context,
+  IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
 
-#endif /* !_NTLSA_AUDIT_ */
-#endif /* !_NTLSA_IFS_ */
+typedef struct _BUS_INTERFACE_STANDARD {
+  USHORT  Size;
+  USHORT  Version;
+  PVOID  Context;
+  PINTERFACE_REFERENCE  InterfaceReference;
+  PINTERFACE_DEREFERENCE  InterfaceDereference;
+  PTRANSLATE_BUS_ADDRESS  TranslateBusAddress;
+  PGET_DMA_ADAPTER  GetDmaAdapter;
+  PGET_SET_DEVICE_DATA  SetBusData;
+  PGET_SET_DEVICE_DATA  GetBusData;
+} BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
 
+typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
+  USHORT  Size;
+  USHORT  Version;
+  PVOID  Context;
+  PINTERFACE_REFERENCE  InterfaceReference;
+  PINTERFACE_DEREFERENCE  InterfaceDereference;
+  PPCI_IS_DEVICE_PRESENT  IsDevicePresent;
+  PPCI_IS_DEVICE_PRESENT_EX  IsDevicePresentEx;
+} PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
 
-/******************************************************************************
- *                            Security Manager Functions                      *
- ******************************************************************************/
-
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
-
-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);
-
-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);
-
-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);
-
-NTKERNELAPI
-NTSTATUS
-NTAPI
-SeDeassignSecurity(
-  IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor);
-
-NTKERNELAPI
-BOOLEAN
-NTAPI
-SeValidSecurityDescriptor(
-  IN ULONG Length,
-  IN PSECURITY_DESCRIPTOR SecurityDescriptor);
+typedef struct _DEVICE_CAPABILITIES {
+  USHORT  Size;
+  USHORT  Version;
+  ULONG  DeviceD1 : 1;
+  ULONG  DeviceD2 : 1;
+  ULONG  LockSupported : 1;
+  ULONG  EjectSupported : 1;
+  ULONG  Removable : 1;
+  ULONG  DockDevice : 1;
+  ULONG  UniqueID : 1;
+  ULONG  SilentInstall : 1;
+  ULONG  RawDeviceOK : 1;
+  ULONG  SurpriseRemovalOK : 1;
+  ULONG  WakeFromD0 : 1;
+  ULONG  WakeFromD1 : 1;
+  ULONG  WakeFromD2 : 1;
+  ULONG  WakeFromD3 : 1;
+  ULONG  HardwareDisabled : 1;
+  ULONG  NonDynamic : 1;
+  ULONG  WarmEjectSupported : 1;
+  ULONG  NoDisplayInUI : 1;
+  ULONG  Reserved : 14;
+  ULONG  Address;
+  ULONG  UINumber;
+  DEVICE_POWER_STATE  DeviceState[PowerSystemMaximum];
+  SYSTEM_POWER_STATE  SystemWake;
+  DEVICE_POWER_STATE  DeviceWake;
+  ULONG  D1Latency;
+  ULONG  D2Latency;
+  ULONG  D3Latency;
+} DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
 
-NTKERNELAPI
-ULONG
-NTAPI
-SeObjectCreateSaclAccessBits(
-  IN PSECURITY_DESCRIPTOR SecurityDescriptor);
+typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
+  USHORT  Version;
+  USHORT  Size;
+  GUID  Event;
+  GUID  InterfaceClassGuid;
+  PUNICODE_STRING  SymbolicLinkName;
+} DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
 
-NTKERNELAPI
-VOID
-NTAPI
-SeReleaseSubjectContext(
-  IN OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
+typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
+  USHORT  Version;
+  USHORT  Size;
+  GUID  Event;
+} HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
 
-NTKERNELAPI
-VOID
-NTAPI
-SeUnlockSubjectContext(
-  IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
+#undef INTERFACE
 
-NTKERNELAPI
-VOID
-NTAPI
-SeCaptureSubjectContext(
-  OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
+typedef struct _INTERFACE {
+  USHORT  Size;
+  USHORT  Version;
+  PVOID  Context;
+  PINTERFACE_REFERENCE  InterfaceReference;
+  PINTERFACE_DEREFERENCE  InterfaceDereference;
+} INTERFACE, *PINTERFACE;
 
-NTKERNELAPI
-VOID
-NTAPI
-SeLockSubjectContext(
-  IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
+typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
+  USHORT  Version;
+  USHORT  Size;
+  GUID  Event;
+} PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
 
-#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
 
-#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+/* PNP_DEVICE_STATE */
 
-NTSTATUS
-NTAPI
-SeSetAuditParameter(
-  IN OUT PSE_ADT_PARAMETER_ARRAY AuditParameters,
-  IN SE_ADT_PARAMETER_TYPE Type,
-  IN ULONG Index,
-  IN PVOID Data);
+#define PNP_DEVICE_DISABLED                      0x00000001
+#define PNP_DEVICE_DONT_DISPLAY_IN_UI            0x00000002
+#define PNP_DEVICE_FAILED                        0x00000004
+#define PNP_DEVICE_REMOVED                       0x00000008
+#define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
+#define PNP_DEVICE_NOT_DISABLEABLE               0x00000020
 
-NTSTATUS
-NTAPI
-SeReportSecurityEvent(
-  IN ULONG Flags,
-  IN PUNICODE_STRING SourceName,
-  IN PSID UserSid OPTIONAL,
-  IN PSE_ADT_PARAMETER_ARRAY AuditParameters);
+typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
+  USHORT  Version;
+  USHORT  Size;
+  GUID  Event;
+  struct _FILE_OBJECT  *FileObject;
+  LONG  NameBufferOffset;
+  UCHAR  CustomDataBuffer[1];
+} TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
 
-#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
+typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
+  USHORT  Version;
+  USHORT  Size;
+  GUID  Event;
+  struct _FILE_OBJECT  *FileObject;
+} TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
+typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
+  DeviceUsageTypeUndefined,
+  DeviceUsageTypePaging,
+  DeviceUsageTypeHibernation,
+  DeviceUsageTypeDumpFile
+} DEVICE_USAGE_NOTIFICATION_TYPE;
 
-NTKERNELAPI
-ULONG
-NTAPI
-SeComputeAutoInheritByObjectType(
-  IN PVOID ObjectType,
-  IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
-  IN PSECURITY_DESCRIPTOR ParentSecurityDescriptor OPTIONAL);
+typedef struct _POWER_SEQUENCE {
+  ULONG  SequenceD1;
+  ULONG  SequenceD2;
+  ULONG  SequenceD3;
+} POWER_SEQUENCE, *PPOWER_SEQUENCE;
 
-#ifdef SE_NTFS_WORLD_CACHE
-VOID
-NTAPI
-SeGetWorldRights(
-  IN PSECURITY_DESCRIPTOR SecurityDescriptor,
-  IN PGENERIC_MAPPING GenericMapping,
-  OUT PACCESS_MASK GrantedAccess);
-#endif /* SE_NTFS_WORLD_CACHE */
+typedef enum {
+  DevicePropertyDeviceDescription = 0x0,
+  DevicePropertyHardwareID = 0x1,
+  DevicePropertyCompatibleIDs = 0x2,
+  DevicePropertyBootConfiguration = 0x3,
+  DevicePropertyBootConfigurationTranslated = 0x4,
+  DevicePropertyClassName = 0x5,
+  DevicePropertyClassGuid = 0x6,
+  DevicePropertyDriverKeyName = 0x7,
+  DevicePropertyManufacturer = 0x8,
+  DevicePropertyFriendlyName = 0x9,
+  DevicePropertyLocationInformation = 0xa,
+  DevicePropertyPhysicalDeviceObjectName = 0xb,
+  DevicePropertyBusTypeGuid = 0xc,
+  DevicePropertyLegacyBusType = 0xd,
+  DevicePropertyBusNumber = 0xe,
+  DevicePropertyEnumeratorName = 0xf,
+  DevicePropertyAddress = 0x10,
+  DevicePropertyUINumber = 0x11,
+  DevicePropertyInstallState = 0x12,
+  DevicePropertyRemovalPolicy = 0x13,
+  DevicePropertyResourceRequirements = 0x14,
+  DevicePropertyAllocatedResources = 0x15,
+  DevicePropertyContainerID = 0x16
+} DEVICE_REGISTRY_PROPERTY;
 
-#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
+typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
+  EventCategoryReserved,
+  EventCategoryHardwareProfileChange,
+  EventCategoryDeviceInterfaceChange,
+  EventCategoryTargetDeviceChange
+} IO_NOTIFICATION_EVENT_CATEGORY;
 
+#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES    0x00000001
 
-#if 1
-/******************************************************************************
- *                            Power Management Support Types                  *
- ******************************************************************************/
+typedef NTSTATUS
+(DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
+  IN PVOID NotificationStructure,
+  IN PVOID Context);
 
-#ifndef _PO_DDK_
-#define _PO_DDK_
+typedef VOID
+(DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)(
+  IN PVOID Context);
 
-/* Power States/Levels */
-typedef enum _SYSTEM_POWER_STATE {
-    PowerSystemUnspecified,
-    PowerSystemWorking,
-    PowerSystemSleeping1,
-    PowerSystemSleeping2,
-    PowerSystemSleeping3,
-    PowerSystemHibernate,
-    PowerSystemShutdown,
-    PowerSystemMaximum
-} SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
+typedef enum _FILE_INFORMATION_CLASS {
+  FileDirectoryInformation = 1,
+  FileFullDirectoryInformation,
+  FileBothDirectoryInformation,
+  FileBasicInformation,
+  FileStandardInformation,
+  FileInternalInformation,
+  FileEaInformation,
+  FileAccessInformation,
+  FileNameInformation,
+  FileRenameInformation,
+  FileLinkInformation,
+  FileNamesInformation,
+  FileDispositionInformation,
+  FilePositionInformation,
+  FileFullEaInformation,
+  FileModeInformation,
+  FileAlignmentInformation,
+  FileAllInformation,
+  FileAllocationInformation,
+  FileEndOfFileInformation,
+  FileAlternateNameInformation,
+  FileStreamInformation,
+  FilePipeInformation,
+  FilePipeLocalInformation,
+  FilePipeRemoteInformation,
+  FileMailslotQueryInformation,
+  FileMailslotSetInformation,
+  FileCompressionInformation,
+  FileObjectIdInformation,
+  FileCompletionInformation,
+  FileMoveClusterInformation,
+  FileQuotaInformation,
+  FileReparsePointInformation,
+  FileNetworkOpenInformation,
+  FileAttributeTagInformation,
+  FileTrackingInformation,
+  FileIdBothDirectoryInformation,
+  FileIdFullDirectoryInformation,
+  FileValidDataLengthInformation,
+  FileShortNameInformation,
+  FileIoCompletionNotificationInformation,
+  FileIoStatusBlockRangeInformation,
+  FileIoPriorityHintInformation,
+  FileSfioReserveInformation,
+  FileSfioVolumeInformation,
+  FileHardLinkInformation,
+  FileProcessIdsUsingFileInformation,
+  FileNormalizedNameInformation,
+  FileNetworkPhysicalNameInformation,
+  FileIdGlobalTxDirectoryInformation,
+  FileIsRemoteDeviceInformation,
+  FileAttributeCacheInformation,
+  FileNumaNodeInformation,
+  FileStandardLinkInformation,
+  FileRemoteProtocolInformation,
+  FileMaximumInformation
+} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
 
-#define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
+typedef struct _FILE_POSITION_INFORMATION {
+  LARGE_INTEGER  CurrentByteOffset;
+} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
 
-typedef enum _POWER_INFORMATION_LEVEL {
-    SystemPowerPolicyAc,
-    SystemPowerPolicyDc,
-    VerifySystemPolicyAc,
-    VerifySystemPolicyDc,
-    SystemPowerCapabilities,
-    SystemBatteryState,
-    SystemPowerStateHandler,
-    ProcessorStateHandler,
-    SystemPowerPolicyCurrent,
-    AdministratorPowerPolicy,
-    SystemReserveHiberFile,
-    ProcessorInformation,
-    SystemPowerInformation,
-    ProcessorStateHandler2,
-    LastWakeTime,
-    LastSleepTime,
-    SystemExecutionState,
-    SystemPowerStateNotifyHandler,
-    ProcessorPowerPolicyAc,
-    ProcessorPowerPolicyDc,
-    VerifyProcessorPowerPolicyAc,
-    VerifyProcessorPowerPolicyDc,
-    ProcessorPowerPolicyCurrent,
-    SystemPowerStateLogging,
-    SystemPowerLoggingEntry,
-    SetPowerSettingValue,
-    NotifyUserPowerSetting,
-    PowerInformationLevelUnused0,
-    PowerInformationLevelUnused1,
-    SystemVideoState,
-    TraceApplicationPowerMessage,
-    TraceApplicationPowerMessageEnd,
-    ProcessorPerfStates,
-    ProcessorIdleStates,
-    ProcessorCap,
-    SystemWakeSource,
-    SystemHiberFileInformation,
-    TraceServicePowerMessage,
-    ProcessorLoad,
-    PowerShutdownNotification,
-    MonitorCapabilities,
-    SessionPowerInit,
-    SessionDisplayState,
-    PowerRequestCreate,
-    PowerRequestAction,
-    GetPowerRequestList,
-    ProcessorInformationEx,
-    NotifyUserModeLegacyPowerEvent,
-    GroupPark,
-    ProcessorIdleDomains,
-    WakeTimerList,
-    SystemHiberFileSize,
-    PowerInformationLevelMaximum
-} POWER_INFORMATION_LEVEL;
+#include <pshpack8.h>
+typedef struct _FILE_BASIC_INFORMATION {
+  LARGE_INTEGER  CreationTime;
+  LARGE_INTEGER  LastAccessTime;
+  LARGE_INTEGER  LastWriteTime;
+  LARGE_INTEGER  ChangeTime;
+  ULONG  FileAttributes;
+} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
+#include <poppack.h>
 
-typedef enum {
-    PowerActionNone,
-    PowerActionReserved,
-    PowerActionSleep,
-    PowerActionHibernate,
-    PowerActionShutdown,
-    PowerActionShutdownReset,
-    PowerActionShutdownOff,
-    PowerActionWarmEject
-} POWER_ACTION, *PPOWER_ACTION;
+typedef struct _FILE_STANDARD_INFORMATION {
+  LARGE_INTEGER  AllocationSize;
+  LARGE_INTEGER  EndOfFile;
+  ULONG  NumberOfLinks;
+  BOOLEAN  DeletePending;
+  BOOLEAN  Directory;
+} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
 
-typedef enum _DEVICE_POWER_STATE {
-    PowerDeviceUnspecified,
-    PowerDeviceD0,
-    PowerDeviceD1,
-    PowerDeviceD2,
-    PowerDeviceD3,
-    PowerDeviceMaximum
-} DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
+typedef struct _FILE_NETWORK_OPEN_INFORMATION {
+  LARGE_INTEGER  CreationTime;
+  LARGE_INTEGER  LastAccessTime;
+  LARGE_INTEGER  LastWriteTime;
+  LARGE_INTEGER  ChangeTime;
+  LARGE_INTEGER  AllocationSize;
+  LARGE_INTEGER  EndOfFile;
+  ULONG  FileAttributes;
+} FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
 
-typedef union _POWER_STATE {
-  SYSTEM_POWER_STATE  SystemState;
-  DEVICE_POWER_STATE  DeviceState;
-} POWER_STATE, *PPOWER_STATE;
+typedef enum _FSINFOCLASS {
+  FileFsVolumeInformation = 1,
+  FileFsLabelInformation,
+  FileFsSizeInformation,
+  FileFsDeviceInformation,
+  FileFsAttributeInformation,
+  FileFsControlInformation,
+  FileFsFullSizeInformation,
+  FileFsObjectIdInformation,
+  FileFsDriverPathInformation,
+  FileFsVolumeFlagsInformation,
+  FileFsMaximumInformation
+} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
 
-typedef enum _POWER_STATE_TYPE {
-  SystemPowerState = 0,
-  DevicePowerState
-} POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
+typedef struct _FILE_FS_DEVICE_INFORMATION {
+  DEVICE_TYPE  DeviceType;
+  ULONG  Characteristics;
+} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
 
-#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_) */
+typedef struct _FILE_FULL_EA_INFORMATION {
+  ULONG  NextEntryOffset;
+  UCHAR  Flags;
+  UCHAR  EaNameLength;
+  USHORT  EaValueLength;
+  CHAR  EaName[1];
+} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
 
-#endif /* !_PO_DDK_ */
+#define FM_LOCK_BIT             (0x1)
+#define FM_LOCK_BIT_V           (0x0)
+#define FM_LOCK_WAITER_WOKEN    (0x2)
+#define FM_LOCK_WAITER_INC      (0x4)
 
-typedef VOID
-(DDKAPI *PREQUEST_POWER_COMPLETE)(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN UCHAR  MinorFunction,
-  IN POWER_STATE  PowerState,
-  IN PVOID  Context,
-  IN struct _IO_STATUS_BLOCK  *IoStatus);
+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;
 
-/******************************************************************************
- *                            Power Management Support Functions              *
- ******************************************************************************/
+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;
 
-#define PoSetDeviceBusy(IdlePointer) ((void)(*(IdlePointer) = 0))
+/* ERESOURCE.Flag */
+#define ResourceNeverExclusive            0x0010
+#define ResourceReleaseByOtherThread      0x0020
+#define ResourceOwnedExclusive            0x0080
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+#define RESOURCE_HASH_TABLE_SIZE          64
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-PoCallDriver(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN OUT struct _IRP  *Irp);
-
-NTKERNELAPI
-PULONG
-NTAPI
-PoRegisterDeviceForIdleDetection(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN ULONG  ConservationIdleTime,
-  IN ULONG  PerformanceIdleTime,
-  IN DEVICE_POWER_STATE  State);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN ULONG  Length,
+  IN BOOLEAN  Wait,
+  IN ULONG  LockKey,
+  IN BOOLEAN  CheckForReadOperation,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-PVOID
-NTAPI
-PoRegisterSystemState(
-  IN OUT PVOID StateHandle OPTIONAL,
-  IN EXECUTION_STATE Flags);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_READ)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN ULONG  Length,
+  IN BOOLEAN  Wait,
+  IN ULONG  LockKey,
+  OUT PVOID  Buffer,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-NTSTATUS
-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);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_WRITE)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN ULONG  Length,
+  IN BOOLEAN  Wait,
+  IN ULONG  LockKey,
+  IN PVOID  Buffer,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-POWER_STATE
-NTAPI
-PoSetPowerState(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN POWER_STATE_TYPE  Type,
-  IN POWER_STATE  State);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_QUERY_BASIC_INFO)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN BOOLEAN  Wait,
+  OUT PFILE_BASIC_INFORMATION  Buffer,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-VOID
-NTAPI
-PoSetSystemState(
-  IN EXECUTION_STATE  Flags);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN BOOLEAN  Wait,
+  OUT PFILE_STANDARD_INFORMATION  Buffer,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-VOID
-NTAPI
-PoStartNextPowerIrp(
-  IN OUT struct _IRP *Irp);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_LOCK)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN PLARGE_INTEGER  Length,
+  PEPROCESS  ProcessId,
+  ULONG  Key,
+  BOOLEAN  FailImmediately,
+  BOOLEAN  ExclusiveLock,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-VOID
-NTAPI
-PoUnregisterSystemState(
-  IN OUT PVOID StateHandle);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_UNLOCK_SINGLE)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN PLARGE_INTEGER  Length,
+  PEPROCESS  ProcessId,
+  ULONG  Key,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_UNLOCK_ALL)(
+  IN struct _FILE_OBJECT  *FileObject,
+  PEPROCESS  ProcessId,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-#if (NTDDI_VERSION >= NTDDI_VISTA)
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)(
+  IN struct _FILE_OBJECT  *FileObject,
+  PVOID  ProcessId,
+  ULONG  Key,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-VOID
-NTAPI
-PoSetSystemWake(
-  IN OUT struct _IRP *Irp);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_DEVICE_CONTROL)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN BOOLEAN  Wait,
+  IN PVOID  InputBuffer  OPTIONAL,
+  IN ULONG  InputBufferLength,
+  OUT PVOID  OutputBuffer  OPTIONAL,
+  IN ULONG  OutputBufferLength,
+  IN ULONG  IoControlCode,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-PoGetSystemWake(
-  IN struct _IRP *Irp);
+typedef VOID
+(DDKAPI *PFAST_IO_ACQUIRE_FILE)(
+  IN struct _FILE_OBJECT  *FileObject);
 
-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);
+typedef VOID
+(DDKAPI *PFAST_IO_RELEASE_FILE)(
+  IN struct _FILE_OBJECT  *FileObject);
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-PoUnregisterPowerSettingCallback(
-  IN OUT PVOID Handle);
+typedef VOID
+(DDKAPI *PFAST_IO_DETACH_DEVICE)(
+  IN struct _DEVICE_OBJECT  *SourceDevice,
+  IN struct _DEVICE_OBJECT  *TargetDevice);
 
-#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN BOOLEAN  Wait,
+  OUT struct _FILE_NETWORK_OPEN_INFORMATION  *Buffer,
+  OUT struct _IO_STATUS_BLOCK  *IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-#if (NTDDI_VERSION >= NTDDI_VISTASP1)
+typedef NTSTATUS
+(DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  EndingOffset,
+  OUT struct _ERESOURCE  **ResourceToRelease,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-VOID
-NTAPI
-PoSetDeviceBusyEx(
-  IN OUT PULONG IdlePointer);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_MDL_READ)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN ULONG  Length,
+  IN ULONG  LockKey,
+  OUT PMDL  *MdlChain,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_MDL_READ_COMPLETE)(
+  IN struct _FILE_OBJECT *FileObject,
+  IN PMDL MdlChain,
+  IN struct _DEVICE_OBJECT *DeviceObject);
 
-#if (NTDDI_VERSION >= NTDDI_WIN7)
-NTKERNELAPI
-VOID
-NTAPI
-PoStartDeviceBusy(
-  IN OUT PULONG IdlePointer);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN ULONG  Length,
+  IN ULONG  LockKey,
+  OUT PMDL  *MdlChain,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-VOID
-NTAPI
-PoEndDeviceBusy(
-  IN OUT PULONG IdlePointer);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN PMDL  MdlChain,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-BOOLEAN
-NTAPI
-PoQueryWatchdogTime(
-  IN PDEVICE_OBJECT Pdo,
-  OUT PULONG SecondsRemaining);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_READ_COMPRESSED)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN ULONG  Length,
+  IN ULONG  LockKey,
+  OUT PVOID  Buffer,
+  OUT PMDL  *MdlChain,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  OUT struct _COMPRESSED_DATA_INFO  *CompressedDataInfo,
+  IN ULONG  CompressedDataInfoLength,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-VOID
-NTAPI
-PoDeletePowerRequest(
-  IN OUT PVOID PowerRequest);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_WRITE_COMPRESSED)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN ULONG  Length,
+  IN ULONG  LockKey,
+  IN PVOID  Buffer,
+  OUT PMDL  *MdlChain,
+  OUT PIO_STATUS_BLOCK  IoStatus,
+  IN struct _COMPRESSED_DATA_INFO  *CompressedDataInfo,
+  IN ULONG  CompressedDataInfoLength,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-PoSetPowerRequest(
-  IN OUT PVOID PowerRequest,
-  IN POWER_REQUEST_TYPE Type);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PMDL  MdlChain,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-PoClearPowerRequest(
-  IN OUT PVOID PowerRequest,
-  IN POWER_REQUEST_TYPE Type);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN PLARGE_INTEGER  FileOffset,
+  IN PMDL  MdlChain,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-PoCreatePowerRequest(
-  OUT PVOID *PowerRequest,
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PCOUNTED_REASON_CONTEXT Context);
+typedef BOOLEAN
+(DDKAPI *PFAST_IO_QUERY_OPEN)(
+  IN struct _IRP  *Irp,
+  OUT PFILE_NETWORK_OPEN_INFORMATION  NetworkInformation,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
-#endif
+typedef NTSTATUS
+(DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN struct _ERESOURCE  *ResourceToRelease,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-/******************************************************************************
- *                            Configuration Manager Types                     *
- ******************************************************************************/
+typedef NTSTATUS
+(DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)(
+  IN struct _FILE_OBJECT  *FileObject,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-/* Resource list definitions */
-typedef int CM_RESOURCE_TYPE;
+typedef NTSTATUS
+(DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) (
+  IN struct _FILE_OBJECT  *FileObject,
+  IN struct _DEVICE_OBJECT  *DeviceObject);
 
-#define CmResourceTypeNull              0
-#define CmResourceTypePort              1
-#define CmResourceTypeInterrupt         2
-#define CmResourceTypeMemory            3
-#define CmResourceTypeDma               4
-#define CmResourceTypeDeviceSpecific    5
-#define CmResourceTypeBusNumber         6
-#define CmResourceTypeNonArbitrated      128
-#define CmResourceTypeConfigData         128
-#define CmResourceTypeDevicePrivate      129
-#define CmResourceTypePcCardConfig       130
-#define CmResourceTypeMfCardConfig       131
+typedef struct _FAST_IO_DISPATCH {
+  ULONG  SizeOfFastIoDispatch;
+  PFAST_IO_CHECK_IF_POSSIBLE  FastIoCheckIfPossible;
+  PFAST_IO_READ  FastIoRead;
+  PFAST_IO_WRITE  FastIoWrite;
+  PFAST_IO_QUERY_BASIC_INFO  FastIoQueryBasicInfo;
+  PFAST_IO_QUERY_STANDARD_INFO  FastIoQueryStandardInfo;
+  PFAST_IO_LOCK  FastIoLock;
+  PFAST_IO_UNLOCK_SINGLE  FastIoUnlockSingle;
+  PFAST_IO_UNLOCK_ALL  FastIoUnlockAll;
+  PFAST_IO_UNLOCK_ALL_BY_KEY  FastIoUnlockAllByKey;
+  PFAST_IO_DEVICE_CONTROL  FastIoDeviceControl;
+  PFAST_IO_ACQUIRE_FILE  AcquireFileForNtCreateSection;
+  PFAST_IO_RELEASE_FILE  ReleaseFileForNtCreateSection;
+  PFAST_IO_DETACH_DEVICE  FastIoDetachDevice;
+  PFAST_IO_QUERY_NETWORK_OPEN_INFO  FastIoQueryNetworkOpenInfo;
+  PFAST_IO_ACQUIRE_FOR_MOD_WRITE  AcquireForModWrite;
+  PFAST_IO_MDL_READ  MdlRead;
+  PFAST_IO_MDL_READ_COMPLETE  MdlReadComplete;
+  PFAST_IO_PREPARE_MDL_WRITE  PrepareMdlWrite;
+  PFAST_IO_MDL_WRITE_COMPLETE  MdlWriteComplete;
+  PFAST_IO_READ_COMPRESSED  FastIoReadCompressed;
+  PFAST_IO_WRITE_COMPRESSED  FastIoWriteCompressed;
+  PFAST_IO_MDL_READ_COMPLETE_COMPRESSED  MdlReadCompleteCompressed;
+  PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED  MdlWriteCompleteCompressed;
+  PFAST_IO_QUERY_OPEN  FastIoQueryOpen;
+  PFAST_IO_RELEASE_FOR_MOD_WRITE  ReleaseForModWrite;
+  PFAST_IO_ACQUIRE_FOR_CCFLUSH  AcquireForCcFlush;
+  PFAST_IO_RELEASE_FOR_CCFLUSH  ReleaseForCcFlush;
+} FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
 
-/* KEY_VALUE_Xxx.Type */
-#define REG_NONE                           0
-#define REG_SZ                             1
-#define REG_EXPAND_SZ                      2
-#define REG_BINARY                         3
-#define REG_DWORD                          4
-#define REG_DWORD_LITTLE_ENDIAN            4
-#define REG_DWORD_BIG_ENDIAN               5
-#define REG_LINK                           6
-#define REG_MULTI_SZ                       7
-#define REG_RESOURCE_LIST                  8
-#define REG_FULL_RESOURCE_DESCRIPTOR       9
-#define REG_RESOURCE_REQUIREMENTS_LIST    10
-#define REG_QWORD                         11
-#define REG_QWORD_LITTLE_ENDIAN           11
+typedef struct _SECTION_OBJECT_POINTERS {
+  PVOID  DataSectionObject;
+  PVOID  SharedCacheMap;
+  PVOID  ImageSectionObject;
+} SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
 
-/* Registry Access Rights */
-#define KEY_QUERY_VALUE         (0x0001)
-#define KEY_SET_VALUE           (0x0002)
-#define KEY_CREATE_SUB_KEY      (0x0004)
-#define KEY_ENUMERATE_SUB_KEYS  (0x0008)
-#define KEY_NOTIFY              (0x0010)
-#define KEY_CREATE_LINK         (0x0020)
-#define KEY_WOW64_32KEY         (0x0200)
-#define KEY_WOW64_64KEY         (0x0100)
-#define KEY_WOW64_RES           (0x0300)
+typedef struct _IO_COMPLETION_CONTEXT {
+  PVOID  Port;
+  PVOID  Key;
+} IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
 
-#define KEY_READ                ((STANDARD_RIGHTS_READ       |\
-                                  KEY_QUERY_VALUE            |\
-                                  KEY_ENUMERATE_SUB_KEYS     |\
-                                  KEY_NOTIFY)                 \
-                                  &                           \
-                                 (~SYNCHRONIZE))
+/* FILE_OBJECT.Flags */
+#define FO_FILE_OPEN                 0x00000001
+#define FO_SYNCHRONOUS_IO            0x00000002
+#define FO_ALERTABLE_IO              0x00000004
+#define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
+#define FO_WRITE_THROUGH             0x00000010
+#define FO_SEQUENTIAL_ONLY           0x00000020
+#define FO_CACHE_SUPPORTED           0x00000040
+#define FO_NAMED_PIPE                0x00000080
+#define FO_STREAM_FILE               0x00000100
+#define FO_MAILSLOT                  0x00000200
+#define FO_GENERATE_AUDIT_ON_CLOSE   0x00000400
+#define FO_QUEUE_IRP_TO_THREAD       0x00000400
+#define FO_DIRECT_DEVICE_OPEN        0x00000800
+#define FO_FILE_MODIFIED             0x00001000
+#define FO_FILE_SIZE_CHANGED         0x00002000
+#define FO_CLEANUP_COMPLETE          0x00004000
+#define FO_TEMPORARY_FILE            0x00008000
+#define FO_DELETE_ON_CLOSE           0x00010000
+#define FO_OPENED_CASE_SENSITIVE     0x00020000
+#define FO_HANDLE_CREATED            0x00040000
+#define FO_FILE_FAST_IO_READ         0x00080000
+#define FO_RANDOM_ACCESS             0x00100000
+#define FO_FILE_OPEN_CANCELLED       0x00200000
+#define FO_VOLUME_OPEN               0x00400000
+#define FO_REMOTE_ORIGIN             0x01000000
+#define FO_DISALLOW_EXCLUSIVE        0x02000000
+#define FO_SKIP_COMPLETION_PORT      0x02000000
+#define FO_SKIP_SET_EVENT            0x04000000
+#define FO_SKIP_SET_FAST_IO          0x08000000
 
-#define KEY_WRITE               ((STANDARD_RIGHTS_WRITE      |\
-                                  KEY_SET_VALUE              |\
-                                  KEY_CREATE_SUB_KEY)         \
-                                  &                           \
-                                 (~SYNCHRONIZE))
+/* VPB.Flags */
+#define VPB_MOUNTED                       0x0001
+#define VPB_LOCKED                        0x0002
+#define VPB_PERSISTENT                    0x0004
+#define VPB_REMOVE_PENDING                0x0008
+#define VPB_RAW_MOUNT                     0x0010
+#define VPB_DIRECT_WRITES_ALLOWED         0x0020
 
-#define KEY_EXECUTE             ((KEY_READ)                   \
-                                  &                           \
-                                 (~SYNCHRONIZE))
+/* IRP.Flags */
 
-#define KEY_ALL_ACCESS          ((STANDARD_RIGHTS_ALL        |\
-                                  KEY_QUERY_VALUE            |\
-                                  KEY_SET_VALUE              |\
-                                  KEY_CREATE_SUB_KEY         |\
-                                  KEY_ENUMERATE_SUB_KEYS     |\
-                                  KEY_NOTIFY                 |\
-                                  KEY_CREATE_LINK)            \
-                                  &                           \
-                                 (~SYNCHRONIZE))
+#define SL_FORCE_ACCESS_CHECK             0x01
+#define SL_OPEN_PAGING_FILE               0x02
+#define SL_OPEN_TARGET_DIRECTORY          0x04
+#define SL_CASE_SENSITIVE                 0x80
 
-/* Registry Open/Create Options */
-#define REG_OPTION_RESERVED         (0x00000000L)
-#define REG_OPTION_NON_VOLATILE     (0x00000000L)
-#define REG_OPTION_VOLATILE         (0x00000001L)
-#define REG_OPTION_CREATE_LINK      (0x00000002L)
-#define REG_OPTION_BACKUP_RESTORE   (0x00000004L)
-#define REG_OPTION_OPEN_LINK        (0x00000008L)
+#define SL_KEY_SPECIFIED                  0x01
+#define SL_OVERRIDE_VERIFY_VOLUME         0x02
+#define SL_WRITE_THROUGH                  0x04
+#define SL_FT_SEQUENTIAL_WRITE            0x08
 
-#define REG_LEGAL_OPTION            \
-                (REG_OPTION_RESERVED            |\
-                 REG_OPTION_NON_VOLATILE        |\
-                 REG_OPTION_VOLATILE            |\
-                 REG_OPTION_CREATE_LINK         |\
-                 REG_OPTION_BACKUP_RESTORE      |\
-                 REG_OPTION_OPEN_LINK)
+#define SL_FAIL_IMMEDIATELY               0x01
+#define SL_EXCLUSIVE_LOCK                 0x02
 
-/* Key creation/open disposition */
-#define REG_CREATED_NEW_KEY         (0x00000001L)
-#define REG_OPENED_EXISTING_KEY     (0x00000002L)
+#define SL_RESTART_SCAN                   0x01
+#define SL_RETURN_SINGLE_ENTRY            0x02
+#define SL_INDEX_SPECIFIED                0x04
 
-/* Key restore & hive load flags */
-#define REG_WHOLE_HIVE_VOLATILE         (0x00000001L)
-#define REG_REFRESH_HIVE                (0x00000002L)
-#define REG_NO_LAZY_FLUSH               (0x00000004L)
-#define REG_FORCE_RESTORE               (0x00000008L)
-#define REG_APP_HIVE                    (0x00000010L)
-#define REG_PROCESS_PRIVATE             (0x00000020L)
-#define REG_START_JOURNAL               (0x00000040L)
-#define REG_HIVE_EXACT_FILE_GROWTH      (0x00000080L)
-#define REG_HIVE_NO_RM                  (0x00000100L)
-#define REG_HIVE_SINGLE_LOG             (0x00000200L)
+#define SL_WATCH_TREE                     0x01
 
-/* Unload Flags */
-#define REG_FORCE_UNLOAD            1
+#define SL_ALLOW_RAW_MOUNT                0x01
 
-/* Notify Filter Values */
-#define REG_NOTIFY_CHANGE_NAME          (0x00000001L)
-#define REG_NOTIFY_CHANGE_ATTRIBUTES    (0x00000002L)
-#define REG_NOTIFY_CHANGE_LAST_SET      (0x00000004L)
-#define REG_NOTIFY_CHANGE_SECURITY      (0x00000008L)
+#define CTL_CODE(DeviceType, Function, Method, Access) \
+  (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
 
-#define REG_LEGAL_CHANGE_FILTER                 \
-                (REG_NOTIFY_CHANGE_NAME          |\
-                 REG_NOTIFY_CHANGE_ATTRIBUTES    |\
-                 REG_NOTIFY_CHANGE_LAST_SET      |\
-                 REG_NOTIFY_CHANGE_SECURITY)
+#define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
 
-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;
+#define IRP_NOCACHE                     0x00000001
+#define IRP_PAGING_IO                   0x00000002
+#define IRP_MOUNT_COMPLETION            0x00000002
+#define IRP_SYNCHRONOUS_API             0x00000004
+#define IRP_ASSOCIATED_IRP              0x00000008
+#define IRP_BUFFERED_IO                 0x00000010
+#define IRP_DEALLOCATE_BUFFER           0x00000020
+#define IRP_INPUT_OPERATION             0x00000040
+#define IRP_SYNCHRONOUS_PAGING_IO       0x00000040
+#define IRP_CREATE_OPERATION            0x00000080
+#define IRP_READ_OPERATION              0x00000100
+#define IRP_WRITE_OPERATION             0x00000200
+#define IRP_CLOSE_OPERATION             0x00000400
+#define IRP_DEFER_IO_COMPLETION         0x00000800
+#define IRP_OB_QUERY_NAME               0x00001000
+#define IRP_HOLD_DEVICE_QUEUE           0x00002000
 
-#include <pshpack4.h>
-typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
-  UCHAR Type;
-  UCHAR ShareDisposition;
-  USHORT Flags;
-  union {
-    struct {
-      PHYSICAL_ADDRESS Start;
-      ULONG Length;
-    } Generic;
-    struct {
-      PHYSICAL_ADDRESS Start;
-      ULONG Length;
-    } Port;
-    struct {
-#if defined(NT_PROCESSOR_GROUPS)
-      USHORT Level;
-      USHORT Group;
-#else
-      ULONG Level;
-#endif
-      ULONG Vector;
-      KAFFINITY Affinity;
-    } Interrupt;
-#if (NTDDI_VERSION >= NTDDI_LONGHORN)
-    struct {
-      __GNU_EXTENSION union {
-        struct {
-#if defined(NT_PROCESSOR_GROUPS)
-          USHORT Group;
-#else
-          USHORT Reserved;
-#endif
-          USHORT MessageCount;
-          ULONG Vector;
-          KAFFINITY Affinity;
-        } Raw;
-        struct {
-#if defined(NT_PROCESSOR_GROUPS)
-          USHORT Level;
-          USHORT Group;
-#else
-          ULONG Level;
-#endif
-          ULONG Vector;
-          KAFFINITY Affinity;
-        } Translated;
-      } DUMMYUNIONNAME;
-    } MessageInterrupt;
-#endif
-    struct {
-      PHYSICAL_ADDRESS Start;
-      ULONG Length;
-    } Memory;
-    struct {
-      ULONG Channel;
-      ULONG Port;
-      ULONG Reserved1;
-    } Dma;
-    struct {
-      ULONG Data[3];
-    } DevicePrivate;
-    struct {
-      ULONG Start;
-      ULONG Length;
-      ULONG Reserved;
-    } BusNumber;
-    struct {
-      ULONG DataSize;
-      ULONG Reserved1;
-      ULONG Reserved2;
-    } DeviceSpecificData;
-#if (NTDDI_VERSION >= NTDDI_LONGHORN)
-    struct {
-      PHYSICAL_ADDRESS Start;
-      ULONG Length40;
-    } Memory40;
-    struct {
-      PHYSICAL_ADDRESS Start;
-      ULONG Length48;
-    } Memory48;
-    struct {
-      PHYSICAL_ADDRESS Start;
-      ULONG Length64;
-    } Memory64;
-#endif
-  } u;
-} CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
-#include <poppack.h>
+#define IRP_QUOTA_CHARGED                 0x01
+#define IRP_ALLOCATED_MUST_SUCCEED        0x02
+#define IRP_ALLOCATED_FIXED_SIZE          0x04
+#define IRP_LOOKASIDE_ALLOCATION          0x08
 
-/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
-#define CmResourceTypeNull                0
-#define CmResourceTypePort                1
-#define CmResourceTypeInterrupt           2
-#define CmResourceTypeMemory              3
-#define CmResourceTypeDma                 4
-#define CmResourceTypeDeviceSpecific      5
-#define CmResourceTypeBusNumber           6
-#define CmResourceTypeMemoryLarge         7
-#define CmResourceTypeNonArbitrated     128
-#define CmResourceTypeConfigData        128
-#define CmResourceTypeDevicePrivate     129
-#define CmResourceTypePcCardConfig      130
-#define CmResourceTypeMfCardConfig      131
+/*
+** IRP function codes
+*/
 
-/* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
-typedef enum _CM_SHARE_DISPOSITION {
-  CmResourceShareUndetermined,
-  CmResourceShareDeviceExclusive,
-  CmResourceShareDriverExclusive,
-  CmResourceShareShared
-} CM_SHARE_DISPOSITION;
+#define IRP_MJ_CREATE                     0x00
+#define IRP_MJ_CREATE_NAMED_PIPE          0x01
+#define IRP_MJ_CLOSE                      0x02
+#define IRP_MJ_READ                       0x03
+#define IRP_MJ_WRITE                      0x04
+#define IRP_MJ_QUERY_INFORMATION          0x05
+#define IRP_MJ_SET_INFORMATION            0x06
+#define IRP_MJ_QUERY_EA                   0x07
+#define IRP_MJ_SET_EA                     0x08
+#define IRP_MJ_FLUSH_BUFFERS              0x09
+#define IRP_MJ_QUERY_VOLUME_INFORMATION   0x0a
+#define IRP_MJ_SET_VOLUME_INFORMATION     0x0b
+#define IRP_MJ_DIRECTORY_CONTROL          0x0c
+#define IRP_MJ_FILE_SYSTEM_CONTROL        0x0d
+#define IRP_MJ_DEVICE_CONTROL             0x0e
+#define IRP_MJ_INTERNAL_DEVICE_CONTROL    0x0f
+#define IRP_MJ_SCSI                       0x0f
+#define IRP_MJ_SHUTDOWN                   0x10
+#define IRP_MJ_LOCK_CONTROL               0x11
+#define IRP_MJ_CLEANUP                    0x12
+#define IRP_MJ_CREATE_MAILSLOT            0x13
+#define IRP_MJ_QUERY_SECURITY             0x14
+#define IRP_MJ_SET_SECURITY               0x15
+#define IRP_MJ_POWER                      0x16
+#define IRP_MJ_SYSTEM_CONTROL             0x17
+#define IRP_MJ_DEVICE_CHANGE              0x18
+#define IRP_MJ_QUERY_QUOTA                0x19
+#define IRP_MJ_SET_QUOTA                  0x1a
+#define IRP_MJ_PNP                        0x1b
+#define IRP_MJ_PNP_POWER                  0x1b
+#define IRP_MJ_MAXIMUM_FUNCTION           0x1b
 
-/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
-#define CM_RESOURCE_PORT_MEMORY           0x0000
-#define CM_RESOURCE_PORT_IO               0x0001
-#define CM_RESOURCE_PORT_10_BIT_DECODE    0x0004
-#define CM_RESOURCE_PORT_12_BIT_DECODE    0x0008
-#define CM_RESOURCE_PORT_16_BIT_DECODE    0x0010
-#define CM_RESOURCE_PORT_POSITIVE_DECODE  0x0020
-#define CM_RESOURCE_PORT_PASSIVE_DECODE   0x0040
-#define CM_RESOURCE_PORT_WINDOW_DECODE    0x0080
-#define CM_RESOURCE_PORT_BAR              0x0100
+#define IRP_MN_SCSI_CLASS                 0x01
 
-/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
-#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
-#define CM_RESOURCE_INTERRUPT_LATCHED         0x0001
-#define CM_RESOURCE_INTERRUPT_MESSAGE         0x0002
-#define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004
+#define IRP_MN_START_DEVICE               0x00
+#define IRP_MN_QUERY_REMOVE_DEVICE        0x01
+#define IRP_MN_REMOVE_DEVICE              0x02
+#define IRP_MN_CANCEL_REMOVE_DEVICE       0x03
+#define IRP_MN_STOP_DEVICE                0x04
+#define IRP_MN_QUERY_STOP_DEVICE          0x05
+#define IRP_MN_CANCEL_STOP_DEVICE         0x06
 
-/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
-#define CM_RESOURCE_MEMORY_READ_WRITE                    0x0000
-#define CM_RESOURCE_MEMORY_READ_ONLY                     0x0001
-#define CM_RESOURCE_MEMORY_WRITE_ONLY                    0x0002
-#define CM_RESOURCE_MEMORY_WRITEABILITY_MASK             0x0003
-#define CM_RESOURCE_MEMORY_PREFETCHABLE                  0x0004
-#define CM_RESOURCE_MEMORY_COMBINEDWRITE                 0x0008
-#define CM_RESOURCE_MEMORY_24                            0x0010
-#define CM_RESOURCE_MEMORY_CACHEABLE                     0x0020
-#define CM_RESOURCE_MEMORY_WINDOW_DECODE                 0x0040
-#define CM_RESOURCE_MEMORY_BAR                           0x0080
-#define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100
+#define IRP_MN_QUERY_DEVICE_RELATIONS       0x07
+#define IRP_MN_QUERY_INTERFACE              0x08
+#define IRP_MN_QUERY_CAPABILITIES           0x09
+#define IRP_MN_QUERY_RESOURCES              0x0A
+#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS  0x0B
+#define IRP_MN_QUERY_DEVICE_TEXT            0x0C
+#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
 
-/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
-#define CM_RESOURCE_DMA_8                 0x0000
-#define CM_RESOURCE_DMA_16                0x0001
-#define CM_RESOURCE_DMA_32                0x0002
-#define CM_RESOURCE_DMA_8_AND_16          0x0004
-#define CM_RESOURCE_DMA_BUS_MASTER        0x0008
-#define CM_RESOURCE_DMA_TYPE_A            0x0010
-#define CM_RESOURCE_DMA_TYPE_B            0x0020
-#define CM_RESOURCE_DMA_TYPE_F            0x0040
+#define IRP_MN_READ_CONFIG                  0x0F
+#define IRP_MN_WRITE_CONFIG                 0x10
+#define IRP_MN_EJECT                        0x11
+#define IRP_MN_SET_LOCK                     0x12
+#define IRP_MN_QUERY_ID                     0x13
+#define IRP_MN_QUERY_PNP_DEVICE_STATE       0x14
+#define IRP_MN_QUERY_BUS_INFORMATION        0x15
+#define IRP_MN_DEVICE_USAGE_NOTIFICATION    0x16
+#define IRP_MN_SURPRISE_REMOVAL             0x17
 
-typedef struct _CM_PARTIAL_RESOURCE_LIST {
-  USHORT  Version;
-  USHORT  Revision;
-  ULONG  Count;
-  CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
-} CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
+#define IRP_MN_WAIT_WAKE                  0x00
+#define IRP_MN_POWER_SEQUENCE             0x01
+#define IRP_MN_SET_POWER                  0x02
+#define IRP_MN_QUERY_POWER                0x03
 
-typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
-  INTERFACE_TYPE  InterfaceType;
-  ULONG  BusNumber;
-  CM_PARTIAL_RESOURCE_LIST  PartialResourceList;
-} CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
+#define IRP_MN_QUERY_ALL_DATA             0x00
+#define IRP_MN_QUERY_SINGLE_INSTANCE      0x01
+#define IRP_MN_CHANGE_SINGLE_INSTANCE     0x02
+#define IRP_MN_CHANGE_SINGLE_ITEM         0x03
+#define IRP_MN_ENABLE_EVENTS              0x04
+#define IRP_MN_DISABLE_EVENTS             0x05
+#define IRP_MN_ENABLE_COLLECTION          0x06
+#define IRP_MN_DISABLE_COLLECTION         0x07
+#define IRP_MN_REGINFO                    0x08
+#define IRP_MN_EXECUTE_METHOD             0x09
 
-typedef struct _CM_RESOURCE_LIST {
-  ULONG  Count;
-  CM_FULL_RESOURCE_DESCRIPTOR  List[1];
-} CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
+#define IRP_MN_REGINFO_EX                 0x0b
 
-#include <pshpack1.h>
-typedef struct _CM_INT13_DRIVE_PARAMETER {
-  USHORT  DriveSelect;
-  ULONG  MaxCylinders;
-  USHORT  SectorsPerTrack;
-  USHORT  MaxHeads;
-  USHORT  NumberDrives;
-} CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
+typedef struct _FILE_OBJECT
+{
+    CSHORT Type;
+    CSHORT Size;
+    PDEVICE_OBJECT DeviceObject;
+    PVPB Vpb;
+    PVOID FsContext;
+    PVOID FsContext2;
+    PSECTION_OBJECT_POINTERS SectionObjectPointer;
+    PVOID PrivateCacheMap;
+    NTSTATUS FinalStatus;
+    struct _FILE_OBJECT *RelatedFileObject;
+    BOOLEAN LockOperation;
+    BOOLEAN DeletePending;
+    BOOLEAN ReadAccess;
+    BOOLEAN WriteAccess;
+    BOOLEAN DeleteAccess;
+    BOOLEAN SharedRead;
+    BOOLEAN SharedWrite;
+    BOOLEAN SharedDelete;
+    ULONG Flags;
+    UNICODE_STRING FileName;
+    LARGE_INTEGER CurrentByteOffset;
+    volatile ULONG Waiters;
+    volatile ULONG Busy;
+    PVOID LastLock;
+    KEVENT Lock;
+    KEVENT Event;
+    volatile PIO_COMPLETION_CONTEXT CompletionContext;
+    KSPIN_LOCK IrpListLock;
+    LIST_ENTRY IrpList;
+    volatile PVOID FileObjectExtension;
+} FILE_OBJECT, *PFILE_OBJECT;
 
-typedef struct _CM_PNP_BIOS_DEVICE_NODE {
-  USHORT Size;
-  UCHAR Node;
-  ULONG ProductId;
-  UCHAR DeviceType[3];
-  USHORT DeviceAttributes;
-} CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
+typedef struct _IO_ERROR_LOG_PACKET {
+  UCHAR  MajorFunctionCode;
+  UCHAR  RetryCount;
+  USHORT  DumpDataSize;
+  USHORT  NumberOfStrings;
+  USHORT  StringOffset;
+  USHORT  EventCategory;
+  NTSTATUS  ErrorCode;
+  ULONG  UniqueErrorValue;
+  NTSTATUS  FinalStatus;
+  ULONG  SequenceNumber;
+  ULONG  IoControlCode;
+  LARGE_INTEGER  DeviceOffset;
+  ULONG  DumpData[1];
+} IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
 
-typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
-  UCHAR Signature[4];
-  UCHAR Revision;
-  UCHAR Length;
-  USHORT ControlField;
-  UCHAR Checksum;
-  ULONG EventFlagAddress;
-  USHORT RealModeEntryOffset;
-  USHORT RealModeEntrySegment;
-  USHORT ProtectedModeEntryOffset;
-  ULONG ProtectedModeCodeBaseAddress;
-  ULONG OemDeviceId;
-  USHORT RealModeDataBaseAddress;
-  ULONG ProtectedModeDataBaseAddress;
-} CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
-#include <poppack.h>
+typedef struct _IO_ERROR_LOG_MESSAGE {
+  USHORT  Type;
+  USHORT  Size;
+  USHORT  DriverNameLength;
+  LARGE_INTEGER  TimeStamp;
+  ULONG  DriverNameOffset;
+  IO_ERROR_LOG_PACKET  EntryData;
+} IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
 
-typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA {
-    ULONG BytesPerSector;
-    ULONG NumberOfCylinders;
-    ULONG SectorsPerTrack;
-    ULONG NumberOfHeads;
-} CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
+#define ERROR_LOG_LIMIT_SIZE               240
+#define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
+                                            sizeof(IO_ERROR_LOG_PACKET) + \
+                                            (sizeof(WCHAR) * 40))
+#define ERROR_LOG_MESSAGE_LIMIT_SIZE                                          \
+    (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
+#define IO_ERROR_LOG_MESSAGE_LENGTH                                           \
+    ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ?           \
+        ERROR_LOG_MESSAGE_LIMIT_SIZE :                                        \
+        PORT_MAXIMUM_MESSAGE_LENGTH)
+#define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH -                 \
+                                IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
 
-typedef struct _CM_KEYBOARD_DEVICE_DATA {
-  USHORT  Version;
-  USHORT  Revision;
-  UCHAR  Type;
-  UCHAR  Subtype;
-  USHORT  KeyboardFlags;
-} CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
+typedef enum _DMA_WIDTH {
+  Width8Bits,
+  Width16Bits,
+  Width32Bits,
+  MaximumDmaWidth
+} DMA_WIDTH, *PDMA_WIDTH;
 
-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 enum _DMA_SPEED {
+  Compatible,
+  TypeA,
+  TypeB,
+  TypeC,
+  TypeF,
+  MaximumDmaSpeed
+} DMA_SPEED, *PDMA_SPEED;
 
-#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;
+/* DEVICE_DESCRIPTION.Version */
 
-#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
+#define DEVICE_DESCRIPTION_VERSION        0x0000
+#define DEVICE_DESCRIPTION_VERSION1       0x0001
+#define DEVICE_DESCRIPTION_VERSION2       0x0002
 
-#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
+typedef struct _DEVICE_DESCRIPTION {
+  ULONG  Version;
+  BOOLEAN  Master;
+  BOOLEAN  ScatterGather;
+  BOOLEAN  DemandMode;
+  BOOLEAN  AutoInitialize;
+  BOOLEAN  Dma32BitAddresses;
+  BOOLEAN  IgnoreCount;
+  BOOLEAN  Reserved1;
+  BOOLEAN  Dma64BitAddresses;
+  ULONG  BusNumber;
+  ULONG  DmaChannel;
+  INTERFACE_TYPE  InterfaceType;
+  DMA_WIDTH  DmaWidth;
+  DMA_SPEED  DmaSpeed;
+  ULONG  MaximumLength;
+  ULONG  DmaPort;
+} DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
 
-typedef struct _CM_SCSI_DEVICE_DATA {
-  USHORT  Version;
-  USHORT  Revision;
-  UCHAR  HostIdentifier;
-} CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
+typedef enum _DEVICE_RELATION_TYPE {
+  BusRelations,
+  EjectionRelations,
+  PowerRelations,
+  RemovalRelations,
+  TargetDeviceRelation,
+  SingleBusRelations,
+  TransportRelations
+} DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
 
-typedef struct _CM_SERIAL_DEVICE_DATA {
-  USHORT  Version;
-  USHORT  Revision;
-  ULONG  BaudClock;
-} CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
+typedef struct _DEVICE_RELATIONS {
+  ULONG  Count;
+  PDEVICE_OBJECT Objects[1];
+} DEVICE_RELATIONS, *PDEVICE_RELATIONS;
 
-typedef enum _KEY_INFORMATION_CLASS {
-  KeyBasicInformation,
-  KeyNodeInformation,
-  KeyFullInformation,
-  KeyNameInformation,
-  KeyCachedInformation,
-  KeyFlagsInformation
-} KEY_INFORMATION_CLASS;
+typedef struct _DEVOBJ_EXTENSION
+{
+    CSHORT Type;
+    USHORT Size;
+    PDEVICE_OBJECT DeviceObject;
+} DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
 
-typedef struct _KEY_BASIC_INFORMATION {
-  LARGE_INTEGER  LastWriteTime;
-  ULONG  TitleIndex;
-  ULONG  NameLength;
-  WCHAR  Name[1];
-} KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
+typedef struct _SCATTER_GATHER_ELEMENT {
+  PHYSICAL_ADDRESS  Address;
+  ULONG  Length;
+  ULONG_PTR  Reserved;
+} SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
 
-typedef struct _KEY_FULL_INFORMATION {
-  LARGE_INTEGER  LastWriteTime;
-  ULONG  TitleIndex;
-  ULONG  ClassOffset;
-  ULONG  ClassLength;
-  ULONG  SubKeys;
-  ULONG  MaxNameLen;
-  ULONG  MaxClassLen;
-  ULONG  Values;
-  ULONG  MaxValueNameLen;
-  ULONG  MaxValueDataLen;
-  WCHAR  Class[1];
-} KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
+#if defined(_MSC_EXTENSIONS)
 
-typedef struct _KEY_NODE_INFORMATION {
-  LARGE_INTEGER  LastWriteTime;
-  ULONG  TitleIndex;
-  ULONG  ClassOffset;
-  ULONG  ClassLength;
-  ULONG  NameLength;
-  WCHAR  Name[1];
-} KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
+#if _MSC_VER >= 1200
+#pragma warning(push)
+#endif
+#pragma warning(disable:4200)
+typedef struct _SCATTER_GATHER_LIST {
+  ULONG  NumberOfElements;
+  ULONG_PTR  Reserved;
+  SCATTER_GATHER_ELEMENT  Elements[1];
+} SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
 
-typedef struct _KEY_VALUE_BASIC_INFORMATION {
-  ULONG  TitleIndex;
-  ULONG  Type;
-  ULONG  NameLength;
-  WCHAR  Name[1];
-} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
+#if _MSC_VER >= 1200
+#pragma warning(pop)
+#else
+#pragma warning(default:4200)
+#endif
 
-typedef struct _KEY_VALUE_FULL_INFORMATION {
-  ULONG  TitleIndex;
-  ULONG  Type;
-  ULONG  DataOffset;
-  ULONG  DataLength;
-  ULONG  NameLength;
-  WCHAR  Name[1];
-} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
+#else
 
-typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
-  ULONG  TitleIndex;
-  ULONG  Type;
-  ULONG  DataLength;
-  UCHAR  Data[1];
-} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
+struct _SCATTER_GATHER_LIST;
+typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
 
-typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
-  ULONG  Type;
-  ULONG  DataLength;
-  UCHAR  Data[1];
-} KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
+#endif
 
-typedef struct _KEY_VALUE_ENTRY {
-  PUNICODE_STRING  ValueName;
-  ULONG  DataLength;
-  ULONG  DataOffset;
-  ULONG  Type;
-} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
+typedef NTSTATUS
+(DDKAPI DRIVER_ADD_DEVICE)(
+  IN struct _DRIVER_OBJECT  *DriverObject,
+  IN struct _DEVICE_OBJECT  *PhysicalDeviceObject);
+typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
 
-typedef enum _KEY_VALUE_INFORMATION_CLASS {
-  KeyValueBasicInformation,
-  KeyValueFullInformation,
-  KeyValuePartialInformation,
-  KeyValueFullInformationAlign64,
-  KeyValuePartialInformationAlign64
-} KEY_VALUE_INFORMATION_CLASS;
+typedef struct _DRIVER_EXTENSION {
+  struct _DRIVER_OBJECT  *DriverObject;
+  PDRIVER_ADD_DEVICE  AddDevice;
+  ULONG  Count;
+  UNICODE_STRING  ServiceKeyName;
+} DRIVER_EXTENSION, *PDRIVER_EXTENSION;
 
-typedef struct _KEY_WRITE_TIME_INFORMATION {
-  LARGE_INTEGER  LastWriteTime;
-} KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
+#define DRVO_UNLOAD_INVOKED               0x00000001
+#define DRVO_LEGACY_DRIVER                0x00000002
+#define DRVO_BUILTIN_DRIVER               0x00000004
 
-typedef enum _KEY_SET_INFORMATION_CLASS {
-  KeyWriteTimeInformation,
-  KeyWow64FlagsInformation,
-  KeyControlFlagsInformation,
-  KeySetVirtualizationInformation,
-  KeySetDebugInformation,
-  KeySetHandleTagsInformation,
-  MaxKeySetInfoClass
-} KEY_SET_INFORMATION_CLASS;
+typedef NTSTATUS
+(DDKAPI DRIVER_INITIALIZE)(
+  IN struct _DRIVER_OBJECT  *DriverObject,
+  IN PUNICODE_STRING  RegistryPath);
+typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE;
 
-typedef enum _REG_NOTIFY_CLASS {
-  RegNtDeleteKey,
-  RegNtPreDeleteKey = RegNtDeleteKey,
-  RegNtSetValueKey,
-  RegNtPreSetValueKey = RegNtSetValueKey,
-  RegNtDeleteValueKey,
-  RegNtPreDeleteValueKey = RegNtDeleteValueKey,
-  RegNtSetInformationKey,
-  RegNtPreSetInformationKey = RegNtSetInformationKey,
-  RegNtRenameKey,
-  RegNtPreRenameKey = RegNtRenameKey,
-  RegNtEnumerateKey,
-  RegNtPreEnumerateKey = RegNtEnumerateKey,
-  RegNtEnumerateValueKey,
-  RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
-  RegNtQueryKey,
-  RegNtPreQueryKey = RegNtQueryKey,
-  RegNtQueryValueKey,
-  RegNtPreQueryValueKey = RegNtQueryValueKey,
-  RegNtQueryMultipleValueKey,
-  RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
-  RegNtPreCreateKey,
-  RegNtPostCreateKey,
-  RegNtPreOpenKey,
-  RegNtPostOpenKey,
-  RegNtKeyHandleClose,
-  RegNtPreKeyHandleClose = RegNtKeyHandleClose,
-  RegNtPostDeleteKey,
-  RegNtPostSetValueKey,
-  RegNtPostDeleteValueKey,
-  RegNtPostSetInformationKey,
-  RegNtPostRenameKey,
-  RegNtPostEnumerateKey,
-  RegNtPostEnumerateValueKey,
-  RegNtPostQueryKey,
-  RegNtPostQueryValueKey,
-  RegNtPostQueryMultipleValueKey,
-  RegNtPostKeyHandleClose,
-  RegNtPreCreateKeyEx,
-  RegNtPostCreateKeyEx,
-  RegNtPreOpenKeyEx,
-  RegNtPostOpenKeyEx,
-  RegNtPreFlushKey,
-  RegNtPostFlushKey,
-  RegNtPreLoadKey,
-  RegNtPostLoadKey,
-  RegNtPreUnLoadKey,
-  RegNtPostUnLoadKey,
-  RegNtPreQueryKeySecurity,
-  RegNtPostQueryKeySecurity,
-  RegNtPreSetKeySecurity,
-  RegNtPostSetKeySecurity,
-  RegNtCallbackObjectContextCleanup,
-  RegNtPreRestoreKey,
-  RegNtPostRestoreKey,
-  RegNtPreSaveKey,
-  RegNtPostSaveKey,
-  RegNtPreReplaceKey,
-  RegNtPostReplaceKey,
-  MaxRegNtNotifyClass
-} REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
+typedef VOID
+(DDKAPI DRIVER_STARTIO)(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN struct _IRP  *Irp);
+typedef DRIVER_STARTIO *PDRIVER_STARTIO;
+
+typedef VOID
+(DDKAPI DRIVER_UNLOAD)(
+  IN struct _DRIVER_OBJECT  *DriverObject);
+typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
 
 typedef NTSTATUS
-(NTAPI *PEX_CALLBACK_FUNCTION)(
-    IN PVOID CallbackContext,
-    IN PVOID Argument1,
-    IN PVOID Argument2
-);
+(DDKAPI DRIVER_DISPATCH)(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN struct _IRP  *Irp);
+typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
 
-typedef struct _REG_DELETE_KEY_INFORMATION {
-  PVOID Object;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION
-#if (NTDDI_VERSION >= NTDDI_VISTA)
-, REG_FLUSH_KEY_INFORMATION, *PREG_FLUSH_KEY_INFORMATION
-#endif
-;
+typedef struct _DRIVER_OBJECT {
+  CSHORT  Type;
+  CSHORT  Size;
+  PDEVICE_OBJECT  DeviceObject;
+  ULONG  Flags;
+  PVOID  DriverStart;
+  ULONG  DriverSize;
+  PVOID  DriverSection;
+  PDRIVER_EXTENSION  DriverExtension;
+  UNICODE_STRING  DriverName;
+  PUNICODE_STRING  HardwareDatabase;
+  struct _FAST_IO_DISPATCH *FastIoDispatch;
+  PDRIVER_INITIALIZE  DriverInit;
+  PDRIVER_STARTIO  DriverStartIo;
+  PDRIVER_UNLOAD  DriverUnload;
+  PDRIVER_DISPATCH  MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
+} DRIVER_OBJECT;
+typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
 
-typedef struct _REG_SET_VALUE_KEY_INFORMATION {
-  PVOID Object;
-  PUNICODE_STRING ValueName;
-  ULONG TitleIndex;
-  ULONG Type;
-  PVOID Data;
-  ULONG DataSize;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
+typedef struct _DMA_ADAPTER {
+  USHORT  Version;
+  USHORT  Size;
+  struct _DMA_OPERATIONS*  DmaOperations;
+} DMA_ADAPTER, *PDMA_ADAPTER;
 
-typedef struct _REG_DELETE_VALUE_KEY_INFORMATION {
-  PVOID Object;
-  PUNICODE_STRING ValueName;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
+typedef VOID
+(DDKAPI *PPUT_DMA_ADAPTER)(
+  IN PDMA_ADAPTER  DmaAdapter);
 
-typedef struct _REG_SET_INFORMATION_KEY_INFORMATION {
-  PVOID Object;
-  KEY_SET_INFORMATION_CLASS KeySetInformationClass;
-  PVOID KeySetInformation;
-  ULONG KeySetInformationLength;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
+typedef PVOID
+(DDKAPI *PALLOCATE_COMMON_BUFFER)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN ULONG  Length,
+  OUT PPHYSICAL_ADDRESS  LogicalAddress,
+  IN BOOLEAN  CacheEnabled);
 
-typedef struct _REG_ENUMERATE_KEY_INFORMATION {
-  PVOID Object;
-  ULONG Index;
-  KEY_INFORMATION_CLASS KeyInformationClass;
-  PVOID KeyInformation;
-  ULONG Length;
-  PULONG ResultLength;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
-
-typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION {
-  PVOID Object;
-  ULONG Index;
-  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
-  PVOID KeyValueInformation;
-  ULONG Length;
-  PULONG ResultLength;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
-
-typedef struct _REG_QUERY_KEY_INFORMATION {
-  PVOID Object;
-  KEY_INFORMATION_CLASS KeyInformationClass;
-  PVOID KeyInformation;
-  ULONG Length;
-  PULONG ResultLength;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
-
-typedef struct _REG_QUERY_VALUE_KEY_INFORMATION {
-  PVOID Object;
-  PUNICODE_STRING ValueName;
-  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
-  PVOID KeyValueInformation;
-  ULONG Length;
-  PULONG ResultLength;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
-
-typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION {
-  PVOID Object;
-  PKEY_VALUE_ENTRY ValueEntries;
-  ULONG EntryCount;
-  PVOID ValueBuffer;
-  PULONG BufferLength;
-  PULONG RequiredBufferLength;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
-
-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;;
-
-typedef struct _REG_POST_CREATE_KEY_INFORMATION {
-  PUNICODE_STRING CompleteName;
-  PVOID Object;
-  NTSTATUS Status;
-} REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
-
-typedef struct _REG_POST_OPERATION_INFORMATION {
-  PVOID Object;
-  NTSTATUS Status;
-  PVOID PreInformation;
-  NTSTATUS ReturnStatus;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
+typedef VOID
+(DDKAPI *PFREE_COMMON_BUFFER)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN ULONG  Length,
+  IN PHYSICAL_ADDRESS  LogicalAddress,
+  IN PVOID  VirtualAddress,
+  IN BOOLEAN  CacheEnabled);
 
-typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION {
-  PVOID Object;
-  PVOID CallContext;
-  PVOID ObjectContext;
-  PVOID Reserved;
-} REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
+typedef NTSTATUS
+(DDKAPI *PALLOCATE_ADAPTER_CHANNEL)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN ULONG  NumberOfMapRegisters,
+  IN PDRIVER_CONTROL  ExecutionRoutine,
+  IN PVOID  Context);
 
+typedef BOOLEAN
+(DDKAPI *PFLUSH_ADAPTER_BUFFERS)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN PMDL  Mdl,
+  IN PVOID  MapRegisterBase,
+  IN PVOID  CurrentVa,
+  IN ULONG  Length,
+  IN BOOLEAN  WriteToDevice);
 
-/******************************************************************************
- *                         Configuration Manager Functions                    *
- ******************************************************************************/
+typedef VOID
+(DDKAPI *PFREE_ADAPTER_CHANNEL)(
+  IN PDMA_ADAPTER  DmaAdapter);
 
-#if (NTDDI_VERSION >= NTDDI_WINXP)
-NTKERNELAPI
-NTSTATUS
-NTAPI
-CmRegisterCallback(
-  IN PEX_CALLBACK_FUNCTION  Function,
-  IN PVOID  Context  OPTIONAL,
-  OUT PLARGE_INTEGER  Cookie);
+typedef VOID
+(DDKAPI *PFREE_MAP_REGISTERS)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  PVOID  MapRegisterBase,
+  ULONG  NumberOfMapRegisters);
 
-NTKERNELAPI
-NTSTATUS
-NTAPI
-CmUnRegisterCallback(
-  IN LARGE_INTEGER  Cookie);
-#endif
+typedef PHYSICAL_ADDRESS
+(DDKAPI *PMAP_TRANSFER)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN PMDL  Mdl,
+  IN PVOID  MapRegisterBase,
+  IN PVOID  CurrentVa,
+  IN OUT PULONG  Length,
+  IN BOOLEAN  WriteToDevice);
 
+typedef ULONG
+(DDKAPI *PGET_DMA_ALIGNMENT)(
+  IN PDMA_ADAPTER  DmaAdapter);
 
-/******************************************************************************
- *                                 RTL Types                                  *
- ******************************************************************************/
+typedef ULONG
+(DDKAPI *PREAD_DMA_COUNTER)(
+  IN PDMA_ADAPTER  DmaAdapter);
 
-#define RTL_REGISTRY_ABSOLUTE             0
-#define RTL_REGISTRY_SERVICES             1
-#define RTL_REGISTRY_CONTROL              2
-#define RTL_REGISTRY_WINDOWS_NT           3
-#define RTL_REGISTRY_DEVICEMAP            4
-#define RTL_REGISTRY_USER                 5
-#define RTL_REGISTRY_MAXIMUM              6
-#define RTL_REGISTRY_HANDLE               0x40000000
-#define RTL_REGISTRY_OPTIONAL             0x80000000
+typedef VOID
+(DDKAPI *PDRIVER_LIST_CONTROL)(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN struct _IRP  *Irp,
+  IN struct _SCATTER_GATHER_LIST  *ScatterGather,
+  IN PVOID  Context);
 
-/* RTL_QUERY_REGISTRY_TABLE.Flags */
-#define RTL_QUERY_REGISTRY_SUBKEY         0x00000001
-#define RTL_QUERY_REGISTRY_TOPKEY         0x00000002
-#define RTL_QUERY_REGISTRY_REQUIRED       0x00000004
-#define RTL_QUERY_REGISTRY_NOVALUE        0x00000008
-#define RTL_QUERY_REGISTRY_NOEXPAND       0x00000010
-#define RTL_QUERY_REGISTRY_DIRECT         0x00000020
-#define RTL_QUERY_REGISTRY_DELETE         0x00000040
+typedef NTSTATUS
+(DDKAPI *PGET_SCATTER_GATHER_LIST)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN PMDL  Mdl,
+  IN PVOID  CurrentVa,
+  IN ULONG  Length,
+  IN PDRIVER_LIST_CONTROL  ExecutionRoutine,
+  IN PVOID  Context,
+  IN BOOLEAN  WriteToDevice);
 
-#define HASH_STRING_ALGORITHM_DEFAULT     0
-#define HASH_STRING_ALGORITHM_X65599      1
-#define HASH_STRING_ALGORITHM_INVALID     0xffffffff
+typedef VOID
+(DDKAPI *PPUT_SCATTER_GATHER_LIST)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN PSCATTER_GATHER_LIST  ScatterGather,
+  IN BOOLEAN  WriteToDevice);
 
-typedef struct _RTL_BITMAP {
-    ULONG SizeOfBitMap;
-    PULONG Buffer;
-} RTL_BITMAP, *PRTL_BITMAP;
+typedef NTSTATUS
+(DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN PMDL  Mdl  OPTIONAL,
+  IN PVOID  CurrentVa,
+  IN ULONG  Length,
+  OUT PULONG  ScatterGatherListSize,
+  OUT PULONG  pNumberOfMapRegisters  OPTIONAL);
 
-typedef struct _RTL_BITMAP_RUN {
-    ULONG StartingIndex;
-    ULONG NumberOfBits;
-} RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
+typedef NTSTATUS
+(DDKAPI *PBUILD_SCATTER_GATHER_LIST)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN PDEVICE_OBJECT  DeviceObject,
+  IN PMDL  Mdl,
+  IN PVOID  CurrentVa,
+  IN ULONG  Length,
+  IN PDRIVER_LIST_CONTROL  ExecutionRoutine,
+  IN PVOID  Context,
+  IN BOOLEAN  WriteToDevice,
+  IN PVOID  ScatterGatherBuffer,
+  IN ULONG  ScatterGatherLength);
 
 typedef NTSTATUS
-(DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)(
-    IN PWSTR ValueName,
-    IN ULONG ValueType,
-    IN PVOID ValueData,
-    IN ULONG ValueLength,
-    IN PVOID Context,
-    IN PVOID EntryContext);
+(DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
+  IN PDMA_ADAPTER  DmaAdapter,
+  IN PSCATTER_GATHER_LIST  ScatterGather,
+  IN PMDL  OriginalMdl,
+  OUT PMDL  *TargetMdl);
 
-typedef struct _RTL_QUERY_REGISTRY_TABLE {
-    PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
-    ULONG Flags;
-    PCWSTR Name;
-    PVOID EntryContext;
-    ULONG DefaultType;
-    PVOID DefaultData;
-    ULONG DefaultLength;
-} RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
+typedef struct _DMA_OPERATIONS {
+  ULONG  Size;
+  PPUT_DMA_ADAPTER  PutDmaAdapter;
+  PALLOCATE_COMMON_BUFFER  AllocateCommonBuffer;
+  PFREE_COMMON_BUFFER  FreeCommonBuffer;
+  PALLOCATE_ADAPTER_CHANNEL  AllocateAdapterChannel;
+  PFLUSH_ADAPTER_BUFFERS  FlushAdapterBuffers;
+  PFREE_ADAPTER_CHANNEL  FreeAdapterChannel;
+  PFREE_MAP_REGISTERS  FreeMapRegisters;
+  PMAP_TRANSFER  MapTransfer;
+  PGET_DMA_ALIGNMENT  GetDmaAlignment;
+  PREAD_DMA_COUNTER  ReadDmaCounter;
+  PGET_SCATTER_GATHER_LIST  GetScatterGatherList;
+  PPUT_SCATTER_GATHER_LIST  PutScatterGatherList;
+  PCALCULATE_SCATTER_GATHER_LIST_SIZE  CalculateScatterGatherList;
+  PBUILD_SCATTER_GATHER_LIST  BuildScatterGatherList;
+  PBUILD_MDL_FROM_SCATTER_GATHER_LIST  BuildMdlFromScatterGatherList;
+} DMA_OPERATIONS, *PDMA_OPERATIONS;
 
-typedef struct _TIME_FIELDS {
-    CSHORT Year;
-    CSHORT Month;
-    CSHORT Day;
-    CSHORT Hour;
-    CSHORT Minute;
-    CSHORT Second;
-    CSHORT Milliseconds;
-    CSHORT Weekday;
-} TIME_FIELDS, *PTIME_FIELDS;
-
-/* Slist Header */
-#ifndef _SLIST_HEADER_
-#define _SLIST_HEADER_
-
-#if defined(_WIN64)
-typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
-typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
-       PSLIST_ENTRY Next;
-} SLIST_ENTRY;
-typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
+typedef struct _IO_RESOURCE_DESCRIPTOR {
+  UCHAR  Option;
+  UCHAR  Type;
+  UCHAR  ShareDisposition;
+  UCHAR  Spare1;
+  USHORT  Flags;
+  USHORT  Spare2;
+  union {
     struct {
-        ULONGLONG Alignment;
-        ULONGLONG Region;
-    } DUMMYSTRUCTNAME;
+      ULONG  Length;
+      ULONG  Alignment;
+      PHYSICAL_ADDRESS  MinimumAddress;
+      PHYSICAL_ADDRESS  MaximumAddress;
+    } Port;
     struct {
-        ULONGLONG Depth:16;
-        ULONGLONG Sequence:9;
-        ULONGLONG NextEntry:39;
-        ULONGLONG HeaderType:1;
-        ULONGLONG Init:1;
-        ULONGLONG Reserved:59;
-        ULONGLONG Region:3;
-    } Header8;
+      ULONG  Length;
+      ULONG  Alignment;
+      PHYSICAL_ADDRESS  MinimumAddress;
+      PHYSICAL_ADDRESS  MaximumAddress;
+    } Memory;
     struct {
-        ULONGLONG Depth:16;
-        ULONGLONG Sequence:48;
-        ULONGLONG HeaderType:1;
-        ULONGLONG Init:1;
-        ULONGLONG Reserved:2;
-        ULONGLONG NextEntry:60;
-    } Header16;
-} SLIST_HEADER, *PSLIST_HEADER;
-#else
-#define SLIST_ENTRY SINGLE_LIST_ENTRY
-#define _SLIST_ENTRY _SINGLE_LIST_ENTRY
-#define PSLIST_ENTRY PSINGLE_LIST_ENTRY
-typedef union _SLIST_HEADER {
-    ULONGLONG Alignment;
+      ULONG  MinimumVector;
+      ULONG  MaximumVector;
+    } Interrupt;
     struct {
-        SLIST_ENTRY Next;
-        USHORT Depth;
-        USHORT Sequence;
-    } DUMMYSTRUCTNAME;
-} SLIST_HEADER, *PSLIST_HEADER;
-#endif
-
-#endif /* _SLIST_HEADER_ */
+      ULONG  MinimumChannel;
+      ULONG  MaximumChannel;
+    } Dma;
+    struct {
+      ULONG  Length;
+      ULONG  Alignment;
+      PHYSICAL_ADDRESS  MinimumAddress;
+      PHYSICAL_ADDRESS  MaximumAddress;
+    } Generic;
+    struct {
+      ULONG  Data[3];
+    } DevicePrivate;
+    struct {
+      ULONG  Length;
+      ULONG  MinBusNumber;
+      ULONG  MaxBusNumber;
+      ULONG  Reserved;
+    } BusNumber;
+    struct {
+      ULONG  Priority;
+      ULONG  Reserved1;
+      ULONG  Reserved2;
+    } ConfigData;
+  } u;
+} IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
 
+typedef struct _IO_RESOURCE_LIST {
+  USHORT  Version;
+  USHORT  Revision;
+  ULONG  Count;
+  IO_RESOURCE_DESCRIPTOR  Descriptors[1];
+} IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
 
-/******************************************************************************
- *                               RTL Functions                                *
- ******************************************************************************/
+typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
+  ULONG  ListSize;
+  INTERFACE_TYPE  InterfaceType;
+  ULONG  BusNumber;
+  ULONG  SlotNumber;
+  ULONG  Reserved[3];
+  ULONG  AlternativeLists;
+  IO_RESOURCE_LIST  List[1];
+} IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
 
-FORCEINLINE
-VOID
-InitializeListHead(
-  OUT PLIST_ENTRY ListHead)
-{
-  ListHead->Flink = ListHead->Blink = ListHead;
-}
+typedef VOID
+(DDKAPI DRIVER_CANCEL)(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN struct _IRP  *Irp);
+typedef DRIVER_CANCEL *PDRIVER_CANCEL;
 
-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;
-}
+typedef struct _IRP {
+  CSHORT  Type;
+  USHORT  Size;
+  struct _MDL  *MdlAddress;
+  ULONG  Flags;
+  union {
+    struct _IRP  *MasterIrp;
+    volatile LONG  IrpCount;
+    PVOID  SystemBuffer;
+  } AssociatedIrp;
+  LIST_ENTRY  ThreadListEntry;
+  IO_STATUS_BLOCK  IoStatus;
+  KPROCESSOR_MODE  RequestorMode;
+  BOOLEAN  PendingReturned;
+  CHAR  StackCount;
+  CHAR  CurrentLocation;
+  BOOLEAN  Cancel;
+  KIRQL  CancelIrql;
+  CCHAR  ApcEnvironment;
+  UCHAR  AllocationFlags;
+  PIO_STATUS_BLOCK  UserIosb;
+  PKEVENT  UserEvent;
+  union {
+    struct {
+      _ANONYMOUS_UNION union {      
+        PIO_APC_ROUTINE  UserApcRoutine;
+        PVOID IssuingProcess;
+      } DUMMYUNIONNAME;
+      PVOID  UserApcContext;
+    } AsynchronousParameters;
+    LARGE_INTEGER  AllocationSize;
+  } Overlay;
+  volatile PDRIVER_CANCEL  CancelRoutine;
+  PVOID  UserBuffer;
+  union {
+    struct {
+      _ANONYMOUS_UNION union {
+        KDEVICE_QUEUE_ENTRY  DeviceQueueEntry;
+        _ANONYMOUS_STRUCT struct {
+          PVOID  DriverContext[4];
+        } DUMMYSTRUCTNAME;
+      } DUMMYUNIONNAME;
+      PETHREAD  Thread;
+      PCHAR  AuxiliaryBuffer;
+      _ANONYMOUS_STRUCT struct {
+        LIST_ENTRY  ListEntry;
+        _ANONYMOUS_UNION union {
+          struct _IO_STACK_LOCATION  *CurrentStackLocation;
+          ULONG  PacketType;
+        } DUMMYUNIONNAME;
+      } DUMMYSTRUCTNAME;
+      struct _FILE_OBJECT  *OriginalFileObject;
+    } Overlay;
+    KAPC  Apc;
+    PVOID  CompletionKey;
+  } Tail;
+} IRP;
+typedef struct _IRP *PIRP;
 
-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;
-}
+typedef enum _IO_PAGING_PRIORITY {
+  IoPagingPriorityInvalid,
+  IoPagingPriorityNormal,
+  IoPagingPriorityHigh,
+  IoPagingPriorityReserved1,
+  IoPagingPriorityReserved2
+} IO_PAGING_PRIORITY;
 
-BOOLEAN
-FORCEINLINE
-IsListEmpty(
-  IN CONST LIST_ENTRY * ListHead)
-{
-  return (BOOLEAN)(ListHead->Flink == ListHead);
-}
+typedef NTSTATUS
+(DDKAPI IO_COMPLETION_ROUTINE)(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN struct _IRP  *Irp,
+  IN PVOID  Context);
+typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE;
 
-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;
-}
+typedef VOID
+(DDKAPI *PIO_DPC_ROUTINE)(
+  IN struct _KDPC  *Dpc,
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN struct _IRP  *Irp,
+  IN PVOID  Context);
 
-FORCEINLINE
-VOID
-PushEntryList(
-  IN OUT PSINGLE_LIST_ENTRY ListHead,
-  IN OUT PSINGLE_LIST_ENTRY Entry)
-{
-  Entry->Next = ListHead->Next;
-  ListHead->Next = Entry;
-}
+typedef NTSTATUS
+(DDKAPI *PMM_DLL_INITIALIZE)(
+  IN PUNICODE_STRING  RegistryPath);
 
-FORCEINLINE
-BOOLEAN
-RemoveEntryList(
-  IN PLIST_ENTRY  Entry)
-{
-  PLIST_ENTRY OldFlink;
-  PLIST_ENTRY OldBlink;
-
-  OldFlink = Entry->Flink;
-  OldBlink = Entry->Blink;
-  OldFlink->Blink = OldBlink;
-  OldBlink->Flink = OldFlink;
-  return (BOOLEAN)(OldFlink == OldBlink);
-}
-
-FORCEINLINE
-PLIST_ENTRY
-RemoveHeadList(
-  IN OUT PLIST_ENTRY  ListHead)
-{
-  PLIST_ENTRY Flink;
-  PLIST_ENTRY Entry;
-
-  Entry = ListHead->Flink;
-  Flink = Entry->Flink;
-  ListHead->Flink = Flink;
-  Flink->Blink = ListHead;
-  return Entry;
-}
-
-FORCEINLINE
-PLIST_ENTRY
-RemoveTailList(
-  IN OUT PLIST_ENTRY  ListHead)
-{
-  PLIST_ENTRY Blink;
-  PLIST_ENTRY Entry;
-
-  Entry = ListHead->Blink;
-  Blink = Entry->Blink;
-  ListHead->Blink = Blink;
-  Blink->Flink = ListHead;
-  return Entry;
-}
-
-NTSYSAPI
-VOID
-NTAPI
-RtlAssert(
-    IN PVOID FailedAssertion,
-    IN PVOID FileName,
-    IN ULONG LineNumber,
-    IN PSTR Message);
-
-/* VOID
- * RtlCopyMemory(
- *     IN VOID UNALIGNED *Destination,
- *     IN CONST VOID UNALIGNED *Source,
- *     IN SIZE_T Length)
- */
-#define RtlCopyMemory(Destination, Source, Length) \
-    memcpy(Destination, Source, Length)
-
-#define RtlCopyBytes RtlCopyMemory
-
-#if defined(_M_AMD64)
-NTSYSAPI
-VOID
-NTAPI
-RtlCopyMemoryNonTemporal(
-    VOID UNALIGNED *Destination,
-    CONST VOID UNALIGNED *Source,
-    SIZE_T Length);
-#else
-#define RtlCopyMemoryNonTemporal RtlCopyMemory
-#endif
-
-/* BOOLEAN
- * RtlEqualLuid(
- *     IN PLUID Luid1,
- *     IN PLUID Luid2)
- */
-#define RtlEqualLuid(Luid1, Luid2) \
-    (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->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))
-
-/* VOID
- * RtlFillMemory(
- *     IN VOID UNALIGNED *Destination,
- *     IN SIZE_T Length,
- *     IN UCHAR Fill)
- */
-#define RtlFillMemory(Destination, Length, Fill) \
-    memset(Destination, Fill, Length)
+typedef NTSTATUS
+(DDKAPI *PMM_DLL_UNLOAD)(
+  VOID);
 
-#define RtlFillBytes RtlFillMemory
+typedef BOOLEAN
+(DDKAPI KSERVICE_ROUTINE)(
+  IN struct _KINTERRUPT  *Interrupt,
+  IN PVOID  ServiceContext);
+typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
 
-NTSYSAPI
-VOID
-NTAPI
-RtlFreeUnicodeString(
-    IN OUT PUNICODE_STRING UnicodeString);
+typedef VOID
+(DDKAPI *PIO_TIMER_ROUTINE)(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN PVOID  Context);
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlGUIDFromString(
-    IN PUNICODE_STRING GuidString,
-    OUT GUID *Guid);
+typedef struct _IO_SECURITY_CONTEXT {
+  PSECURITY_QUALITY_OF_SERVICE  SecurityQos;
+  PACCESS_STATE  AccessState;
+  ACCESS_MASK  DesiredAccess;
+  ULONG  FullCreateOptions;
+} IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
 
-NTSYSAPI
-VOID
-NTAPI
-RtlInitUnicodeString(
-    IN OUT PUNICODE_STRING DestinationString,
-    IN PCWSTR SourceString OPTIONAL);
+struct _IO_CSQ;
 
-/* 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 struct _IO_CSQ_IRP_CONTEXT {
+  ULONG  Type;
+  struct _IRP  *Irp;
+  struct _IO_CSQ  *Csq;
+} IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlStringFromGUID(
-    IN REFGUID Guid,
-    OUT PUNICODE_STRING GuidString);
+typedef VOID
+(DDKAPI *PIO_CSQ_INSERT_IRP)(
+  IN struct _IO_CSQ  *Csq,
+  IN PIRP  Irp);
 
-/* VOID
- * RtlZeroMemory(
- *     IN VOID UNALIGNED *Destination,
- *     IN SIZE_T Length)
- */
-#define RtlZeroMemory(Destination, Length) \
-    memset(Destination, 0, Length)
+typedef VOID
+(DDKAPI *PIO_CSQ_REMOVE_IRP)(
+  IN struct _IO_CSQ  *Csq,
+  IN PIRP  Irp);
 
-#define RtlZeroBytes RtlZeroMemory
+typedef PIRP
+(DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)(
+  IN struct _IO_CSQ  *Csq,
+  IN PIRP  Irp,
+  IN PVOID  PeekContext);
 
+typedef VOID
+(DDKAPI *PIO_CSQ_ACQUIRE_LOCK)(
+  IN  struct _IO_CSQ  *Csq,
+  OUT PKIRQL  Irql);
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlAreBitsClear(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG StartingIndex,
-    IN ULONG Length);
+typedef VOID
+(DDKAPI *PIO_CSQ_RELEASE_LOCK)(
+  IN struct _IO_CSQ  *Csq,
+  IN KIRQL  Irql);
 
-NTSYSAPI
-BOOLEAN
-NTAPI
-RtlAreBitsSet(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG StartingIndex,
-    IN ULONG Length);
+typedef VOID
+(DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
+  IN  struct _IO_CSQ  *Csq,
+  IN  PIRP  Irp);
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAnsiStringToUnicodeString(
-    IN OUT PUNICODE_STRING DestinationString,
-    IN PANSI_STRING SourceString,
-    IN BOOLEAN AllocateDestinationString);
+typedef struct _IO_CSQ {
+  ULONG  Type;
+  PIO_CSQ_INSERT_IRP  CsqInsertIrp;
+  PIO_CSQ_REMOVE_IRP  CsqRemoveIrp;
+  PIO_CSQ_PEEK_NEXT_IRP  CsqPeekNextIrp;
+  PIO_CSQ_ACQUIRE_LOCK  CsqAcquireLock;
+  PIO_CSQ_RELEASE_LOCK  CsqReleaseLock;
+  PIO_CSQ_COMPLETE_CANCELED_IRP  CsqCompleteCanceledIrp;
+  PVOID  ReservePointer;
+} IO_CSQ, *PIO_CSQ;
 
-NTSYSAPI
-ULONG
-NTAPI
-RtlxAnsiStringToUnicodeSize(
-    IN PCANSI_STRING AnsiString);
+typedef enum _BUS_QUERY_ID_TYPE {
+  BusQueryDeviceID,
+  BusQueryHardwareIDs,
+  BusQueryCompatibleIDs,
+  BusQueryInstanceID,
+  BusQueryDeviceSerialNumber
+} BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
 
-#define RtlAnsiStringToUnicodeSize(String) (               \
-  NLS_MB_CODE_PAGE_TAG ?                                   \
-  RtlxAnsiStringToUnicodeSize(String) :                    \
-  ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR)   \
-)
+typedef enum _DEVICE_TEXT_TYPE {
+  DeviceTextDescription,
+  DeviceTextLocationInformation
+} DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
 
-NTSYSAPI
-NTSTATUS
-NTAPI
-RtlAppendUnicodeStringToString(
-    IN OUT PUNICODE_STRING Destination,
-    IN PCUNICODE_STRING Source);
+typedef enum _WORK_QUEUE_TYPE {
+  CriticalWorkQueue,
+  DelayedWorkQueue,
+  HyperCriticalWorkQueue,
+  MaximumWorkQueue
+} WORK_QUEUE_TYPE;
+
+#if !defined(_AMD64_) && !defined(_IA64_)
+#include <pshpack4.h>
+#endif
+typedef struct _IO_STACK_LOCATION {
+  UCHAR  MajorFunction;
+  UCHAR  MinorFunction;
+  UCHAR  Flags;
+  UCHAR  Control;
+  union {
+    struct {
+      PIO_SECURITY_CONTEXT  SecurityContext;
+      ULONG  Options;
+      USHORT POINTER_ALIGNMENT  FileAttributes;
+      USHORT  ShareAccess;
+      ULONG POINTER_ALIGNMENT  EaLength;
+    } Create;
+    struct {
+      ULONG  Length;
+      ULONG POINTER_ALIGNMENT  Key;
+      LARGE_INTEGER  ByteOffset;
+    } Read;
+    struct {
+      ULONG  Length;
+      ULONG POINTER_ALIGNMENT  Key;
+      LARGE_INTEGER  ByteOffset;
+    } Write;
+    struct {
+      ULONG  Length;
+      PUNICODE_STRING  FileName;
+      FILE_INFORMATION_CLASS  FileInformationClass;
+      ULONG  FileIndex;
+    } QueryDirectory;
+    struct {
+      ULONG  Length;
+      ULONG  CompletionFilter;
+    } NotifyDirectory;
+    struct {
+      ULONG  Length;
+      FILE_INFORMATION_CLASS POINTER_ALIGNMENT  FileInformationClass;
+    } QueryFile;
+    struct {
+      ULONG  Length;
+      FILE_INFORMATION_CLASS POINTER_ALIGNMENT  FileInformationClass;
+      PFILE_OBJECT  FileObject;
+      _ANONYMOUS_UNION union {
+        _ANONYMOUS_STRUCT struct {
+          BOOLEAN  ReplaceIfExists;
+          BOOLEAN  AdvanceOnly;
+        } DUMMYSTRUCTNAME;
+        ULONG  ClusterCount;
+        HANDLE  DeleteHandle;
+      } DUMMYUNIONNAME;
+    } SetFile;
+    struct {
+      ULONG  Length;
+      PVOID  EaList;
+      ULONG  EaListLength;
+      ULONG  EaIndex;
+    } QueryEa;
+    struct {
+      ULONG  Length;
+    } SetEa;
+    struct {
+      ULONG  Length;
+      FS_INFORMATION_CLASS POINTER_ALIGNMENT  FsInformationClass;
+    } QueryVolume;
+    struct {
+      ULONG  Length;
+      FS_INFORMATION_CLASS  FsInformationClass;
+    } SetVolume;
+    struct {
+      ULONG  OutputBufferLength;
+      ULONG  InputBufferLength;
+      ULONG  FsControlCode;
+      PVOID  Type3InputBuffer;
+    } FileSystemControl;
+    struct {
+      PLARGE_INTEGER  Length;
+      ULONG  Key;
+      LARGE_INTEGER  ByteOffset;
+    } LockControl;
+    struct {
+      ULONG  OutputBufferLength;
+      ULONG POINTER_ALIGNMENT  InputBufferLength;
+      ULONG POINTER_ALIGNMENT  IoControlCode;
+      PVOID  Type3InputBuffer;
+    } DeviceIoControl;
+    struct {
+      SECURITY_INFORMATION  SecurityInformation;
+      ULONG POINTER_ALIGNMENT  Length;
+    } QuerySecurity;
+    struct {
+      SECURITY_INFORMATION  SecurityInformation;
+      PSECURITY_DESCRIPTOR  SecurityDescriptor;
+    } SetSecurity;
+    struct {
+      PVPB  Vpb;
+      PDEVICE_OBJECT  DeviceObject;
+    } MountVolume;
+    struct {
+      PVPB  Vpb;
+      PDEVICE_OBJECT  DeviceObject;
+    } VerifyVolume;
+    struct {
+      struct _SCSI_REQUEST_BLOCK  *Srb;
+    } Scsi;
+    struct {
+      ULONG  Length;
+      PSID  StartSid;
+      struct _FILE_GET_QUOTA_INFORMATION  *SidList;
+      ULONG  SidListLength;
+    } QueryQuota;
+    struct {
+      ULONG  Length;
+    } SetQuota;
+    struct {
+      DEVICE_RELATION_TYPE  Type;
+    } QueryDeviceRelations;
+    struct {
+      CONST GUID  *InterfaceType;
+      USHORT  Size;
+      USHORT  Version;
+      PINTERFACE  Interface;
+      PVOID  InterfaceSpecificData;
+    } QueryInterface;
+    struct {
+      PDEVICE_CAPABILITIES  Capabilities;
+    } DeviceCapabilities;
+    struct {
+      PIO_RESOURCE_REQUIREMENTS_LIST  IoResourceRequirementList;
+    } FilterResourceRequirements;
+    struct {
+      ULONG  WhichSpace;
+      PVOID  Buffer;
+      ULONG  Offset;
+      ULONG POINTER_ALIGNMENT  Length;
+    } ReadWriteConfig;
+    struct {
+      BOOLEAN  Lock;
+    } SetLock;
+    struct {
+      BUS_QUERY_ID_TYPE  IdType;
+    } QueryId;
+    struct {
+      DEVICE_TEXT_TYPE  DeviceTextType;
+      LCID POINTER_ALIGNMENT  LocaleId;
+    } QueryDeviceText;
+    struct {
+      BOOLEAN  InPath;
+      BOOLEAN  Reserved[3];
+      DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT  Type;
+    } UsageNotification;
+    struct {
+      SYSTEM_POWER_STATE  PowerState;
+    } WaitWake;
+    struct {
+      PPOWER_SEQUENCE  PowerSequence;
+    } PowerSequence;
+    struct {
+      ULONG  SystemContext;
+      POWER_STATE_TYPE POINTER_ALIGNMENT  Type;
+      POWER_STATE POINTER_ALIGNMENT  State;
+      POWER_ACTION POINTER_ALIGNMENT  ShutdownType;
+    } Power;
+    struct {
+      PCM_RESOURCE_LIST  AllocatedResources;
+      PCM_RESOURCE_LIST  AllocatedResourcesTranslated;
+    } StartDevice;
+    struct {
+      ULONG_PTR  ProviderId;
+      PVOID  DataPath;
+      ULONG  BufferSize;
+      PVOID  Buffer;
+    } WMI;
+    struct {
+      PVOID  Argument1;
+      PVOID  Argument2;
+      PVOID  Argument3;
+      PVOID  Argument4;
+    } Others;
+  } Parameters;
+  PDEVICE_OBJECT  DeviceObject;
+  PFILE_OBJECT  FileObject;
+  PIO_COMPLETION_ROUTINE  CompletionRoutine;
+  PVOID  Context;
+} IO_STACK_LOCATION, *PIO_STACK_LOCATION;
+#if !defined(_AMD64_) && !defined(_IA64_)
+#include <poppack.h>
+#endif
+
+/* IO_STACK_LOCATION.Control */
+
+#define SL_PENDING_RETURNED               0x01
+#define SL_ERROR_RETURNED                 0x02
+#define SL_INVOKE_ON_CANCEL               0x20
+#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
+#define METHOD_NEITHER                    3
+
+
+#define FILE_SUPERSEDED                   0x00000000
+#define FILE_OPENED                       0x00000001
+#define FILE_CREATED                      0x00000002
+#define FILE_OVERWRITTEN                  0x00000003
+#define FILE_EXISTS                       0x00000004
+#define FILE_DOES_NOT_EXIST               0x00000005
+
+#define FILE_USE_FILE_POINTER_POSITION    0xfffffffe
+#define FILE_WRITE_TO_END_OF_FILE         0xffffffff
+
+/* also in winnt.h */
+#define FILE_LIST_DIRECTORY               0x00000001
+#define FILE_READ_DATA                    0x00000001
+#define FILE_ADD_FILE                     0x00000002
+#define FILE_WRITE_DATA                   0x00000002
+#define FILE_ADD_SUBDIRECTORY             0x00000004
+#define FILE_APPEND_DATA                  0x00000004
+#define FILE_CREATE_PIPE_INSTANCE         0x00000004
+#define FILE_READ_EA                      0x00000008
+#define FILE_WRITE_EA                     0x00000010
+#define FILE_EXECUTE                      0x00000020
+#define FILE_TRAVERSE                     0x00000020
+#define FILE_DELETE_CHILD                 0x00000040
+#define FILE_READ_ATTRIBUTES              0x00000080
+#define FILE_WRITE_ATTRIBUTES             0x00000100
+
+#define FILE_SHARE_READ                   0x00000001
+#define FILE_SHARE_WRITE                  0x00000002
+#define FILE_SHARE_DELETE                 0x00000004
+#define FILE_SHARE_VALID_FLAGS            0x00000007
+
+#define FILE_ATTRIBUTE_READONLY           0x00000001
+#define FILE_ATTRIBUTE_HIDDEN             0x00000002
+#define FILE_ATTRIBUTE_SYSTEM             0x00000004
+#define FILE_ATTRIBUTE_DIRECTORY          0x00000010
+#define FILE_ATTRIBUTE_ARCHIVE            0x00000020
+#define FILE_ATTRIBUTE_DEVICE             0x00000040
+#define FILE_ATTRIBUTE_NORMAL             0x00000080
+#define FILE_ATTRIBUTE_TEMPORARY          0x00000100
+#define FILE_ATTRIBUTE_SPARSE_FILE        0x00000200
+#define FILE_ATTRIBUTE_REPARSE_POINT      0x00000400
+#define FILE_ATTRIBUTE_COMPRESSED         0x00000800
+#define FILE_ATTRIBUTE_OFFLINE            0x00001000
+#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
+#define FILE_ATTRIBUTE_ENCRYPTED          0x00004000
+
+#define FILE_ATTRIBUTE_VALID_FLAGS        0x00007fb7
+#define FILE_ATTRIBUTE_VALID_SET_FLAGS    0x000031a7
+
+#define FILE_VALID_OPTION_FLAGS           0x00ffffff
+#define FILE_VALID_PIPE_OPTION_FLAGS      0x00000032
+#define FILE_VALID_MAILSLOT_OPTION_FLAGS  0x00000032
+#define FILE_VALID_SET_FLAGS              0x00000036
+
+#define FILE_SUPERSEDE                    0x00000000
+#define FILE_OPEN                         0x00000001
+#define FILE_CREATE                       0x00000002
+#define FILE_OPEN_IF                      0x00000003
+#define FILE_OVERWRITE                    0x00000004
+#define FILE_OVERWRITE_IF                 0x00000005
+#define FILE_MAXIMUM_DISPOSITION          0x00000005
+
+#define FILE_DIRECTORY_FILE               0x00000001
+#define FILE_WRITE_THROUGH                0x00000002
+#define FILE_SEQUENTIAL_ONLY              0x00000004
+#define FILE_NO_INTERMEDIATE_BUFFERING    0x00000008
+#define FILE_SYNCHRONOUS_IO_ALERT         0x00000010
+#define FILE_SYNCHRONOUS_IO_NONALERT      0x00000020
+#define FILE_NON_DIRECTORY_FILE           0x00000040
+#define FILE_CREATE_TREE_CONNECTION       0x00000080
+#define FILE_COMPLETE_IF_OPLOCKED         0x00000100
+#define FILE_NO_EA_KNOWLEDGE              0x00000200
+#define FILE_OPEN_REMOTE_INSTANCE         0x00000400
+#define FILE_RANDOM_ACCESS                0x00000800
+#define FILE_DELETE_ON_CLOSE              0x00001000
+#define FILE_OPEN_BY_FILE_ID              0x00002000
+#define FILE_OPEN_FOR_BACKUP_INTENT       0x00004000
+#define FILE_NO_COMPRESSION               0x00008000
+#define FILE_RESERVE_OPFILTER             0x00100000
+#define FILE_OPEN_REPARSE_POINT           0x00200000
+#define FILE_OPEN_NO_RECALL               0x00400000
+#define FILE_OPEN_FOR_FREE_SPACE_QUERY    0x00800000
+
+#define FILE_ANY_ACCESS                   0x00000000
+#define FILE_SPECIAL_ACCESS               FILE_ANY_ACCESS
+#define FILE_READ_ACCESS                  0x00000001
+#define FILE_WRITE_ACCESS                 0x00000002
+
+#define FILE_ALL_ACCESS \
+  (STANDARD_RIGHTS_REQUIRED | \
+   SYNCHRONIZE | \
+   0x1FF)
+
+#define FILE_GENERIC_EXECUTE \
+  (STANDARD_RIGHTS_EXECUTE | \
+   FILE_READ_ATTRIBUTES | \
+   FILE_EXECUTE | \
+   SYNCHRONIZE)
+
+#define FILE_GENERIC_READ \
+  (STANDARD_RIGHTS_READ | \
+   FILE_READ_DATA | \
+   FILE_READ_ATTRIBUTES | \
+   FILE_READ_EA | \
+   SYNCHRONIZE)
+
+#define FILE_GENERIC_WRITE \
+  (STANDARD_RIGHTS_WRITE | \
+   FILE_WRITE_DATA | \
+   FILE_WRITE_ATTRIBUTES | \
+   FILE_WRITE_EA | \
+   FILE_APPEND_DATA | \
+   SYNCHRONIZE)
+
+/* 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 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;
+
+
+/******************************************************************************
+ *                           Process Manager Types                            *
+ ******************************************************************************/
+
+#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
+
+/* 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;
+
+/* 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
+
+#define PROCESS_DUP_HANDLE                 (0x0040)
+
+#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 (NTDDI_VERSION >= NTDDI_VISTA)
+#define THREAD_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
+#else
+#define THREAD_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF)
+#endif
+
+#define ES_SYSTEM_REQUIRED                0x00000001
+#define ES_DISPLAY_REQUIRED               0x00000002
+#define ES_USER_PRESENT                   0x00000004
+#define ES_CONTINUOUS                     0x80000000
+
+#define LOW_PRIORITY                      0
+#define LOW_REALTIME_PRIORITY             16
+#define HIGH_PRIORITY                     31
+#define MAXIMUM_PRIORITY                  32
+
+/******************************************************************************
+ *                         Runtime Library Functions                          *
+ ******************************************************************************/
+
+FORCEINLINE
+VOID
+InitializeListHead(
+  OUT PLIST_ENTRY ListHead)
+{
+  ListHead->Flink = ListHead->Blink = ListHead;
+}
+
+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;
+}
+
+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;
+}
+
+BOOLEAN
+FORCEINLINE
+IsListEmpty(
+  IN CONST LIST_ENTRY * ListHead)
+{
+  return (BOOLEAN)(ListHead->Flink == ListHead);
+}
+
+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;
+}
+
+FORCEINLINE
+VOID
+PushEntryList(
+  IN OUT PSINGLE_LIST_ENTRY ListHead,
+  IN OUT PSINGLE_LIST_ENTRY Entry)
+{
+  Entry->Next = ListHead->Next;
+  ListHead->Next = Entry;
+}
+
+FORCEINLINE
+BOOLEAN
+RemoveEntryList(
+  IN PLIST_ENTRY  Entry)
+{
+  PLIST_ENTRY OldFlink;
+  PLIST_ENTRY OldBlink;
+
+  OldFlink = Entry->Flink;
+  OldBlink = Entry->Blink;
+  OldFlink->Blink = OldBlink;
+  OldBlink->Flink = OldFlink;
+  return (BOOLEAN)(OldFlink == OldBlink);
+}
+
+FORCEINLINE
+PLIST_ENTRY
+RemoveHeadList(
+  IN OUT PLIST_ENTRY  ListHead)
+{
+  PLIST_ENTRY Flink;
+  PLIST_ENTRY Entry;
+
+  Entry = ListHead->Flink;
+  Flink = Entry->Flink;
+  ListHead->Flink = Flink;
+  Flink->Blink = ListHead;
+  return Entry;
+}
+
+FORCEINLINE
+PLIST_ENTRY
+RemoveTailList(
+  IN OUT PLIST_ENTRY  ListHead)
+{
+  PLIST_ENTRY Blink;
+  PLIST_ENTRY Entry;
+
+  Entry = ListHead->Blink;
+  Blink = Entry->Blink;
+  ListHead->Blink = Blink;
+  Blink->Flink = ListHead;
+  return Entry;
+}
+
+NTSYSAPI
+VOID
+NTAPI
+RtlAssert(
+    IN PVOID FailedAssertion,
+    IN PVOID FileName,
+    IN ULONG LineNumber,
+    IN PSTR Message);
+
+/* VOID
+ * RtlCopyMemory(
+ *     IN VOID UNALIGNED *Destination,
+ *     IN CONST VOID UNALIGNED *Source,
+ *     IN SIZE_T Length)
+ */
+#define RtlCopyMemory(Destination, Source, Length) \
+    memcpy(Destination, Source, Length)
+
+#define RtlCopyBytes RtlCopyMemory
+
+#if defined(_M_AMD64)
+NTSYSAPI
+VOID
+NTAPI
+RtlCopyMemoryNonTemporal(
+    VOID UNALIGNED *Destination,
+    CONST VOID UNALIGNED *Source,
+    SIZE_T Length);
+#else
+#define RtlCopyMemoryNonTemporal RtlCopyMemory
+#endif
+
+/* BOOLEAN
+ * RtlEqualLuid(
+ *     IN PLUID Luid1,
+ *     IN PLUID Luid2)
+ */
+#define RtlEqualLuid(Luid1, Luid2) \
+    (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->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))
+
+/* VOID
+ * RtlFillMemory(
+ *     IN VOID UNALIGNED *Destination,
+ *     IN SIZE_T Length,
+ *     IN UCHAR Fill)
+ */
+#define RtlFillMemory(Destination, Length, Fill) \
+    memset(Destination, Fill, Length)
+
+#define RtlFillBytes RtlFillMemory
+
+NTSYSAPI
+VOID
+NTAPI
+RtlFreeUnicodeString(
+    IN OUT PUNICODE_STRING UnicodeString);
+
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlGUIDFromString(
+    IN PUNICODE_STRING GuidString,
+    OUT GUID *Guid);
+
+NTSYSAPI
+VOID
+NTAPI
+RtlInitUnicodeString(
+    IN OUT PUNICODE_STRING DestinationString,
+    IN PCWSTR SourceString OPTIONAL);
+
+/* VOID
+ * RtlMoveMemory(
+ *    IN VOID UNALIGNED *Destination,
+ *    IN CONST VOID UNALIGNED *Source,
+ *    IN SIZE_T Length)
+ */
+#define RtlMoveMemory(Destination, Source, Length) \
+    memmove(Destination, Source, Length)
+
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlStringFromGUID(
+    IN REFGUID Guid,
+    OUT PUNICODE_STRING GuidString);
+
+/* VOID
+ * RtlZeroMemory(
+ *     IN VOID UNALIGNED *Destination,
+ *     IN SIZE_T Length)
+ */
+#define RtlZeroMemory(Destination, Length) \
+    memset(Destination, 0, Length)
+
+#define RtlZeroBytes RtlZeroMemory
+
+
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
+NTSYSAPI
+BOOLEAN
+NTAPI
+RtlAreBitsClear(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG StartingIndex,
+    IN ULONG Length);
+
+NTSYSAPI
+BOOLEAN
+NTAPI
+RtlAreBitsSet(
+    IN PRTL_BITMAP BitMapHeader,
+    IN ULONG StartingIndex,
+    IN ULONG Length);
+
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlAnsiStringToUnicodeString(
+    IN OUT PUNICODE_STRING DestinationString,
+    IN PANSI_STRING SourceString,
+    IN BOOLEAN AllocateDestinationString);
+
+NTSYSAPI
+ULONG
+NTAPI
+RtlxAnsiStringToUnicodeSize(
+    IN PCANSI_STRING AnsiString);
+
+#define RtlAnsiStringToUnicodeSize(String) (               \
+  NLS_MB_CODE_PAGE_TAG ?                                   \
+  RtlxAnsiStringToUnicodeSize(String) :                    \
+  ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR)   \
+)
+
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlAppendUnicodeStringToString(
+    IN OUT PUNICODE_STRING Destination,
+    IN PCUNICODE_STRING Source);
 
 NTSYSAPI
 NTSTATUS
@@ -4958,7 +6092,7 @@ NTSYSAPI
 ULONGLONG
 NTAPI
 RtlCmDecodeMemIoResource(
-    IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
+    IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor,
     OUT PULONGLONG Start OPTIONAL);
 
 NTSYSAPI
@@ -5262,2365 +6396,1553 @@ RtlCheckBit(
 #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(exp)  ((VOID)0)
-#define NT_ASSERTMSGW(exp) ((VOID)0)
-
-#endif /* DBG */
-
-
-/******************************************************************************
- *                         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
-
-/* 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
-
-/* 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 PCI_CONFIGURATION_TYPE(PciData) \
-  (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
-
-#define PCI_MULTIFUNCTION_DEVICE(PciData) \
-  ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
-
-/* 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
-
-/* 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
-
-/* 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
-
-#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
-#define IO_TYPE_DRIVER                  4
-#define IO_TYPE_FILE                    5
-#define IO_TYPE_IRP                     6
-#define IO_TYPE_MASTER_ADAPTER          7
-#define IO_TYPE_OPEN_PACKET             8
-#define IO_TYPE_TIMER                   9
-#define IO_TYPE_VPB                     10
-#define IO_TYPE_ERROR_LOG               11
-#define IO_TYPE_ERROR_MESSAGE           12
-#define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
-
-#define IO_TYPE_CSQ_IRP_CONTEXT 1
-#define IO_TYPE_CSQ 2
-#define IO_TYPE_CSQ_EX 3
+#define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
 
-/* IO_RESOURCE_DESCRIPTOR.Option */
-#define IO_RESOURCE_PREFERRED             0x01
-#define IO_RESOURCE_DEFAULT               0x02
-#define IO_RESOURCE_ALTERNATIVE           0x08
+#define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
+#define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
 
-/* 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
+#define NT_ASSERT(exp)     ((VOID)0)
+#define NT_ASSERTMSG(exp)  ((VOID)0)
+#define NT_ASSERTMSGW(exp) ((VOID)0)
 
-/* 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
+#endif /* DBG */
 
-/* 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
+#if !defined(_WINBASE_)
 
-/* DEVICE_OBJECT.DeviceType */
-#define DEVICE_TYPE ULONG
+#if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
 
-#define FILE_DEVICE_BEEP                  0x00000001
-#define FILE_DEVICE_CD_ROM                0x00000002
-#define FILE_DEVICE_CD_ROM_FILE_SYSTEM    0x00000003
-#define FILE_DEVICE_CONTROLLER            0x00000004
-#define FILE_DEVICE_DATALINK              0x00000005
-#define FILE_DEVICE_DFS                   0x00000006
-#define FILE_DEVICE_DISK                  0x00000007
-#define FILE_DEVICE_DISK_FILE_SYSTEM      0x00000008
-#define FILE_DEVICE_FILE_SYSTEM           0x00000009
-#define FILE_DEVICE_INPORT_PORT           0x0000000a
-#define FILE_DEVICE_KEYBOARD              0x0000000b
-#define FILE_DEVICE_MAILSLOT              0x0000000c
-#define FILE_DEVICE_MIDI_IN               0x0000000d
-#define FILE_DEVICE_MIDI_OUT              0x0000000e
-#define FILE_DEVICE_MOUSE                 0x0000000f
-#define FILE_DEVICE_MULTI_UNC_PROVIDER    0x00000010
-#define FILE_DEVICE_NAMED_PIPE            0x00000011
-#define FILE_DEVICE_NETWORK               0x00000012
-#define FILE_DEVICE_NETWORK_BROWSER       0x00000013
-#define FILE_DEVICE_NETWORK_FILE_SYSTEM   0x00000014
-#define FILE_DEVICE_NULL                  0x00000015
-#define FILE_DEVICE_PARALLEL_PORT         0x00000016
-#define FILE_DEVICE_PHYSICAL_NETCARD      0x00000017
-#define FILE_DEVICE_PRINTER               0x00000018
-#define FILE_DEVICE_SCANNER               0x00000019
-#define FILE_DEVICE_SERIAL_MOUSE_PORT     0x0000001a
-#define FILE_DEVICE_SERIAL_PORT           0x0000001b
-#define FILE_DEVICE_SCREEN                0x0000001c
-#define FILE_DEVICE_SOUND                 0x0000001d
-#define FILE_DEVICE_STREAMS               0x0000001e
-#define FILE_DEVICE_TAPE                  0x0000001f
-#define FILE_DEVICE_TAPE_FILE_SYSTEM      0x00000020
-#define FILE_DEVICE_TRANSPORT             0x00000021
-#define FILE_DEVICE_UNKNOWN               0x00000022
-#define FILE_DEVICE_VIDEO                 0x00000023
-#define FILE_DEVICE_VIRTUAL_DISK          0x00000024
-#define FILE_DEVICE_WAVE_IN               0x00000025
-#define FILE_DEVICE_WAVE_OUT              0x00000026
-#define FILE_DEVICE_8042_PORT             0x00000027
-#define FILE_DEVICE_NETWORK_REDIRECTOR    0x00000028
-#define FILE_DEVICE_BATTERY               0x00000029
-#define FILE_DEVICE_BUS_EXTENDER          0x0000002a
-#define FILE_DEVICE_MODEM                 0x0000002b
-#define FILE_DEVICE_VDM                   0x0000002c
-#define FILE_DEVICE_MASS_STORAGE          0x0000002d
-#define FILE_DEVICE_SMB                   0x0000002e
-#define FILE_DEVICE_KS                    0x0000002f
-#define FILE_DEVICE_CHANGER               0x00000030
-#define FILE_DEVICE_SMARTCARD             0x00000031
-#define FILE_DEVICE_ACPI                  0x00000032
-#define FILE_DEVICE_DVD                   0x00000033
-#define FILE_DEVICE_FULLSCREEN_VIDEO      0x00000034
-#define FILE_DEVICE_DFS_FILE_SYSTEM       0x00000035
-#define FILE_DEVICE_DFS_VOLUME            0x00000036
-#define FILE_DEVICE_SERENUM               0x00000037
-#define FILE_DEVICE_TERMSRV               0x00000038
-#define FILE_DEVICE_KSEC                  0x00000039
-#define FILE_DEVICE_FIPS                  0x0000003A
-#define FILE_DEVICE_INFINIBAND            0x0000003B
-#define FILE_DEVICE_VMBUS                 0x0000003E
-#define FILE_DEVICE_CRYPT_PROVIDER        0x0000003F
-#define FILE_DEVICE_WPD                   0x00000040
-#define FILE_DEVICE_BLUETOOTH             0x00000041
-#define FILE_DEVICE_MT_COMPOSITE          0x00000042
-#define FILE_DEVICE_MT_TRANSPORT          0x00000043
-#define FILE_DEVICE_BIOMETRIC             0x00000044
-#define FILE_DEVICE_PMI                   0x00000045
+NTKERNELAPI
+VOID
+InitializeSListHead(
+  OUT PSLIST_HEADER SListHead);
 
-#define MAXIMUM_VOLUME_LABEL_LENGTH       (32 * sizeof(WCHAR))
+#else
 
-typedef struct _OBJECT_HANDLE_INFORMATION {
-  ULONG HandleAttributes;
-  ACCESS_MASK GrantedAccess;
-} OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
+VOID
+FORCEINLINE
+InitializeSListHead(
+  OUT PSLIST_HEADER SListHead)
+{
+#if defined(_IA64_)
+    ULONG64 FeatureBits;
+#endif
 
-typedef struct _CLIENT_ID {
-  HANDLE  UniqueProcess;
-  HANDLE  UniqueThread;
-} CLIENT_ID, *PCLIENT_ID;
+#if defined(_WIN64)
+    if (((ULONG_PTR)SListHead & 0xf) != 0)
+    {
+        RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
+    }
+#endif
 
-typedef VOID
-(DDKAPI *PKSTART_ROUTINE)(
-  IN PVOID  StartContext);
+    RtlZeroMemory(SListHead, sizeof(SLIST_HEADER));
 
-typedef struct _VPB {
-  CSHORT  Type;
-  CSHORT  Size;
-  USHORT  Flags;
-  USHORT  VolumeLabelLength;
-  struct _DEVICE_OBJECT  *DeviceObject;
-  struct _DEVICE_OBJECT  *RealDevice;
-  ULONG  SerialNumber;
-  ULONG  ReferenceCount;
-  WCHAR  VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
-} VPB, *PVPB;
+#if defined(_IA64_)
+    FeatureBits = __getReg(CV_IA64_CPUID4);
+    if ((FeatureBits & KF_16BYTE_INSTR) != 0)
+    {
+        SListHead->Header16.HeaderType = 1;
+        SListHead->Header16.Init = 1;
+    }
+#endif
+}
 
-typedef enum _IO_ALLOCATION_ACTION {
-  KeepObject = 1,
-  DeallocateObject,
-  DeallocateObjectKeepRegisters
-} IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
+#endif
 
-typedef IO_ALLOCATION_ACTION
-(DDKAPI *PDRIVER_CONTROL)(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN struct _IRP  *Irp,
-  IN PVOID  MapRegisterBase,
-  IN PVOID  Context);
+#if defined(_WIN64)
 
-typedef struct _WAIT_CONTEXT_BLOCK {
-  KDEVICE_QUEUE_ENTRY  WaitQueueEntry;
-  PDRIVER_CONTROL  DeviceRoutine;
-  PVOID  DeviceContext;
-  ULONG  NumberOfMapRegisters;
-  PVOID  DeviceObject;
-  PVOID  CurrentIrp;
-  PKDPC  BufferChainingDpc;
-} WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
+#define InterlockedPopEntrySList(Head) \
+    ExpInterlockedPopEntrySList(Head)
 
-typedef struct _DEVICE_OBJECT {
-  CSHORT  Type;
-  USHORT  Size;
-  LONG  ReferenceCount;
-  struct _DRIVER_OBJECT  *DriverObject;
-  struct _DEVICE_OBJECT  *NextDevice;
-  struct _DEVICE_OBJECT  *AttachedDevice;
-  struct _IRP  *CurrentIrp;
-  PIO_TIMER  Timer;
-  ULONG  Flags;
-  ULONG  Characteristics;
-  volatile PVPB  Vpb;
-  PVOID  DeviceExtension;
-  DEVICE_TYPE  DeviceType;
-  CCHAR  StackSize;
-  union {
-    LIST_ENTRY  ListEntry;
-    WAIT_CONTEXT_BLOCK  Wcb;
-  } Queue;
-  ULONG  AlignmentRequirement;
-  KDEVICE_QUEUE  DeviceQueue;
-  KDPC  Dpc;
-  ULONG  ActiveThreadCount;
-  PSECURITY_DESCRIPTOR  SecurityDescriptor;
-  KEVENT  DeviceLock;
-  USHORT  SectorSize;
-  USHORT  Spare1;
-  struct _DEVOBJ_EXTENSION  *DeviceObjectExtension;
-  PVOID  Reserved;
-} DEVICE_OBJECT, *PDEVICE_OBJECT;
+#define InterlockedPushEntrySList(Head, Entry) \
+    ExpInterlockedPushEntrySList(Head, Entry)
 
-typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
+#define InterlockedFlushSList(Head) \
+    ExpInterlockedFlushSList(Head)
 
-typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
-  BOOLEAN  Removed;
-  BOOLEAN  Reserved[3];
-  volatile LONG  IoCount;
-  KEVENT  RemoveEvent;
-} IO_REMOVE_LOCK_COMMON_BLOCK;
+#define QueryDepthSList(Head) \
+    ExQueryDepthSList(Head)
 
-typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
-  LONG  Signature;
-  LONG  HighWatermark;
-  LONGLONG  MaxLockedTicks;
-  LONG  AllocateTag;
-  LIST_ENTRY  LockList;
-  KSPIN_LOCK  Spin;
-  volatile LONG  LowMemoryCount;
-  ULONG  Reserved1[4];
-  PVOID  Reserved2;
-  PIO_REMOVE_LOCK_TRACKING_BLOCK  Blocks;
-} IO_REMOVE_LOCK_DBG_BLOCK;
+#else /* !defined(_WIN64) */
 
-typedef struct _IO_REMOVE_LOCK {
-  IO_REMOVE_LOCK_COMMON_BLOCK  Common;
-#if DBG
-  IO_REMOVE_LOCK_DBG_BLOCK  Dbg;
-#endif
-} IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
+NTKERNELAPI
+PSLIST_ENTRY
+FASTCALL
+InterlockedPopEntrySList(
+    IN PSLIST_HEADER ListHead);
 
-typedef struct _IO_WORKITEM *PIO_WORKITEM;
+NTKERNELAPI
+PSLIST_ENTRY
+FASTCALL
+InterlockedPushEntrySList(
+    IN PSLIST_HEADER ListHead,
+    IN PSLIST_ENTRY ListEntry);
 
-typedef VOID
-(DDKAPI IO_WORKITEM_ROUTINE)(
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN PVOID  Context);
-typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
+#define InterlockedFlushSList(ListHead) \
+    ExInterlockedFlushSList(ListHead)
 
-typedef struct _SHARE_ACCESS {
-  ULONG  OpenCount;
-  ULONG  Readers;
-  ULONG  Writers;
-  ULONG  Deleters;
-  ULONG  SharedRead;
-  ULONG  SharedWrite;
-  ULONG  SharedDelete;
-} SHARE_ACCESS, *PSHARE_ACCESS;
+#define QueryDepthSList(Head) \
+    ExQueryDepthSList(Head)
 
-/* While MS WDK uses inheritance in C++, we cannot do this with gcc, as
-   inheritance, even from a struct renders the type non-POD. So we use
-   this hack */
-#define PCI_COMMON_HEADER_LAYOUT \
-  USHORT  VendorID; \
-  USHORT  DeviceID; \
-  USHORT  Command; \
-  USHORT  Status; \
-  UCHAR   RevisionID; \
-  UCHAR   ProgIf; \
-  UCHAR   SubClass; \
-  UCHAR   BaseClass; \
-  UCHAR   CacheLineSize; \
-  UCHAR   LatencyTimer; \
-  UCHAR   HeaderType; \
-  UCHAR   BIST; \
-  union { \
-    struct _PCI_HEADER_TYPE_0 { \
-      ULONG   BaseAddresses[PCI_TYPE0_ADDRESSES]; \
-      ULONG   CIS; \
-      USHORT  SubVendorID; \
-      USHORT  SubSystemID; \
-      ULONG   ROMBaseAddress; \
-      UCHAR   CapabilitiesPtr; \
-      UCHAR   Reserved1[3]; \
-      ULONG   Reserved2; \
-      UCHAR   InterruptLine; \
-      UCHAR   InterruptPin; \
-      UCHAR   MinimumGrant; \
-      UCHAR   MaximumLatency; \
-    } type0; \
-    struct _PCI_HEADER_TYPE_1 { \
-      ULONG   BaseAddresses[PCI_TYPE1_ADDRESSES]; \
-      UCHAR   PrimaryBus; \
-      UCHAR   SecondaryBus; \
-      UCHAR   SubordinateBus; \
-      UCHAR   SecondaryLatency; \
-      UCHAR   IOBase; \
-      UCHAR   IOLimit; \
-      USHORT  SecondaryStatus; \
-      USHORT  MemoryBase; \
-      USHORT  MemoryLimit; \
-      USHORT  PrefetchBase; \
-      USHORT  PrefetchLimit; \
-      ULONG   PrefetchBaseUpper32; \
-      ULONG   PrefetchLimitUpper32; \
-      USHORT  IOBaseUpper16; \
-      USHORT  IOLimitUpper16; \
-      UCHAR   CapabilitiesPtr; \
-      UCHAR   Reserved1[3]; \
-      ULONG   ROMBaseAddress; \
-      UCHAR   InterruptLine; \
-      UCHAR   InterruptPin; \
-      USHORT  BridgeControl; \
-    } type1; \
-    struct _PCI_HEADER_TYPE_2 { \
-      ULONG   SocketRegistersBaseAddress; \
-      UCHAR   CapabilitiesPtr; \
-      UCHAR   Reserved; \
-      USHORT  SecondaryStatus; \
-      UCHAR   PrimaryBus; \
-      UCHAR   SecondaryBus; \
-      UCHAR   SubordinateBus; \
-      UCHAR   SecondaryLatency; \
-      struct  { \
-        ULONG   Base; \
-        ULONG   Limit; \
-      } Range[PCI_TYPE2_ADDRESSES-1]; \
-      UCHAR   InterruptLine; \
-      UCHAR   InterruptPin; \
-      USHORT  BridgeControl; \
-    } type2; \
-  } u;
+#endif /* !defined(_WIN64) */
 
-typedef struct _PCI_COMMON_HEADER {
-  PCI_COMMON_HEADER_LAYOUT
-} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
+#endif /* !defined(_WINBASE_) */
 
-#ifdef __cplusplus
-typedef struct _PCI_COMMON_CONFIG {
-  PCI_COMMON_HEADER_LAYOUT
-  UCHAR  DeviceSpecific[192];
-} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
+/******************************************************************************
+ *                              Kernel Functions                              *
+ ******************************************************************************/
+
+#if defined(_M_IX86)
+#define YieldProcessor _mm_pause
+#elif defined (_M_AMD64)
+#define YieldProcessor _mm_pause
+#elif defined(_M_PPC)
+#define YieldProcessor() __asm__ __volatile__("nop");
+#elif defined(_M_MIPS)
+#define YieldProcessor() __asm__ __volatile__("nop");
+#elif defined(_M_ARM)
+#define YieldProcessor()
 #else
-typedef struct _PCI_COMMON_CONFIG {
-  PCI_COMMON_HEADER DUMMYSTRUCTNAME;
-  UCHAR  DeviceSpecific[192];
-} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
+#error Unknown architecture
 #endif
 
-typedef enum _CREATE_FILE_TYPE {
-  CreateFileTypeNone,
-  CreateFileTypeNamedPipe,
-  CreateFileTypeMailslot
-} CREATE_FILE_TYPE;
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeEvent(
+  OUT PRKEVENT  Event,
+  IN EVENT_TYPE  Type,
+  IN BOOLEAN  State);
 
-#define IO_FORCE_ACCESS_CHECK               0x001
-#define IO_NO_PARAMETER_CHECKING            0x100
+NTKERNELAPI
+VOID
+NTAPI
+KeClearEvent(
+  IN OUT PRKEVENT Event);
 
-#define IO_REPARSE                      0x0
-#define IO_REMOUNT                      0x1
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
-typedef struct _IO_STATUS_BLOCK {
-  _ANONYMOUS_UNION union {
-    NTSTATUS  Status;
-    PVOID  Pointer;
-  } DUMMYUNIONNAME;
-  ULONG_PTR  Information;
-} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
+#if defined(SINGLE_GROUP_LEGACY_API)
+NTKERNELAPI
+VOID
+NTAPI
+KeRevertToUserAffinityThread(VOID);
 
-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;
+NTKERNELAPI
+VOID
+NTAPI
+KeSetSystemAffinityThread(
+    IN KAFFINITY Affinity);
 
-typedef VOID
-(DDKAPI *PIO_APC_ROUTINE)(
-  IN PVOID ApcContext,
-  IN PIO_STATUS_BLOCK IoStatusBlock,
-  IN ULONG Reserved);
+NTKERNELAPI
+VOID
+NTAPI
+KeSetTargetProcessorDpc(
+  IN OUT PRKDPC Dpc,
+  IN CCHAR Number);
 
-typedef VOID
-(DDKAPI *WMI_NOTIFICATION_CALLBACK)(
-  PVOID  Wnode,
-  PVOID  Context);
+NTKERNELAPI
+KAFFINITY
+NTAPI
+KeQueryActiveProcessors(
+  VOID);
+#endif
 
-#define EVENT_INCREMENT                   1
-#define IO_NO_INCREMENT                   0
-#define IO_CD_ROM_INCREMENT               1
-#define IO_DISK_INCREMENT                 1
-#define IO_KEYBOARD_INCREMENT             6
-#define IO_MAILSLOT_INCREMENT             2
-#define IO_MOUSE_INCREMENT                6
-#define IO_NAMED_PIPE_INCREMENT           2
-#define IO_NETWORK_INCREMENT              2
-#define IO_PARALLEL_INCREMENT             1
-#define IO_SERIAL_INCREMENT               2
-#define IO_SOUND_INCREMENT                8
-#define IO_VIDEO_INCREMENT                1
-#define SEMAPHORE_INCREMENT               1
+#if !defined(_M_AMD64)
+NTKERNELAPI
+ULONGLONG
+NTAPI
+KeQueryInterruptTime(
+  VOID);
+
+NTKERNELAPI
+VOID
+NTAPI
+KeQuerySystemTime(
+  OUT PLARGE_INTEGER  CurrentTime);
+#endif /* !_M_AMD64 */
+
+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);
 
-#define MM_MAXIMUM_DISK_IO_SIZE          (0x10000)
+NTKERNELAPI
+VOID
+NTAPI
+KeEnterCriticalRegion(VOID);
 
-typedef struct _BOOTDISK_INFORMATION {
-  LONGLONG  BootPartitionOffset;
-  LONGLONG  SystemPartitionOffset;
-  ULONG  BootDeviceSignature;
-  ULONG  SystemDeviceSignature;
-} BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeDeviceQueue(
+  OUT PKDEVICE_QUEUE  DeviceQueue);
 
-typedef struct _BOOTDISK_INFORMATION_EX {
-  LONGLONG  BootPartitionOffset;
-  LONGLONG  SystemPartitionOffset;
-  ULONG  BootDeviceSignature;
-  ULONG  SystemDeviceSignature;
-  GUID  BootDeviceGuid;
-  GUID  SystemDeviceGuid;
-  BOOLEAN  BootDeviceIsGpt;
-  BOOLEAN  SystemDeviceIsGpt;
-} BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeDpc(
+  OUT PRKDPC  Dpc,
+  IN PKDEFERRED_ROUTINE  DeferredRoutine,
+  IN PVOID  DeferredContext OPTIONAL);
 
-typedef struct _EISA_MEMORY_TYPE {
-  UCHAR  ReadWrite : 1;
-  UCHAR  Cached : 1;
-  UCHAR  Reserved0 : 1;
-  UCHAR  Type : 2;
-  UCHAR  Shared : 1;
-  UCHAR  Reserved1 : 1;
-  UCHAR  MoreEntries : 1;
-} EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeMutex(
+  OUT PRKMUTEX  Mutex,
+  IN ULONG  Level);
 
-#include <pshpack1.h>
-typedef struct _EISA_MEMORY_CONFIGURATION {
-  EISA_MEMORY_TYPE  ConfigurationByte;
-  UCHAR  DataSize;
-  USHORT  AddressLowWord;
-  UCHAR  AddressHighByte;
-  USHORT  MemorySize;
-} EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
-#include <poppack.h>
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeSemaphore(
+  OUT PRKSEMAPHORE  Semaphore,
+  IN LONG  Count,
+  IN LONG  Limit);
 
-typedef struct _EISA_IRQ_DESCRIPTOR {
-  UCHAR  Interrupt : 4;
-  UCHAR  Reserved : 1;
-  UCHAR  LevelTriggered : 1;
-  UCHAR  Shared : 1;
-  UCHAR  MoreEntries : 1;
-} EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeTimer(
+  OUT PKTIMER  Timer);
 
-typedef struct _EISA_IRQ_CONFIGURATION {
-  EISA_IRQ_DESCRIPTOR  ConfigurationByte;
-  UCHAR  Reserved;
-} EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeTimerEx(
+  OUT PKTIMER  Timer,
+  IN TIMER_TYPE  Type);
 
-typedef struct _DMA_CONFIGURATION_BYTE0 {
-  UCHAR Channel : 3;
-  UCHAR Reserved : 3;
-  UCHAR Shared : 1;
-  UCHAR MoreEntries : 1;
-} DMA_CONFIGURATION_BYTE0;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeInsertByKeyDeviceQueue(
+  IN OUT PKDEVICE_QUEUE  DeviceQueue,
+  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry,
+  IN ULONG  SortKey);
 
-typedef struct _DMA_CONFIGURATION_BYTE1 {
-  UCHAR  Reserved0 : 2;
-  UCHAR  TransferSize : 2;
-  UCHAR  Timing : 2;
-  UCHAR  Reserved1 : 2;
-} DMA_CONFIGURATION_BYTE1;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeInsertDeviceQueue(
+  IN OUT PKDEVICE_QUEUE  DeviceQueue,
+  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry);
 
-typedef struct _EISA_DMA_CONFIGURATION {
-  DMA_CONFIGURATION_BYTE0  ConfigurationByte0;
-  DMA_CONFIGURATION_BYTE1  ConfigurationByte1;
-} EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeInsertQueueDpc(
+  IN OUT PRKDPC  Dpc,
+  IN PVOID  SystemArgument1 OPTIONAL,
+  IN PVOID  SystemArgument2 OPTIONAL);
 
-#include <pshpack1.h>
-typedef struct _EISA_PORT_DESCRIPTOR {
-  UCHAR  NumberPorts : 5;
-  UCHAR  Reserved : 1;
-  UCHAR  Shared : 1;
-  UCHAR  MoreEntries : 1;
-} EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
+NTKERNELAPI
+VOID
+NTAPI
+KeLeaveCriticalRegion(VOID);
 
-typedef struct _EISA_PORT_CONFIGURATION {
-  EISA_PORT_DESCRIPTOR  Configuration;
-  USHORT  PortAddress;
-} EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
-#include <poppack.h>
+NTHALAPI
+LARGE_INTEGER
+NTAPI
+KeQueryPerformanceCounter(
+  OUT PLARGE_INTEGER  PerformanceFrequency  OPTIONAL);
 
-typedef struct _CM_EISA_FUNCTION_INFORMATION {
-  ULONG  CompressedId;
-  UCHAR  IdSlotFlags1;
-  UCHAR  IdSlotFlags2;
-  UCHAR  MinorRevision;
-  UCHAR  MajorRevision;
-  UCHAR  Selections[26];
-  UCHAR  FunctionFlags;
-  UCHAR  TypeString[80];
-  EISA_MEMORY_CONFIGURATION  EisaMemory[9];
-  EISA_IRQ_CONFIGURATION  EisaIrq[7];
-  EISA_DMA_CONFIGURATION  EisaDma[4];
-  EISA_PORT_CONFIGURATION  EisaPort[20];
-  UCHAR  InitializationData[60];
-} CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
+NTKERNELAPI
+KPRIORITY
+NTAPI
+KeQueryPriorityThread(
+  IN PRKTHREAD  Thread);
 
-/* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryTimeIncrement(
+  VOID);
 
-#define EISA_FUNCTION_ENABLED           0x80
-#define EISA_FREE_FORM_DATA             0x40
-#define EISA_HAS_PORT_INIT_ENTRY        0x20
-#define EISA_HAS_PORT_RANGE             0x10
-#define EISA_HAS_DMA_ENTRY              0x08
-#define EISA_HAS_IRQ_ENTRY              0x04
-#define EISA_HAS_MEMORY_ENTRY           0x02
-#define EISA_HAS_TYPE_ENTRY             0x01
-#define EISA_HAS_INFORMATION \
-  (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
-  + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
+NTKERNELAPI
+LONG
+NTAPI
+KeReadStateEvent(
+  IN PRKEVENT  Event);
 
-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;
+NTKERNELAPI
+LONG
+NTAPI
+KeReadStateMutex(
+  IN PRKMUTEX  Mutex);
 
-/* CM_EISA_SLOT_INFORMATION.ReturnCode */
 
-#define EISA_INVALID_SLOT               0x80
-#define EISA_INVALID_FUNCTION           0x81
-#define EISA_INVALID_CONFIGURATION      0x82
-#define EISA_EMPTY_SLOT                 0x83
-#define EISA_INVALID_BIOS_CALL          0x86
+NTKERNELAPI
+LONG
+NTAPI
+KeReadStateSemaphore(
+  IN PRKSEMAPHORE  Semaphore);
 
-/*
-** Plug and Play structures
-*/
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeReadStateTimer(
+  IN PKTIMER  Timer);
 
-typedef VOID
-(DDKAPI *PINTERFACE_REFERENCE)(
-  PVOID  Context);
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeRegisterBugCheckCallback(
+  OUT PKBUGCHECK_CALLBACK_RECORD  CallbackRecord,
+  IN PKBUGCHECK_CALLBACK_ROUTINE  CallbackRoutine,
+  IN PVOID  Buffer,
+  IN ULONG  Length,
+  IN PUCHAR  Component);
 
-typedef VOID
-(DDKAPI *PINTERFACE_DEREFERENCE)(
-  PVOID Context);
+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);
 
-typedef BOOLEAN
-(DDKAPI *PTRANSLATE_BUS_ADDRESS)(
-  IN PVOID  Context,
-  IN PHYSICAL_ADDRESS  BusAddress,
-  IN ULONG  Length,
-  IN OUT PULONG  AddressSpace,
-  OUT PPHYSICAL_ADDRESS  TranslatedAddress);
+NTKERNELAPI
+PKDEVICE_QUEUE_ENTRY
+NTAPI
+KeRemoveDeviceQueue(
+  IN OUT PKDEVICE_QUEUE  DeviceQueue);
 
-typedef struct _DMA_ADAPTER*
-(DDKAPI *PGET_DMA_ADAPTER)(
-  IN PVOID  Context,
-  IN struct _DEVICE_DESCRIPTION  *DeviceDescriptor,
-  OUT PULONG  NumberOfMapRegisters);
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeRemoveEntryDeviceQueue(
+  IN OUT PKDEVICE_QUEUE  DeviceQueue,
+  IN OUT PKDEVICE_QUEUE_ENTRY  DeviceQueueEntry);
 
-typedef ULONG
-(DDKAPI *PGET_SET_DEVICE_DATA)(
-  IN PVOID  Context,
-  IN ULONG  DataType,
-  IN PVOID  Buffer,
-  IN ULONG  Offset,
-  IN ULONG  Length);
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeRemoveQueueDpc(
+  IN OUT PRKDPC  Dpc);
 
-/* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
-#define PCI_USE_SUBSYSTEM_IDS   0x00000001
-#define PCI_USE_REVISION        0x00000002
-#define PCI_USE_VENDEV_IDS      0x00000004
-#define PCI_USE_CLASS_SUBCLASS  0x00000008
-#define PCI_USE_PROGIF          0x00000010
-#define PCI_USE_LOCAL_BUS       0x00000020
-#define PCI_USE_LOCAL_DEVICE    0x00000040
+NTKERNELAPI
+LONG
+NTAPI
+KeResetEvent(
+  IN OUT PRKEVENT  Event);
 
-typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
-  ULONG   Size;
-  ULONG   Flags;
-  USHORT  VendorID;
-  USHORT  DeviceID;
-  UCHAR   RevisionID;
-  USHORT  SubVendorID;
-  USHORT  SubSystemID;
-  UCHAR   BaseClass;
-  UCHAR   SubClass;
-  UCHAR   ProgIf;
-} PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
+NTKERNELAPI
+LONG
+NTAPI
+KeSetEvent(
+  IN OUT PRKEVENT  Event,
+  IN KPRIORITY  Increment,
+  IN BOOLEAN  Wait);
 
-typedef BOOLEAN
-(DDKAPI *PPCI_IS_DEVICE_PRESENT)(
-  IN USHORT  VendorID,
-  IN USHORT  DeviceID,
-  IN UCHAR   RevisionID,
-  IN USHORT  SubVendorID,
-  IN USHORT  SubSystemID,
-  IN ULONG   Flags);
+NTKERNELAPI
+VOID
+NTAPI
+KeSetImportanceDpc(
+  IN OUT PRKDPC  Dpc,
+  IN KDPC_IMPORTANCE  Importance);
 
-typedef BOOLEAN
-(DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)(
-  IN PVOID Context,
-  IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
+NTKERNELAPI
+KPRIORITY
+NTAPI
+KeSetPriorityThread(
+  IN OUT PKTHREAD  Thread,
+  IN KPRIORITY  Priority);
 
-typedef struct _BUS_INTERFACE_STANDARD {
-  USHORT  Size;
-  USHORT  Version;
-  PVOID  Context;
-  PINTERFACE_REFERENCE  InterfaceReference;
-  PINTERFACE_DEREFERENCE  InterfaceDereference;
-  PTRANSLATE_BUS_ADDRESS  TranslateBusAddress;
-  PGET_DMA_ADAPTER  GetDmaAdapter;
-  PGET_SET_DEVICE_DATA  SetBusData;
-  PGET_SET_DEVICE_DATA  GetBusData;
-} BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeSetTimer(
+  IN OUT PKTIMER  Timer,
+  IN LARGE_INTEGER  DueTime,
+  IN PKDPC  Dpc  OPTIONAL);
 
-typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
-  USHORT  Size;
-  USHORT  Version;
-  PVOID  Context;
-  PINTERFACE_REFERENCE  InterfaceReference;
-  PINTERFACE_DEREFERENCE  InterfaceDereference;
-  PPCI_IS_DEVICE_PRESENT  IsDevicePresent;
-  PPCI_IS_DEVICE_PRESENT_EX  IsDevicePresentEx;
-} PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeSetTimerEx(
+  IN OUT PKTIMER  Timer,
+  IN LARGE_INTEGER  DueTime,
+  IN LONG  Period  OPTIONAL,
+  IN PKDPC  Dpc  OPTIONAL);
 
-typedef struct _DEVICE_CAPABILITIES {
-  USHORT  Size;
-  USHORT  Version;
-  ULONG  DeviceD1 : 1;
-  ULONG  DeviceD2 : 1;
-  ULONG  LockSupported : 1;
-  ULONG  EjectSupported : 1;
-  ULONG  Removable : 1;
-  ULONG  DockDevice : 1;
-  ULONG  UniqueID : 1;
-  ULONG  SilentInstall : 1;
-  ULONG  RawDeviceOK : 1;
-  ULONG  SurpriseRemovalOK : 1;
-  ULONG  WakeFromD0 : 1;
-  ULONG  WakeFromD1 : 1;
-  ULONG  WakeFromD2 : 1;
-  ULONG  WakeFromD3 : 1;
-  ULONG  HardwareDisabled : 1;
-  ULONG  NonDynamic : 1;
-  ULONG  WarmEjectSupported : 1;
-  ULONG  NoDisplayInUI : 1;
-  ULONG  Reserved : 14;
-  ULONG  Address;
-  ULONG  UINumber;
-  DEVICE_POWER_STATE  DeviceState[PowerSystemMaximum];
-  SYSTEM_POWER_STATE  SystemWake;
-  DEVICE_POWER_STATE  DeviceWake;
-  ULONG  D1Latency;
-  ULONG  D2Latency;
-  ULONG  D3Latency;
-} DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
+NTHALAPI
+VOID
+NTAPI
+KeStallExecutionProcessor(
+  IN ULONG  MicroSeconds);
 
-typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
-  USHORT  Version;
-  USHORT  Size;
-  GUID  Event;
-  GUID  InterfaceClassGuid;
-  PUNICODE_STRING  SymbolicLinkName;
-} DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeSynchronizeExecution(
+  IN OUT PKINTERRUPT    Interrupt,
+  IN PKSYNCHRONIZE_ROUTINE  SynchronizeRoutine,
+  IN PVOID  SynchronizeContext OPTIONAL);
 
-typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
-  USHORT  Version;
-  USHORT  Size;
-  GUID  Event;
-} HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
+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);
 
-#undef INTERFACE
+#define KeWaitForMutexObject KeWaitForSingleObject
 
-typedef struct _INTERFACE {
-  USHORT  Size;
-  USHORT  Version;
-  PVOID  Context;
-  PINTERFACE_REFERENCE  InterfaceReference;
-  PINTERFACE_DEREFERENCE  InterfaceDereference;
-} INTERFACE, *PINTERFACE;
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeWaitForSingleObject(
+  IN PVOID  Object,
+  IN KWAIT_REASON  WaitReason,
+  IN KPROCESSOR_MODE  WaitMode,
+  IN BOOLEAN  Alertable,
+  IN PLARGE_INTEGER  Timeout  OPTIONAL);
 
-typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
-  USHORT  Version;
-  USHORT  Size;
-  GUID  Event;
-} PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
 
-typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
+#if (NTDDI_VERSION >= NTDDI_WINXP)
 
-/* PNP_DEVICE_STATE */
+// _DECL_HAL_KE_IMPORT
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLock(
+  IN OUT PKSPIN_LOCK SpinLock,
+  OUT PKLOCK_QUEUE_HANDLE LockHandle);
 
-#define PNP_DEVICE_DISABLED                      0x00000001
-#define PNP_DEVICE_DONT_DISPLAY_IN_UI            0x00000002
-#define PNP_DEVICE_FAILED                        0x00000004
-#define PNP_DEVICE_REMOVED                       0x00000008
-#define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
-#define PNP_DEVICE_NOT_DISABLEABLE               0x00000020
+NTKERNELAPI
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLockAtDpcLevel(
+  IN OUT PKSPIN_LOCK  SpinLock,
+  OUT PKLOCK_QUEUE_HANDLE  LockHandle);
 
-typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
-  USHORT  Version;
-  USHORT  Size;
-  GUID  Event;
-  struct _FILE_OBJECT  *FileObject;
-  LONG  NameBufferOffset;
-  UCHAR  CustomDataBuffer[1];
-} TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
+NTKERNELAPI
+KIRQL
+NTAPI
+KeAcquireInterruptSpinLock(
+  IN OUT PKINTERRUPT  Interrupt);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeAreApcsDisabled(VOID);
 
-typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
-  USHORT  Version;
-  USHORT  Size;
-  GUID  Event;
-  struct _FILE_OBJECT  *FileObject;
-} TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
+NTKERNELAPI
+ULONG
+NTAPI
+KeGetRecommendedSharedDataAlignment(VOID);
 
-typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
-  DeviceUsageTypeUndefined,
-  DeviceUsageTypePaging,
-  DeviceUsageTypeHibernation,
-  DeviceUsageTypeDumpFile
-} DEVICE_USAGE_NOTIFICATION_TYPE;
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryRuntimeThread(
+  IN PKTHREAD Thread,
+  OUT PULONG UserTime);
 
-typedef struct _POWER_SEQUENCE {
-  ULONG  SequenceD1;
-  ULONG  SequenceD2;
-  ULONG  SequenceD3;
-} POWER_SEQUENCE, *PPOWER_SEQUENCE;
+NTKERNELAPI
+VOID
+FASTCALL
+KeReleaseInStackQueuedSpinLockFromDpcLevel(
+  IN PKLOCK_QUEUE_HANDLE  LockHandle);
 
-typedef enum {
-  DevicePropertyDeviceDescription = 0x0,
-  DevicePropertyHardwareID = 0x1,
-  DevicePropertyCompatibleIDs = 0x2,
-  DevicePropertyBootConfiguration = 0x3,
-  DevicePropertyBootConfigurationTranslated = 0x4,
-  DevicePropertyClassName = 0x5,
-  DevicePropertyClassGuid = 0x6,
-  DevicePropertyDriverKeyName = 0x7,
-  DevicePropertyManufacturer = 0x8,
-  DevicePropertyFriendlyName = 0x9,
-  DevicePropertyLocationInformation = 0xa,
-  DevicePropertyPhysicalDeviceObjectName = 0xb,
-  DevicePropertyBusTypeGuid = 0xc,
-  DevicePropertyLegacyBusType = 0xd,
-  DevicePropertyBusNumber = 0xe,
-  DevicePropertyEnumeratorName = 0xf,
-  DevicePropertyAddress = 0x10,
-  DevicePropertyUINumber = 0x11,
-  DevicePropertyInstallState = 0x12,
-  DevicePropertyRemovalPolicy = 0x13,
-  DevicePropertyResourceRequirements = 0x14,
-  DevicePropertyAllocatedResources = 0x15,
-  DevicePropertyContainerID = 0x16
-} DEVICE_REGISTRY_PROPERTY;
+NTKERNELAPI
+VOID
+NTAPI
+KeReleaseInterruptSpinLock(
+  IN OUT PKINTERRUPT  Interrupt,
+  IN KIRQL  OldIrql);
 
-typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
-  EventCategoryReserved,
-  EventCategoryHardwareProfileChange,
-  EventCategoryDeviceInterfaceChange,
-  EventCategoryTargetDeviceChange
-} IO_NOTIFICATION_EVENT_CATEGORY;
+NTKERNELAPI
+PKDEVICE_QUEUE_ENTRY
+NTAPI
+KeRemoveByKeyDeviceQueueIfBusy(
+  IN OUT PKDEVICE_QUEUE DeviceQueue,
+  IN ULONG SortKey);
 
-#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES    0x00000001
+//_DECL_HAL_KE_IMPORT
+VOID
+FASTCALL
+KeReleaseInStackQueuedSpinLock(
+  IN PKLOCK_QUEUE_HANDLE LockHandle);
 
-typedef NTSTATUS
-(DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
-  IN PVOID NotificationStructure,
-  IN PVOID Context);
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
 
-typedef VOID
-(DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)(
-  IN PVOID Context);
+#if (NTDDI_VERSION >= NTDDI_WINXPSP1)
 
-typedef enum _FILE_INFORMATION_CLASS {
-  FileDirectoryInformation = 1,
-  FileFullDirectoryInformation,
-  FileBothDirectoryInformation,
-  FileBasicInformation,
-  FileStandardInformation,
-  FileInternalInformation,
-  FileEaInformation,
-  FileAccessInformation,
-  FileNameInformation,
-  FileRenameInformation,
-  FileLinkInformation,
-  FileNamesInformation,
-  FileDispositionInformation,
-  FilePositionInformation,
-  FileFullEaInformation,
-  FileModeInformation,
-  FileAlignmentInformation,
-  FileAllInformation,
-  FileAllocationInformation,
-  FileEndOfFileInformation,
-  FileAlternateNameInformation,
-  FileStreamInformation,
-  FilePipeInformation,
-  FilePipeLocalInformation,
-  FilePipeRemoteInformation,
-  FileMailslotQueryInformation,
-  FileMailslotSetInformation,
-  FileCompressionInformation,
-  FileObjectIdInformation,
-  FileCompletionInformation,
-  FileMoveClusterInformation,
-  FileQuotaInformation,
-  FileReparsePointInformation,
-  FileNetworkOpenInformation,
-  FileAttributeTagInformation,
-  FileTrackingInformation,
-  FileIdBothDirectoryInformation,
-  FileIdFullDirectoryInformation,
-  FileValidDataLengthInformation,
-  FileShortNameInformation,
-  FileIoCompletionNotificationInformation,
-  FileIoStatusBlockRangeInformation,
-  FileIoPriorityHintInformation,
-  FileSfioReserveInformation,
-  FileSfioVolumeInformation,
-  FileHardLinkInformation,
-  FileProcessIdsUsingFileInformation,
-  FileNormalizedNameInformation,
-  FileNetworkPhysicalNameInformation,
-  FileIdGlobalTxDirectoryInformation,
-  FileIsRemoteDeviceInformation,
-  FileAttributeCacheInformation,
-  FileNumaNodeInformation,
-  FileStandardLinkInformation,
-  FileRemoteProtocolInformation,
-  FileMaximumInformation
-} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeDeregisterBugCheckReasonCallback(
+  IN OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord);
 
-typedef struct _FILE_POSITION_INFORMATION {
-  LARGE_INTEGER  CurrentByteOffset;
-} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeRegisterBugCheckReasonCallback(
+  OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord,
+  IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine,
+  IN KBUGCHECK_CALLBACK_REASON Reason,
+  IN PUCHAR Component);
 
-#include <pshpack8.h>
-typedef struct _FILE_BASIC_INFORMATION {
-  LARGE_INTEGER  CreationTime;
-  LARGE_INTEGER  LastAccessTime;
-  LARGE_INTEGER  LastWriteTime;
-  LARGE_INTEGER  ChangeTime;
-  ULONG  FileAttributes;
-} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
-#include <poppack.h>
+#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */
 
-typedef struct _FILE_STANDARD_INFORMATION {
-  LARGE_INTEGER  AllocationSize;
-  LARGE_INTEGER  EndOfFile;
-  ULONG  NumberOfLinks;
-  BOOLEAN  DeletePending;
-  BOOLEAN  Directory;
-} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
+#if (NTDDI_VERSION >= NTDDI_WINXPSP2)
 
-typedef struct _FILE_NETWORK_OPEN_INFORMATION {
-  LARGE_INTEGER  CreationTime;
-  LARGE_INTEGER  LastAccessTime;
-  LARGE_INTEGER  LastWriteTime;
-  LARGE_INTEGER  ChangeTime;
-  LARGE_INTEGER  AllocationSize;
-  LARGE_INTEGER  EndOfFile;
-  ULONG  FileAttributes;
-} FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
+NTKERNELAPI
+VOID
+NTAPI
+KeFlushQueuedDpcs(
+  VOID);
 
-typedef enum _FSINFOCLASS {
-  FileFsVolumeInformation = 1,
-  FileFsLabelInformation,
-  FileFsSizeInformation,
-  FileFsDeviceInformation,
-  FileFsAttributeInformation,
-  FileFsControlInformation,
-  FileFsFullSizeInformation,
-  FileFsObjectIdInformation,
-  FileFsDriverPathInformation,
-  FileFsVolumeFlagsInformation,
-  FileFsMaximumInformation
-} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
+#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */
 
-typedef struct _FILE_FS_DEVICE_INFORMATION {
-  DEVICE_TYPE  DeviceType;
-  ULONG  Characteristics;
-} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
+#if (NTDDI_VERSION >= NTDDI_WS03)
 
-typedef struct _FILE_FULL_EA_INFORMATION {
-  ULONG  NextEntryOffset;
-  UCHAR  Flags;
-  UCHAR  EaNameLength;
-  USHORT  EaValueLength;
-  CHAR  EaName[1];
-} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
+NTKERNELAPI
+PVOID
+NTAPI
+KeRegisterNmiCallback(
+  IN PNMI_CALLBACK CallbackRoutine,
+  IN PVOID Context OPTIONAL);
 
-#define FM_LOCK_BIT             (0x1)
-#define FM_LOCK_BIT_V           (0x0)
-#define FM_LOCK_WAITER_WOKEN    (0x2)
-#define FM_LOCK_WAITER_INC      (0x4)
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeDeregisterNmiCallback(
+  IN PVOID Handle);
 
-typedef struct _FAST_MUTEX {
-  volatile LONG Count;
-  PKTHREAD Owner;
-  ULONG Contention;
-  KEVENT Event;
-  ULONG OldIrql;
-} FAST_MUTEX, *PFAST_MUTEX;
+NTKERNELAPI
+VOID
+NTAPI
+KeInitializeThreadedDpc(
+  OUT PRKDPC Dpc,
+  IN PKDEFERRED_ROUTINE DeferredRoutine,
+  IN PVOID DeferredContext OPTIONAL);
 
-typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD;
+NTKERNELAPI
+ULONG_PTR
+NTAPI
+KeIpiGenericCall(
+  IN PKIPI_BROADCAST_WORKER BroadcastFunction,
+  IN ULONG_PTR Context);
 
-typedef struct _OWNER_ENTRY {
-    ERESOURCE_THREAD OwnerThread;
-    _ANONYMOUS_UNION union {
-        LONG OwnerCount;
-        ULONG TableSize;
-    } DUMMYUNIONNAME;
-} OWNER_ENTRY, *POWNER_ENTRY;
+NTKERNELAPI
+KIRQL
+FASTCALL
+KeAcquireSpinLockForDpc(
+  IN OUT PKSPIN_LOCK SpinLock);
 
-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;
+NTKERNELAPI
+VOID
+FASTCALL
+KeReleaseSpinLockForDpc(
+  IN OUT PKSPIN_LOCK SpinLock,
+  IN KIRQL OldIrql);
 
-/* ERESOURCE.Flag */
-#define ResourceNeverExclusive            0x0010
-#define ResourceReleaseByOtherThread      0x0020
-#define ResourceOwnedExclusive            0x0080
+#endif /* (NTDDI_VERSION >= NTDDI_WS03) */
 
-#define RESOURCE_HASH_TABLE_SIZE          64
+#if (NTDDI_VERSION >= NTDDI_WS03SP1)
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN ULONG  Length,
-  IN BOOLEAN  Wait,
-  IN ULONG  LockKey,
-  IN BOOLEAN  CheckForReadOperation,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+KeTryToAcquireSpinLockAtDpcLevel(
+  IN OUT PKSPIN_LOCK SpinLock);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_READ)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN ULONG  Length,
-  IN BOOLEAN  Wait,
-  IN ULONG  LockKey,
-  OUT PVOID  Buffer,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeAreAllApcsDisabled(
+  VOID);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_WRITE)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN ULONG  Length,
-  IN BOOLEAN  Wait,
-  IN ULONG  LockKey,
-  IN PVOID  Buffer,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+VOID
+FASTCALL
+KeAcquireGuardedMutex(
+    IN OUT PKGUARDED_MUTEX GuardedMutex
+);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_QUERY_BASIC_INFO)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN BOOLEAN  Wait,
-  OUT PFILE_BASIC_INFORMATION  Buffer,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+VOID
+FASTCALL
+KeAcquireGuardedMutexUnsafe(
+    IN OUT PKGUARDED_MUTEX GuardedMutex
+);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN BOOLEAN  Wait,
-  OUT PFILE_STANDARD_INFORMATION  Buffer,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+VOID
+NTAPI
+KeEnterGuardedRegion(
+    VOID
+);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_LOCK)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN PLARGE_INTEGER  Length,
-  PEPROCESS  ProcessId,
-  ULONG  Key,
-  BOOLEAN  FailImmediately,
-  BOOLEAN  ExclusiveLock,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+VOID
+NTAPI
+KeLeaveGuardedRegion(
+    VOID
+);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_UNLOCK_SINGLE)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN PLARGE_INTEGER  Length,
-  PEPROCESS  ProcessId,
-  ULONG  Key,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+VOID
+FASTCALL
+KeInitializeGuardedMutex(
+    OUT PKGUARDED_MUTEX GuardedMutex
+);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_UNLOCK_ALL)(
-  IN struct _FILE_OBJECT  *FileObject,
-  PEPROCESS  ProcessId,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+VOID
+FASTCALL
+KeReleaseGuardedMutexUnsafe(
+    IN OUT PKGUARDED_MUTEX GuardedMutex
+);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)(
-  IN struct _FILE_OBJECT  *FileObject,
-  PVOID  ProcessId,
-  ULONG  Key,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+VOID
+FASTCALL
+KeReleaseGuardedMutex(
+    IN OUT PKGUARDED_MUTEX GuardedMutex
+);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_DEVICE_CONTROL)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN BOOLEAN  Wait,
-  IN PVOID  InputBuffer  OPTIONAL,
-  IN ULONG  InputBufferLength,
-  OUT PVOID  OutputBuffer  OPTIONAL,
-  IN ULONG  OutputBufferLength,
-  IN ULONG  IoControlCode,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+KeTryToAcquireGuardedMutex(
+    IN OUT PKGUARDED_MUTEX GuardedMutex
+);
 
-typedef VOID
-(DDKAPI *PFAST_IO_ACQUIRE_FILE)(
-  IN struct _FILE_OBJECT  *FileObject);
+#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
 
-typedef VOID
-(DDKAPI *PFAST_IO_RELEASE_FILE)(
-  IN struct _FILE_OBJECT  *FileObject);
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 
-typedef VOID
-(DDKAPI *PFAST_IO_DETACH_DEVICE)(
-  IN struct _DEVICE_OBJECT  *SourceDevice,
-  IN struct _DEVICE_OBJECT  *TargetDevice);
+NTKERNELAPI
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLockForDpc(
+  IN OUT PKSPIN_LOCK SpinLock,
+  OUT PKLOCK_QUEUE_HANDLE LockHandle);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN BOOLEAN  Wait,
-  OUT struct _FILE_NETWORK_OPEN_INFORMATION  *Buffer,
-  OUT struct _IO_STATUS_BLOCK  *IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+VOID
+FASTCALL
+KeReleaseInStackQueuedSpinLockForDpc(
+  IN PKLOCK_QUEUE_HANDLE LockHandle);
 
-typedef NTSTATUS
-(DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  EndingOffset,
-  OUT struct _ERESOURCE  **ResourceToRelease,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeQueryDpcWatchdogInformation(
+  OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_MDL_READ)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN ULONG  Length,
-  IN ULONG  LockKey,
-  OUT PMDL  *MdlChain,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+#if defined(SINGLE_GROUP_LEGACY_API)
+NTKERNELAPI
+KAFFINITY
+NTAPI
+KeSetSystemAffinityThreadEx(
+  IN KAFFINITY Affinity);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_MDL_READ_COMPLETE)(
-  IN struct _FILE_OBJECT *FileObject,
-  IN PMDL MdlChain,
-  IN struct _DEVICE_OBJECT *DeviceObject);
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryActiveProcessorCount(
+  OUT PKAFFINITY ActiveProcessors OPTIONAL);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN ULONG  Length,
-  IN ULONG  LockKey,
-  OUT PMDL  *MdlChain,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryMaximumProcessorCount(
+  VOID);
+#endif
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN PMDL  MdlChain,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+#endif /*  (NTDDI_VERSION >= NTDDI_VISTA) */
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_READ_COMPRESSED)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN ULONG  Length,
-  IN ULONG  LockKey,
-  OUT PVOID  Buffer,
-  OUT PMDL  *MdlChain,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  OUT struct _COMPRESSED_DATA_INFO  *CompressedDataInfo,
-  IN ULONG  CompressedDataInfoLength,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+#if (NTDDI_VERSION >= NTDDI_WS08)
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_WRITE_COMPRESSED)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN ULONG  Length,
-  IN ULONG  LockKey,
-  IN PVOID  Buffer,
-  OUT PMDL  *MdlChain,
-  OUT PIO_STATUS_BLOCK  IoStatus,
-  IN struct _COMPRESSED_DATA_INFO  *CompressedDataInfo,
-  IN ULONG  CompressedDataInfoLength,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+PVOID
+KeRegisterProcessorChangeCallback(
+  IN PPROCESSOR_CALLBACK_FUNCTION CallbackFunction,
+  IN PVOID CallbackContext OPTIONAL,
+  IN ULONG Flags);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PMDL  MdlChain,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+VOID
+KeDeregisterProcessorChangeCallback(
+  IN PVOID CallbackHandle);
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN PLARGE_INTEGER  FileOffset,
-  IN PMDL  MdlChain,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+#endif /* (NTDDI_VERSION >= NTDDI_WS08) */
 
-typedef BOOLEAN
-(DDKAPI *PFAST_IO_QUERY_OPEN)(
-  IN struct _IRP  *Irp,
-  OUT PFILE_NETWORK_OPEN_INFORMATION  NetworkInformation,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+#if (NTDDI_VERSION >= NTDDI_WIN7)
 
-typedef NTSTATUS
-(DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN struct _ERESOURCE  *ResourceToRelease,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+ULONG64
+NTAPI
+KeQueryTotalCycleTimeProcess(
+  IN OUT PKPROCESS Process,
+  OUT PULONG64 CycleTimeStamp);
 
-typedef NTSTATUS
-(DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)(
-  IN struct _FILE_OBJECT  *FileObject,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+ULONG64
+NTAPI
+KeQueryTotalCycleTimeThread(
+  IN OUT PKTHREAD Thread,
+  OUT PULONG64 CycleTimeStamp);
 
-typedef NTSTATUS
-(DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) (
-  IN struct _FILE_OBJECT  *FileObject,
-  IN struct _DEVICE_OBJECT  *DeviceObject);
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeSetTargetProcessorDpcEx(
+  IN OUT PKDPC Dpc,
+  IN PPROCESSOR_NUMBER ProcNumber);
 
-typedef struct _FAST_IO_DISPATCH {
-  ULONG  SizeOfFastIoDispatch;
-  PFAST_IO_CHECK_IF_POSSIBLE  FastIoCheckIfPossible;
-  PFAST_IO_READ  FastIoRead;
-  PFAST_IO_WRITE  FastIoWrite;
-  PFAST_IO_QUERY_BASIC_INFO  FastIoQueryBasicInfo;
-  PFAST_IO_QUERY_STANDARD_INFO  FastIoQueryStandardInfo;
-  PFAST_IO_LOCK  FastIoLock;
-  PFAST_IO_UNLOCK_SINGLE  FastIoUnlockSingle;
-  PFAST_IO_UNLOCK_ALL  FastIoUnlockAll;
-  PFAST_IO_UNLOCK_ALL_BY_KEY  FastIoUnlockAllByKey;
-  PFAST_IO_DEVICE_CONTROL  FastIoDeviceControl;
-  PFAST_IO_ACQUIRE_FILE  AcquireFileForNtCreateSection;
-  PFAST_IO_RELEASE_FILE  ReleaseFileForNtCreateSection;
-  PFAST_IO_DETACH_DEVICE  FastIoDetachDevice;
-  PFAST_IO_QUERY_NETWORK_OPEN_INFO  FastIoQueryNetworkOpenInfo;
-  PFAST_IO_ACQUIRE_FOR_MOD_WRITE  AcquireForModWrite;
-  PFAST_IO_MDL_READ  MdlRead;
-  PFAST_IO_MDL_READ_COMPLETE  MdlReadComplete;
-  PFAST_IO_PREPARE_MDL_WRITE  PrepareMdlWrite;
-  PFAST_IO_MDL_WRITE_COMPLETE  MdlWriteComplete;
-  PFAST_IO_READ_COMPRESSED  FastIoReadCompressed;
-  PFAST_IO_WRITE_COMPRESSED  FastIoWriteCompressed;
-  PFAST_IO_MDL_READ_COMPLETE_COMPRESSED  MdlReadCompleteCompressed;
-  PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED  MdlWriteCompleteCompressed;
-  PFAST_IO_QUERY_OPEN  FastIoQueryOpen;
-  PFAST_IO_RELEASE_FOR_MOD_WRITE  ReleaseForModWrite;
-  PFAST_IO_ACQUIRE_FOR_CCFLUSH  AcquireForCcFlush;
-  PFAST_IO_RELEASE_FOR_CCFLUSH  ReleaseForCcFlush;
-} FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
+NTKERNELAPI
+VOID
+NTAPI
+KeSetSystemGroupAffinityThread(
+  IN PGROUP_AFFINITY Affinity,
+  OUT PGROUP_AFFINITY PreviousAffinity OPTIONAL);
 
-typedef struct _SECTION_OBJECT_POINTERS {
-  PVOID  DataSectionObject;
-  PVOID  SharedCacheMap;
-  PVOID  ImageSectionObject;
-} SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
+NTKERNELAPI
+VOID
+NTAPI
+KeRevertToUserGroupAffinityThread(
+  IN PGROUP_AFFINITY PreviousAffinity);
 
-typedef struct _IO_COMPLETION_CONTEXT {
-  PVOID  Port;
-  PVOID  Key;
-} IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KeSetCoalescableTimer(
+  IN OUT PKTIMER Timer,
+  IN LARGE_INTEGER DueTime,
+  IN ULONG Period,
+  IN ULONG TolerableDelay,
+  IN PKDPC Dpc OPTIONAL);
 
-/* FILE_OBJECT.Flags */
-#define FO_FILE_OPEN                 0x00000001
-#define FO_SYNCHRONOUS_IO            0x00000002
-#define FO_ALERTABLE_IO              0x00000004
-#define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
-#define FO_WRITE_THROUGH             0x00000010
-#define FO_SEQUENTIAL_ONLY           0x00000020
-#define FO_CACHE_SUPPORTED           0x00000040
-#define FO_NAMED_PIPE                0x00000080
-#define FO_STREAM_FILE               0x00000100
-#define FO_MAILSLOT                  0x00000200
-#define FO_GENERATE_AUDIT_ON_CLOSE   0x00000400
-#define FO_QUEUE_IRP_TO_THREAD       0x00000400
-#define FO_DIRECT_DEVICE_OPEN        0x00000800
-#define FO_FILE_MODIFIED             0x00001000
-#define FO_FILE_SIZE_CHANGED         0x00002000
-#define FO_CLEANUP_COMPLETE          0x00004000
-#define FO_TEMPORARY_FILE            0x00008000
-#define FO_DELETE_ON_CLOSE           0x00010000
-#define FO_OPENED_CASE_SENSITIVE     0x00020000
-#define FO_HANDLE_CREATED            0x00040000
-#define FO_FILE_FAST_IO_READ         0x00080000
-#define FO_RANDOM_ACCESS             0x00100000
-#define FO_FILE_OPEN_CANCELLED       0x00200000
-#define FO_VOLUME_OPEN               0x00400000
-#define FO_REMOTE_ORIGIN             0x01000000
-#define FO_DISALLOW_EXCLUSIVE        0x02000000
-#define FO_SKIP_COMPLETION_PORT      0x02000000
-#define FO_SKIP_SET_EVENT            0x04000000
-#define FO_SKIP_SET_FAST_IO          0x08000000
+NTKERNELAPI
+ULONGLONG
+NTAPI
+KeQueryUnbiasedInterruptTime(
+  VOID);
 
-/* VPB.Flags */
-#define VPB_MOUNTED                       0x0001
-#define VPB_LOCKED                        0x0002
-#define VPB_PERSISTENT                    0x0004
-#define VPB_REMOVE_PENDING                0x0008
-#define VPB_RAW_MOUNT                     0x0010
-#define VPB_DIRECT_WRITES_ALLOWED         0x0020
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryActiveProcessorCountEx(
+  IN USHORT GroupNumber);
 
-/* IRP.Flags */
+NTKERNELAPI
+ULONG
+NTAPI
+KeQueryMaximumProcessorCountEx(
+  IN USHORT GroupNumber);
 
-#define SL_FORCE_ACCESS_CHECK             0x01
-#define SL_OPEN_PAGING_FILE               0x02
-#define SL_OPEN_TARGET_DIRECTORY          0x04
-#define SL_CASE_SENSITIVE                 0x80
+NTKERNELAPI
+USHORT
+NTAPI
+KeQueryActiveGroupCount(
+  VOID);
 
-#define SL_KEY_SPECIFIED                  0x01
-#define SL_OVERRIDE_VERIFY_VOLUME         0x02
-#define SL_WRITE_THROUGH                  0x04
-#define SL_FT_SEQUENTIAL_WRITE            0x08
+NTKERNELAPI
+USHORT
+NTAPI
+KeQueryMaximumGroupCount(
+  VOID);
 
-#define SL_FAIL_IMMEDIATELY               0x01
-#define SL_EXCLUSIVE_LOCK                 0x02
+NTKERNELAPI
+KAFFINITY
+NTAPI
+KeQueryGroupAffinity 
+  IN USHORT GroupNumber);
 
-#define SL_RESTART_SCAN                   0x01
-#define SL_RETURN_SINGLE_ENTRY            0x02
-#define SL_INDEX_SPECIFIED                0x04
+NTKERNELAPI
+ULONG
+NTAPI
+KeGetCurrentProcessorNumberEx(
+  OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL);
 
-#define SL_WATCH_TREE                     0x01
+NTKERNELAPI
+VOID
+NTAPI
+KeQueryNodeActiveAffinity(
+  IN USHORT NodeNumber,
+  OUT PGROUP_AFFINITY Affinity OPTIONAL,
+  OUT PUSHORT Count OPTIONAL);
 
-#define SL_ALLOW_RAW_MOUNT                0x01
+NTKERNELAPI
+USHORT
+NTAPI
+KeQueryNodeMaximumProcessorCount(
+  IN USHORT NodeNumber);
 
-#define CTL_CODE(DeviceType, Function, Method, Access) \
-  (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
+NTKERNELAPI
+USHORT
+NTAPI
+KeQueryHighestNodeNumber(
+  VOID);
 
-#define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
+NTKERNELAPI
+USHORT
+NTAPI
+KeGetCurrentNodeNumber(
+  VOID);
 
-#define IRP_NOCACHE                     0x00000001
-#define IRP_PAGING_IO                   0x00000002
-#define IRP_MOUNT_COMPLETION            0x00000002
-#define IRP_SYNCHRONOUS_API             0x00000004
-#define IRP_ASSOCIATED_IRP              0x00000008
-#define IRP_BUFFERED_IO                 0x00000010
-#define IRP_DEALLOCATE_BUFFER           0x00000020
-#define IRP_INPUT_OPERATION             0x00000040
-#define IRP_SYNCHRONOUS_PAGING_IO       0x00000040
-#define IRP_CREATE_OPERATION            0x00000080
-#define IRP_READ_OPERATION              0x00000100
-#define IRP_WRITE_OPERATION             0x00000200
-#define IRP_CLOSE_OPERATION             0x00000400
-#define IRP_DEFER_IO_COMPLETION         0x00000800
-#define IRP_OB_QUERY_NAME               0x00001000
-#define IRP_HOLD_DEVICE_QUEUE           0x00002000
+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);
 
-#define IRP_QUOTA_CHARGED                 0x01
-#define IRP_ALLOCATED_MUST_SUCCEED        0x02
-#define IRP_ALLOCATED_FIXED_SIZE          0x04
-#define IRP_LOOKASIDE_ALLOCATION          0x08
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeSaveExtendedProcessorState(
+  IN ULONG64 Mask,
+  OUT PXSTATE_SAVE XStateSave);
 
-/*
-** IRP function codes
-*/
+NTKERNELAPI
+VOID
+NTAPI
+KeRestoreExtendedProcessorState(
+  IN PXSTATE_SAVE XStateSave);
 
-#define IRP_MJ_CREATE                     0x00
-#define IRP_MJ_CREATE_NAMED_PIPE          0x01
-#define IRP_MJ_CLOSE                      0x02
-#define IRP_MJ_READ                       0x03
-#define IRP_MJ_WRITE                      0x04
-#define IRP_MJ_QUERY_INFORMATION          0x05
-#define IRP_MJ_SET_INFORMATION            0x06
-#define IRP_MJ_QUERY_EA                   0x07
-#define IRP_MJ_SET_EA                     0x08
-#define IRP_MJ_FLUSH_BUFFERS              0x09
-#define IRP_MJ_QUERY_VOLUME_INFORMATION   0x0a
-#define IRP_MJ_SET_VOLUME_INFORMATION     0x0b
-#define IRP_MJ_DIRECTORY_CONTROL          0x0c
-#define IRP_MJ_FILE_SYSTEM_CONTROL        0x0d
-#define IRP_MJ_DEVICE_CONTROL             0x0e
-#define IRP_MJ_INTERNAL_DEVICE_CONTROL    0x0f
-#define IRP_MJ_SCSI                       0x0f
-#define IRP_MJ_SHUTDOWN                   0x10
-#define IRP_MJ_LOCK_CONTROL               0x11
-#define IRP_MJ_CLEANUP                    0x12
-#define IRP_MJ_CREATE_MAILSLOT            0x13
-#define IRP_MJ_QUERY_SECURITY             0x14
-#define IRP_MJ_SET_SECURITY               0x15
-#define IRP_MJ_POWER                      0x16
-#define IRP_MJ_SYSTEM_CONTROL             0x17
-#define IRP_MJ_DEVICE_CHANGE              0x18
-#define IRP_MJ_QUERY_QUOTA                0x19
-#define IRP_MJ_SET_QUOTA                  0x1a
-#define IRP_MJ_PNP                        0x1b
-#define IRP_MJ_PNP_POWER                  0x1b
-#define IRP_MJ_MAXIMUM_FUNCTION           0x1b
+#endif /*  (NTDDI_VERSION >= NTDDI_WIN7) */
 
-#define IRP_MN_SCSI_CLASS                 0x01
+#if defined(_X86_)
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeSaveFloatingPointState(
+  OUT PKFLOATING_SAVE  FloatSave);
 
-#define IRP_MN_START_DEVICE               0x00
-#define IRP_MN_QUERY_REMOVE_DEVICE        0x01
-#define IRP_MN_REMOVE_DEVICE              0x02
-#define IRP_MN_CANCEL_REMOVE_DEVICE       0x03
-#define IRP_MN_STOP_DEVICE                0x04
-#define IRP_MN_QUERY_STOP_DEVICE          0x05
-#define IRP_MN_CANCEL_STOP_DEVICE         0x06
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeRestoreFloatingPointState(
+  IN PKFLOATING_SAVE  FloatSave);
+#endif
 
-#define IRP_MN_QUERY_DEVICE_RELATIONS       0x07
-#define IRP_MN_QUERY_INTERFACE              0x08
-#define IRP_MN_QUERY_CAPABILITIES           0x09
-#define IRP_MN_QUERY_RESOURCES              0x0A
-#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS  0x0B
-#define IRP_MN_QUERY_DEVICE_TEXT            0x0C
-#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
+#if defined(_IA64_)
+FORCEINLINE
+VOID
+KeFlushWriteBuffer(VOID)
+{
+  __mf ();
+  return;
+}
+#else
+NTHALAPI
+VOID
+NTAPI
+KeFlushWriteBuffer(VOID);
+#endif
 
-#define IRP_MN_READ_CONFIG                  0x0F
-#define IRP_MN_WRITE_CONFIG                 0x10
-#define IRP_MN_EJECT                        0x11
-#define IRP_MN_SET_LOCK                     0x12
-#define IRP_MN_QUERY_ID                     0x13
-#define IRP_MN_QUERY_PNP_DEVICE_STATE       0x14
-#define IRP_MN_QUERY_BUS_INFORMATION        0x15
-#define IRP_MN_DEVICE_USAGE_NOTIFICATION    0x16
-#define IRP_MN_SURPRISE_REMOVAL             0x17
+/*
+ * VOID
+ * KeFlushIoBuffers(
+ *   IN PMDL  Mdl,
+ *   IN BOOLEAN  ReadOperation,
+ *   IN BOOLEAN  DmaOperation)
+ */
+#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
 
-#define IRP_MN_WAIT_WAKE                  0x00
-#define IRP_MN_POWER_SEQUENCE             0x01
-#define IRP_MN_SET_POWER                  0x02
-#define IRP_MN_QUERY_POWER                0x03
+#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 IRP_MN_QUERY_ALL_DATA             0x00
-#define IRP_MN_QUERY_SINGLE_INSTANCE      0x01
-#define IRP_MN_CHANGE_SINGLE_INSTANCE     0x02
-#define IRP_MN_CHANGE_SINGLE_ITEM         0x03
-#define IRP_MN_ENABLE_EVENTS              0x04
-#define IRP_MN_DISABLE_EVENTS             0x05
-#define IRP_MN_ENABLE_COLLECTION          0x06
-#define IRP_MN_DISABLE_COLLECTION         0x07
-#define IRP_MN_REGINFO                    0x08
-#define IRP_MN_EXECUTE_METHOD             0x09
+#if (NTDDI_VERSION >= NTDDI_WS03)
+NTKERNELAPI
+BOOLEAN
+FASTCALL
+KeTestSpinLock(
+    IN PKSPIN_LOCK SpinLock
+);
+#endif
 
-#define IRP_MN_REGINFO_EX                 0x0b
+NTHALAPI
+KIRQL
+NTAPI
+KeGetCurrentIrql(
+    VOID);
 
-typedef struct _FILE_OBJECT
+#if defined(_M_AMD64)
+FORCEINLINE
+PKTHREAD
+KeGetCurrentThread (
+  VOID)
 {
-    CSHORT Type;
-    CSHORT Size;
-    PDEVICE_OBJECT DeviceObject;
-    PVPB Vpb;
-    PVOID FsContext;
-    PVOID FsContext2;
-    PSECTION_OBJECT_POINTERS SectionObjectPointer;
-    PVOID PrivateCacheMap;
-    NTSTATUS FinalStatus;
-    struct _FILE_OBJECT *RelatedFileObject;
-    BOOLEAN LockOperation;
-    BOOLEAN DeletePending;
-    BOOLEAN ReadAccess;
-    BOOLEAN WriteAccess;
-    BOOLEAN DeleteAccess;
-    BOOLEAN SharedRead;
-    BOOLEAN SharedWrite;
-    BOOLEAN SharedDelete;
-    ULONG Flags;
-    UNICODE_STRING FileName;
-    LARGE_INTEGER CurrentByteOffset;
-    volatile ULONG Waiters;
-    volatile ULONG Busy;
-    PVOID LastLock;
-    KEVENT Lock;
-    KEVENT Event;
-    volatile PIO_COMPLETION_CONTEXT CompletionContext;
-    KSPIN_LOCK IrpListLock;
-    LIST_ENTRY IrpList;
-    volatile PVOID FileObjectExtension;
-} FILE_OBJECT, *PFILE_OBJECT;
+    return (struct _KTHREAD *)__readgsqword(0x188);
+}
+#endif
 
-typedef struct _IO_ERROR_LOG_PACKET {
-  UCHAR  MajorFunctionCode;
-  UCHAR  RetryCount;
-  USHORT  DumpDataSize;
-  USHORT  NumberOfStrings;
-  USHORT  StringOffset;
-  USHORT  EventCategory;
-  NTSTATUS  ErrorCode;
-  ULONG  UniqueErrorValue;
-  NTSTATUS  FinalStatus;
-  ULONG  SequenceNumber;
-  ULONG  IoControlCode;
-  LARGE_INTEGER  DeviceOffset;
-  ULONG  DumpData[1];
-} IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
+#if defined(_M_IX86) || defined(_M_IA64)
+NTSYSAPI
+PKTHREAD
+NTAPI
+KeGetCurrentThread(
+  VOID);
+#endif
 
-typedef struct _IO_ERROR_LOG_MESSAGE {
-  USHORT  Type;
-  USHORT  Size;
-  USHORT  DriverNameLength;
-  LARGE_INTEGER  TimeStamp;
-  ULONG  DriverNameOffset;
-  IO_ERROR_LOG_PACKET  EntryData;
-} IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
+/*
+ * VOID
+ * KeInitializeCallbackRecord(
+ *   IN PKBUGCHECK_CALLBACK_RECORD  CallbackRecord)
+ */
+#define KeInitializeCallbackRecord(CallbackRecord) \
+  CallbackRecord->State = BufferEmpty;
 
-#define ERROR_LOG_LIMIT_SIZE               240
-#define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
-                                            sizeof(IO_ERROR_LOG_PACKET) + \
-                                            (sizeof(WCHAR) * 40))
-#define ERROR_LOG_MESSAGE_LIMIT_SIZE                                          \
-    (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
-#define IO_ERROR_LOG_MESSAGE_LENGTH                                           \
-    ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ?           \
-        ERROR_LOG_MESSAGE_LIMIT_SIZE :                                        \
-        PORT_MAXIMUM_MESSAGE_LENGTH)
-#define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH -                 \
-                                IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
+#if DBG
 
-typedef enum _DMA_WIDTH {
-  Width8Bits,
-  Width16Bits,
-  Width32Bits,
-  MaximumDmaWidth
-} DMA_WIDTH, *PDMA_WIDTH;
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+#define PAGED_ASSERT( exp ) NT_ASSERT( exp )
+#else
+#define PAGED_ASSERT( exp ) ASSERT( exp )
+#endif
 
-typedef enum _DMA_SPEED {
-  Compatible,
-  TypeA,
-  TypeB,
-  TypeC,
-  TypeF,
-  MaximumDmaSpeed
-} DMA_SPEED, *PDMA_SPEED;
+#define PAGED_CODE() { \
+  if (KeGetCurrentIrql() > APC_LEVEL) { \
+    KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \
+    PAGED_ASSERT(FALSE); \
+  } \
+}
 
-/* DEVICE_DESCRIPTION.Version */
+#else
 
-#define DEVICE_DESCRIPTION_VERSION        0x0000
-#define DEVICE_DESCRIPTION_VERSION1       0x0001
-#define DEVICE_DESCRIPTION_VERSION2       0x0002
+#define PAGED_CODE()
 
-typedef struct _DEVICE_DESCRIPTION {
-  ULONG  Version;
-  BOOLEAN  Master;
-  BOOLEAN  ScatterGather;
-  BOOLEAN  DemandMode;
-  BOOLEAN  AutoInitialize;
-  BOOLEAN  Dma32BitAddresses;
-  BOOLEAN  IgnoreCount;
-  BOOLEAN  Reserved1;
-  BOOLEAN  Dma64BitAddresses;
-  ULONG  BusNumber;
-  ULONG  DmaChannel;
-  INTERFACE_TYPE  InterfaceType;
-  DMA_WIDTH  DmaWidth;
-  DMA_SPEED  DmaSpeed;
-  ULONG  MaximumLength;
-  ULONG  DmaPort;
-} DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
+#endif
 
-typedef enum _DEVICE_RELATION_TYPE {
-  BusRelations,
-  EjectionRelations,
-  PowerRelations,
-  RemovalRelations,
-  TargetDeviceRelation,
-  SingleBusRelations,
-  TransportRelations
-} DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
+#define PAGED_CODE_LOCKED() NOP_FUNCTION;
 
-typedef struct _DEVICE_RELATIONS {
-  ULONG  Count;
-  PDEVICE_OBJECT Objects[1];
-} DEVICE_RELATIONS, *PDEVICE_RELATIONS;
 
-typedef struct _DEVOBJ_EXTENSION
-{
-    CSHORT Type;
-    USHORT Size;
-    PDEVICE_OBJECT DeviceObject;
-} DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
-typedef struct _SCATTER_GATHER_ELEMENT {
-  PHYSICAL_ADDRESS  Address;
-  ULONG  Length;
-  ULONG_PTR  Reserved;
-} SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
+NTKERNELAPI
+VOID
+NTAPI
+ProbeForRead(
+  IN CONST VOID *Address, /* CONST is added */
+  IN SIZE_T Length,
+  IN ULONG Alignment);
 
-#if defined(_MSC_EXTENSIONS)
+NTKERNELAPI
+VOID
+NTAPI
+ProbeForWrite(
+  IN PVOID Address,
+  IN SIZE_T Length,
+  IN ULONG Alignment);
 
-#if _MSC_VER >= 1200
-#pragma warning(push)
 #endif
-#pragma warning(disable:4200)
-typedef struct _SCATTER_GATHER_LIST {
-  ULONG  NumberOfElements;
-  ULONG_PTR  Reserved;
-  SCATTER_GATHER_ELEMENT  Elements[1];
-} SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
 
-#if _MSC_VER >= 1200
-#pragma warning(pop)
-#else
-#pragma warning(default:4200)
-#endif
+#if defined(_X86_) || defined(_AMD64_)
 
-#else
+/* x86 and x64 performs a 0x2C interrupt */
+#define DbgRaiseAssertionFailure __int2c
 
-struct _SCATTER_GATHER_LIST;
-typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
+#elif defined(_ARM_)
 
-#endif
+//
+// TODO
+//
 
-typedef NTSTATUS
-(DDKAPI DRIVER_ADD_DEVICE)(
-  IN struct _DRIVER_OBJECT  *DriverObject,
-  IN struct _DEVICE_OBJECT  *PhysicalDeviceObject);
-typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
+#else
+#error Unsupported Architecture
+#endif
 
-typedef struct _DRIVER_EXTENSION {
-  struct _DRIVER_OBJECT  *DriverObject;
-  PDRIVER_ADD_DEVICE  AddDevice;
-  ULONG  Count;
-  UNICODE_STRING  ServiceKeyName;
-} DRIVER_EXTENSION, *PDRIVER_EXTENSION;
+/******************************************************************************
+ *                       Memory manager Functions                             *
+ ******************************************************************************/
 
-#define DRVO_UNLOAD_INVOKED               0x00000001
-#define DRVO_LEGACY_DRIVER                0x00000002
-#define DRVO_BUILTIN_DRIVER               0x00000004
+/*
+ * Alignment Macros
+ */
+#define ALIGN_DOWN_BY(size, align) \
+    ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
 
-typedef NTSTATUS
-(DDKAPI DRIVER_INITIALIZE)(
-  IN struct _DRIVER_OBJECT  *DriverObject,
-  IN PUNICODE_STRING  RegistryPath);
-typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE;
+#define ALIGN_UP_BY(size, align) \
+    (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
 
-typedef VOID
-(DDKAPI DRIVER_STARTIO)(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN struct _IRP  *Irp);
-typedef DRIVER_STARTIO *PDRIVER_STARTIO;
+#define ALIGN_DOWN_POINTER_BY(ptr, align) \
+    ((PVOID)ALIGN_DOWN_BY(ptr, align))
 
-typedef VOID
-(DDKAPI DRIVER_UNLOAD)(
-  IN struct _DRIVER_OBJECT  *DriverObject);
-typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
+#define ALIGN_UP_POINTER_BY(ptr, align) \
+    ((PVOID)ALIGN_UP_BY(ptr, align))
 
-typedef NTSTATUS
-(DDKAPI DRIVER_DISPATCH)(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN struct _IRP  *Irp);
-typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
+#define ALIGN_DOWN(size, type) \
+    ALIGN_DOWN_BY(size, sizeof(type))
 
-typedef struct _DRIVER_OBJECT {
-  CSHORT  Type;
-  CSHORT  Size;
-  PDEVICE_OBJECT  DeviceObject;
-  ULONG  Flags;
-  PVOID  DriverStart;
-  ULONG  DriverSize;
-  PVOID  DriverSection;
-  PDRIVER_EXTENSION  DriverExtension;
-  UNICODE_STRING  DriverName;
-  PUNICODE_STRING  HardwareDatabase;
-  struct _FAST_IO_DISPATCH *FastIoDispatch;
-  PDRIVER_INITIALIZE  DriverInit;
-  PDRIVER_STARTIO  DriverStartIo;
-  PDRIVER_UNLOAD  DriverUnload;
-  PDRIVER_DISPATCH  MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
-} DRIVER_OBJECT;
-typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
+#define ALIGN_UP(size, type) \
+    ALIGN_UP_BY(size, sizeof(type))
 
-typedef struct _DMA_ADAPTER {
-  USHORT  Version;
-  USHORT  Size;
-  struct _DMA_OPERATIONS*  DmaOperations;
-} DMA_ADAPTER, *PDMA_ADAPTER;
+#define ALIGN_DOWN_POINTER(ptr, type) \
+    ALIGN_DOWN_POINTER_BY(ptr, sizeof(type))
 
-typedef VOID
-(DDKAPI *PPUT_DMA_ADAPTER)(
-  IN PDMA_ADAPTER  DmaAdapter);
+#define ALIGN_UP_POINTER(ptr, type) \
+    ALIGN_UP_POINTER_BY(ptr, sizeof(type))
 
-typedef PVOID
-(DDKAPI *PALLOCATE_COMMON_BUFFER)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN ULONG  Length,
-  OUT PPHYSICAL_ADDRESS  LogicalAddress,
-  IN BOOLEAN  CacheEnabled);
+/* ULONG
+ * BYTE_OFFSET(
+ *   IN PVOID  Va)
+ */
+#define BYTE_OFFSET(Va) \
+  ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
 
-typedef VOID
-(DDKAPI *PFREE_COMMON_BUFFER)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN ULONG  Length,
-  IN PHYSICAL_ADDRESS  LogicalAddress,
-  IN PVOID  VirtualAddress,
-  IN BOOLEAN  CacheEnabled);
+/* ULONG
+ * BYTES_TO_PAGES(
+ *   IN ULONG  Size)
+ */
+#define BYTES_TO_PAGES(Size) \
+  (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0))
 
-typedef NTSTATUS
-(DDKAPI *PALLOCATE_ADAPTER_CHANNEL)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN ULONG  NumberOfMapRegisters,
-  IN PDRIVER_CONTROL  ExecutionRoutine,
-  IN PVOID  Context);
+/* PVOID
+ * PAGE_ALIGN(
+ *   IN PVOID  Va)
+ */
+#define PAGE_ALIGN(Va) \
+  ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
 
-typedef BOOLEAN
-(DDKAPI *PFLUSH_ADAPTER_BUFFERS)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN PMDL  Mdl,
-  IN PVOID  MapRegisterBase,
-  IN PVOID  CurrentVa,
-  IN ULONG  Length,
-  IN BOOLEAN  WriteToDevice);
+/* ULONG_PTR
+ * ROUND_TO_PAGES(
+ *   IN ULONG_PTR  Size)
+ */
+#define ROUND_TO_PAGES(Size) \
+  (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
 
-typedef VOID
-(DDKAPI *PFREE_ADAPTER_CHANNEL)(
-  IN PDMA_ADAPTER  DmaAdapter);
+/*
+ * ULONG
+ * MmGetMdlByteCount(
+ *   IN PMDL  Mdl)
+ */
+#define MmGetMdlByteCount(_Mdl) \
+  ((_Mdl)->ByteCount)
 
-typedef VOID
-(DDKAPI *PFREE_MAP_REGISTERS)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  PVOID  MapRegisterBase,
-  ULONG  NumberOfMapRegisters);
+/*
+ * ULONG
+ * MmGetMdlByteOffset(
+ *   IN PMDL  Mdl)
+ */
+#define MmGetMdlByteOffset(_Mdl) \
+  ((_Mdl)->ByteOffset)
 
-typedef PHYSICAL_ADDRESS
-(DDKAPI *PMAP_TRANSFER)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN PMDL  Mdl,
-  IN PVOID  MapRegisterBase,
-  IN PVOID  CurrentVa,
-  IN OUT PULONG  Length,
-  IN BOOLEAN  WriteToDevice);
+/*
+ * PPFN_NUMBER
+ * MmGetMdlPfnArray(
+ *   IN PMDL  Mdl)
+ */
+#define MmGetMdlPfnArray(_Mdl) \
+  ((PPFN_NUMBER) ((_Mdl) + 1))
 
-typedef ULONG
-(DDKAPI *PGET_DMA_ALIGNMENT)(
-  IN PDMA_ADAPTER  DmaAdapter);
+/*
+ * PVOID
+ * MmGetMdlVirtualAddress(
+ *   IN PMDL  Mdl)
+ */
+#define MmGetMdlVirtualAddress(_Mdl) \
+  ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))
 
-typedef ULONG
-(DDKAPI *PREAD_DMA_COUNTER)(
-  IN PDMA_ADAPTER  DmaAdapter);
+#define MmGetProcedureAddress(Address) (Address)
 
-typedef VOID
-(DDKAPI *PDRIVER_LIST_CONTROL)(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN struct _IRP  *Irp,
-  IN struct _SCATTER_GATHER_LIST  *ScatterGather,
-  IN PVOID  Context);
+/* 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)))
 
-typedef NTSTATUS
-(DDKAPI *PGET_SCATTER_GATHER_LIST)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN PMDL  Mdl,
-  IN PVOID  CurrentVa,
-  IN ULONG  Length,
-  IN PDRIVER_LIST_CONTROL  ExecutionRoutine,
-  IN PVOID  Context,
-  IN BOOLEAN  WriteToDevice);
+/* 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)))
 
-typedef VOID
-(DDKAPI *PPUT_SCATTER_GATHER_LIST)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN PSCATTER_GATHER_LIST  ScatterGather,
-  IN BOOLEAN  WriteToDevice);
+/*
+ * 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; \
+}
 
-typedef NTSTATUS
-(DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN PMDL  Mdl  OPTIONAL,
-  IN PVOID  CurrentVa,
-  IN ULONG  Length,
-  OUT PULONG  ScatterGatherListSize,
-  OUT PULONG  pNumberOfMapRegisters  OPTIONAL);
+/*
+ * 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); \
+  } \
+}
 
-typedef NTSTATUS
-(DDKAPI *PBUILD_SCATTER_GATHER_LIST)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN PDEVICE_OBJECT  DeviceObject,
-  IN PMDL  Mdl,
-  IN PVOID  CurrentVa,
-  IN ULONG  Length,
-  IN PDRIVER_LIST_CONTROL  ExecutionRoutine,
-  IN PVOID  Context,
-  IN BOOLEAN  WriteToDevice,
-  IN PVOID  ScatterGatherBuffer,
-  IN ULONG  ScatterGatherLength);
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
-typedef NTSTATUS
-(DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
-  IN PDMA_ADAPTER  DmaAdapter,
-  IN PSCATTER_GATHER_LIST  ScatterGather,
-  IN PMDL  OriginalMdl,
-  OUT PMDL  *TargetMdl);
+NTKERNELAPI
+PVOID
+NTAPI
+MmAllocateContiguousMemory(
+  IN SIZE_T  NumberOfBytes,
+  IN PHYSICAL_ADDRESS  HighestAcceptableAddress);
 
-typedef struct _DMA_OPERATIONS {
-  ULONG  Size;
-  PPUT_DMA_ADAPTER  PutDmaAdapter;
-  PALLOCATE_COMMON_BUFFER  AllocateCommonBuffer;
-  PFREE_COMMON_BUFFER  FreeCommonBuffer;
-  PALLOCATE_ADAPTER_CHANNEL  AllocateAdapterChannel;
-  PFLUSH_ADAPTER_BUFFERS  FlushAdapterBuffers;
-  PFREE_ADAPTER_CHANNEL  FreeAdapterChannel;
-  PFREE_MAP_REGISTERS  FreeMapRegisters;
-  PMAP_TRANSFER  MapTransfer;
-  PGET_DMA_ALIGNMENT  GetDmaAlignment;
-  PREAD_DMA_COUNTER  ReadDmaCounter;
-  PGET_SCATTER_GATHER_LIST  GetScatterGatherList;
-  PPUT_SCATTER_GATHER_LIST  PutScatterGatherList;
-  PCALCULATE_SCATTER_GATHER_LIST_SIZE  CalculateScatterGatherList;
-  PBUILD_SCATTER_GATHER_LIST  BuildScatterGatherList;
-  PBUILD_MDL_FROM_SCATTER_GATHER_LIST  BuildMdlFromScatterGatherList;
-} DMA_OPERATIONS, *PDMA_OPERATIONS;
+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);
 
-typedef struct _IO_RESOURCE_DESCRIPTOR {
-  UCHAR  Option;
-  UCHAR  Type;
-  UCHAR  ShareDisposition;
-  UCHAR  Spare1;
-  USHORT  Flags;
-  USHORT  Spare2;
-  union {
-    struct {
-      ULONG  Length;
-      ULONG  Alignment;
-      PHYSICAL_ADDRESS  MinimumAddress;
-      PHYSICAL_ADDRESS  MaximumAddress;
-    } Port;
-    struct {
-      ULONG  Length;
-      ULONG  Alignment;
-      PHYSICAL_ADDRESS  MinimumAddress;
-      PHYSICAL_ADDRESS  MaximumAddress;
-    } Memory;
-    struct {
-      ULONG  MinimumVector;
-      ULONG  MaximumVector;
-    } Interrupt;
-    struct {
-      ULONG  MinimumChannel;
-      ULONG  MaximumChannel;
-    } Dma;
-    struct {
-      ULONG  Length;
-      ULONG  Alignment;
-      PHYSICAL_ADDRESS  MinimumAddress;
-      PHYSICAL_ADDRESS  MaximumAddress;
-    } Generic;
-    struct {
-      ULONG  Data[3];
-    } DevicePrivate;
-    struct {
-      ULONG  Length;
-      ULONG  MinBusNumber;
-      ULONG  MaxBusNumber;
-      ULONG  Reserved;
-    } BusNumber;
-    struct {
-      ULONG  Priority;
-      ULONG  Reserved1;
-      ULONG  Reserved2;
-    } ConfigData;
-  } u;
-} IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
+NTKERNELAPI
+PMDL
+NTAPI
+MmAllocatePagesForMdl(
+  IN PHYSICAL_ADDRESS  LowAddress,
+  IN PHYSICAL_ADDRESS  HighAddress,
+  IN PHYSICAL_ADDRESS  SkipBytes,
+  IN SIZE_T  TotalBytes);
 
-typedef struct _IO_RESOURCE_LIST {
-  USHORT  Version;
-  USHORT  Revision;
-  ULONG  Count;
-  IO_RESOURCE_DESCRIPTOR  Descriptors[1];
-} IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
+NTKERNELAPI
+VOID
+NTAPI
+MmBuildMdlForNonPagedPool(
+  IN OUT PMDLX  MemoryDescriptorList);
 
-typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
-  ULONG  ListSize;
-  INTERFACE_TYPE  InterfaceType;
-  ULONG  BusNumber;
-  ULONG  SlotNumber;
-  ULONG  Reserved[3];
-  ULONG  AlternativeLists;
-  IO_RESOURCE_LIST  List[1];
-} IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
+//DECLSPEC_DEPRECATED_DDK
+NTKERNELAPI
+PMDL
+NTAPI
+MmCreateMdl(
+  IN PMDL  MemoryDescriptorList  OPTIONAL,
+  IN PVOID  Base,
+  IN SIZE_T  Length);
 
-typedef VOID
-(DDKAPI DRIVER_CANCEL)(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN struct _IRP  *Irp);
-typedef DRIVER_CANCEL *PDRIVER_CANCEL;
+NTKERNELAPI
+VOID
+NTAPI
+MmFreeContiguousMemory(
+  IN PVOID  BaseAddress);
 
-typedef struct _IRP {
-  CSHORT  Type;
-  USHORT  Size;
-  struct _MDL  *MdlAddress;
-  ULONG  Flags;
-  union {
-    struct _IRP  *MasterIrp;
-    volatile LONG  IrpCount;
-    PVOID  SystemBuffer;
-  } AssociatedIrp;
-  LIST_ENTRY  ThreadListEntry;
-  IO_STATUS_BLOCK  IoStatus;
-  KPROCESSOR_MODE  RequestorMode;
-  BOOLEAN  PendingReturned;
-  CHAR  StackCount;
-  CHAR  CurrentLocation;
-  BOOLEAN  Cancel;
-  KIRQL  CancelIrql;
-  CCHAR  ApcEnvironment;
-  UCHAR  AllocationFlags;
-  PIO_STATUS_BLOCK  UserIosb;
-  PKEVENT  UserEvent;
-  union {
-    struct {
-      _ANONYMOUS_UNION union {      
-        PIO_APC_ROUTINE  UserApcRoutine;
-        PVOID IssuingProcess;
-      } DUMMYUNIONNAME;
-      PVOID  UserApcContext;
-    } AsynchronousParameters;
-    LARGE_INTEGER  AllocationSize;
-  } Overlay;
-  volatile PDRIVER_CANCEL  CancelRoutine;
-  PVOID  UserBuffer;
-  union {
-    struct {
-      _ANONYMOUS_UNION union {
-        KDEVICE_QUEUE_ENTRY  DeviceQueueEntry;
-        _ANONYMOUS_STRUCT struct {
-          PVOID  DriverContext[4];
-        } DUMMYSTRUCTNAME;
-      } DUMMYUNIONNAME;
-      PETHREAD  Thread;
-      PCHAR  AuxiliaryBuffer;
-      _ANONYMOUS_STRUCT struct {
-        LIST_ENTRY  ListEntry;
-        _ANONYMOUS_UNION union {
-          struct _IO_STACK_LOCATION  *CurrentStackLocation;
-          ULONG  PacketType;
-        } DUMMYUNIONNAME;
-      } DUMMYSTRUCTNAME;
-      struct _FILE_OBJECT  *OriginalFileObject;
-    } Overlay;
-    KAPC  Apc;
-    PVOID  CompletionKey;
-  } Tail;
-} IRP;
-typedef struct _IRP *PIRP;
+NTKERNELAPI
+VOID
+NTAPI
+MmFreeContiguousMemorySpecifyCache(
+  IN PVOID  BaseAddress,
+  IN SIZE_T  NumberOfBytes,
+  IN MEMORY_CACHING_TYPE  CacheType);
 
-typedef enum _IO_PAGING_PRIORITY {
-  IoPagingPriorityInvalid,
-  IoPagingPriorityNormal,
-  IoPagingPriorityHigh,
-  IoPagingPriorityReserved1,
-  IoPagingPriorityReserved2
-} IO_PAGING_PRIORITY;
+NTKERNELAPI
+VOID
+NTAPI
+MmFreePagesFromMdl(
+  IN PMDLX MemoryDescriptorList);
 
-typedef NTSTATUS
-(DDKAPI IO_COMPLETION_ROUTINE)(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN struct _IRP  *Irp,
-  IN PVOID  Context);
-typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE;
+NTKERNELAPI
+PVOID
+NTAPI
+MmGetSystemRoutineAddress(
+  IN PUNICODE_STRING  SystemRoutineName);
 
-typedef VOID
-(DDKAPI *PIO_DPC_ROUTINE)(
-  IN struct _KDPC  *Dpc,
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN struct _IRP  *Irp,
-  IN PVOID  Context);
+NTKERNELAPI
+LOGICAL
+NTAPI
+MmIsDriverVerifying(
+  IN struct _DRIVER_OBJECT *DriverObject);
 
-typedef NTSTATUS
-(DDKAPI *PMM_DLL_INITIALIZE)(
-  IN PUNICODE_STRING  RegistryPath);
+NTKERNELAPI
+PVOID
+NTAPI
+MmLockPagableDataSection(
+  IN PVOID  AddressWithinSection);
 
-typedef NTSTATUS
-(DDKAPI *PMM_DLL_UNLOAD)(
-  VOID);
+NTKERNELAPI
+PVOID
+NTAPI
+MmMapIoSpace(
+  IN PHYSICAL_ADDRESS  PhysicalAddress,
+  IN SIZE_T  NumberOfBytes,
+  IN MEMORY_CACHING_TYPE  CacheEnable);
 
-typedef BOOLEAN
-(DDKAPI KSERVICE_ROUTINE)(
-  IN struct _KINTERRUPT  *Interrupt,
-  IN PVOID  ServiceContext);
-typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
+NTKERNELAPI
+PVOID
+NTAPI
+MmMapLockedPages(
+  IN PMDL  MemoryDescriptorList,
+  IN KPROCESSOR_MODE  AccessMode);
 
-typedef VOID
-(DDKAPI *PIO_TIMER_ROUTINE)(
-  IN struct _DEVICE_OBJECT  *DeviceObject,
-  IN PVOID  Context);
+NTKERNELAPI
+PVOID
+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);
 
-typedef struct _IO_SECURITY_CONTEXT {
-  PSECURITY_QUALITY_OF_SERVICE  SecurityQos;
-  PACCESS_STATE  AccessState;
-  ACCESS_MASK  DesiredAccess;
-  ULONG  FullCreateOptions;
-} IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
+NTKERNELAPI
+PVOID
+NTAPI
+MmPageEntireDriver(
+  IN PVOID  AddressWithinSection);
 
-struct _IO_CSQ;
+NTKERNELAPI
+VOID
+NTAPI
+MmProbeAndLockPages(
+  IN OUT PMDL  MemoryDescriptorList,
+  IN KPROCESSOR_MODE  AccessMode,
+  IN LOCK_OPERATION  Operation);
 
-typedef struct _IO_CSQ_IRP_CONTEXT {
-  ULONG  Type;
-  struct _IRP  *Irp;
-  struct _IO_CSQ  *Csq;
-} IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
+NTKERNELAPI
+MM_SYSTEMSIZE
+NTAPI
+MmQuerySystemSize(
+  VOID);
 
-typedef VOID
-(DDKAPI *PIO_CSQ_INSERT_IRP)(
-  IN struct _IO_CSQ  *Csq,
-  IN PIRP  Irp);
+NTKERNELAPI
+VOID
+NTAPI
+MmResetDriverPaging(
+  IN PVOID  AddressWithinSection);
 
-typedef VOID
-(DDKAPI *PIO_CSQ_REMOVE_IRP)(
-  IN struct _IO_CSQ  *Csq,
-  IN PIRP  Irp);
+NTKERNELAPI
+SIZE_T
+NTAPI
+MmSizeOfMdl(
+  IN PVOID  Base,
+  IN SIZE_T  Length);
 
-typedef PIRP
-(DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)(
-  IN struct _IO_CSQ  *Csq,
-  IN PIRP  Irp,
-  IN PVOID  PeekContext);
+NTKERNELAPI
+VOID
+NTAPI
+MmUnlockPagableImageSection(
+  IN PVOID  ImageSectionHandle);
 
-typedef VOID
-(DDKAPI *PIO_CSQ_ACQUIRE_LOCK)(
-  IN  struct _IO_CSQ  *Csq,
-  OUT PKIRQL  Irql);
+NTKERNELAPI
+VOID
+NTAPI
+MmUnlockPages(
+  IN OUT PMDL  MemoryDescriptorList);
+
+NTKERNELAPI
+VOID
+NTAPI
+MmUnmapIoSpace(
+  IN PVOID  BaseAddress,
+  IN SIZE_T  NumberOfBytes);
+
+NTKERNELAPI
+VOID
+NTAPI
+MmProbeAndLockProcessPages(
+  IN OUT PMDL  MemoryDescriptorList,
+  IN PEPROCESS  Process,
+  IN KPROCESSOR_MODE  AccessMode,
+  IN LOCK_OPERATION  Operation);
 
-typedef VOID
-(DDKAPI *PIO_CSQ_RELEASE_LOCK)(
-  IN struct _IO_CSQ  *Csq,
-  IN KIRQL  Irql);
+NTKERNELAPI
+VOID
+NTAPI
+MmUnmapLockedPages(
+  IN PVOID  BaseAddress,
+  IN PMDL  MemoryDescriptorList);
 
-typedef VOID
-(DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
-  IN  struct _IO_CSQ  *Csq,
-  IN  PIRP  Irp);
+#endif
 
-typedef struct _IO_CSQ {
-  ULONG  Type;
-  PIO_CSQ_INSERT_IRP  CsqInsertIrp;
-  PIO_CSQ_REMOVE_IRP  CsqRemoveIrp;
-  PIO_CSQ_PEEK_NEXT_IRP  CsqPeekNextIrp;
-  PIO_CSQ_ACQUIRE_LOCK  CsqAcquireLock;
-  PIO_CSQ_RELEASE_LOCK  CsqReleaseLock;
-  PIO_CSQ_COMPLETE_CANCELED_IRP  CsqCompleteCanceledIrp;
-  PVOID  ReservePointer;
-} IO_CSQ, *PIO_CSQ;
+#if (NTDDI_VERSION >= NTDDI_WINXP)
 
-typedef enum _BUS_QUERY_ID_TYPE {
-  BusQueryDeviceID,
-  BusQueryHardwareIDs,
-  BusQueryCompatibleIDs,
-  BusQueryInstanceID,
-  BusQueryDeviceSerialNumber
-} BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
+NTKERNELAPI
+NTSTATUS
+NTAPI
+MmAdvanceMdl(
+  IN OUT PMDL  Mdl,
+  IN ULONG  NumberOfBytes);
 
-typedef enum _DEVICE_TEXT_TYPE {
-  DeviceTextDescription,
-  DeviceTextLocationInformation
-} DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
+NTKERNELAPI
+PVOID
+NTAPI
+MmAllocateMappingAddress(
+  IN SIZE_T  NumberOfBytes,
+  IN ULONG  PoolTag);
 
-typedef enum _WORK_QUEUE_TYPE {
-  CriticalWorkQueue,
-  DelayedWorkQueue,
-  HyperCriticalWorkQueue,
-  MaximumWorkQueue
-} WORK_QUEUE_TYPE;
+NTKERNELAPI
+VOID
+NTAPI
+MmFreeMappingAddress(
+  IN PVOID  BaseAddress,
+  IN ULONG  PoolTag);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+MmIsVerifierEnabled(
+  OUT PULONG  VerifierFlags);
+
+NTKERNELAPI
+PVOID
+NTAPI
+MmMapLockedPagesWithReservedMapping(
+  IN PVOID  MappingAddress,
+  IN ULONG  PoolTag,
+  IN PMDL  MemoryDescriptorList,
+  IN MEMORY_CACHING_TYPE  CacheType);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+MmProtectMdlSystemAddress(
+  IN PMDL  MemoryDescriptorList,
+  IN ULONG  NewProtect);
+
+NTKERNELAPI
+VOID
+NTAPI
+MmUnmapReservedMapping(
+  IN PVOID  BaseAddress,
+  IN ULONG  PoolTag,
+  IN PMDL  MemoryDescriptorList);
 
-#if !defined(_AMD64_) && !defined(_IA64_)
-#include <pshpack4.h>
-#endif
-typedef struct _IO_STACK_LOCATION {
-  UCHAR  MajorFunction;
-  UCHAR  MinorFunction;
-  UCHAR  Flags;
-  UCHAR  Control;
-  union {
-    struct {
-      PIO_SECURITY_CONTEXT  SecurityContext;
-      ULONG  Options;
-      USHORT POINTER_ALIGNMENT  FileAttributes;
-      USHORT  ShareAccess;
-      ULONG POINTER_ALIGNMENT  EaLength;
-    } Create;
-    struct {
-      ULONG  Length;
-      ULONG POINTER_ALIGNMENT  Key;
-      LARGE_INTEGER  ByteOffset;
-    } Read;
-    struct {
-      ULONG  Length;
-      ULONG POINTER_ALIGNMENT  Key;
-      LARGE_INTEGER  ByteOffset;
-    } Write;
-    struct {
-      ULONG  Length;
-      PUNICODE_STRING  FileName;
-      FILE_INFORMATION_CLASS  FileInformationClass;
-      ULONG  FileIndex;
-    } QueryDirectory;
-    struct {
-      ULONG  Length;
-      ULONG  CompletionFilter;
-    } NotifyDirectory;
-    struct {
-      ULONG  Length;
-      FILE_INFORMATION_CLASS POINTER_ALIGNMENT  FileInformationClass;
-    } QueryFile;
-    struct {
-      ULONG  Length;
-      FILE_INFORMATION_CLASS POINTER_ALIGNMENT  FileInformationClass;
-      PFILE_OBJECT  FileObject;
-      _ANONYMOUS_UNION union {
-        _ANONYMOUS_STRUCT struct {
-          BOOLEAN  ReplaceIfExists;
-          BOOLEAN  AdvanceOnly;
-        } DUMMYSTRUCTNAME;
-        ULONG  ClusterCount;
-        HANDLE  DeleteHandle;
-      } DUMMYUNIONNAME;
-    } SetFile;
-    struct {
-      ULONG  Length;
-      PVOID  EaList;
-      ULONG  EaListLength;
-      ULONG  EaIndex;
-    } QueryEa;
-    struct {
-      ULONG  Length;
-    } SetEa;
-    struct {
-      ULONG  Length;
-      FS_INFORMATION_CLASS POINTER_ALIGNMENT  FsInformationClass;
-    } QueryVolume;
-    struct {
-      ULONG  Length;
-      FS_INFORMATION_CLASS  FsInformationClass;
-    } SetVolume;
-    struct {
-      ULONG  OutputBufferLength;
-      ULONG  InputBufferLength;
-      ULONG  FsControlCode;
-      PVOID  Type3InputBuffer;
-    } FileSystemControl;
-    struct {
-      PLARGE_INTEGER  Length;
-      ULONG  Key;
-      LARGE_INTEGER  ByteOffset;
-    } LockControl;
-    struct {
-      ULONG  OutputBufferLength;
-      ULONG POINTER_ALIGNMENT  InputBufferLength;
-      ULONG POINTER_ALIGNMENT  IoControlCode;
-      PVOID  Type3InputBuffer;
-    } DeviceIoControl;
-    struct {
-      SECURITY_INFORMATION  SecurityInformation;
-      ULONG POINTER_ALIGNMENT  Length;
-    } QuerySecurity;
-    struct {
-      SECURITY_INFORMATION  SecurityInformation;
-      PSECURITY_DESCRIPTOR  SecurityDescriptor;
-    } SetSecurity;
-    struct {
-      PVPB  Vpb;
-      PDEVICE_OBJECT  DeviceObject;
-    } MountVolume;
-    struct {
-      PVPB  Vpb;
-      PDEVICE_OBJECT  DeviceObject;
-    } VerifyVolume;
-    struct {
-      struct _SCSI_REQUEST_BLOCK  *Srb;
-    } Scsi;
-    struct {
-      ULONG  Length;
-      PSID  StartSid;
-      struct _FILE_GET_QUOTA_INFORMATION  *SidList;
-      ULONG  SidListLength;
-    } QueryQuota;
-    struct {
-      ULONG  Length;
-    } SetQuota;
-    struct {
-      DEVICE_RELATION_TYPE  Type;
-    } QueryDeviceRelations;
-    struct {
-      CONST GUID  *InterfaceType;
-      USHORT  Size;
-      USHORT  Version;
-      PINTERFACE  Interface;
-      PVOID  InterfaceSpecificData;
-    } QueryInterface;
-    struct {
-      PDEVICE_CAPABILITIES  Capabilities;
-    } DeviceCapabilities;
-    struct {
-      PIO_RESOURCE_REQUIREMENTS_LIST  IoResourceRequirementList;
-    } FilterResourceRequirements;
-    struct {
-      ULONG  WhichSpace;
-      PVOID  Buffer;
-      ULONG  Offset;
-      ULONG POINTER_ALIGNMENT  Length;
-    } ReadWriteConfig;
-    struct {
-      BOOLEAN  Lock;
-    } SetLock;
-    struct {
-      BUS_QUERY_ID_TYPE  IdType;
-    } QueryId;
-    struct {
-      DEVICE_TEXT_TYPE  DeviceTextType;
-      LCID POINTER_ALIGNMENT  LocaleId;
-    } QueryDeviceText;
-    struct {
-      BOOLEAN  InPath;
-      BOOLEAN  Reserved[3];
-      DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT  Type;
-    } UsageNotification;
-    struct {
-      SYSTEM_POWER_STATE  PowerState;
-    } WaitWake;
-    struct {
-      PPOWER_SEQUENCE  PowerSequence;
-    } PowerSequence;
-    struct {
-      ULONG  SystemContext;
-      POWER_STATE_TYPE POINTER_ALIGNMENT  Type;
-      POWER_STATE POINTER_ALIGNMENT  State;
-      POWER_ACTION POINTER_ALIGNMENT  ShutdownType;
-    } Power;
-    struct {
-      PCM_RESOURCE_LIST  AllocatedResources;
-      PCM_RESOURCE_LIST  AllocatedResourcesTranslated;
-    } StartDevice;
-    struct {
-      ULONG_PTR  ProviderId;
-      PVOID  DataPath;
-      ULONG  BufferSize;
-      PVOID  Buffer;
-    } WMI;
-    struct {
-      PVOID  Argument1;
-      PVOID  Argument2;
-      PVOID  Argument3;
-      PVOID  Argument4;
-    } Others;
-  } Parameters;
-  PDEVICE_OBJECT  DeviceObject;
-  PFILE_OBJECT  FileObject;
-  PIO_COMPLETION_ROUTINE  CompletionRoutine;
-  PVOID  Context;
-} IO_STACK_LOCATION, *PIO_STACK_LOCATION;
-#if !defined(_AMD64_) && !defined(_IA64_)
-#include <poppack.h>
 #endif
 
-/* IO_STACK_LOCATION.Control */
+#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 SL_PENDING_RETURNED               0x01
-#define SL_ERROR_RETURNED                 0x02
-#define SL_INVOKE_ON_CANCEL               0x20
-#define SL_INVOKE_ON_SUCCESS              0x40
-#define SL_INVOKE_ON_ERROR                0x80
+/******************************************************************************
+ *                            Security Manager Functions                      *
+ ******************************************************************************/
 
-/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
-#define PCI_WHICHSPACE_CONFIG             0x0
-#define PCI_WHICHSPACE_ROM                0x52696350 /* 'PciR' */
+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);
+
+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);
+
+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);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+SeDeassignSecurity(
+  IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor);
+
+NTKERNELAPI
+BOOLEAN
+NTAPI
+SeValidSecurityDescriptor(
+  IN ULONG Length,
+  IN PSECURITY_DESCRIPTOR SecurityDescriptor);
+
+NTKERNELAPI
+ULONG
+NTAPI
+SeObjectCreateSaclAccessBits(
+  IN PSECURITY_DESCRIPTOR SecurityDescriptor);
+
+NTKERNELAPI
+VOID
+NTAPI
+SeReleaseSubjectContext(
+  IN OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
+
+NTKERNELAPI
+VOID
+NTAPI
+SeUnlockSubjectContext(
+  IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
+
+NTKERNELAPI
+VOID
+NTAPI
+SeCaptureSubjectContext(
+  OUT PSECURITY_SUBJECT_CONTEXT SubjectContext);
+
+NTKERNELAPI
+VOID
+NTAPI
+SeLockSubjectContext(
+  IN PSECURITY_SUBJECT_CONTEXT SubjectContext);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+
+#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+
+NTSTATUS
+NTAPI
+SeSetAuditParameter(
+  IN OUT PSE_ADT_PARAMETER_ARRAY AuditParameters,
+  IN SE_ADT_PARAMETER_TYPE Type,
+  IN ULONG Index,
+  IN PVOID Data);
+
+NTSTATUS
+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)
+
+NTKERNELAPI
+ULONG
+NTAPI
+SeComputeAutoInheritByObjectType(
+  IN PVOID ObjectType,
+  IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
+  IN PSECURITY_DESCRIPTOR ParentSecurityDescriptor OPTIONAL);
+
+#ifdef SE_NTFS_WORLD_CACHE
+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                    *
+ ******************************************************************************/
+
+#if (NTDDI_VERSION >= NTDDI_WINXP)
+NTKERNELAPI
+NTSTATUS
+NTAPI
+CmRegisterCallback(
+  IN PEX_CALLBACK_FUNCTION  Function,
+  IN PVOID  Context  OPTIONAL,
+  OUT PLARGE_INTEGER  Cookie);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+CmUnRegisterCallback(
+  IN LARGE_INTEGER  Cookie);
+#endif
 
 
 /******************************************************************************
@@ -9196,262 +9518,171 @@ IoGetRemainingStackSize(
   ULONG_PTR Result;
 
   IoGetStackLimits(&Begin, &End);
-  Result = (ULONG_PTR)(&End) - Begin;
-  return Result;
-}
-
-
-/******************************************************************************
- *                             WINBASE Functions                              *
- ******************************************************************************/
-#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)
+  Result = (ULONG_PTR)(&End) - Begin;
+  return Result;
+}
 
-#define InterlockedFlushSList(Head) \
-    ExpInterlockedFlushSList(Head)
+/******************************************************************************
+ *                     Power Management Support Functions                     *
+ ******************************************************************************/
 
-#define QueryDepthSList(Head) \
-    ExQueryDepthSList(Head)
+#define PoSetDeviceBusy(IdlePointer) ((void)(*(IdlePointer) = 0))
 
-#else // !defined(_WIN64)
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
 NTKERNELAPI
-PSLIST_ENTRY
-FASTCALL
-InterlockedPopEntrySList(
-    IN PSLIST_HEADER ListHead);
+NTSTATUS
+NTAPI
+PoCallDriver(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN OUT struct _IRP  *Irp);
 
 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_)
-
+PULONG
+NTAPI
+PoRegisterDeviceForIdleDetection(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN ULONG  ConservationIdleTime,
+  IN ULONG  PerformanceIdleTime,
+  IN DEVICE_POWER_STATE  State);
 
-/******************************************************************************
- *                            Executive Types                                 *
- ******************************************************************************/
+NTKERNELAPI
+PVOID
+NTAPI
+PoRegisterSystemState(
+  IN OUT PVOID StateHandle OPTIONAL,
+  IN EXECUTION_STATE Flags);
 
-#define EX_RUNDOWN_ACTIVE                 0x1
-#define EX_RUNDOWN_COUNT_SHIFT            0x1
-#define EX_RUNDOWN_COUNT_INC              (1 << EX_RUNDOWN_COUNT_SHIFT)
+NTKERNELAPI
+NTSTATUS
+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);
 
-#ifdef _WIN64
-#define PORT_MAXIMUM_MESSAGE_LENGTH 512
-#else
-#define PORT_MAXIMUM_MESSAGE_LENGTH 256
-#endif
+NTKERNELAPI
+POWER_STATE
+NTAPI
+PoSetPowerState(
+  IN struct _DEVICE_OBJECT  *DeviceObject,
+  IN POWER_STATE_TYPE  Type,
+  IN POWER_STATE  State);
 
-typedef enum _SUITE_TYPE {
-    SmallBusiness,
-    Enterprise,
-    BackOffice,
-    CommunicationServer,
-    TerminalServer,
-    SmallBusinessRestricted,
-    EmbeddedNT,
-    DataCenter,
-    SingleUserTS,
-    Personal,
-    Blade,
-    EmbeddedRestricted,
-    SecurityAppliance,
-    StorageServer,
-    ComputeServer,
-    WHServer,
-    MaxSuiteType
-} SUITE_TYPE;
+NTKERNELAPI
+VOID
+NTAPI
+PoSetSystemState(
+  IN EXECUTION_STATE  Flags);
 
-typedef enum _EX_POOL_PRIORITY {
-    LowPoolPriority,
-    LowPoolPrioritySpecialPoolOverrun = 8,
-    LowPoolPrioritySpecialPoolUnderrun = 9,
-    NormalPoolPriority = 16,
-    NormalPoolPrioritySpecialPoolOverrun = 24,
-    NormalPoolPrioritySpecialPoolUnderrun = 25,
-    HighPoolPriority = 32,
-    HighPoolPrioritySpecialPoolOverrun = 40,
-    HighPoolPrioritySpecialPoolUnderrun = 41
-} EX_POOL_PRIORITY;
+NTKERNELAPI
+VOID
+NTAPI
+PoStartNextPowerIrp(
+  IN OUT struct _IRP *Irp);
 
-#if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
-#define LOOKASIDE_ALIGN
-#else
-#define LOOKASIDE_ALIGN /* FIXME: DECLSPEC_CACHEALIGN */
-#endif
+NTKERNELAPI
+VOID
+NTAPI
+PoUnregisterSystemState(
+  IN OUT PVOID StateHandle);
 
-typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX;
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
 
-typedef PVOID
-(DDKAPI *PALLOCATE_FUNCTION)(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes,
-    IN ULONG Tag);
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 
-typedef PVOID
-(DDKAPI *PALLOCATE_FUNCTION_EX)(
-    IN POOL_TYPE PoolType,
-    IN SIZE_T NumberOfBytes,
-    IN ULONG Tag,
-    IN OUT PLOOKASIDE_LIST_EX Lookaside);
+NTKERNELAPI
+VOID
+NTAPI
+PoSetSystemWake(
+  IN OUT struct _IRP *Irp);
 
-typedef VOID
-(DDKAPI *PFREE_FUNCTION)(
-    IN PVOID Buffer);
+NTKERNELAPI
+BOOLEAN
+NTAPI
+PoGetSystemWake(
+  IN struct _IRP *Irp);
 
-typedef VOID
-(DDKAPI *PFREE_FUNCTION_EX)(
-    IN PVOID Buffer,
-    IN OUT PLOOKASIDE_LIST_EX 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);
 
-typedef VOID
-(DDKAPI *PCALLBACK_FUNCTION)(
-  IN PVOID  CallbackContext,
-  IN PVOID  Argument1,
-  IN PVOID  Argument2);
+NTKERNELAPI
+NTSTATUS
+NTAPI
+PoUnregisterPowerSettingCallback(
+  IN OUT PVOID Handle);
 
-#define GENERAL_LOOKASIDE_LAYOUT                \
-    union {                                     \
-        SLIST_HEADER ListHead;                  \
-        SINGLE_LIST_ENTRY SingleListHead;       \
-    } DUMMYUNIONNAME;                           \
-    USHORT Depth;                               \
-    USHORT MaximumDepth;                        \
-    ULONG TotalAllocates;                       \
-    union {                                     \
-        ULONG AllocateMisses;                   \
-        ULONG AllocateHits;                     \
-    } DUMMYUNIONNAME2;                          \
-                                                \
-    ULONG TotalFrees;                           \
-    union {                                     \
-        ULONG FreeMisses;                       \
-        ULONG FreeHits;                         \
-    } DUMMYUNIONNAME3;                          \
-                                                \
-    POOL_TYPE Type;                             \
-    ULONG Tag;                                  \
-    ULONG Size;                                 \
-    union {                                     \
-        PALLOCATE_FUNCTION_EX AllocateEx;       \
-        PALLOCATE_FUNCTION Allocate;            \
-    } DUMMYUNIONNAME4;                          \
-                                                \
-    union {                                     \
-        PFREE_FUNCTION_EX FreeEx;               \
-        PFREE_FUNCTION Free;                    \
-    } DUMMYUNIONNAME5;                          \
-                                                \
-    LIST_ENTRY ListEntry;                       \
-    ULONG LastTotalAllocates;                   \
-    union {                                     \
-        ULONG LastAllocateMisses;               \
-        ULONG LastAllocateHits;                 \
-    } DUMMYUNIONNAME6;                          \
-    ULONG Future[2];
+#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
 
-typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE {
-    GENERAL_LOOKASIDE_LAYOUT
-} GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
+#if (NTDDI_VERSION >= NTDDI_VISTASP1)
 
-typedef struct _GENERAL_LOOKASIDE_POOL {
-    GENERAL_LOOKASIDE_LAYOUT
-} GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
+NTKERNELAPI
+VOID
+NTAPI
+PoSetDeviceBusyEx(
+  IN OUT PULONG IdlePointer);
 
-typedef struct _PAGED_LOOKASIDE_LIST {
-    GENERAL_LOOKASIDE L;
-#if !defined(_AMD64_) && !defined(_IA64_)
-    FAST_MUTEX Lock__ObsoleteButDoNotDelete;
-#endif
-} PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
+#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */
 
-typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST {
-    GENERAL_LOOKASIDE L;
-#if !defined(_AMD64_) && !defined(_IA64_)
-    KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
-#endif
-} NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+NTKERNELAPI
+VOID
+NTAPI
+PoStartDeviceBusy(
+  IN OUT PULONG IdlePointer);
 
-typedef struct _LOOKASIDE_LIST_EX {
-    GENERAL_LOOKASIDE_POOL L;
-} LOOKASIDE_LIST_EX;
+NTKERNELAPI
+VOID
+NTAPI
+PoEndDeviceBusy(
+  IN OUT PULONG IdlePointer);
 
-typedef struct _EX_RUNDOWN_REF {
-    __GNU_EXTENSION union {
-        volatile ULONG_PTR Count;
-        volatile PVOID Ptr;
-    };
-} EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
+NTKERNELAPI
+BOOLEAN
+NTAPI
+PoQueryWatchdogTime(
+  IN PDEVICE_OBJECT Pdo,
+  OUT PULONG SecondsRemaining);
 
-typedef struct _EX_RUNDOWN_REF_CACHE_AWARE  *PEX_RUNDOWN_REF_CACHE_AWARE;
+NTKERNELAPI
+VOID
+NTAPI
+PoDeletePowerRequest(
+  IN OUT PVOID PowerRequest);
 
-typedef VOID
-(DDKAPI *PWORKER_THREAD_ROUTINE)(
-  IN PVOID Parameter);
+NTKERNELAPI
+NTSTATUS
+NTAPI
+PoSetPowerRequest(
+  IN OUT PVOID PowerRequest,
+  IN POWER_REQUEST_TYPE Type);
 
-typedef struct _WORK_QUEUE_ITEM {
-  LIST_ENTRY  List;
-  PWORKER_THREAD_ROUTINE  WorkerRoutine;
-  volatile PVOID  Parameter;
-} WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
+NTKERNELAPI
+NTSTATUS
+NTAPI
+PoClearPowerRequest(
+  IN OUT PVOID PowerRequest,
+  IN POWER_REQUEST_TYPE Type);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+PoCreatePowerRequest(
+  OUT PVOID *PowerRequest,
+  IN PDEVICE_OBJECT DeviceObject,
+  IN PCOUNTED_REASON_CONTEXT Context);
 
+#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
 
 /******************************************************************************
  *                          Executive Functions                               *
@@ -10093,174 +10324,482 @@ ExAllocateFromNPagedLookasideList(
     return Entry;
 }
 
-static __inline PVOID
-ExAllocateFromPagedLookasideList(
-    IN PPAGED_LOOKASIDE_LIST Lookaside)
-{
-    PVOID Entry;
+static __inline PVOID
+ExAllocateFromPagedLookasideList(
+    IN PPAGED_LOOKASIDE_LIST Lookaside)
+{
+    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;
+}
+
+static __inline VOID
+ExFreeToNPagedLookasideList(
+    IN PNPAGED_LOOKASIDE_LIST Lookaside,
+    IN PVOID  Entry)
+{
+    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);
+    }
+}
+
+static __inline VOID
+ExFreeToPagedLookasideList(
+    IN PPAGED_LOOKASIDE_LIST Lookaside,
+    IN PVOID  Entry)
+{
+    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);
+    }
+}
+
+#endif // !defined(MIDL_PASS)
+
+/******************************************************************************
+ *                          Object Manager Functions                          *
+ ******************************************************************************/
+
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
+
+NTKERNELAPI
+LONG_PTR
+FASTCALL
+ObfDereferenceObject(
+  IN PVOID Object);
+#define ObDereferenceObject ObfDereferenceObject
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+ObGetObjectSecurity(
+  IN PVOID Object,
+  OUT PSECURITY_DESCRIPTOR *SecurityDescriptor,
+  OUT PBOOLEAN MemoryAllocated);
+
+NTKERNELAPI
+LONG_PTR
+FASTCALL
+ObfReferenceObject(
+  IN PVOID Object);
+#define ObReferenceObject ObfReferenceObject
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+ObReferenceObjectByHandle(
+  IN HANDLE Handle,
+  IN ACCESS_MASK DesiredAccess,
+  IN POBJECT_TYPE ObjectType OPTIONAL,
+  IN KPROCESSOR_MODE AccessMode,
+  OUT PVOID *Object,
+  OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+ObReferenceObjectByPointer(
+  IN PVOID  Object,
+  IN ACCESS_MASK DesiredAccess,
+  IN POBJECT_TYPE ObjectType OPTIONAL,
+  IN KPROCESSOR_MODE AccessMode);
+
+NTKERNELAPI
+VOID
+NTAPI
+ObReleaseObjectSecurity(
+  IN PSECURITY_DESCRIPTOR SecurityDescriptor,
+  IN BOOLEAN MemoryAllocated);
+
+#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
+
+/******************************************************************************
+ *                          Process Manager Functions                         *
+ ******************************************************************************/
+
+/*
+ * PEPROCESS
+ * PsGetCurrentProcess(VOID)
+ */
+#define PsGetCurrentProcess IoGetCurrentProcess
+
+#if !defined(_PSGETCURRENTTHREAD_)
+
+#define _PSGETCURRENTTHREAD_
+
+FORCEINLINE
+PETHREAD
+NTAPI
+PsGetCurrentThread (
+  VOID)
+{
+  return (PETHREAD)KeGetCurrentThread();
+}
+
+#endif
+
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+PsCreateSystemThread(
+  OUT PHANDLE  ThreadHandle,
+  IN ULONG  DesiredAccess,
+  IN POBJECT_ATTRIBUTES  ObjectAttributes  OPTIONAL,
+  IN HANDLE  ProcessHandle  OPTIONAL,
+  OUT PCLIENT_ID  ClientId  OPTIONAL,
+  IN PKSTART_ROUTINE  StartRoutine,
+  IN PVOID  StartContext OPTIONAL);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+PsTerminateSystemThread(
+  IN NTSTATUS  ExitStatus);
+
+#endif
+
+/******************************************************************************
+ *                          WMI Library Support Functions                     *
+ ******************************************************************************/
+
+#ifdef RUN_WPP
+
+#if (NTDDI_VERSION >= NTDDI_WINXP)
+NTKERNELAPI
+NTSTATUS
+DDKCDECLAPI
+WmiTraceMessage(
+  IN TRACEHANDLE  LoggerHandle,
+  IN ULONG  MessageFlags,
+  IN LPGUID  MessageGuid,
+  IN USHORT  MessageNumber,
+  IN ...);
+#endif
+
+#endif
+
+ #if (NTDDI_VERSION >= NTDDI_WINXP)
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+WmiQueryTraceInformation(
+  IN TRACE_INFORMATION_CLASS  TraceInformationClass,
+  OUT PVOID  TraceInformation,
+  IN ULONG  TraceInformationLength,
+  OUT PULONG  RequiredLength OPTIONAL,
+  IN PVOID  Buffer OPTIONAL);
+
+#if 0
+/* FIXME: Get va_list from where? */
+NTKERNELAPI
+NTSTATUS
+DDKCDECLAPI
+WmiTraceMessageVa(
+  IN TRACEHANDLE  LoggerHandle,
+  IN ULONG  MessageFlags,
+  IN LPGUID  MessageGuid,
+  IN USHORT  MessageNumber,
+  IN va_list  MessageArgList);
+#endif
+
+#endif
+
+/******************************************************************************
+ *                          Kernel Debugger Functions                         *
+ ******************************************************************************/
+
+#ifndef _DBGNT_
+ULONG
+DDKCDECLAPI
+DbgPrint(
+  IN PCSTR  Format,
+  IN ...);
+#endif
+
+#if DBG
+
+#define KdPrint(_x_) DbgPrint _x_
+#define KdPrintEx(_x_) DbgPrintEx _x_
+#define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_
+#define KdBreakPoint() DbgBreakPoint()
+#define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s)
+
+#else /* !DBG */
+
+#define KdPrint(_x_)
+#define KdPrintEx(_x_)
+#define vKdPrintExWithPrefix(_x_)
+#define KdBreakPoint()
+#define KdBreakPointWithStatus(s)
+
+#endif /* !DBG */
 
-    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;
-}
+#if defined(__GNUC__)
 
-static __inline VOID
-ExFreeToNPagedLookasideList(
-    IN PNPAGED_LOOKASIDE_LIST Lookaside,
-    IN PVOID  Entry)
-{
-    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);
-    }
-}
+extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent;
+extern NTKERNELAPI BOOLEAN KdDebuggerEnabled;
+#define KD_DEBUGGER_ENABLED     KdDebuggerEnabled
+#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent
 
-static __inline VOID
-ExFreeToPagedLookasideList(
-    IN PPAGED_LOOKASIDE_LIST Lookaside,
-    IN PVOID  Entry)
-{
-    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);
-    }
-}
+#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_)
 
-#endif // !defined(MIDL_PASS)
+extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent;
+extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled;
+#define KD_DEBUGGER_ENABLED     *KdDebuggerEnabled
+#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent
 
-/******************************************************************************
- *                          Object Manager Functions                          *
- ******************************************************************************/
+#else
 
-/*
- * VOID
- * ObDereferenceObject(
- *   IN PVOID  Object)
- */
-#define ObDereferenceObject ObfDereferenceObject
+extern BOOLEAN KdDebuggerNotPresent;
+extern BOOLEAN KdDebuggerEnabled;
+#define KD_DEBUGGER_ENABLED     KdDebuggerEnabled
+#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent
 
-/*
- * VOID
- * ObReferenceObject(
- *   IN PVOID  Object)
- */
-#define ObReferenceObject ObfReferenceObject
+#endif
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+#ifdef _VA_LIST_DEFINED
+#if (NTDDI_VERSION >= NTDDI_WINXP)
 
-NTKERNELAPI
-LONG_PTR
-FASTCALL
-ObfDereferenceObject(
-  IN PVOID  Object);
+NTSYSAPI
+ULONG
+NTAPI
+vDbgPrintEx(
+  IN ULONG ComponentId,
+  IN ULONG Level,
+  IN PCCH Format,
+  IN va_list ap);
 
-NTKERNELAPI
-NTSTATUS
+NTSYSAPI
+ULONG
 NTAPI
-ObGetObjectSecurity(
-  IN PVOID  Object,
-  OUT PSECURITY_DESCRIPTOR  *SecurityDescriptor,
-  OUT PBOOLEAN  MemoryAllocated);
+vDbgPrintExWithPrefix(
+  IN PCCH Prefix,
+  IN ULONG ComponentId,
+  IN ULONG Level,
+  IN PCCH Format,
+  IN va_list ap);
 
-NTKERNELAPI
-LONG_PTR
-FASTCALL
-ObfReferenceObject(
-  IN PVOID  Object);
+#endif
+#endif // _VA_LIST_DEFINED
+
+#if (NTDDI_VERSION >= NTDDI_WIN2K)
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-ObReferenceObjectByHandle(
-  IN HANDLE  Handle,
-  IN ACCESS_MASK  DesiredAccess,
-  IN POBJECT_TYPE  ObjectType  OPTIONAL,
-  IN KPROCESSOR_MODE  AccessMode,
-  OUT PVOID  *Object,
-  OUT POBJECT_HANDLE_INFORMATION  HandleInformation  OPTIONAL);
+KdDisableDebugger(
+  VOID);
 
 NTKERNELAPI
 NTSTATUS
 NTAPI
-ObReferenceObjectByPointer(
-  IN PVOID  Object,
-  IN ACCESS_MASK  DesiredAccess,
-  IN POBJECT_TYPE  ObjectType OPTIONAL,
-  IN KPROCESSOR_MODE  AccessMode);
+KdEnableDebugger(
+  VOID);
 
-NTKERNELAPI
+#if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK)
+#define DbgBreakPoint __debugbreak
+#else
 VOID
 NTAPI
-ObReleaseObjectSecurity(
-  IN PSECURITY_DESCRIPTOR  SecurityDescriptor,
-  IN BOOLEAN  MemoryAllocated);
-
+DbgBreakPoint(
+  VOID);
 #endif
 
-/******************************************************************************
- *                          Process Manager Functions                         *
- ******************************************************************************/
+NTSYSAPI
+VOID
+NTAPI
+DbgBreakPointWithStatus(
+  IN ULONG  Status);
 
-/*
- * PEPROCESS
- * PsGetCurrentProcess(VOID)
- */
-#define PsGetCurrentProcess IoGetCurrentProcess
+NTSYSAPI
+ULONG
+DDKCDECLAPI
+DbgPrintReturnControlC(
+  IN PCCH  Format,
+  IN ...);
 
-#if !defined(_PSGETCURRENTTHREAD_)
+#endif
 
-#define _PSGETCURRENTTHREAD_
+#if (NTDDI_VERSION >= NTDDI_WINXP)
 
-FORCEINLINE
-PETHREAD
+NTSYSAPI
+ULONG
+DDKCDECLAPI
+DbgPrintEx(
+  IN ULONG  ComponentId,
+  IN ULONG  Level,
+  IN PCSTR  Format,
+  IN ...);
+
+NTSYSAPI
+NTSTATUS
 NTAPI
-PsGetCurrentThread (
-  VOID)
-{
-  return (PETHREAD)KeGetCurrentThread();
-}
+DbgQueryDebugFilterState(
+  IN ULONG  ComponentId,
+  IN ULONG  Level);
+
+NTSYSAPI
+NTSTATUS
+NTAPI
+DbgSetDebugFilterState(
+  IN ULONG  ComponentId,
+  IN ULONG  Level,
+  IN BOOLEAN  State);
 
 #endif
 
-#if (NTDDI_VERSION >= NTDDI_WIN2K)
+#if (NTDDI_VERSION >= NTDDI_WS03)
 
 NTKERNELAPI
-NTSTATUS
+BOOLEAN
 NTAPI
-PsCreateSystemThread(
-  OUT PHANDLE  ThreadHandle,
-  IN ULONG  DesiredAccess,
-  IN POBJECT_ATTRIBUTES  ObjectAttributes  OPTIONAL,
-  IN HANDLE  ProcessHandle  OPTIONAL,
-  OUT PCLIENT_ID  ClientId  OPTIONAL,
-  IN PKSTART_ROUTINE  StartRoutine,
-  IN PVOID  StartContext OPTIONAL);
+KdRefreshDebuggerNotPresent(
+    VOID
+);
+
+#endif
 
+#if (NTDDI_VERSION >= NTDDI_WS03SP1)
 NTKERNELAPI
 NTSTATUS
 NTAPI
-PsTerminateSystemThread(
-  IN NTSTATUS  ExitStatus);
+KdChangeOption(
+  IN KD_OPTION Option,
+  IN ULONG InBufferBytes OPTIONAL,
+  IN PVOID InBuffer,
+  IN ULONG OutBufferBytes OPTIONAL,
+  OUT PVOID OutBuffer,
+  OUT PULONG OutBufferNeeded OPTIONAL);
+#endif
+
+#if defined(USE_DMA_MACROS) && !defined(_NTHA