mirror of
https://github.com/reactos/reactos.git
synced 2024-09-10 12:54:51 +00:00
![Amine Khaldi](/assets/img/avatar_default.png)
- Add the missing definitions needed to autogenerate ntddk.h - Add ntddk.template.h as a template for autogenerating ntddk.h - Adjust generate.bat to generate ntddk.h too. [DDK] - Introduce the autogenerated ntddk.h into DDK. svn path=/branches/header-work/; revision=46348
919 lines
23 KiB
C
919 lines
23 KiB
C
/*
|
|
* ntddk.h
|
|
*
|
|
* Windows NT Device Driver Kit
|
|
*
|
|
* This file is part of the ReactOS DDK package.
|
|
*
|
|
* Contributors:
|
|
* Amine Khaldi
|
|
* Timo Kreuzer (timo.kreuzer@reactos.org)
|
|
*
|
|
* THIS SOFTWARE IS NOT COPYRIGHTED
|
|
*
|
|
* This source code is offered for use in the public domain. You may
|
|
* use, modify or distribute it freely.
|
|
*
|
|
* This code is distributed in the hope that it will be useful but
|
|
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
|
* DISCLAIMED. This includes but is not limited to warranties of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#define _NTDDK_
|
|
|
|
#if !defined(_NTHAL_) && !defined(_NTIFS_)
|
|
#define _NTDDK_INCLUDED_
|
|
#define _DDK_DRIVER_
|
|
#endif
|
|
|
|
/* Dependencies */
|
|
|
|
#define NT_INCLUDED
|
|
#define _CTYPE_DISABLE_MACROS
|
|
|
|
#include <wdm.h>
|
|
#include <excpt.h>
|
|
#include <ntdef.h>
|
|
#include <ntstatus.h>
|
|
|
|
/* FIXME
|
|
#include <bugcodes.h>
|
|
#include <ntiologc.h>
|
|
*/
|
|
|
|
#include <stdarg.h> // FIXME
|
|
#include <basetyps.h> // FIXME
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* GUID and UUID */
|
|
#ifndef _NTLSA_IFS_
|
|
#ifndef _NTLSA_AUDIT_
|
|
#define _NTLSA_AUDIT_
|
|
|
|
#ifndef GUID_DEFINED
|
|
#include <guiddef.h>
|
|
#endif
|
|
|
|
#endif /* _NTLSA_AUDIT_ */
|
|
#endif /* _NTLSA_IFS_ */
|
|
|
|
typedef GUID UUID;
|
|
|
|
struct _LOADER_PARAMETER_BLOCK;
|
|
struct _CREATE_DISK;
|
|
struct _DRIVE_LAYOUT_INFORMATION_EX;
|
|
struct _SET_PARTITION_INFORMATION_EX;
|
|
|
|
typedef struct _BUS_HANDLER *PBUS_HANDLER;
|
|
typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
|
|
#if defined(_NTHAL_INCLUDED_)
|
|
typedef struct _KAFFINITY_EX *PKAFFINITY_EX;
|
|
#endif
|
|
typedef struct _PEB *PPEB;
|
|
|
|
#ifndef _NTIMAGE_
|
|
|
|
typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32;
|
|
typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
|
|
|
|
#ifdef _WIN64
|
|
typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
|
|
#else
|
|
typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
|
|
#endif
|
|
|
|
#endif /* _NTIMAGE_ */
|
|
|
|
#define PsGetCurrentProcess IoGetCurrentProcess
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_VISTA)
|
|
extern NTSYSAPI volatile CCHAR KeNumberProcessors;
|
|
#elif (NTDDI_VERSION >= NTDDI_WINXP)
|
|
extern NTSYSAPI CCHAR KeNumberProcessors;
|
|
#else
|
|
extern PCCHAR KeNumberProcessors;
|
|
#endif
|
|
|
|
#include <mce.h>
|
|
|
|
#ifdef _X86_
|
|
|
|
#define KERNEL_STACK_SIZE 12288
|
|
#define KERNEL_LARGE_STACK_SIZE 61440
|
|
#define KERNEL_LARGE_STACK_COMMIT 12288
|
|
|
|
#define SIZE_OF_80387_REGISTERS 80
|
|
|
|
#if !defined(RC_INVOKED)
|
|
|
|
#define CONTEXT_i386 0x10000
|
|
#define CONTEXT_i486 0x10000
|
|
#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
|
|
#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
|
|
#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
|
|
#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
|
|
#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
|
|
#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
|
|
|
|
#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
|
|
#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
|
|
CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \
|
|
CONTEXT_EXTENDED_REGISTERS)
|
|
|
|
#define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L)
|
|
|
|
#endif /* !defined(RC_INVOKED) */
|
|
|
|
typedef struct _FLOATING_SAVE_AREA {
|
|
ULONG ControlWord;
|
|
ULONG StatusWord;
|
|
ULONG TagWord;
|
|
ULONG ErrorOffset;
|
|
ULONG ErrorSelector;
|
|
ULONG DataOffset;
|
|
ULONG DataSelector;
|
|
UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
|
|
ULONG Cr0NpxState;
|
|
} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
|
|
|
|
#include "pshpack4.h"
|
|
typedef struct _CONTEXT {
|
|
ULONG ContextFlags;
|
|
ULONG Dr0;
|
|
ULONG Dr1;
|
|
ULONG Dr2;
|
|
ULONG Dr3;
|
|
ULONG Dr6;
|
|
ULONG Dr7;
|
|
FLOATING_SAVE_AREA FloatSave;
|
|
ULONG SegGs;
|
|
ULONG SegFs;
|
|
ULONG SegEs;
|
|
ULONG SegDs;
|
|
ULONG Edi;
|
|
ULONG Esi;
|
|
ULONG Ebx;
|
|
ULONG Edx;
|
|
ULONG Ecx;
|
|
ULONG Eax;
|
|
ULONG Ebp;
|
|
ULONG Eip;
|
|
ULONG SegCs;
|
|
ULONG EFlags;
|
|
ULONG Esp;
|
|
ULONG SegSs;
|
|
UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
|
|
} CONTEXT;
|
|
#include "poppack.h"
|
|
|
|
#endif /* _X86_ */
|
|
|
|
#ifdef _AMD64_
|
|
|
|
#define KERNEL_STACK_SIZE 0x6000
|
|
#define KERNEL_LARGE_STACK_SIZE 0x12000
|
|
#define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE
|
|
|
|
#define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000
|
|
|
|
#define EXCEPTION_READ_FAULT 0
|
|
#define EXCEPTION_WRITE_FAULT 1
|
|
#define EXCEPTION_EXECUTE_FAULT 8
|
|
|
|
#if !defined(RC_INVOKED)
|
|
|
|
#define CONTEXT_AMD64 0x100000
|
|
|
|
#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
|
|
#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
|
|
#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
|
|
#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
|
|
#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
|
|
|
|
#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
|
|
#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
|
|
|
|
#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L)
|
|
|
|
#define CONTEXT_EXCEPTION_ACTIVE 0x8000000
|
|
#define CONTEXT_SERVICE_ACTIVE 0x10000000
|
|
#define CONTEXT_EXCEPTION_REQUEST 0x40000000
|
|
#define CONTEXT_EXCEPTION_REPORTING 0x80000000
|
|
|
|
#endif /* !defined(RC_INVOKED) */
|
|
|
|
#define INITIAL_MXCSR 0x1f80
|
|
#define INITIAL_FPCSR 0x027f
|
|
|
|
typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
|
|
ULONG64 P1Home;
|
|
ULONG64 P2Home;
|
|
ULONG64 P3Home;
|
|
ULONG64 P4Home;
|
|
ULONG64 P5Home;
|
|
ULONG64 P6Home;
|
|
ULONG ContextFlags;
|
|
ULONG MxCsr;
|
|
USHORT SegCs;
|
|
USHORT SegDs;
|
|
USHORT SegEs;
|
|
USHORT SegFs;
|
|
USHORT SegGs;
|
|
USHORT SegSs;
|
|
ULONG EFlags;
|
|
ULONG64 Dr0;
|
|
ULONG64 Dr1;
|
|
ULONG64 Dr2;
|
|
ULONG64 Dr3;
|
|
ULONG64 Dr6;
|
|
ULONG64 Dr7;
|
|
ULONG64 Rax;
|
|
ULONG64 Rcx;
|
|
ULONG64 Rdx;
|
|
ULONG64 Rbx;
|
|
ULONG64 Rsp;
|
|
ULONG64 Rbp;
|
|
ULONG64 Rsi;
|
|
ULONG64 Rdi;
|
|
ULONG64 R8;
|
|
ULONG64 R9;
|
|
ULONG64 R10;
|
|
ULONG64 R11;
|
|
ULONG64 R12;
|
|
ULONG64 R13;
|
|
ULONG64 R14;
|
|
ULONG64 R15;
|
|
ULONG64 Rip;
|
|
union {
|
|
XMM_SAVE_AREA32 FltSave;
|
|
struct {
|
|
M128A Header[2];
|
|
M128A Legacy[8];
|
|
M128A Xmm0;
|
|
M128A Xmm1;
|
|
M128A Xmm2;
|
|
M128A Xmm3;
|
|
M128A Xmm4;
|
|
M128A Xmm5;
|
|
M128A Xmm6;
|
|
M128A Xmm7;
|
|
M128A Xmm8;
|
|
M128A Xmm9;
|
|
M128A Xmm10;
|
|
M128A Xmm11;
|
|
M128A Xmm12;
|
|
M128A Xmm13;
|
|
M128A Xmm14;
|
|
M128A Xmm15;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
M128A VectorRegister[26];
|
|
ULONG64 VectorControl;
|
|
ULONG64 DebugControl;
|
|
ULONG64 LastBranchToRip;
|
|
ULONG64 LastBranchFromRip;
|
|
ULONG64 LastExceptionToRip;
|
|
ULONG64 LastExceptionFromRip;
|
|
} CONTEXT;
|
|
|
|
#endif /* _AMD64_ */
|
|
|
|
$define (_NTDDK_)
|
|
$include (extypes.h)
|
|
$include (iotypes.h)
|
|
$include (haltypes.h)
|
|
$include (ketypes.h)
|
|
$include (kdtypes.h)
|
|
$include (mmtypes.h)
|
|
$include (pstypes.h)
|
|
$include (rtltypes.h)
|
|
$include (setypes.h)
|
|
|
|
$include (exfuncs.h)
|
|
$include (halfuncs.h)
|
|
$include (iofuncs.h)
|
|
$include (kdfuncs.h)
|
|
$include (kefuncs.h)
|
|
$include (mmfuncs.h)
|
|
$include (psfuncs.h)
|
|
$include (rtlfuncs.h)
|
|
$include (sefuncs.h)
|
|
$include (zwfuncs.h)
|
|
|
|
|
|
/* UNSORTED */
|
|
|
|
#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
|
|
((ConditionMask) = VerSetConditionMask((ConditionMask), \
|
|
(TypeBitMask), (ComparisonType)))
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_WIN2K)
|
|
NTSYSAPI
|
|
ULONGLONG
|
|
NTAPI
|
|
VerSetConditionMask(
|
|
IN ULONGLONG ConditionMask,
|
|
IN ULONG TypeMask,
|
|
IN UCHAR Condition);
|
|
#endif
|
|
|
|
typedef struct _KEY_NAME_INFORMATION {
|
|
ULONG NameLength;
|
|
WCHAR Name[1];
|
|
} KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION;
|
|
|
|
typedef struct _KEY_CACHED_INFORMATION {
|
|
LARGE_INTEGER LastWriteTime;
|
|
ULONG TitleIndex;
|
|
ULONG SubKeys;
|
|
ULONG MaxNameLen;
|
|
ULONG Values;
|
|
ULONG MaxValueNameLen;
|
|
ULONG MaxValueDataLen;
|
|
ULONG NameLength;
|
|
} KEY_CACHED_INFORMATION, *PKEY_CACHED_INFORMATION;
|
|
|
|
typedef struct _KEY_VIRTUALIZATION_INFORMATION {
|
|
ULONG VirtualizationCandidate:1;
|
|
ULONG VirtualizationEnabled:1;
|
|
ULONG VirtualTarget:1;
|
|
ULONG VirtualStore:1;
|
|
ULONG VirtualSource:1;
|
|
ULONG Reserved:27;
|
|
} KEY_VIRTUALIZATION_INFORMATION, *PKEY_VIRTUALIZATION_INFORMATION;
|
|
|
|
#define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
|
|
#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
|
|
#define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
|
|
#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
|
|
#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
|
|
|
|
typedef 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;
|
|
|
|
typedef union _RATE_QUOTA_LIMIT {
|
|
ULONG RateData;
|
|
struct {
|
|
ULONG RatePercent:7;
|
|
ULONG Reserved0:25;
|
|
} DUMMYSTRUCTNAME;
|
|
} RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
|
|
|
|
typedef struct _QUOTA_LIMITS_EX {
|
|
SIZE_T PagedPoolLimit;
|
|
SIZE_T NonPagedPoolLimit;
|
|
SIZE_T MinimumWorkingSetSize;
|
|
SIZE_T MaximumWorkingSetSize;
|
|
SIZE_T PagefileLimit;
|
|
LARGE_INTEGER TimeLimit;
|
|
SIZE_T WorkingSetLimit;
|
|
SIZE_T Reserved2;
|
|
SIZE_T Reserved3;
|
|
SIZE_T Reserved4;
|
|
ULONG Flags;
|
|
RATE_QUOTA_LIMIT CpuRateLimit;
|
|
} QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
|
|
|
|
typedef struct _IO_COUNTERS {
|
|
ULONGLONG ReadOperationCount;
|
|
ULONGLONG WriteOperationCount;
|
|
ULONGLONG OtherOperationCount;
|
|
ULONGLONG ReadTransferCount;
|
|
ULONGLONG WriteTransferCount;
|
|
ULONGLONG OtherTransferCount;
|
|
} IO_COUNTERS, *PIO_COUNTERS;
|
|
|
|
typedef struct _VM_COUNTERS {
|
|
SIZE_T PeakVirtualSize;
|
|
SIZE_T VirtualSize;
|
|
ULONG PageFaultCount;
|
|
SIZE_T PeakWorkingSetSize;
|
|
SIZE_T WorkingSetSize;
|
|
SIZE_T QuotaPeakPagedPoolUsage;
|
|
SIZE_T QuotaPagedPoolUsage;
|
|
SIZE_T QuotaPeakNonPagedPoolUsage;
|
|
SIZE_T QuotaNonPagedPoolUsage;
|
|
SIZE_T PagefileUsage;
|
|
SIZE_T PeakPagefileUsage;
|
|
} VM_COUNTERS, *PVM_COUNTERS;
|
|
|
|
typedef struct _VM_COUNTERS_EX {
|
|
SIZE_T PeakVirtualSize;
|
|
SIZE_T VirtualSize;
|
|
ULONG PageFaultCount;
|
|
SIZE_T PeakWorkingSetSize;
|
|
SIZE_T WorkingSetSize;
|
|
SIZE_T QuotaPeakPagedPoolUsage;
|
|
SIZE_T QuotaPagedPoolUsage;
|
|
SIZE_T QuotaPeakNonPagedPoolUsage;
|
|
SIZE_T QuotaNonPagedPoolUsage;
|
|
SIZE_T PagefileUsage;
|
|
SIZE_T PeakPagefileUsage;
|
|
SIZE_T PrivateUsage;
|
|
} VM_COUNTERS_EX, *PVM_COUNTERS_EX;
|
|
|
|
#define MAX_HW_COUNTERS 16
|
|
#define THREAD_PROFILING_FLAG_DISPATCH 0x00000001
|
|
|
|
typedef enum _HARDWARE_COUNTER_TYPE {
|
|
PMCCounter,
|
|
MaxHardwareCounterType
|
|
} HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE;
|
|
|
|
typedef struct _HARDWARE_COUNTER {
|
|
HARDWARE_COUNTER_TYPE Type;
|
|
ULONG Reserved;
|
|
ULONG64 Index;
|
|
} HARDWARE_COUNTER, *PHARDWARE_COUNTER;
|
|
|
|
typedef struct _POOLED_USAGE_AND_LIMITS {
|
|
SIZE_T PeakPagedPoolUsage;
|
|
SIZE_T PagedPoolUsage;
|
|
SIZE_T PagedPoolLimit;
|
|
SIZE_T PeakNonPagedPoolUsage;
|
|
SIZE_T NonPagedPoolUsage;
|
|
SIZE_T NonPagedPoolLimit;
|
|
SIZE_T PeakPagefileUsage;
|
|
SIZE_T PagefileUsage;
|
|
SIZE_T PagefileLimit;
|
|
} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
|
|
|
|
typedef struct _PROCESS_ACCESS_TOKEN {
|
|
HANDLE Token;
|
|
HANDLE Thread;
|
|
} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
|
|
|
|
#define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL
|
|
#define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1))
|
|
|
|
typedef struct _PROCESS_EXCEPTION_PORT {
|
|
IN HANDLE ExceptionPortHandle;
|
|
IN OUT ULONG StateFlags;
|
|
} PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT;
|
|
|
|
typedef struct _KERNEL_USER_TIMES {
|
|
LARGE_INTEGER CreateTime;
|
|
LARGE_INTEGER ExitTime;
|
|
LARGE_INTEGER KernelTime;
|
|
LARGE_INTEGER UserTime;
|
|
} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
|
|
|
|
/* NtXxx Functions */
|
|
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtOpenProcess(
|
|
OUT PHANDLE ProcessHandle,
|
|
IN ACCESS_MASK DesiredAccess,
|
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
|
IN PCLIENT_ID ClientId OPTIONAL);
|
|
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryInformationProcess(
|
|
IN HANDLE ProcessHandle,
|
|
IN PROCESSINFOCLASS ProcessInformationClass,
|
|
OUT PVOID ProcessInformation OPTIONAL,
|
|
IN ULONG ProcessInformationLength,
|
|
OUT PULONG ReturnLength OPTIONAL);
|
|
|
|
typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION {
|
|
SystemFirmwareTable_Enumerate,
|
|
SystemFirmwareTable_Get
|
|
} SYSTEM_FIRMWARE_TABLE_ACTION;
|
|
|
|
typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION {
|
|
ULONG ProviderSignature;
|
|
SYSTEM_FIRMWARE_TABLE_ACTION Action;
|
|
ULONG TableID;
|
|
ULONG TableBufferLength;
|
|
UCHAR TableBuffer[ANYSIZE_ARRAY];
|
|
} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
|
|
|
|
typedef NTSTATUS
|
|
(__cdecl *PFNFTH)(
|
|
IN OUT PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo);
|
|
|
|
typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER {
|
|
ULONG ProviderSignature;
|
|
BOOLEAN Register;
|
|
PFNFTH FirmwareTableHandler;
|
|
PVOID DriverObject;
|
|
} SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER;
|
|
|
|
typedef ULONG_PTR
|
|
(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
|
|
IN PVOID Context);
|
|
|
|
typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
|
|
PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
|
|
PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
|
|
} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
|
|
|
|
#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
|
|
#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
|
|
#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
|
|
#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
|
|
#define DRIVER_VERIFIER_IO_CHECKING 0x0010
|
|
|
|
#define MAX_WOW64_SHARED_ENTRIES 16
|
|
|
|
#define NX_SUPPORT_POLICY_ALWAYSOFF 0
|
|
#define NX_SUPPORT_POLICY_ALWAYSON 1
|
|
#define NX_SUPPORT_POLICY_OPTIN 2
|
|
#define NX_SUPPORT_POLICY_OPTOUT 3
|
|
|
|
#define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0
|
|
#define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1
|
|
#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2
|
|
#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3
|
|
#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_SPARE_V 0x4
|
|
#define SHARED_GLOBAL_FLAGS_SPARE \
|
|
(1UL << SHARED_GLOBAL_FLAGS_SPARE_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5
|
|
#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6
|
|
#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V)
|
|
|
|
#define EX_INIT_BITS(Flags, Bit) \
|
|
*((Flags)) |= (Bit) // Safe to use before concurrently accessible
|
|
|
|
#define EX_TEST_SET_BIT(Flags, Bit) \
|
|
InterlockedBitTestAndSet ((PLONG)(Flags), (Bit))
|
|
|
|
#define EX_TEST_CLEAR_BIT(Flags, Bit) \
|
|
InterlockedBitTestAndReset ((PLONG)(Flags), (Bit))
|
|
|
|
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;
|
|
|
|
#define CmResourceTypeMaximum 8
|
|
|
|
typedef struct _CM_PCCARD_DEVICE_DATA {
|
|
UCHAR Flags;
|
|
UCHAR ErrorCode;
|
|
USHORT Reserved;
|
|
ULONG BusData;
|
|
ULONG DeviceId;
|
|
ULONG LegacyBaseAddress;
|
|
UCHAR IRQMap[16];
|
|
} CM_PCCARD_DEVICE_DATA, *PCM_PCCARD_DEVICE_DATA;
|
|
|
|
#define PCCARD_MAP_ERROR 0x01
|
|
#define PCCARD_DEVICE_PCI 0x10
|
|
|
|
#define PCCARD_SCAN_DISABLED 0x01
|
|
#define PCCARD_MAP_ZERO 0x02
|
|
#define PCCARD_NO_TIMER 0x03
|
|
#define PCCARD_NO_PIC 0x04
|
|
#define PCCARD_NO_LEGACY_BASE 0x05
|
|
#define PCCARD_DUP_LEGACY_BASE 0x06
|
|
#define PCCARD_NO_CONTROLLERS 0x07
|
|
|
|
#if defined(_X86_) || defined(_AMD64_)
|
|
#define PAUSE_PROCESSOR YieldProcessor();
|
|
#elif defined(_IA64_)
|
|
#define PAUSE_PROCESSOR __yield();
|
|
#endif
|
|
|
|
#define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2))
|
|
|
|
/* Filesystem runtime library routines */
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_WIN2K)
|
|
NTKERNELAPI
|
|
BOOLEAN
|
|
NTAPI
|
|
FsRtlIsTotalDeviceFailure(
|
|
IN NTSTATUS Status);
|
|
#endif
|
|
|
|
/* FIXME : These definitions below doesn't belong to NTDDK */
|
|
|
|
#ifdef _X86_
|
|
|
|
extern NTKERNELAPI PVOID MmHighestUserAddress;
|
|
extern NTKERNELAPI PVOID MmSystemRangeStart;
|
|
extern NTKERNELAPI ULONG MmUserProbeAddress;
|
|
|
|
#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
|
|
#define MM_SYSTEM_RANGE_START MmSystemRangeStart
|
|
#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
|
|
#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
|
|
extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
|
|
#else
|
|
#define MM_USER_PROBE_ADDRESS MmUserProbeAddress
|
|
#endif
|
|
#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
|
|
#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
|
|
#define MM_SYSTEM_SPACE_END 0xFFFFFFFF
|
|
#if !defined (_X86PAE_)
|
|
#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
|
|
#else
|
|
#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
|
|
#endif
|
|
|
|
#define KeGetPcr() PCR
|
|
|
|
#define PCR_MINOR_VERSION 1
|
|
#define PCR_MAJOR_VERSION 1
|
|
|
|
typedef struct _KPCR {
|
|
union {
|
|
NT_TIB NtTib;
|
|
struct {
|
|
struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
|
|
PVOID Used_StackBase;
|
|
PVOID Spare2;
|
|
PVOID TssCopy;
|
|
ULONG ContextSwitches;
|
|
KAFFINITY SetMemberCopy;
|
|
PVOID Used_Self;
|
|
};
|
|
};
|
|
struct _KPCR *SelfPcr;
|
|
struct _KPRCB *Prcb;
|
|
KIRQL Irql;
|
|
ULONG IRR;
|
|
ULONG IrrActive;
|
|
ULONG IDR;
|
|
PVOID KdVersionBlock;
|
|
struct _KIDTENTRY *IDT;
|
|
struct _KGDTENTRY *GDT;
|
|
struct _KTSS *TSS;
|
|
USHORT MajorVersion;
|
|
USHORT MinorVersion;
|
|
KAFFINITY SetMember;
|
|
ULONG StallScaleFactor;
|
|
UCHAR SpareUnused;
|
|
UCHAR Number;
|
|
UCHAR Spare0;
|
|
UCHAR SecondLevelCacheAssociativity;
|
|
ULONG VdmAlert;
|
|
ULONG KernelReserved[14];
|
|
ULONG SecondLevelCacheSize;
|
|
ULONG HalReserved[16];
|
|
} KPCR, *PKPCR;
|
|
|
|
FORCEINLINE
|
|
ULONG
|
|
KeGetCurrentProcessorNumber(VOID)
|
|
{
|
|
return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
|
|
}
|
|
|
|
typedef enum _INTERLOCKED_RESULT {
|
|
ResultNegative = RESULT_NEGATIVE,
|
|
ResultZero = RESULT_ZERO,
|
|
ResultPositive = RESULT_POSITIVE
|
|
} INTERLOCKED_RESULT;
|
|
|
|
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_ */
|
|
|
|
#ifdef _AMD64_
|
|
|
|
#define PTI_SHIFT 12L
|
|
#define PDI_SHIFT 21L
|
|
#define PPI_SHIFT 30L
|
|
#define PXI_SHIFT 39L
|
|
#define PTE_PER_PAGE 512
|
|
#define PDE_PER_PAGE 512
|
|
#define PPE_PER_PAGE 512
|
|
#define PXE_PER_PAGE 512
|
|
#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
|
|
#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
|
|
#define PPI_MASK (PPE_PER_PAGE - 1)
|
|
#define PXI_MASK (PXE_PER_PAGE - 1)
|
|
|
|
#define PXE_BASE 0xFFFFF6FB7DBED000ULL
|
|
#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
|
|
#define PPE_BASE 0xFFFFF6FB7DA00000ULL
|
|
#define PDE_BASE 0xFFFFF6FB40000000ULL
|
|
#define PTE_BASE 0xFFFFF68000000000ULL
|
|
#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
|
|
#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
|
|
#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
|
|
#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
|
|
|
|
#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
|
|
#define MM_SYSTEM_RANGE_START MmSystemRangeStart
|
|
#define MM_USER_PROBE_ADDRESS MmUserProbeAddress
|
|
#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
|
|
#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
|
|
#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
|
|
|
|
typedef struct _KPCR
|
|
{
|
|
_ANONYMOUS_UNION union
|
|
{
|
|
NT_TIB NtTib;
|
|
_ANONYMOUS_STRUCT struct
|
|
{
|
|
union _KGDTENTRY64 *GdtBase;
|
|
struct _KTSS64 *TssBase;
|
|
ULONG64 UserRsp;
|
|
struct _KPCR *Self;
|
|
struct _KPRCB *CurrentPrcb;
|
|
PKSPIN_LOCK_QUEUE LockArray;
|
|
PVOID Used_Self;
|
|
};
|
|
};
|
|
union _KIDTENTRY64 *IdtBase;
|
|
ULONG64 Unused[2];
|
|
KIRQL Irql;
|
|
UCHAR SecondLevelCacheAssociativity;
|
|
UCHAR ObsoleteNumber;
|
|
UCHAR Fill0;
|
|
ULONG Unused0[3];
|
|
USHORT MajorVersion;
|
|
USHORT MinorVersion;
|
|
ULONG StallScaleFactor;
|
|
PVOID Unused1[3];
|
|
ULONG KernelReserved[15];
|
|
ULONG SecondLevelCacheSize;
|
|
ULONG HalReserved[16];
|
|
ULONG Unused2;
|
|
PVOID KdVersionBlock;
|
|
PVOID Unused3;
|
|
ULONG PcrAlign1[24];
|
|
} KPCR, *PKPCR;
|
|
|
|
FORCEINLINE
|
|
PKPCR
|
|
KeGetPcr(VOID)
|
|
{
|
|
return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
|
|
}
|
|
|
|
FORCEINLINE
|
|
ULONG
|
|
KeGetCurrentProcessorNumber(VOID)
|
|
{
|
|
return (ULONG)__readgsword(0x184);
|
|
}
|
|
|
|
#endif /* _AMD64_ */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|