ntddk.h revision ad27e1d5e48ca41245120c331cc88b50464813ce
/*++ BUILD Version: 0121 // Increment this if a change has global effects
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
Abstract:
This module defines the NT types, constants, and functions that are
exposed to device drivers.
Revision History:
--*/
#ifndef _NTDDK_
#define _NTDDK_
#ifndef RC_INVOKED
#if _MSC_VER < 1300
#endif
#endif // RC_INVOKED
#define NT_INCLUDED
#define _CTYPE_DISABLE_MACROS
#include <excpt.h>
#include <ntdef.h>
#include <ntstatus.h>
#include <bugcodes.h>
#include <ntiologc.h>
//
// Kernel Mutex Level Numbers (must be globally assigned within executive)
// The third token in the name is the sub-component name that defines and
// uses the level number.
//
//
// Used by Vdm for protecting io simulation structures
//
//
// The LANMAN Redirector uses the file system major function, but defines
// it's own mutex levels. We can do this safely because we know that the
// local filesystem will never call the remote filesystem and vice versa.
//
//
// File System levels.
//
//
// In the NT STREAMS environment, a mutex is used to serialize open, close
// and Scheduler threads executing in a subsystem-parallelized stack.
//
//
// Mutex level used by LDT support on x86
//
//
// Define types that are not exported.
//
typedef struct _BUS_HANDLER *PBUS_HANDLER;
typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
typedef struct _KINTERRUPT *PKINTERRUPT;
typedef struct _OBJECT_TYPE *POBJECT_TYPE;
#if defined(_M_AMD64)
);
#endif // defined(_M_AMD64)
#if defined(_M_IX86)
#endif // defined(_M_IX86)
#if defined(_M_IA64)
//
// Define Address of Processor Control Registers.
//
//
// Define Pointer to Processor Control Registers.
//
#endif // defined(_M_IA64)
#define PsGetCurrentProcess() IoGetCurrentProcess()
#include <mce.h>
#ifndef FAR
#define FAR
#endif
//
// Define alignment macros to align structure sizes and pointers up and down.
//
//@@@AH 20041106 not available in NT4SP0
//#define POOL_TAGGING 1
#ifndef DBG
#define DBG 0
#endif
#if DBG
#else
#endif
#if DEVL
extern ULONG NtGlobalFlag;
#define IF_NTOS_DEBUG( FlagName ) \
#else
#endif
//
// Kernel definitions that need to be here for forward reference purposes
//
//
// Processor modes.
//
typedef CCHAR KPROCESSOR_MODE;
typedef enum _MODE {
} MODE;
//
// APC function types
//
//
// Put in an empty definition for the KAPC so that the
// routines can reference it before it is declared.
//
struct _KAPC;
typedef
(*PKNORMAL_ROUTINE) (
);
typedef
(*PKKERNEL_ROUTINE) (
);
typedef
(*PKRUNDOWN_ROUTINE) (
);
typedef
);
typedef
(*PKTRANSFER_ROUTINE) (
);
//
//
// Asynchronous Procedure Call (APC) object
//
//
typedef struct _KAPC {
//
// N.B. The following two members MUST be together.
//
//
// DPC routine
//
struct _KDPC;
typedef
(*PKDEFERRED_ROUTINE) (
);
//
// Define DPC importance.
//
// LowImportance - Queue DPC at end of target DPC queue.
// MediumImportance - Queue DPC at end of target DPC queue.
// HighImportance - Queue DPC at front of target DPC DPC queue.
//
// If there is currently a DPC active on the target processor, or a DPC
// interrupt has already been requested on the target processor when a
// DPC is queued, then no further action is necessary. The DPC will be
// executed on the target processor when its queue entry is processed.
//
// If there is not a DPC active on the target processor and a DPC interrupt
// has not been requested on the target processor, then the exact treatment
// of the DPC is dependent on whether the host system is a UP system or an
// MP system.
//
// UP system.
//
// If the DPC is of medium or high importance, the current DPC queue depth
// is greater than the maximum target depth, or current DPC request rate is
// less the minimum target rate, then a DPC interrupt is requested on the
// host processor and the DPC will be processed when the interrupt occurs.
// Otherwise, no DPC interrupt is requested and the DPC execution will be
// delayed until the DPC queue depth is greater that the target depth or the
// minimum DPC rate is less than the target rate.
//
// MP system.
//
// If the DPC is being queued to another processor and the depth of the DPC
// queue on the target processor is greater than the maximum target depth or
// the DPC is of high importance, then a DPC interrupt is requested on the
// target processor and the DPC will be processed when the interrupt occurs.
// Otherwise, the DPC execution will be delayed on the target processor until
// the DPC queue depth on the target processor is greater that the maximum
// target depth or the minimum DPC rate on the target processor is less than
// the target minimum rate.
//
// If the DPC is being queued to the current processor and the DPC is not of
// low importance, the current DPC queue depth is greater than the maximum
// target depth, or the minimum DPC rate is less than the minimum target rate,
// then a DPC interrupt is request on the current processor and the DPV will
// be processed whne the interrupt occurs. Otherwise, no DPC interrupt is
// requested and the DPC execution will be delayed until the DPC queue depth
// is greater that the target depth or the minimum DPC rate is less than the
// target rate.
//
typedef enum _KDPC_IMPORTANCE {
//
// Define DPC type indices.
//
#define DPC_NORMAL 0
#define DPC_THREADED 1
//
// Deferred Procedure Call (DPC) object
//
typedef struct _KDPC {
//
// Interprocessor interrupt worker routine function prototype.
//
typedef PVOID PKIPI_CONTEXT;
typedef
(*PKIPI_WORKER)(
);
//
// Define interprocessor interrupt performance counters.
//
typedef struct _KIPI_COUNTS {
} KIPI_COUNTS, *PKIPI_COUNTS;
//
// I/O system definitions.
//
// Define a Memory Descriptor List (MDL)
//
// An MDL describes pages in a virtual buffer in terms of physical pages. The
// pages associated with the buffer are described in an array that is allocated
// just after the MDL header structure itself.
//
// One simply calculates the base of the array by adding one to the base
// MDL pointer:
//
// Pages = (PPFN_NUMBER) (Mdl + 1);
//
// Notice that while in the context of the subject thread, the base virtual
// address of a buffer mapped by an MDL may be referenced using the following:
//
// Mdl->StartVa | Mdl->ByteOffset
//
typedef struct _MDL {
#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_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \
MDL_PAGES_LOCKED | \
MDL_SYSTEM_VA | \
//
// switch to DBG when appropriate
//
#ifdef DEBUG
#define PAGED_CODE() \
{ if (KeGetCurrentIrql() > APC_LEVEL) { \
Log(("i8042prt: %s: EXECPTION: IOCTL_MRX_VBOX_GETGLOBALCONN: Pageable code called at IRQL = %d! This driver will raise a bugcheck now ....\n", __FUNCTION__, KeGetCurrentIrql())); \
} \
}
#else
#define PAGED_CODE() NOP_FUNCTION;
#endif
#define NTKERNELAPI DECLSPEC_IMPORT
#else
#define NTHALAPI // nthal
#endif
//
// Common dispatcher object header
//
// N.B. The size field contains the number of dwords in the structure.
//
typedef struct _DISPATCHER_HEADER {
union {
struct {
union {
};
};
};
//
// Event object
//
typedef struct _KEVENT {
//
// Timer object
//
typedef struct _KTIMER {
typedef enum _LOCK_OPERATION {
#ifdef _X86_
//
// Disable these two pragmas that evaluate to "sti" "cli" on x86 so that driver
// writers to not leave them inadvertently in their code.
//
#if !defined(MIDL_PASS)
#if !defined(RC_INVOKED)
#if _MSC_VER >= 1200
#endif
// build with /Od don't get weird errors !
#ifdef _M_IX86
#endif
#if _MSC_VER >= 1200
#else
#endif
#endif
#endif
#if (_MSC_FULL_VER >= 13012035)
//
// Define bit scan intrinsics.
//
//#define BitScanForward _BitScanForward
//#define BitScanReverse _BitScanReverse
//BOOLEAN
//_BitScanForward (
// OUT ULONG *Index,
// IN ULONG Mask
// );
//BOOLEAN
//_BitScanReverse (
// OUT ULONG *Index,
// IN ULONG Mask
// );
//#pragma intrinsic(_BitScanForward)
//#pragma intrinsic(_BitScanReverse)
//
// Define FS referencing intrinsics
//
#ifdef __cplusplus
extern "C" {
#endif
);
);
);
);
);
);
#ifdef __cplusplus
}
#endif
#pragma intrinsic(__readfsbyte)
#pragma intrinsic(__readfsword)
#pragma intrinsic(__readfsdword)
#pragma intrinsic(__writefsbyte)
#pragma intrinsic(__writefsword)
#pragma intrinsic(__writefsdword)
#endif
#endif
//
// Size of kernel mode stack.
//
#define KERNEL_STACK_SIZE 12288
//
// Define size of large kernel mode stack for callbacks.
//
#define KERNEL_LARGE_STACK_SIZE 61440
//
// Define number of pages to initialize in a large kernel stack.
//
#define KERNEL_LARGE_STACK_COMMIT 12288
#ifdef _X86_
)
{
__asm {
}
}
//
// Prefetch is not supported on all x86 processors.
//
#define PreFetchCacheLine(l, a)
//
// PreFetchCacheLine level defines.
//
#define PF_TEMPORAL_LEVEL_1
#define PF_NON_TEMPORAL_LEVEL_ALL
#endif
//
// Define the size of the 80387 save area, which is in the context frame.
//
#define SIZE_OF_80387_REGISTERS 80
//
// The following flags control the contents of the CONTEXT structure.
//
#if !defined(RC_INVOKED)
#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
#endif
#define MAXIMUM_SUPPORTED_EXTENSION 512
typedef struct _FLOATING_SAVE_AREA {
typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
//
// Context Frame
//
// This frame has a several purposes: 1) it is used as an argument to
// NtContinue, 2) is is used to construct a call frame for APC delivery,
// and 3) it is used in the user level thread creation routines.
//
// The layout of the record conforms to a standard call frame.
//
typedef struct _CONTEXT {
//
// The flags values within this flag control the contents of
// a CONTEXT record.
//
// If the context record is used as an input parameter, then
// for each portion of the context record controlled by a flag
// whose value is set, it is assumed that that portion of the
// context record contains valid context. If the context record
// is being used to modify a threads context, then only that
// portion of the threads context will be modified.
//
// If the context record is used as an IN OUT parameter to capture
// the context of a thread, then only those portions of the thread's
// context corresponding to set flags will be returned.
//
// The context record is never used as an OUT only parameter.
//
//
// set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
// included in CONTEXT_FULL.
//
//
// ContextFlags word contains the flag CONTEXT_FLOATING_POINT.
//
//
// ContextFlags word contains the flag CONTEXT_SEGMENTS.
//
//
// ContextFlags word contains the flag CONTEXT_INTEGER.
//
//
// ContextFlags word contains the flag CONTEXT_CONTROL.
//
//
// contains the flag CONTEXT_EXTENDED_REGISTERS.
// The format and contexts are processor specific
//
} CONTEXT;
#endif //_X86_
#endif // _X86_
#if defined(_AMD64_)
//
// Define bit test intrinsics.
//
#ifdef __cplusplus
extern "C" {
#endif
#define BitTestAndSet _bittestandset
#define BitTestAndReset _bittestandreset
#define BitTest64 _bittest64
#define BitTestAndSet64 _bittestandset64
#define BitTestAndReset64 _bittestandreset64
_bittest (
);
);
);
);
);
);
);
);
);
);
);
);
#pragma intrinsic(_bittestandcomplement)
#pragma intrinsic(_bittestandset)
#pragma intrinsic(_bittestandreset)
#pragma intrinsic(_interlockedbittestandset)
#pragma intrinsic(_interlockedbittestandreset)
#pragma intrinsic(_bittest64)
#pragma intrinsic(_bittestandcomplement64)
#pragma intrinsic(_bittestandset64)
#pragma intrinsic(_bittestandreset64)
#pragma intrinsic(_interlockedbittestandset64)
#pragma intrinsic(_interlockedbittestandreset64)
//
// Define bit scan intrinsics.
//
#define BitScanForward _BitScanForward
#define BitScanReverse _BitScanReverse
#define BitScanForward64 _BitScanForward64
#define BitScanReverse64 _BitScanReverse64
);
);
);
);
#pragma intrinsic(_BitScanForward)
#pragma intrinsic(_BitScanReverse)
#pragma intrinsic(_BitScanForward64)
#pragma intrinsic(_BitScanReverse64)
//
// Define function to flush a cache line.
//
);
#pragma intrinsic(_mm_clflush)
//
// Define memory fence intrinsics
//
#define LoadFence _mm_lfence
#define MemoryFence _mm_mfence
#define StoreFence _mm_sfence
);
);
);
void
int sel
);
/* constants for use with _mm_prefetch */
#define _MM_HINT_T0 1
#define _MM_HINT_T1 2
#define _MM_HINT_T2 3
#define _MM_HINT_NTA 0
#pragma intrinsic(_mm_prefetch)
#pragma intrinsic(_mm_lfence)
#pragma intrinsic(_mm_mfence)
#pragma intrinsic(_mm_sfence)
#define YieldProcessor()
#define MemoryBarrier _mm_mfence
//
// PreFetchCacheLine level defines.
//
#define PF_TEMPORAL_LEVEL_1 _MM_HINT_T0
//
// Define function to get the caller's EFLAGs value.
//
#define GetCallersEflags() __getcallerseflags()
unsigned __int32
);
#pragma intrinsic(__getcallerseflags)
//
// Define function to read the value of the time stamp counter
//
#define ReadTimeStampCounter() __rdtsc()
__rdtsc (
);
//
// Define functions to move strings as bytes, words, dwords, and qwords.
//
__movsb (
);
__movsw (
);
__movsd (
);
__movsq (
);
//
// Define functions to store strings as bytes, words, dwords, and qwords.
//
__stosb (
);
__stosw (
);
__stosd (
);
__stosq (
);
//
// Define functions to capture the high 64-bits of a 128-bit multiply.
//
#define MultiplyHigh __mulh
#define UnsignedMultiplyHigh __umulh
);
);
//
//
);
);
);
);
);
);
);
);
#pragma intrinsic(__readgsbyte)
#pragma intrinsic(__readgsword)
#pragma intrinsic(__readgsdword)
#pragma intrinsic(__readgsqword)
#pragma intrinsic(__writegsbyte)
#pragma intrinsic(__writegsword)
#pragma intrinsic(__writegsdword)
#pragma intrinsic(__writegsqword)
#ifdef __cplusplus
}
#endif
#endif // defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
//
// Size of kernel mode stack.
//
#define KERNEL_STACK_SIZE 0x6000
//
// Define size of large kernel mode stack for callbacks.
//
#define KERNEL_LARGE_STACK_SIZE 0xf000
//
// Define number of pages to initialize in a large kernel stack.
//
#define KERNEL_LARGE_STACK_COMMIT 0x5000
//
// Define the size of the stack used for processing an MCA exception.
//
#define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000
//
// The following flags control the contents of the CONTEXT structure.
//
#if !defined(RC_INVOKED)
#define CONTEXT_AMD64 0x100000
#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
#endif // !defined(RC_INVOKED)
//
// Define initial MxCsr control.
//
//
// Define 128-bit 16-byte aligned xmm register type.
//
//
//
// This structure is used to store the legacy floating point state.
//
typedef struct _LEGACY_SAVE_AREA {
//
// Context Frame
//
// This frame has a several purposes: 1) it is used as an argument to
// NtContinue, 2) is is used to construct a call frame for APC delivery,
// and 3) it is used in the user level thread creation routines.
//
//
// The flags field within this record controls the contents of a CONTEXT
// record.
//
// If the context record is used as an input parameter, then for each
// portion of the context record controlled by a flag whose value is
// set, it is assumed that that portion of the context record contains
// valid context. If the context record is being used to modify a threads
// context, then only that portion of the threads context is modified.
//
// If the context record is used as an output parameter to capture the
// context of a thread, then only those portions of the thread's context
// corresponding to set flags will be returned.
//
// CONTEXT_CONTROL specifies SegSs, Rsp, SegCs, Rip, and EFlags.
//
// CONTEXT_INTEGER specifies Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8-R15.
//
// CONTEXT_SEGMENTS specifies SegDs, SegEs, SegFs, and SegGs.
//
// CONTEXT_DEBUG_REGISTERS specifies Dr0-Dr3 and Dr6-Dr7.
//
// CONTEXT_MMX_REGISTERS specifies the floating point and extended registers
//
//
// Register parameter home addresses.
//
//
// Control flags.
//
//
// Segment Registers and processor flags.
//
//
// Debug registers
//
//
// Integer registers.
//
//
// Program counter.
//
//
//
//
// Legacy floating point state.
//
//
// Special debug control registers.
//
#endif // _AMD64_
#ifdef _IA64_
//
// Define size of kernel mode stack.
//
#define KERNEL_STACK_SIZE 0x8000
//
// Define size of large kernel mode stack for callbacks.
//
#define KERNEL_LARGE_STACK_SIZE 0x1A000
//
// Define number of pages to initialize in a large kernel stack.
//
#define KERNEL_LARGE_STACK_COMMIT 0x8000
//
// Define size of kernel mode backing store stack.
//
#define KERNEL_BSTORE_SIZE 0x8000
//
// Define size of large kernel mode backing store for callbacks.
//
#define KERNEL_LARGE_BSTORE_SIZE 0x10000
//
// Define number of pages to initialize in a large kernel backing store.
//
#define KERNEL_LARGE_BSTORE_COMMIT 0x8000
//
// Define base address for kernel and user space.
//
#define UREGION_INDEX 0
#define KREGION_INDEX 7
void
void
);
void
__mf(
void
);
void
int Level,
);
void
int Level,
);
//
// __lfetch control defines.
//
#define MD_LFHINT_NONE 0x00
#define MD_LFHINT_NT1 0x01
#define MD_LFHINT_NT2 0x02
#define MD_LFHINT_NTA 0x03
#pragma intrinsic (__lfetchfault)
#define YieldProcessor __yield
#define MemoryBarrier __mf
#define PreFetchCacheLine __lfetch
//
// PreFetchCacheLine level defines.
//
#define PF_TEMPORAL_LEVEL_1 MD_LFHINT_NONE
//
// The following flags control the contents of the CONTEXT structure.
//
#if !defined(RC_INVOKED)
#define CONTEXT_IA64 0x00080000
#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
#define CONTEXT_EXCEPTION_ACTIVE 0x8000000
#define CONTEXT_SERVICE_ACTIVE 0x10000000
#define CONTEXT_EXCEPTION_REQUEST 0x40000000
#define CONTEXT_EXCEPTION_REPORTING 0x80000000
#endif // !defined(RC_INVOKED)
//
// Context Frame
//
// This frame has a several purposes: 1) it is used as an argument to
// NtContinue, 2) it is used to construct a call frame for APC delivery,
// 3) it is used to construct a call frame for exception dispatching
// in user mode, 4) it is used in the user level thread creation
// routines, and 5) it is used to to pass thread state to debuggers.
//
// N.B. Because this record is used as a call frame, it must be EXACTLY
// a multiple of 16 bytes in length and aligned on a 16-byte boundary.
//
typedef struct _CONTEXT {
//
// The flags values within this flag control the contents of
// a CONTEXT record.
//
// If the context record is used as an input parameter, then
// for each portion of the context record controlled by a flag
// whose value is set, it is assumed that that portion of the
// context record contains valid context. If the context record
// is being used to modify a thread's context, then only that
// portion of the threads context will be modified.
//
// If the context record is used as an IN OUT parameter to capture
// the context of a thread, then only those portions of the thread's
// context corresponding to set flags will be returned.
//
// The context record is never used as an OUT only parameter.
//
//
// the flag CONTEXT_DEBUG.
//
// N.B. CONTEXT_DEBUG is *not* part of CONTEXT_FULL.
//
//
// the flag CONTEXT_LOWER_FLOATING_POINT.
//
//
// the flag CONTEXT_HIGHER_FLOATING_POINT.
//
//
// the flag CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT | CONTEXT_CONTROL.
//
//
// the flag CONTEXT_INTEGER.
//
// N.B. The registers gp, sp, rp are part of the control context
//
// r1-r31 in bits 1 thru 31.
//
// the flag CONTEXT_CONTROL.
//
// Other application registers
// Register stack info
// Trap Status Information
// iA32 related control registers
//
// Plabel descriptor structure definition
//
typedef struct _PLABEL_DESCRIPTOR {
#endif // _IA64_
//
// Define an access token from a programmer's viewpoint. The structure is
// completely opaque and the programer is only allowed to have pointers
// to tokens.
//
typedef PVOID PACCESS_TOKEN;
//
// Pointer to a SECURITY_DESCRIPTOR opaque data type.
//
typedef PVOID PSECURITY_DESCRIPTOR;
//
// Define a pointer to the Security ID data type (an opaque data type)
//
typedef ULONG ACCESS_MASK;
typedef ACCESS_MASK *PACCESS_MASK;
//
// The following are masks for the predefined standard access types
//
#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)
//
// AccessSystemAcl access type
//
#define ACCESS_SYSTEM_SECURITY (0x01000000L)
//
// MaximumAllowed access type
//
#define MAXIMUM_ALLOWED (0x02000000L)
//
// These are the generic rights.
//
#define GENERIC_READ (0x80000000L)
#define GENERIC_WRITE (0x40000000L)
#define GENERIC_EXECUTE (0x20000000L)
#define GENERIC_ALL (0x10000000L)
//
// Define the generic mapping array. This is used to denote the
// mapping of each generic access right to a specific access mask.
//
typedef struct _GENERIC_MAPPING {
typedef GENERIC_MAPPING *PGENERIC_MAPPING;
////////////////////////////////////////////////////////////////////////
// //
// LUID_AND_ATTRIBUTES //
// //
////////////////////////////////////////////////////////////////////////
//
//
#include <pshpack4.h>
typedef struct _LUID_AND_ATTRIBUTES {
#include <poppack.h>
typedef enum {
WinNullSid = 0,
WinWorldSid = 1,
WinLocalSid = 2,
WinCreatorOwnerSid = 3,
WinCreatorGroupSid = 4,
WinNtAuthoritySid = 7,
WinDialupSid = 8,
WinNetworkSid = 9,
WinBatchSid = 10,
WinInteractiveSid = 11,
WinServiceSid = 12,
WinAnonymousSid = 13,
WinProxySid = 14,
WinSelfSid = 16,
WinAuthenticatedUserSid = 17,
WinRestrictedCodeSid = 18,
WinTerminalServerSid = 19,
WinRemoteLogonIdSid = 20,
WinLogonIdsSid = 21,
WinLocalSystemSid = 22,
WinLocalServiceSid = 23,
WinNetworkServiceSid = 24,
WinBuiltinDomainSid = 25,
WinBuiltinUsersSid = 27,
WinBuiltinGuestsSid = 28,
WinBuiltinPowerUsersSid = 29,
WinBuiltinReplicatorSid = 34,
WinAccountGuestSid = 39,
WinAccountKrbtgtSid = 40,
WinAccountDomainUsersSid = 42,
WinAccountComputersSid = 44,
WinAccountControllersSid = 45,
WinAccountCertAdminsSid = 46,
WinNTLMAuthenticationSid = 51,
WinThisOrganizationSid = 54,
WinOtherOrganizationSid = 55,
// This is the *current* ACL revision
#define ACL_REVISION (2)
#define ACL_REVISION_DS (4)
// This is the history of ACL revisions. Add a new one whenever
// ACL_REVISION is updated
#define ACL_REVISION1 (1)
#define MIN_ACL_REVISION ACL_REVISION2
#define ACL_REVISION2 (2)
#define ACL_REVISION3 (3)
#define ACL_REVISION4 (4)
#define MAX_ACL_REVISION ACL_REVISION4
typedef struct _ACL {
} ACL;
//
// Current security descriptor revision value
//
#define SECURITY_DESCRIPTOR_REVISION (1)
#define SECURITY_DESCRIPTOR_REVISION1 (1)
//
// 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)
//
// Privilege Set Control flags
//
#define PRIVILEGE_SET_ALL_NECESSARY (1)
//
// Privilege Set - This is defined for a privilege set of one.
// If more than one privilege is needed, then this structure
// will need to be allocated with more space.
//
// Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET
// structure (defined in se.h)
//
typedef struct _PRIVILEGE_SET {
} PRIVILEGE_SET, * PPRIVILEGE_SET;
//
// These must be converted to LUIDs before use.
//
#define SE_MIN_WELL_KNOWN_PRIVILEGE (2L)
#define SE_CREATE_TOKEN_PRIVILEGE (2L)
#define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE (3L)
#define SE_LOCK_MEMORY_PRIVILEGE (4L)
#define SE_INCREASE_QUOTA_PRIVILEGE (5L)
//
// Unsolicited Input is obsolete and unused.
//
#define SE_UNSOLICITED_INPUT_PRIVILEGE (6L)
#define SE_MACHINE_ACCOUNT_PRIVILEGE (6L)
#define SE_TCB_PRIVILEGE (7L)
#define SE_SECURITY_PRIVILEGE (8L)
#define SE_TAKE_OWNERSHIP_PRIVILEGE (9L)
#define SE_LOAD_DRIVER_PRIVILEGE (10L)
#define SE_SYSTEM_PROFILE_PRIVILEGE (11L)
#define SE_SYSTEMTIME_PRIVILEGE (12L)
#define SE_PROF_SINGLE_PROCESS_PRIVILEGE (13L)
#define SE_INC_BASE_PRIORITY_PRIVILEGE (14L)
#define SE_CREATE_PAGEFILE_PRIVILEGE (15L)
#define SE_CREATE_PERMANENT_PRIVILEGE (16L)
#define SE_BACKUP_PRIVILEGE (17L)
#define SE_RESTORE_PRIVILEGE (18L)
#define SE_SHUTDOWN_PRIVILEGE (19L)
#define SE_DEBUG_PRIVILEGE (20L)
#define SE_AUDIT_PRIVILEGE (21L)
#define SE_SYSTEM_ENVIRONMENT_PRIVILEGE (22L)
#define SE_CHANGE_NOTIFY_PRIVILEGE (23L)
#define SE_REMOTE_SHUTDOWN_PRIVILEGE (24L)
#define SE_UNDOCK_PRIVILEGE (25L)
#define SE_SYNC_AGENT_PRIVILEGE (26L)
#define SE_ENABLE_DELEGATION_PRIVILEGE (27L)
#define SE_MANAGE_VOLUME_PRIVILEGE (28L)
#define SE_IMPERSONATE_PRIVILEGE (29L)
#define SE_CREATE_GLOBAL_PRIVILEGE (30L)
//
// Impersonation Level
//
// Impersonation level is represented by a pair of bits in Windows.
// If a new impersonation level is added or lowest value is changed from
// 0 to something else, fix the Windows CreateFile call.
//
typedef enum _SECURITY_IMPERSONATION_LEVEL {
#define VALID_IMPERSONATION_LEVEL(L) (((L) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((L) <= SECURITY_MAX_IMPERSONATION_LEVEL))
//
// Security Tracking Mode
//
#define SECURITY_DYNAMIC_TRACKING (TRUE)
#define SECURITY_STATIC_TRACKING (FALSE)
typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
//
// Quality Of Service
//
typedef struct _SECURITY_QUALITY_OF_SERVICE {
//
// Used to represent information related to a thread impersonation
//
typedef struct _SE_IMPERSONATION_STATE {
#define OWNER_SECURITY_INFORMATION (0x00000001L)
#define GROUP_SECURITY_INFORMATION (0x00000002L)
#define DACL_SECURITY_INFORMATION (0x00000004L)
#define SACL_SECURITY_INFORMATION (0x00000008L)
#define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
#define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
#define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
#define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
#define LOW_PRIORITY 0 // Lowest thread priority level
//
// Define system time structure.
//
typedef struct _KSYSTEM_TIME {
//
// Thread priority
//
//
// Spin Lock
//
typedef ULONG_PTR KSPIN_LOCK;
typedef KSPIN_LOCK *PKSPIN_LOCK;
//
// Define per processor lock queue structure.
//
// N.B. The lock field of the spin lock queue structure contains the address
// of the associated kernel spin lock, an owner bit, and a lock bit. Bit
// 0 of the spin lock address is the wait bit and bit 1 is the owner bit.
// The use of this field is such that the bits can be set and cleared
// noninterlocked, however, the back pointer must be preserved.
//
// The lock wait bit is set when a processor enqueues itself on the lock
// queue and it is not the only entry in the queue. The processor will
// spin on this bit waiting for the lock to be granted.
//
// The owner bit is set when the processor owns the respective lock.
//
// The next field of the spin lock queue structure is used to line the
// queued lock structures together in fifo order. It also can set set and
// cleared noninterlocked.
//
#define LOCK_QUEUE_WAIT 1
#define LOCK_QUEUE_OWNER 2
typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
typedef struct _KSPIN_LOCK_QUEUE {
struct _KSPIN_LOCK_QUEUE * volatile Next;
PKSPIN_LOCK volatile Lock;
typedef struct _KLOCK_QUEUE_HANDLE {
//
// Interrupt routine (first level dispatch)
//
typedef
(*PKINTERRUPT_ROUTINE) (
);
//
// Profile source types
//
typedef enum _KPROFILE_SOURCE {
//
// for move macros
//
#ifdef _MAC
#ifndef _INC_STRING
#include <string.h>
#endif /* _INC_STRING */
#else
#include <string.h>
#endif // _MAC
#ifndef _SLIST_HEADER_
#define _SLIST_HEADER_
#if defined(_WIN64)
//
// The type SINGLE_LIST_ENTRY is not suitable for use with SLISTs. For
// WIN64, an entry on an SLIST is required to be 16-byte aligned, while a
// SINGLE_LIST_ENTRY structure has only 8 byte alignment.
//
// Therefore, all SLIST code should use the SLIST_ENTRY type instead of the
// SINGLE_LIST_ENTRY type.
//
} SLIST_ENTRY;
#else
#define SLIST_ENTRY SINGLE_LIST_ENTRY
#define _SLIST_ENTRY _SINGLE_LIST_ENTRY
#define PSLIST_ENTRY PSINGLE_LIST_ENTRY
#endif
#if defined(_WIN64)
} SLIST_HEADER;
typedef struct _SLIST_HEADER *PSLIST_HEADER;
#else
typedef union _SLIST_HEADER {
struct {
};
#endif
#endif
//
// If debugging support enabled, define an ASSERT macro that works. Otherwise
// define the ASSERT macro to expand to an empty expression.
//
// The ASSERT macro has been updated to be an expression instead of a statement.
//
);
#if DBG
((!(exp)) ? \
TRUE)
((!(exp)) ? \
TRUE)
#define RTL_SOFT_ASSERT(_exp) \
((!(_exp)) ? \
TRUE)
((!(_exp)) ? \
(DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #_exp, (_msg)),FALSE) : \
TRUE)
#define RTL_VERIFY ASSERT
#define RTL_VERIFYMSG ASSERTMSG
#define RTL_SOFT_VERIFY RTL_SOFT_ASSERT
#define RTL_SOFT_VERIFYMSG RTL_SOFT_ASSERTMSG
#else
#define RTL_SOFT_ASSERT(_exp) ((void) 0)
#endif // DBG
//
// Doubly-linked list manipulation routines.
//
//
// VOID
// InitializeListHead32(
// PLIST_ENTRY32 ListHead
// );
//
#define InitializeListHead32(ListHead) (\
#if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
)
{
}
//
// BOOLEAN
// IsListEmpty(
// PLIST_ENTRY ListHead
// );
//
#define IsListEmpty(ListHead) \
)
{
}
)
{
return Entry;
}
)
{
return Entry;
}
)
{
}
)
{
}
//
//
// PSINGLE_LIST_ENTRY
// PopEntryList(
// PSINGLE_LIST_ENTRY ListHead
// );
//
#define PopEntryList(ListHead) \
{\
if (FirstEntry != NULL) { \
} \
}
//
// VOID
// PushEntryList(
// PSINGLE_LIST_ENTRY ListHead,
// PSINGLE_LIST_ENTRY Entry
// );
//
#endif // !MIDL_PASS
);
#pragma intrinsic(_ReturnAddress)
#endif
*CallersCaller = NULL;
#else
);
#endif
);
//
// Subroutines for dealing with the Registry
//
);
typedef struct _RTL_QUERY_REGISTRY_TABLE {
//
// The following flags specify how the Name field of a RTL_QUERY_REGISTRY_TABLE
// entry is interpreted. A NULL name indicates the end of the table.
//
// table or until next subkey are value
// names for that subkey to look at.
// this and all following table entries.
// entry.
// value name, just wants a call out, not
// an enumeration of all values.
// REG_MULTI_SZ into multiple callouts or
// to prevent the expansion of environment
// variable values in REG_EXPAND_SZ
// field points to location to store value.
// For null terminated strings, EntryContext
// points to UNICODE_STRING structure that
// that describes maximum size of buffer.
// If .Buffer field is NULL then a buffer is
// allocated.
//
// are queried.
);
);
);
);
);
//
// The following values for the RelativeTo parameter determine what the
// Path parameter to RtlQueryRegistryValues is relative to.
//
#define RTL_REGISTRY_ABSOLUTE 0 // Path is a full path
#define RTL_REGISTRY_MAXIMUM 6
);
);
);
#ifdef _WIN64
#else
#define RtlIntPtrToUnicodeString(Value, Base, String) RtlIntegerToUnicodeString(Value, Base, String)
#endif
);
//
// String manipulation routines
//
#ifdef _NTSYSTEM_
#define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
#else
#define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
#define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
#endif // _NTSYSTEM_
);
);
);
const STRING * SourceString
);
);
);
);
const STRING * SourceString
);
//
// NLS String functions
//
);
);
);
);
#define HASH_STRING_ALGORITHM_DEFAULT (0)
#define HASH_STRING_ALGORITHM_X65599 (1)
#define HASH_STRING_ALGORITHM_INVALID (0xffffffff)
);
);
);
);
);
);
);
);
);
);
);
//
// NTSYSAPI
// ULONG
// NTAPI
// RtlAnsiStringToUnicodeSize(
// PANSI_STRING AnsiString
// );
//
#define RtlAnsiStringToUnicodeSize(STRING) ( \
)
#include <guiddef.h>
#ifndef DEFINE_GUIDEX
#endif // !defined(DEFINE_GUIDEX)
#ifndef STATICGUIDOF
#endif // !defined(STATICGUIDOF)
#ifndef __IID_ALIGNED__
#define __IID_ALIGNED__
#ifdef __cplusplus
{
return ((*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)));
}
#else // !__cplusplus
((*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)))
#endif // !__cplusplus
#endif // !__IID_ALIGNED__
);
);
//
// Fast primitives to compare, move, and zero memory
//
);
#if defined(_M_AMD64)
);
);
);
);
#else
#endif
#if !defined(MIDL_PASS)
)
{
while (cnt) {
*vptr = 0;
vptr++;
cnt--;
}
return ptr;
}
#endif
#define RtlCopyBytes RtlCopyMemory
#define RtlZeroBytes RtlZeroMemory
#define RtlFillBytes RtlFillMemory
#if defined(_M_AMD64)
);
#else
#endif
);
//
// Define kernel debugger print prototypes and macros.
//
// N.B. The following function cannot be directly imported because there are
// a few places in the source tree where this function is redefined.
//
);
);
#define DBG_STATUS_CONTROL_C 1
#define DBG_STATUS_SYSRQ 2
#define DBG_STATUS_BUGCHECK_FIRST 3
#define DBG_STATUS_BUGCHECK_SECOND 4
#define DBG_STATUS_FATAL 5
#define DBG_STATUS_DEBUG_CONTROL 6
#define DBG_STATUS_WORKER 7
#if DBG
#define KdBreakPoint() DbgBreakPoint()
#define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s)
#else
#define vKdPrintEx(_x_)
#define vKdPrintExWithPrefix(_x_)
#define KdBreakPoint()
#define KdBreakPointWithStatus(s)
#endif
#ifndef _DBGNT_
...
);
...
);
#ifdef _VA_LIST_DEFINED
);
);
#endif
...
);
);
);
#endif // _DBGNT_
//
// Large integer arithmetic routines.
//
//
// Large integer add - 64-bits + 64-bits -> 64-bits
//
#if !defined(MIDL_PASS)
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Sum;
}
//
// Enlarged integer multiply - 32-bits * 32-bits -> 64-bits
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Product;
}
//
// Unsigned enlarged integer multiply - 32-bits * 32-bits -> 64-bits
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Product;
}
//
// Enlarged integer divide - 64-bits / 32-bits > 32-bits
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
if (ARGUMENT_PRESENT(Remainder)) {
}
return Quotient;
}
//
// Large integer negation - -(64-bits)
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Difference;
}
//
// Large integer subtract - 64-bits - 64-bits -> 64-bits.
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Difference;
}
//
// Extended large integer magic divide - 64-bits / 32-bits -> 64-bits
//
#if defined(_AMD64_)
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
} else {
}
}
return Quotient;
}
#endif // defined(_AMD64_)
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
);
#endif // defined(_X86_) || defined(_IA64_)
//
// Large Integer divide - 64-bits / 32-bits -> 64-bits
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
if (ARGUMENT_PRESENT(Remainder)) {
}
return Quotient;
}
//
// Large Integer divide - 64-bits / 64-bits -> 64-bits
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
if (ARGUMENT_PRESENT(Remainder)) {
}
return Quotient;
}
//
// Extended integer multiply - 32-bits * 64-bits -> 64-bits
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Product;
}
#else
//
// Large Integer divide - 64-bits / 32-bits -> 64-bits
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
);
//
// Large Integer divide - 64-bits / 64-bits -> 64-bits
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
);
//
// Extended integer multiply - 32-bits * 64-bits -> 64-bits
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
);
#endif // defined(_AMD64_) || defined(_IA64_)
//
// Large integer and - 64-bite & 64-bits -> 64-bits.
//
#endif
//
// Convert signed integer to large integer.
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Result;
}
//
// Convert unsigned integer to large integer.
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Result;
}
//
// Large integer shift routines.
//
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Result;
}
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Result;
}
DECLSPEC_DEPRECATED_DDK // Use native __int64 math
)
{
return Result;
}
//
// Large integer comparison routines.
//
#endif
#define RtlLargeIntegerGreaterThan(X,Y) ( \
)
#define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \
)
#define RtlLargeIntegerEqualTo(X,Y) ( \
)
#define RtlLargeIntegerNotEqualTo(X,Y) ( \
)
#define RtlLargeIntegerLessThan(X,Y) ( \
)
#define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \
)
#define RtlLargeIntegerGreaterThanZero(X) ( \
((X).HighPart > 0 ) \
)
#define RtlLargeIntegerGreaterOrEqualToZero(X) ( \
(X).HighPart >= 0 \
)
#define RtlLargeIntegerEqualToZero(X) ( \
)
#define RtlLargeIntegerNotEqualToZero(X) ( \
)
#define RtlLargeIntegerLessThanZero(X) ( \
((X).HighPart < 0) \
)
#define RtlLargeIntegerLessOrEqualToZero(X) ( \
)
#endif // !defined(MIDL_PASS)
//
// Time conversion routines
//
typedef struct _TIME_FIELDS {
} TIME_FIELDS;
typedef TIME_FIELDS *PTIME_FIELDS;
);
//
// A time field record (Weekday ignored) -> 64 bit Time value
//
);
//
// The following macros store and retrieve USHORTS and ULONGS from potentially
// unaligned addresses, avoiding alignment faults. they should probably be
// rewritten in assembler
//
#define SHORT_SIZE (sizeof(USHORT))
#define LONGLONG_SIZE (sizeof(LONGLONG))
#define LOWBYTE_MASK 0x00FF
//
// if MIPS Big Endian, order of bytes is reversed.
//
#define SHORT_LEAST_SIGNIFICANT_BIT 0
#define SHORT_MOST_SIGNIFICANT_BIT 1
#define LONG_LEAST_SIGNIFICANT_BIT 0
#define LONG_3RD_MOST_SIGNIFICANT_BIT 1
#define LONG_2ND_MOST_SIGNIFICANT_BIT 2
#define LONG_MOST_SIGNIFICANT_BIT 3
//++
//
// VOID
// RtlStoreUshort (
// PUSHORT ADDRESS
// USHORT VALUE
// )
//
// Routine Description:
//
// This macro stores a USHORT value in at a particular address, avoiding
// alignment faults.
//
// Arguments:
//
// ADDRESS - where to store USHORT value
// VALUE - USHORT to store
//
// Return Value:
//
// none.
//
//--
} \
else { \
}
//++
//
// VOID
// RtlStoreUlong (
// PULONG ADDRESS
// ULONG VALUE
// )
//
// Routine Description:
//
// This macro stores a ULONG value in at a particular address, avoiding
// alignment faults.
//
// Arguments:
//
// ADDRESS - where to store ULONG value
// VALUE - ULONG to store
//
// Return Value:
//
// none.
//
// Note:
// Depending on the machine, we might want to call storeushort in the
// unaligned case.
//
//--
} \
else { \
}
//++
//
// VOID
// RtlStoreUlonglong (
// PULONGLONG ADDRESS
// ULONG VALUE
// )
//
// Routine Description:
//
// This macro stores a ULONGLONG value in at a particular address, avoiding
// alignment faults.
//
// Arguments:
//
// ADDRESS - where to store ULONGLONG value
// VALUE - ULONGLONG to store
//
// Return Value:
//
// none.
//
//--
} else { \
}
//++
//
// VOID
// RtlStoreUlongPtr (
// PULONG_PTR ADDRESS
// ULONG_PTR VALUE
// )
//
// Routine Description:
//
// This macro stores a ULONG_PTR value in at a particular address, avoiding
// alignment faults.
//
// Arguments:
//
// ADDRESS - where to store ULONG_PTR value
// VALUE - ULONG_PTR to store
//
// Return Value:
//
// none.
//
//--
#ifdef _WIN64
#else
#endif
//++
//
// VOID
// RtlRetrieveUshort (
// PUSHORT DESTINATION_ADDRESS
// PUSHORT SOURCE_ADDRESS
// )
//
// Routine Description:
//
// This macro retrieves a USHORT value from the SOURCE address, avoiding
// alignment faults. The DESTINATION address is assumed to be aligned.
//
// Arguments:
//
// DESTINATION_ADDRESS - where to store USHORT value
// SOURCE_ADDRESS - where to retrieve USHORT value from
//
// Return Value:
//
// none.
//
//--
} \
else { \
} \
//++
//
// VOID
// RtlRetrieveUlong (
// PULONG DESTINATION_ADDRESS
// PULONG SOURCE_ADDRESS
// )
//
// Routine Description:
//
// This macro retrieves a ULONG value from the SOURCE address, avoiding
// alignment faults. The DESTINATION address is assumed to be aligned.
//
// Arguments:
//
// DESTINATION_ADDRESS - where to store ULONG value
// SOURCE_ADDRESS - where to retrieve ULONG value from
//
// Return Value:
//
// none.
//
// Note:
// Depending on the machine, we might want to call retrieveushort in the
// unaligned case.
//
//--
} \
else { \
}
//
// BitMap routines. The following structure, routines, and macros are
// for manipulating bitmaps. The user is responsible for allocating a bitmap
// structure (which is really a header) and a buffer (which must be longword
// aligned and multiple longwords in size).
//
typedef struct _RTL_BITMAP {
} RTL_BITMAP;
typedef RTL_BITMAP *PRTL_BITMAP;
//
// The following routine initializes a new bitmap. It does not alter the
// data currently in the bitmap. This routine must be called before
//
);
//
// The following three routines clear, set, and test the state of a
// single bit in a bitmap.
//
);
);
);
//
// The following two routines either clear or set all of the bits
// in a bitmap.
//
);
);
//
// The following two routines locate a contiguous region of either
// clear or set bits within the bitmap. The region will be at least
// as large as the number specified, and the search of the bitmap will
// begin at the specified hint index (which is a bit index within the
// bitmap, zero based). The return value is the bit index of the located
// region (zero based) or -1 (i.e., 0xffffffff) if such a region cannot
// be located
//
);
);
//
// The following two routines locate a contiguous region of either
// clear or set bits within the bitmap and either set or clear the bits
// within the located region. The region will be as large as the number
// specified, and the search for the region will begin at the specified
// hint index (which is a bit index within the bitmap, zero based). The
// return value is the bit index of the located region (zero based) or
// -1 (i.e., 0xffffffff) if such a region cannot be located. If a region
//
);
);
//
// The following two routines clear or set bits within a specified region
// of the bitmap. The starting index is zero based.
//
);
);
//
// The following routine locates a set of contiguous regions of clear
// bits within the bitmap. The caller specifies whether to return the
// longest runs or just the first found lcoated. The following structure is
// used to denote a contiguous run of bits. The two routines return an array
// of this structure, one for each run located.
//
typedef struct _RTL_BITMAP_RUN {
typedef RTL_BITMAP_RUN *PRTL_BITMAP_RUN;
);
//
// The following routine locates the longest contiguous region of
// clear bits within the bitmap. The returned starting index value
// denotes the first contiguous region located satisfying our requirements
// The return value is the length (in bits) of the longest region found.
//
);
//
// The following routine locates the first contiguous region of
// clear bits within the bitmap. The returned starting index value
// denotes the first contiguous region located satisfying our requirements
// The return value is the length (in bits) of the region found.
//
);
//
// The following macro returns the value of the bit stored within the
// bitmap at the specified location. If the bit is set a value of 1 is
// returned otherwise a value of 0 is returned.
//
// ULONG
// RtlCheckBit (
// PRTL_BITMAP BitMapHeader,
// ULONG BitPosition
// );
//
//
// To implement CheckBit the macro retrieves the longword containing the
// bit in question, shifts the longword to get the bit in question into the
// low order bit position and masks out all other bits.
//
//
// The following two procedures return to the caller the total number of
// clear or set bits within the specified bitmap.
//
);
);
//
// The following two procedures return to the caller a boolean value
// indicating if the specified range of bits are all clear or set.
//
);
);
);
);
//
// The following two procedures return to the caller a value indicating
// the position within a ULONGLONG of the most or least significant non-zero
// bit. A value of zero results in a return value of -1.
//
);
);
//
// BOOLEAN
// RtlEqualLuid(
// PLUID L1,
// PLUID L2
// );
//
// BOOLEAN
// RtlIsZeroLuid(
// PLUID L1
// );
//
#if !defined(MIDL_PASS)
)
{
return(TempLuid);
}
)
{
return(TempLuid);
}
#endif
);
//
// SecurityDescriptor RTL routine definitions
//
);
);
);
);
);
//
// Range list package
//
typedef struct _RTL_RANGE {
//
// The start of the range
//
//
// The end of the range
//
//
// Data the user passed in when they created the range
//
//
// The owner of the range
//
//
// User defined flags the user specified when they created the range
//
//
// Flags (RTL_RANGE_*)
//
} RTL_RANGE, *PRTL_RANGE;
#define RTL_RANGE_SHARED 0x01
#define RTL_RANGE_CONFLICT 0x02
typedef struct _RTL_RANGE_LIST {
//
// The list of ranges
//
//
// These always come in useful
//
//
// The number of entries in the list
//
//
// incremented. It is checked during iteration to ensure that the list
//
typedef struct _RANGE_LIST_ITERATOR {
);
);
);
#define RTL_RANGE_LIST_ADD_IF_CONFLICT 0x00000001
#define RTL_RANGE_LIST_ADD_SHARED 0x00000002
);
);
);
#define RTL_RANGE_LIST_SHARED_OK 0x00000001
#define RTL_RANGE_LIST_NULL_CONFLICT_OK 0x00000002
typedef
);
);
);
)
)
);
);
);
);
);
//
// Byte swap routines. These are used to convert from little-endian to
// big-endian and vice-versa.
//
#if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || ((defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
#ifdef __cplusplus
extern "C" {
#endif
unsigned short __cdecl _byteswap_ushort(unsigned short);
unsigned long __cdecl _byteswap_ulong (unsigned long);
#ifdef __cplusplus
}
#endif
#pragma intrinsic(_byteswap_ushort)
#pragma intrinsic(_byteswap_ulong)
#pragma intrinsic(_byteswap_uint64)
#else
);
);
);
#endif
//
// Routine for converting from a volume device object to a DOS name.
//
);
typedef struct _OSVERSIONINFOA {
typedef struct _OSVERSIONINFOW {
#ifdef UNICODE
typedef OSVERSIONINFOW OSVERSIONINFO;
typedef POSVERSIONINFOW POSVERSIONINFO;
typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
#else
typedef OSVERSIONINFOA OSVERSIONINFO;
typedef POSVERSIONINFOA POSVERSIONINFO;
typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
#endif // UNICODE
typedef struct _OSVERSIONINFOEXA {
typedef struct _OSVERSIONINFOEXW {
} OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
#ifdef UNICODE
typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
#else
typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
#endif // UNICODE
//
// RtlVerifyVersionInfo() conditions
//
#define VER_EQUAL 1
#define VER_GREATER 2
#define VER_GREATER_EQUAL 3
#define VER_LESS 4
#define VER_LESS_EQUAL 5
#define VER_AND 6
#define VER_OR 7
#define VER_CONDITION_MASK 7
#define VER_NUM_BITS_PER_CONDITION_MASK 3
//
// RtlVerifyVersionInfo() type mask bits
//
#define VER_MINORVERSION 0x0000001
#define VER_MAJORVERSION 0x0000002
#define VER_BUILDNUMBER 0x0000004
#define VER_PLATFORMID 0x0000008
#define VER_SERVICEPACKMINOR 0x0000010
#define VER_SERVICEPACKMAJOR 0x0000020
#define VER_SUITENAME 0x0000040
#define VER_PRODUCT_TYPE 0x0000080
//
// RtlVerifyVersionInfo() os product type values
//
#define VER_NT_WORKSTATION 0x0000001
#define VER_NT_DOMAIN_CONTROLLER 0x0000002
#define VER_NT_SERVER 0x0000003
//
// dwPlatformId defines:
//
#define VER_PLATFORM_WIN32s 0
#define VER_PLATFORM_WIN32_WINDOWS 1
#define VER_PLATFORM_WIN32_NT 2
//
//
// VerifyVersionInfo() macro to set the condition mask
//
// For documentation sakes here's the old version of the macro that got
// changed to call an API
// #define VER_SET_CONDITION(_m_,_t_,_c_) _m_=(_m_|(_c_<<(1<<_t_)))
//
);
//
//
);
);
//
//
// Interlocked bit manipulation interfaces
//
//
// Component name filter id enumeration and levels.
//
#define DPFLTR_ERROR_LEVEL 0
#define DPFLTR_WARNING_LEVEL 1
#define DPFLTR_TRACE_LEVEL 2
#define DPFLTR_INFO_LEVEL 3
#define DPFLTR_MASK 0x80000000
typedef enum _DPFLTR_TYPE {
DPFLTR_SYSTEM_ID = 0,
DPFLTR_SMSS_ID = 1,
DPFLTR_SETUP_ID = 2,
DPFLTR_NTFS_ID = 3,
DPFLTR_FSTUB_ID = 4,
DPFLTR_CRASHDUMP_ID = 5,
DPFLTR_CDAUDIO_ID = 6,
DPFLTR_CDROM_ID = 7,
DPFLTR_CLASSPNP_ID = 8,
DPFLTR_DISK_ID = 9,
DPFLTR_REDBOOK_ID = 10,
DPFLTR_STORPROP_ID = 11,
DPFLTR_SCSIPORT_ID = 12,
DPFLTR_SCSIMINIPORT_ID = 13,
DPFLTR_CONFIG_ID = 14,
DPFLTR_I8042PRT_ID = 15,
DPFLTR_SERMOUSE_ID = 16,
DPFLTR_LSERMOUS_ID = 17,
DPFLTR_KBDHID_ID = 18,
DPFLTR_MOUHID_ID = 19,
DPFLTR_KBDCLASS_ID = 20,
DPFLTR_MOUCLASS_ID = 21,
DPFLTR_TWOTRACK_ID = 22,
DPFLTR_WMILIB_ID = 23,
DPFLTR_ACPI_ID = 24,
DPFLTR_AMLI_ID = 25,
DPFLTR_HALIA64_ID = 26,
DPFLTR_VIDEO_ID = 27,
DPFLTR_SVCHOST_ID = 28,
DPFLTR_VIDEOPRT_ID = 29,
DPFLTR_TCPIP_ID = 30,
DPFLTR_DMSYNTH_ID = 31,
DPFLTR_NTOSPNP_ID = 32,
DPFLTR_FASTFAT_ID = 33,
DPFLTR_SAMSS_ID = 34,
DPFLTR_PNPMGR_ID = 35,
DPFLTR_NETAPI_ID = 36,
DPFLTR_SCSERVER_ID = 37,
DPFLTR_SCCLIENT_ID = 38,
DPFLTR_SERIAL_ID = 39,
DPFLTR_SERENUM_ID = 40,
DPFLTR_UHCD_ID = 41,
DPFLTR_RPCPROXY_ID = 42,
DPFLTR_AUTOCHK_ID = 43,
DPFLTR_DCOMSS_ID = 44,
DPFLTR_UNIMODEM_ID = 45,
DPFLTR_SIS_ID = 46,
DPFLTR_FLTMGR_ID = 47,
DPFLTR_WMICORE_ID = 48,
DPFLTR_BURNENG_ID = 49,
DPFLTR_IMAPI_ID = 50,
DPFLTR_SXS_ID = 51,
DPFLTR_FUSION_ID = 52,
DPFLTR_IDLETASK_ID = 53,
DPFLTR_SOFTPCI_ID = 54,
DPFLTR_TAPE_ID = 55,
DPFLTR_MCHGR_ID = 56,
DPFLTR_IDEP_ID = 57,
DPFLTR_PCIIDE_ID = 58,
DPFLTR_FLOPPY_ID = 59,
DPFLTR_FDC_ID = 60,
DPFLTR_TERMSRV_ID = 61,
DPFLTR_W32TIME_ID = 62,
DPFLTR_PREFETCHER_ID = 63,
DPFLTR_RSFILTER_ID = 64,
DPFLTR_FCPORT_ID = 65,
DPFLTR_PCI_ID = 66,
DPFLTR_DMIO_ID = 67,
DPFLTR_DMCONFIG_ID = 68,
DPFLTR_DMADMIN_ID = 69,
DPFLTR_WSOCKTRANSPORT_ID = 70,
DPFLTR_VSS_ID = 71,
DPFLTR_PNPMEM_ID = 72,
DPFLTR_PROCESSOR_ID = 73,
DPFLTR_DMSERVER_ID = 74,
DPFLTR_SR_ID = 75,
DPFLTR_INFINIBAND_ID = 76,
DPFLTR_IHVDRIVER_ID = 77,
DPFLTR_IHVVIDEO_ID = 78,
DPFLTR_IHVAUDIO_ID = 79,
DPFLTR_IHVNETWORK_ID = 80,
DPFLTR_IHVSTREAMING_ID = 81,
DPFLTR_IHVBUS_ID = 82,
DPFLTR_HPS_ID = 83,
DPFLTR_RTLTHREADPOOL_ID = 84,
DPFLTR_LDR_ID = 85,
DPFLTR_TCPIP6_ID = 86,
DPFLTR_ISAPNP_ID = 87,
DPFLTR_SHPC_ID = 88,
DPFLTR_STORPORT_ID = 89,
DPFLTR_STORMINIPORT_ID = 90,
DPFLTR_PRINTSPOOLER_ID = 91,
DPFLTR_VSSDYNDISK_ID = 92,
DPFLTR_VERIFIER_ID = 93,
DPFLTR_VDS_ID = 94,
DPFLTR_VDSBAS_ID = 95,
DPFLTR_VDSDYNDR_ID = 96,
DPFLTR_VDSUTIL_ID = 97,
DPFLTR_DFRGIFC_ID = 98,
} DPFLTR_TYPE;
//
// Define the various device type values. Note that values used by Microsoft
// Corporation are in the range 0-32767, and 32768-65535 are reserved for use
// by customers.
//
#define DEVICE_TYPE ULONG
#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
//
// Macro definition for defining IOCTL and FSCTL function control codes. Note
// that function codes 0-2047 are reserved for Microsoft Corporation, and
// 2048-4095 are reserved for customers.
//
)
//
// Macro to extract device type out of the device io control code
//
//
// Define the method codes for how buffers are passed for I/O and FS controls
//
#define METHOD_BUFFERED 0
#define METHOD_IN_DIRECT 1
#define METHOD_OUT_DIRECT 2
#define METHOD_NEITHER 3
//
// Define some easier to comprehend aliases:
// METHOD_DIRECT_TO_HARDWARE (writes, aka METHOD_IN_DIRECT)
// METHOD_DIRECT_FROM_HARDWARE (reads, aka METHOD_OUT_DIRECT)
//
//
// Define the access check value for any access
//
//
// The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
// ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
// constants *MUST* always be in sync.
//
//
// FILE_SPECIAL_ACCESS is checked by the NT I/O system the same as FILE_ANY_ACCESS.
// The file systems, however, may add additional access checks for I/O and FS controls
// that use this value.
//
#define FILE_ANY_ACCESS 0
#define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS)
//
// Define access rights to files and directories
//
//
// The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in
// devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these
// constants *MUST* always be in sync.
// The values are redefined in devioctl.h because they must be available to
// both DOS and NT.
//
#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
FILE_READ_EA |\
#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\
#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
FILE_EXECUTE |\
//
// Define share access rights to files and directories
//
#define FILE_SHARE_READ 0x00000001
#define FILE_SHARE_WRITE 0x00000002
#define FILE_SHARE_DELETE 0x00000004
#define FILE_SHARE_VALID_FLAGS 0x00000007
//
// Define the file attributes values
//
// Note: 0x00000008 is reserved for use for the old DOS VOLID (volume ID)
// and is therefore not considered valid in NT.
//
// Note: 0x00000010 is reserved for use for the old DOS SUBDIRECTORY flag
// and is therefore not considered valid in NT. This flag has
// been disassociated with file attributes since the other flags are
// protected with READ_ and WRITE_ATTRIBUTES access to the file.
//
// Note: Note also that the order of these flags is set to allow both the
// FAT and the Pinball File Systems to directly set the attributes
// flags in attributes words without having to pick each flag out
// individually. The order of these flags should not be changed!
//
#define FILE_ATTRIBUTE_READONLY 0x00000001
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
//OLD DOS VOLID 0x00000008
#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 the create disposition values
//
#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_FOR_RECOVERY 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_COPY_STRUCTURED_STORAGE 0x00000041
#define FILE_STRUCTURED_STORAGE 0x00000441
#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 the I/O status information return values for NtCreateFile/NtOpenFile
//
#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 special ByteOffset parameters for read and write operations
//
#define FILE_WRITE_TO_END_OF_FILE 0xffffffff
#define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
//
// Define alignment requirement values
//
#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
//
// Define the maximum length of a filename string
//
#define MAXIMUM_FILENAME_LENGTH 256
//
// Define the various device characteristics flags
//
#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
//
// The FILE_EXPECT flags will only exist for WinXP. After that they will be
// ignored and an IRP will be sent in their place.
//
#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200
#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300
#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300
//
// flags specified here will be propagated up and down a device stack
// after FDO and all filter devices are added, but before the device
// stack is started
//
#define FILE_CHARACTERISTICS_PROPAGATED ( FILE_REMOVABLE_MEDIA | \
//
// Define the base asynchronous I/O argument types
//
typedef struct _IO_STATUS_BLOCK {
union {
};
#if defined(_WIN64)
typedef struct _IO_STATUS_BLOCK32 {
#endif
//
// Define an Asynchronous Procedure Call from I/O viewpoint
//
typedef
(NTAPI *PIO_APC_ROUTINE) (
);
#define PIO_APC_ROUTINE_DEFINED
//
// Define the file information class values
//
// WARNING: The order of the following values are assumed by the I/O system.
// Any changes made here should be reflected there as well.
//
typedef enum _FILE_INFORMATION_CLASS {
FileBasicInformation, // 4 wdm
FileStandardInformation, // 5 wdm
FileInternalInformation, // 6
FileEaInformation, // 7
FileAccessInformation, // 8
FileNameInformation, // 9
FileRenameInformation, // 10
FileLinkInformation, // 11
FileNamesInformation, // 12
FileDispositionInformation, // 13
FilePositionInformation, // 14 wdm
FileFullEaInformation, // 15
FileModeInformation, // 16
FileAlignmentInformation, // 17
FileAllInformation, // 18
FileAllocationInformation, // 19
FileEndOfFileInformation, // 20 wdm
FileAlternateNameInformation, // 21
FileStreamInformation, // 22
FilePipeInformation, // 23
FilePipeLocalInformation, // 24
FilePipeRemoteInformation, // 25
FileMailslotQueryInformation, // 26
FileMailslotSetInformation, // 27
FileCompressionInformation, // 28
FileObjectIdInformation, // 29
FileCompletionInformation, // 30
FileMoveClusterInformation, // 31
FileQuotaInformation, // 32
FileReparsePointInformation, // 33
FileNetworkOpenInformation, // 34
FileAttributeTagInformation, // 35
FileTrackingInformation, // 36
FileShortNameInformation, // 40
//
// Define the various structures which are returned on query operations
//
typedef struct _FILE_BASIC_INFORMATION {
typedef struct _FILE_STANDARD_INFORMATION {
typedef struct _FILE_POSITION_INFORMATION {
typedef struct _FILE_ALIGNMENT_INFORMATION {
typedef struct _FILE_NAME_INFORMATION {
typedef struct _FILE_NETWORK_OPEN_INFORMATION {
typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
typedef struct _FILE_DISPOSITION_INFORMATION {
typedef struct _FILE_END_OF_FILE_INFORMATION {
typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
typedef struct _FILE_FULL_EA_INFORMATION {
//
// Define the file system information class values
//
// WARNING: The order of the following values are assumed by the I/O system.
// Any changes made here should be reflected there as well.
typedef enum _FSINFOCLASS {
FileFsLabelInformation, // 2
FileFsSizeInformation, // 3
FileFsDeviceInformation, // 4
FileFsControlInformation, // 6
typedef struct _FILE_FS_DEVICE_INFORMATION {
//
//
typedef union _FILE_SEGMENT_ELEMENT {
//
// Define the I/O bus interface types.
//
typedef enum _INTERFACE_TYPE {
InterfaceTypeUndefined = -1,
Isa,
Eisa,
CBus,
//
// Define the DMA transfer widths.
//
typedef enum _DMA_WIDTH {
}DMA_WIDTH, *PDMA_WIDTH;
//
// Define DMA transfer speeds.
//
typedef enum _DMA_SPEED {
}DMA_SPEED, *PDMA_SPEED;
//
// Define Interface reference/dereference routines for
// Interfaces exported by IRP_MN_QUERY_INTERFACE
//
//
// Define types of bus information.
//
typedef enum _BUS_DATA_TYPE {
Cmos,
Pos,
//
// Define I/O Driver error log packet structure. This structure is filled in
// by the driver.
//
typedef struct _IO_ERROR_LOG_PACKET {
//
// Define the I/O error log message. This message is sent by the error log
// thread over the lpc port.
//
typedef struct _IO_ERROR_LOG_MESSAGE {
//
// Define the maximum message size that will be sent over the LPC to the
// application reading the error log entries.
//
//
// Regardless of LPC size restrictions, ERROR_LOG_MAXIMUM_SIZE must remain
// a value that can fit in a UCHAR.
//
//
// This limit, exclusive of IO_ERROR_LOG_MESSAGE_HEADER_LENGTH, also applies
// to IO_ERROR_LOG_MESSAGE_LENGTH
//
#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 \
//
// IO_ERROR_LOG_MESSAGE_LENGTH is
// min(PORT_MAXIMUM_MESSAGE_LENGTH, ERROR_LOG_MESSAGE_LIMIT_SIZE)
//
#define IO_ERROR_LOG_MESSAGE_LENGTH \
//
// Define the maximum packet size a driver can allocate.
//
#define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \
#ifdef _WIN64
#define PORT_MAXIMUM_MESSAGE_LENGTH 512
#else
#define PORT_MAXIMUM_MESSAGE_LENGTH 256
#endif
//
// Registry Specific 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)
#define KEY_READ ((STANDARD_RIGHTS_READ |\
KEY_NOTIFY) \
& \
(~SYNCHRONIZE))
#define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
& \
(~SYNCHRONIZE))
#define KEY_EXECUTE ((KEY_READ) \
& \
(~SYNCHRONIZE))
#define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
KEY_NOTIFY |\
& \
(~SYNCHRONIZE))
//
//
// when system is rebooted
// when system is rebooted
// symbolic link
// special access rules
// privilege required
#define REG_LEGAL_OPTION \
//
//
//
// hive format to be used by Reg(Nt)SaveKeyEx
//
#define REG_STANDARD_FORMAT 1
#define REG_LATEST_FORMAT 2
#define REG_NO_COMPRESSION 4
//
// Key restore flags
//
#define REG_FORCE_RESTORE (0x00000008L) // Force the restore process even when we have open handles on subkeys
//
// Unload Flags
//
#define REG_FORCE_UNLOAD 1
//
// Key query structures
//
typedef struct _KEY_BASIC_INFORMATION {
typedef struct _KEY_NODE_INFORMATION {
// Class[1]; // Variable length string not declared
typedef struct _KEY_FULL_INFORMATION {
typedef struct _KEY_NAME_INFORMATION {
typedef struct _KEY_CACHED_INFORMATION {
typedef struct _KEY_FLAGS_INFORMATION {
typedef enum _KEY_INFORMATION_CLASS {
,
MaxKeyInfoClass // MaxKeyInfoClass should always be the last enum
typedef struct _KEY_WRITE_TIME_INFORMATION {
typedef struct _KEY_USER_FLAGS_INFORMATION {
typedef enum _KEY_SET_INFORMATION_CLASS {
MaxKeySetInfoClass // MaxKeySetInfoClass should always be the last enum
//
// Value entry query structures
//
typedef struct _KEY_VALUE_BASIC_INFORMATION {
typedef struct _KEY_VALUE_FULL_INFORMATION {
// Data[1]; // Variable size data not declared
typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
typedef struct _KEY_VALUE_ENTRY {
typedef enum _KEY_VALUE_INFORMATION_CLASS {
MaxKeyValueInfoClass // MaxKeyValueInfoClass should always be the last enum
//
// Object Manager Object Type Specific Access Rights.
//
#define OBJECT_TYPE_CREATE (0x0001)
//
// Object Manager Directory Specific Access Rights.
//
#define DIRECTORY_QUERY (0x0001)
#define DIRECTORY_TRAVERSE (0x0002)
#define DIRECTORY_CREATE_OBJECT (0x0004)
#define DIRECTORY_CREATE_SUBDIRECTORY (0x0008)
//
// Object Manager Symbolic Link Specific Access Rights.
//
#define SYMBOLIC_LINK_QUERY (0x0001)
typedef struct _OBJECT_NAME_INFORMATION {
#define DUPLICATE_CLOSE_SOURCE 0x00000001
#define DUPLICATE_SAME_ACCESS 0x00000002
#define DUPLICATE_SAME_ATTRIBUTES 0x00000004
//
// Section Information Structures.
//
typedef enum _SECTION_INHERIT {
ViewShare = 1,
ViewUnmap = 2
//
// 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
SECTION_MAP_READ | \
#define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
#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
#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
#define SEC_RESERVE 0x4000000
#define PROCESS_DUP_HANDLE (0x0040)
0xFFF)
#if defined(_WIN64)
#define MAXIMUM_PROCESSORS 64
#else
#define MAXIMUM_PROCESSORS 32
#endif
//
// Thread Specific Access Rights
//
#define THREAD_TERMINATE (0x0001)
#define THREAD_SET_INFORMATION (0x0020)
0x3FF)
//
// ClientId
//
typedef struct _CLIENT_ID {
} CLIENT_ID;
typedef CLIENT_ID *PCLIENT_ID;
//
// Thread Environment Block (and portable part of Thread Information Block)
//
//
// NT_TIB - Thread Information Block - Portable part.
//
// This is the subsystem portable part of the Thread Information Block.
// It appears as the first part of the TEB for all threads which have
// a user mode component.
//
//
typedef struct _NT_TIB {
union {
};
} NT_TIB;
//
// 32 and 64 bit specific version for wow64 and the debugger
//
typedef struct _NT_TIB32 {
union {
};
typedef struct _NT_TIB64 {
union {
};
//
// Process Information Classes
//
typedef enum _PROCESSINFOCLASS {
ProcessIoPortHandlers, // Note: this is kernel mode only
MaxProcessInfoClass // MaxProcessInfoClass should always be the last enum
//
// Thread Information Classes
//
typedef enum _THREADINFOCLASS {
//
// Process Information Structures
//
//
// PageFaultHistory Information
// NtQueryInformationProcess using ProcessWorkingSetWatch
//
typedef struct _PROCESS_WS_WATCH_INFORMATION {
//
// Basic Process Information
// NtQueryInformationProcess using ProcessBasicInfo
//
typedef struct _PROCESS_BASIC_INFORMATION {
//
// Process Device Map information
// NtQueryInformationProcess using ProcessDeviceMap
// NtSetInformationProcess using ProcessDeviceMap
//
typedef struct _PROCESS_DEVICEMAP_INFORMATION {
union {
struct {
} Set;
struct {
} Query;
};
typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX {
union {
struct {
} Set;
struct {
} Query;
};
//
// PROCESS_DEVICEMAP_INFORMATION_EX flags
//
#define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001
//
// Multi-User Session specific Process Information
// NtQueryInformationProcess using ProcessSessionInformation
//
typedef struct _PROCESS_SESSION_INFORMATION {
typedef struct _PROCESS_HANDLE_TRACING_ENABLE {
typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX {
#define PROCESS_HANDLE_TRACING_MAX_STACKS 16
typedef struct _PROCESS_HANDLE_TRACING_ENTRY {
typedef struct _PROCESS_HANDLE_TRACING_QUERY {
//
// Process Quotas
// NtQueryInformationProcess using ProcessQuotaLimits
// NtQueryInformationProcess using ProcessPooledQuotaLimits
// NtSetInformationProcess using ProcessQuotaLimits
//
typedef struct _QUOTA_LIMITS {
#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
typedef struct _QUOTA_LIMITS_EX {
//
// Process I/O Counters
// NtQueryInformationProcess using ProcessIoCounters
//
typedef struct _IO_COUNTERS {
} IO_COUNTERS;
typedef IO_COUNTERS *PIO_COUNTERS;
//
// Process Virtual Memory Counters
// NtQueryInformationProcess using ProcessVmCounters
//
typedef struct _VM_COUNTERS {
} VM_COUNTERS;
typedef VM_COUNTERS *PVM_COUNTERS;
typedef struct _VM_COUNTERS_EX {
typedef VM_COUNTERS_EX *PVM_COUNTERS_EX;
//
// Process Pooled Quota Usage and Limits
// NtQueryInformationProcess using ProcessPooledUsageAndLimits
//
typedef struct _POOLED_USAGE_AND_LIMITS {
//
// Process Security Context Information
// NtSetInformationProcess using ProcessAccessToken
// PROCESS_SET_ACCESS_TOKEN access to the process is needed
// to use this info level.
//
typedef struct _PROCESS_ACCESS_TOKEN {
//
// Handle to Primary token to assign to the process.
// TOKEN_ASSIGN_PRIMARY access to this token is needed.
//
//
// Handle to the initial thread of the process.
// A process's access token can only be changed if the process has
// no threads or one thread. If the process has no threads, this
// field must be set to NULL. Otherwise, it must contain a handle
// open to the process's only thread. THREAD_QUERY_INFORMATION access
// is needed via this handle.
//
// NtQueryInformationProcess using ProcessTimes
// NtQueryInformationThread using ThreadTimes
//
typedef struct _KERNEL_USER_TIMES {
typedef KERNEL_USER_TIMES *PKERNEL_USER_TIMES;
);
#define ZwCurrentProcess() NtCurrentProcess()
);
#define ZwCurrentThread() NtCurrentThread()
#ifndef _PO_DDK_
#define _PO_DDK_
typedef enum _SYSTEM_POWER_STATE {
PowerSystemWorking = 1,
PowerSystemSleeping1 = 2,
PowerSystemSleeping2 = 3,
PowerSystemSleeping3 = 4,
PowerSystemHibernate = 5,
PowerSystemShutdown = 6,
#define POWER_SYSTEM_MAXIMUM 7
typedef enum {
PowerActionNone = 0,
typedef enum _DEVICE_POWER_STATE {
typedef union _POWER_STATE {
} POWER_STATE, *PPOWER_STATE;
typedef enum _POWER_STATE_TYPE {
SystemPowerState = 0,
//
// Generic power related IOCTLs
//
#define IOCTL_QUERY_DEVICE_POWER_STATE \
#define IOCTL_SET_DEVICE_WAKE \
#define IOCTL_CANCEL_DEVICE_WAKE \
//
// Defines for W32 interfaces
//
typedef ULONG EXECUTION_STATE;
typedef enum {
} LATENCY_TIME;
typedef enum {
LastWakeTime, // Compare with KeQueryInterruptTime()
LastSleepTime, // Compare with KeQueryInterruptTime()
//
// System power manager capabilities
//
typedef struct {
#endif // !_PO_DDK_
#if defined(_X86_)
//
// Types to use to contain PFNs and their counts.
//
//
// Define maximum size of flush multiple TB request.
//
#define FLUSH_MULTIPLE_MAXIMUM 32
//
// Indicate that the i386 compiler supports the pragma textout construct.
//
#define ALLOC_PRAGMA 1
//
// Indicate that the i386 compiler supports the DATA_SEG("INIT") and
// DATA_SEG("PAGE") pragmas
//
#define ALLOC_DATA_PRAGMA 1
#define NORMAL_DISPATCH_LENGTH 106
//
// Interrupt Request Level definitions
//
#define PASSIVE_LEVEL 0 // Passive release level
#define LOW_LEVEL 0 // Lowest interrupt level
//
// I/O space read and write macros.
//
// These have to be actual functions on the 386, because we need
// to use assembler, but cannot return a value if we inline it.
//
// The READ/WRITE_REGISTER_* calls manipulate I/O registers in MEMORY space.
// (Use x86 move instructions, with LOCK prefix to force correct behavior
// w.r.t. caches and write buffers.)
//
// The READ/WRITE_PORT_* calls manipulate I/O registers in PORT space.
//
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
//
// Get data cache fill size.
//
#endif
#define KeGetDcacheFillSize() 1L
#define KeQueryTickCount(CurrentCount ) { \
while (TRUE) { \
} \
}
#else
);
#endif // defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
//
// Processor Control Region Structure Definition
//
#define PCR_MINOR_VERSION 1
#define PCR_MAJOR_VERSION 1
typedef struct _KPCR {
//
// Start of the architecturally defined section of the PCR. This section
// not change from version to version of NT.
//
// Certain fields in the TIB are not used in kernel mode. These include the
// stack limit, subsystem TIB, fiber data, arbitrary user pointer, and the
// self address of then PCR itself (another field has been added for that
// purpose). Therefore, these fields are overlaid with other data to get
// better cache locality.
//
union {
struct {
};
};
// HALs assume they are zero.
struct _KIDTENTRY *IDT;
struct _KGDTENTRY *GDT;
//
// The non-volatile 387 state
//
typedef struct _KFLOATING_SAVE {
//
// i386 Specific portions of mm component
//
//
// Define the page size for the Intel 386 as 4096 (0x1000).
//
#define PAGE_SIZE 0x1000
//
// Define the number of trailing zeroes in a page aligned virtual address.
// This is used as the shift count when shifting virtual addresses to
// virtual page numbers.
//
#define PAGE_SHIFT 12L
//
// Define the number of bits to shift to right justify the Page Directory Index
// field of a PTE.
//
#define PDI_SHIFT_X86 22
#define PDI_SHIFT_X86PAE 21
#if !defined (_X86PAE_)
#define PDI_SHIFT PDI_SHIFT_X86
#else
#define PDI_SHIFT PDI_SHIFT_X86PAE
#define PPI_SHIFT 30
#endif
//
// Define the number of bits to shift to right justify the Page Table Index
// field of a PTE.
//
#define PTI_SHIFT 12
//
// Define the highest user address and user probe address.
//
extern PVOID *MmHighestUserAddress;
extern PVOID *MmSystemRangeStart;
extern ULONG *MmUserProbeAddress;
#define MM_SYSTEM_RANGE_START *MmSystemRangeStart
#define MM_USER_PROBE_ADDRESS *MmUserProbeAddress
//
// The lowest user address reserves the low 64k.
//
//
// The lowest address for system space.
//
#if !defined (_X86PAE_)
#else
#endif
#define KIP0PCRADDRESS 0xffdff000
#define KI_USER_SHARED_DATA 0xffdf0000
//
// Result type definition for i386. (Machine specific enumerate type
// which is return type for portable exinterlockedincrement/decrement
// procedures.) In general, you should use the enumerated type defined
// in ex.h instead of directly referencing these constants.
//
// Flags loaded into AH by LAHF instruction
#define EFLAG_SIGN 0x8000
#define EFLAG_ZERO 0x4000
//
// Convert various portable ExInterlock APIs into their architectural
// equivalents.
//
#endif
//
// Prototypes for architectural specific versions of Exi386 Api
//
//
// Interlocked result type is portable, but its values are machine specific.
//
typedef enum _INTERLOCKED_RESULT {
);
);
);
#if !defined(_WINBASE_) && !defined(NONTOSPINTERLOCK)
#if !defined(MIDL_PASS) // wdm
#if defined(NO_INTERLOCKED_INTRINSICS) || defined(_CROSS_PLATFORM_)
);
);
);
);
);
);
#else // NO_INTERLOCKED_INTRINSICS || _CROSS_PLATFORM_
#if (_MSC_FULL_VER > 13009037)
);
#pragma intrinsic (_InterlockedExchange)
#else
)
{
__asm {
}
}
#endif
#if (_MSC_FULL_VER > 13009037)
);
#pragma intrinsic (_InterlockedIncrement)
#else
#endif
#if (_MSC_FULL_VER > 13009037)
);
#pragma intrinsic (_InterlockedDecrement)
#else
#endif
#if (_MSC_FULL_VER > 13009037)
);
#pragma intrinsic (_InterlockedExchangeAdd)
#else
)
{
__asm {
}
}
#endif
#if (_MSC_FULL_VER > 13009037)
);
#pragma intrinsic (_InterlockedCompareExchange)
#else
)
{
__asm {
}
}
#endif
);
#endif // INTERLOCKED_INTRINSICS || _CROSS_PLATFORM_
#endif // MIDL_PASS
#endif // __WINBASE__ && !NONTOSPINTERLOCK
//
// Turn these intrinsics off until the compiler can handle them
//
#if (_MSC_FULL_VER > 13009037)
);
#pragma intrinsic (_InterlockedOr)
#define InterlockedOr _InterlockedOr
);
#pragma intrinsic (_InterlockedAnd)
#define InterlockedAnd _InterlockedAnd
);
#pragma intrinsic (_InterlockedXor)
#define InterlockedXor _InterlockedXor
#else // compiler version
)
{
LONG i;
LONG j;
j = *Target;
do {
i = j;
i & Set,
i);
} while (i != j);
return j;
}
)
{
LONG i;
LONG j;
j = *Target;
do {
i = j;
i | Set,
i);
} while (i != j);
return j;
}
#endif // compiler version
//
// i386 function definitions
//
#if _MSC_VER >= 1200
#endif
//
// Get current IRQL.
//
// On x86 this function resides in the HAL
//
//
// Get the current processor number
//
{
#if (_MSC_FULL_VER >= 13012035)
#else
#endif
}
#if _MSC_VER >= 1200
#else
#pragma warning(default:4035)
#endif
#endif // !defined(MIDL_PASS) && defined(_M_IX86)
//++
//
// VOID
// KeMemoryBarrier (
// VOID
// )
//
// VOID
// KeMemoryBarrierWithoutFence (
// VOID
// )
//
//
// Routine Description:
//
// These functions order memory accesses as seen by other processors.
//
// Arguments:
//
// None.
//
// Return Value:
//
// None.
//
//--
#ifdef __cplusplus
extern "C" {
#endif
);
#ifdef __cplusplus
}
#endif
#pragma intrinsic (_ReadWriteBarrier)
)
{
__asm {
}
}
#define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
);
);
#endif // defined(_X86_)
// Use the following for kernel mode runtime checks of X86 system architecture
#ifdef _X86_
#ifdef IsNEC_98
#endif
#ifdef IsNotNEC_98
#endif
#ifdef SetNEC_98
#endif
#ifdef SetNotNEC_98
#endif
#endif
//
// Define intrinsic function to do in's and out's.
//
#ifdef __cplusplus
extern "C" {
#endif
__inbyte (
);
__inword (
);
);
);
);
);
);
);
);
);
);
);
#ifdef __cplusplus
}
#endif
#pragma intrinsic(__outdword)
#pragma intrinsic(__inbytestring)
#pragma intrinsic(__inwordstring)
#pragma intrinsic(__indwordstring)
#pragma intrinsic(__outbytestring)
#pragma intrinsic(__outwordstring)
#pragma intrinsic(__outdwordstring)
//
// Interlocked intrinsic functions.
//
#define InterlockedAnd _InterlockedAnd
#define InterlockedOr _InterlockedOr
#define InterlockedXor _InterlockedXor
#define InterlockedAdd _InterlockedAdd
#define InterlockedAnd64 _InterlockedAnd64
#define InterlockedOr64 _InterlockedOr64
#define InterlockedXor64 _InterlockedXor64
#define InterlockedAdd64 _InterlockedAdd64
#ifdef __cplusplus
extern "C" {
#endif
);
);
);
);
);
);
);
);
);
);
#if !defined(_X86AMD64_)
)
{
}
#endif
);
);
);
);
);
#if !defined(_X86AMD64_)
)
{
}
#endif
);
);
);
#pragma intrinsic(_InterlockedAnd)
#pragma intrinsic(_InterlockedOr)
#pragma intrinsic(_InterlockedXor)
#pragma intrinsic(_InterlockedIncrement)
#pragma intrinsic(_InterlockedDecrement)
#pragma intrinsic(_InterlockedExchange)
#pragma intrinsic(_InterlockedExchangeAdd)
#pragma intrinsic(_InterlockedCompareExchange)
#pragma intrinsic(_InterlockedAnd64)
#pragma intrinsic(_InterlockedOr64)
#pragma intrinsic(_InterlockedXor64)
#pragma intrinsic(_InterlockedIncrement64)
#pragma intrinsic(_InterlockedDecrement64)
#pragma intrinsic(_InterlockedExchange64)
#pragma intrinsic(_InterlockedExchangeAdd64)
#pragma intrinsic(_InterlockedCompareExchange64)
#pragma intrinsic(_InterlockedExchangePointer)
#ifdef __cplusplus
}
#endif
#endif // defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
#if defined(_AMD64_)
//
// Types to use to contain PFNs and their counts.
//
//
// Define maximum size of flush multiple TB request.
//
#define FLUSH_MULTIPLE_MAXIMUM 32
//
// Indicate that the AMD64 compiler supports the allocate pragmas.
//
#define ALLOC_PRAGMA 1
#define ALLOC_DATA_PRAGMA 1
#define NORMAL_DISPATCH_LENGTH 106
//
// Interrupt Request Level definitions
//
#define PASSIVE_LEVEL 0 // Passive release level
#define LOW_LEVEL 0 // Lowest interrupt level
//
// I/O space read and write macros.
//
// The READ/WRITE_REGISTER_* calls manipulate I/O registers in MEMORY space.
//
// The READ/WRITE_PORT_* calls manipulate I/O registers in PORT space.
//
)
{
return *Register;
}
)
{
return *Register;
}
)
{
return *Register;
}
)
{
return;
}
)
{
return;
}
)
{
return;
}
)
{
StoreFence();
return;
}
)
{
StoreFence();
return;
}
)
{
StoreFence();
return;
}
)
{
StoreFence();
return;
}
)
{
StoreFence();
return;
}
)
{
StoreFence();
return;
}
)
{
}
)
{
}
)
{
}
)
{
return;
}
)
{
return;
}
)
{
return;
}
)
{
return;
}
)
{
return;
}
)
{
return;
}
)
{
return;
}
)
{
return;
}
)
{
return;
}
//
// Get data cache fill size.
//
#endif
#define KeGetDcacheFillSize() 1L
#define KeQuerySystemTime(CurrentCount) \
#define KeQueryTickCount(CurrentCount) \
//
// Processor Control Region Structure Definition
//
#define PCR_MINOR_VERSION 1
#define PCR_MAJOR_VERSION 1
typedef struct _KPCR {
//
// Start of the architecturally defined section of the PCR. This section
// not change from version to version of NT.
//
// Certain fields in the TIB are not used in kernel mode. These include the
// exception list, stack base, stack limit, subsystem TIB, fiber data, and
// the arbitrary user pointer. Therefore, these fields are overlaid with
// other data to get better cache locality.
union {
struct {
union _KGDTENTRY64 *GdtBase;
};
};
struct _KPRCB *CurrentPrcb;
union _KIDTENTRY64 *IdtBase;
//
// Exception frame
//
// This frame is established when handling an exception. It provides a place
// to save all nonvolatile registers. The volatile registers will already
// have been saved in a trap frame.
//
// N.B. The exception frame has a built in exception record capable of
// storing information for four parameter values. This exception
// record is used exclusively within the trap handling code.
//
#define EXCEPTION_AREA_SIZE 64
typedef struct _KEXCEPTION_FRAME {
//
// Home address for the parameter registers.
//
//
// Kernel callout initial stack value.
//
//
// Saved nonvolatile floating registers.
//
//
// Kernel callout frame variables.
//
//
// Exception record for exceptions.
//
//
// Saved nonvolatile register - not always saved.
//
//
// Saved nonvolatile registers.
//
//
// EFLAGS and return address.
//
//
// Trap frame
//
// This frame is established when handling a trap. It provides a place to
// save all volatile registers. The nonvolatile registers are saved in an
// exception frame or through the normal C calling conventions for saved
// registers.
//
typedef struct _KTRAP_FRAME {
//
// Home address for the parameter registers.
//
//
// Previous processor mode (system services only) and previous IRQL
// (interrupts only).
//
//
//
//
// Floating point state.
//
//
// Volatile registers.
//
// N.B. These registers are only saved on exceptions and interrupts. They
// are not saved for system calls.
//
//
// Volatile floating registers.
//
// N.B. These registers are only saved on exceptions and interrupts. They
// are not saved for system calls.
//
//
// Page fault address.
//
//
// Debug registers.
//
//
// Special debug registers.
//
//
// Segment registers
//
//
// Previous trap frame address.
//
//
// Saved nonvolatile registers RBX, RDI and RSI. These registers are only
// saved in system service trap frames.
//
//
// Saved nonvolatile register RBP. This register is used as a frame
// pointer during trap processing and is saved in all trap frames.
//
//
// Information pushed by hardware.
//
// N.B. The error code is not always pushed by hardware. For those cases
// where it is not pushed by hardware a dummy error code is allocated
// on the stack.
//
} KTRAP_FRAME, *PKTRAP_FRAME;
//
// The nonvolatile floating state
//
typedef struct _KFLOATING_SAVE {
//
// AMD64 Specific portions of mm component.
//
// Define the page size for the AMD64 as 4096 (0x1000).
//
#define PAGE_SIZE 0x1000
//
// Define the number of trailing zeroes in a page aligned virtual address.
// This is used as the shift count when shifting virtual addresses to
// virtual page numbers.
//
#define PAGE_SHIFT 12L
#define PDE_KTBASE_AMD64 PPE_BASE
#define PTI_SHIFT 12
#define PDI_SHIFT 21
#define PPI_SHIFT 30
#define PXI_SHIFT 39
#define PTE_PER_PAGE 512
#define PDE_PER_PAGE 512
#define PPE_PER_PAGE 512
#define PXE_PER_PAGE 512
//
// Define the highest user address and user probe address.
//
extern PVOID *MmHighestUserAddress;
extern PVOID *MmSystemRangeStart;
extern ULONG64 *MmUserProbeAddress;
#define MM_SYSTEM_RANGE_START *MmSystemRangeStart
#define MM_USER_PROBE_ADDRESS *MmUserProbeAddress
//
// The lowest user address reserves the low 64k.
//
//
// The lowest address for system space.
//
//
// Intrinsic functions
//
//
// The following routines are provided for backward compatibility with old
// code. They are no longer the preferred way to accomplish these functions.
//
#endif
#define RESULT_ZERO 0
#define RESULT_NEGATIVE 1
#define RESULT_POSITIVE 2
typedef enum _INTERLOCKED_RESULT {
)
{
if (Result < 0) {
return ResultNegative;
} else if (Result > 0) {
return ResultPositive;
} else {
return ResultZero;
}
}
)
{
if (Result < 0) {
return ResultNegative;
} else if (Result > 0) {
return ResultPositive;
} else {
return ResultZero;
}
}
)
{
}
#endif // defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
//
// AMD646 function prototype definitions
//
//
// Get the current processor number
//
)
{
}
#endif // !defined(MIDL_PASS) && defined(_M_AMD64)
//++
//
//
// VOID
// KeMemoryBarrier (
// VOID
// )
//
// VOID
// KeMemoryBarrierWithoutFence (
// VOID
// )
//
//
// Routine Description:
//
// These functions order memory accesses as seen by other processors.
//
// Arguments:
//
// None.
//
// Return Value:
//
// None.
//
//--
#if !defined(_CROSS_PLATFORM_)
#ifdef __cplusplus
extern "C" {
#endif
);
#pragma intrinsic(_ReadWriteBarrier)
#ifdef __cplusplus
}
#endif
#define KeMemoryBarrier() _ReadWriteBarrier()
#define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
#else
#define KeMemoryBarrier()
#define KeMemoryBarrierWithoutFence()
#endif
);
);
#endif // defined(_AMD64_)
#if defined(_AMD64_)
);
);
#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
);
);
);
#endif // defined(_AMD64_)
#if defined(_IA64_)
//
// Types to use to contain PFNs and their counts.
//
//
// Indicate that the IA64 compiler supports the pragma textout construct.
//
#define ALLOC_PRAGMA 1
//
// Define intrinsic calls and their prototypes
//
#include "ia64reg.h"
#ifdef __cplusplus
extern "C" {
#endif
void __isrlz (void);
void __dsrlz (void);
void __fwb (void);
void __mf (void);
void __mfa (void);
void __synci (void);
void __invalat (void);
void __break (int);
void __sum (int);
void __rsm (int);
void _ReleaseSpinLock( unsigned __int64 *);
void __yield();
void __lfetch(int, void const *);
void __lfetchfault(int, void const *);
#ifdef _M_IA64
#pragma intrinsic (_ReleaseSpinLock)
#pragma intrinsic (__lfetchfault)
#endif // _M_IA64
#ifdef __cplusplus
}
#endif
//
// Define length of interrupt vector table.
//
#define MAXIMUM_VECTOR 256
//
// IA64 specific interlocked operation result values.
//
#define RESULT_ZERO 0
#define RESULT_NEGATIVE 1
#define RESULT_POSITIVE 2
//
// Interlocked result type is portable, but its values are machine specific.
//
typedef enum _INTERLOCKED_RESULT {
//
// Convert portable interlock interfaces to architecture specific interfaces.
//
#endif
);
);
);
//
// IA64 Interrupt Definitions.
//
//
// Define length of interrupt object dispatch code in longwords.
//
// Begin of a block of definitions that must be synchronized with kxia64.h.
//
//
// Define Interrupt Request Levels.
//
#define PASSIVE_LEVEL 0 // Passive release level
#define LOW_LEVEL 0 // Lowest interrupt level
#if defined(_M_IA64) && !defined(RC_INVOKED)
#define InterlockedAdd _InterlockedAdd
#define InterlockedAdd64 _InterlockedAdd64
#ifdef __cplusplus
extern "C" {
#endif
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
#if !defined (InterlockedAnd64)
)
{
do {
Old = *Destination;
} while (InterlockedCompareExchange64(Destination,
return Old;
}
#endif
#if !defined (InterlockedOr64)
)
{
do {
Old = *Destination;
} while (InterlockedCompareExchange64(Destination,
return Old;
}
#endif
#if !defined (InterlockedXor64)
)
{
do {
Old = *Destination;
} while (InterlockedCompareExchange64(Destination,
return Old;
}
#endif
#pragma intrinsic(_InterlockedAdd)
#pragma intrinsic(_InterlockedIncrement)
#pragma intrinsic(_InterlockedIncrement_acq)
#pragma intrinsic(_InterlockedIncrement_rel)
#pragma intrinsic(_InterlockedDecrement)
#pragma intrinsic(_InterlockedDecrement_acq)
#pragma intrinsic(_InterlockedDecrement_rel)
#pragma intrinsic(_InterlockedExchange)
#pragma intrinsic(_InterlockedCompareExchange)
#pragma intrinsic(_InterlockedCompareExchange_acq)
#pragma intrinsic(_InterlockedCompareExchange_rel)
#pragma intrinsic(_InterlockedExchangeAdd)
#pragma intrinsic(_InterlockedAdd64)
#pragma intrinsic(_InterlockedIncrement64)
#pragma intrinsic(_InterlockedDecrement64)
#pragma intrinsic(_InterlockedExchange64)
#pragma intrinsic(_InterlockedExchange64_acq)
#pragma intrinsic(_InterlockedCompareExchange64)
#pragma intrinsic(_InterlockedExchangeAdd64)
#pragma intrinsic(_InterlockedExchangePointer)
#ifdef __cplusplus
}
#endif
#endif // defined(_M_IA64) && !defined(RC_INVOKED)
)
{
LONG i;
LONG j;
j = *Target;
do {
i = j;
i & Set,
i);
} while (i != j);
return j;
}
)
{
LONG i;
LONG j;
j = *Target;
do {
i = j;
i | Set,
i);
} while (i != j);
return j;
}
)
{
LONG i;
LONG j;
j = *Target;
do {
i = j;
i ^ Set,
i);
} while (i != j);
return j;
}
//
// Get address of processor control region.
//
//
// Get address of current kernel thread object.
//
#if defined(_M_IA64)
#endif
//
// Get current processor number.
//
//
// Get data cache fill size.
//
#endif
#define KeSaveFloatingPointState(a) STATUS_SUCCESS
#define KeRestoreFloatingPointState(a) STATUS_SUCCESS
//
//
// VOID
// KeMemoryBarrierWithoutFence (
// VOID
// )
//
//
// Routine Description:
//
// This function cases ordering of memory accesses generated by the compiler.
//
//
// Arguments:
//
// None.
//
// Return Value:
//
// None.
//--
#ifdef __cplusplus
extern "C" {
#endif
);
#ifdef __cplusplus
}
#endif
#pragma intrinsic(_ReadWriteBarrier)
#define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
//++
//
//
// VOID
// KeMemoryBarrier (
// VOID
// )
//
//
// Routine Description:
//
// This function cases ordering of memory accesses as generated by the compiler and
// as seen by other processors.
//
//
// Arguments:
//
// None.
//
// Return Value:
//
// None.
//--
#define KE_MEMORY_BARRIER_REQUIRED
//
// Define the page size
//
#define PAGE_SIZE 0x2000
//
// Define the number of trailing zeroes in a page aligned virtual address.
// This is used as the shift count when shifting virtual addresses to
// virtual page numbers.
//
#define PAGE_SHIFT 13L
//
// Cache and write buffer flush functions.
//
);
//
// Kernel breakin breakpoint
//
);
#define KeQueryTickCount(CurrentCount ) \
#else
);
#endif // defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_)
//
// I/O space read and write macros.
//
);
);
);
);
);
);
);
);
);
);
);
);
#define READ_REGISTER_UCHAR(x) \
#define READ_REGISTER_USHORT(x) \
#define READ_REGISTER_ULONG(x) \
#define READ_REGISTER_BUFFER_UCHAR(x, y, z) { \
PUCHAR registerBuffer = x; \
PUCHAR readBuffer = y; \
__mf(); \
} \
}
#define READ_REGISTER_BUFFER_USHORT(x, y, z) { \
PUSHORT registerBuffer = x; \
PUSHORT readBuffer = y; \
__mf(); \
} \
}
#define READ_REGISTER_BUFFER_ULONG(x, y, z) { \
PULONG registerBuffer = x; \
PULONG readBuffer = y; \
__mf(); \
} \
}
#define WRITE_REGISTER_UCHAR(x, y) { \
*(volatile UCHAR * const)(x) = y; \
KeFlushWriteBuffer(); \
}
#define WRITE_REGISTER_USHORT(x, y) { \
*(volatile USHORT * const)(x) = y; \
KeFlushWriteBuffer(); \
}
#define WRITE_REGISTER_ULONG(x, y) { \
*(volatile ULONG * const)(x) = y; \
KeFlushWriteBuffer(); \
}
#define WRITE_REGISTER_BUFFER_UCHAR(x, y, z) { \
PUCHAR registerBuffer = x; \
PUCHAR writeBuffer = y; \
ULONG writeCount; \
} \
KeFlushWriteBuffer(); \
}
#define WRITE_REGISTER_BUFFER_USHORT(x, y, z) { \
PUSHORT registerBuffer = x; \
PUSHORT writeBuffer = y; \
ULONG writeCount; \
} \
KeFlushWriteBuffer(); \
}
#define WRITE_REGISTER_BUFFER_ULONG(x, y, z) { \
PULONG registerBuffer = x; \
PULONG writeBuffer = y; \
ULONG writeCount; \
} \
KeFlushWriteBuffer(); \
}
//
// Non-volatile floating point state
//
typedef struct _KFLOATING_SAVE {
//
// Define Processor Control Region Structure.
//
#define PCR_MINOR_VERSION 1
#define PCR_MAJOR_VERSION 1
typedef struct _KPCR {
//
// Major and minor version numbers of the PCR.
//
//
// Start of the architecturally defined section of the PCR. This section
// not change from version to version of NT.
//
//
// First and second level cache parameters.
//
//
// Data cache alignment and fill size used for cache flushing and alignment.
// These fields are set to the larger of the first and second level data
// cache fill sizes.
//
//
// Instruction cache alignment and fill size used for cache flushing and
// alignment. These fields are set to the larger of the first and second
// level data cache fill sizes.
//
//
// Processor identification from PrId register.
//
//
// Profiling data.
//
//
// Stall execution count and scale factor.
//
//
// Space reserved for the system.
//
//
// Space reserved for the HAL
//
//
// IRQL mapping tables.
//
//
// External Interrupt vectors.
//
//
// Reserved interrupt vector mask.
//
//
// Processor affinity mask.
//
//
// Complement of the processor affinity mask.
//
//
// Pointer to processor control block.
//
//
// Shadow copy of Prcb->CurrentThread for fast access
//
struct _KTHREAD *CurrentThread;
//
// Processor number.
//
);
);
);
);
//
// The highest user address reserves 64K bytes for a guard page. This
// the probing of address from kernel mode to only have to check the
// starting address for structures of 64k bytes or less.
//
//
// The lowest user address reserves the low 64k.
//
#define MmLockPagableCodeSection(PLabelAddress) \
//
// The lowest address for system space.
//
#endif // defined(_IA64_)
//
// Event Specific Access Rights.
//
#define EVENT_QUERY_STATE 0x0001
#define EVENT_MODIFY_STATE 0x0002
//
// Semaphore Specific Access Rights.
//
#define SEMAPHORE_QUERY_STATE 0x0001
#define SEMAPHORE_MODIFY_STATE 0x0002
//
// Timer APC routine definition.
//
typedef
(*PTIMER_APC_ROUTINE) (
);
//
// Driver Verifier Definitions
//
typedef ULONG_PTR (*PDRIVER_VERIFIER_THUNK_ROUTINE) (
);
//
// This structure is passed in by drivers that want to thunk callers of
// their exports.
//
typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
//
// Driver Verifier flags.
//
#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
//
// Defined processor features
//
#define PF_FLOATING_POINT_PRECISION_ERRATA 0
#define PF_FLOATING_POINT_EMULATED 1
#define PF_COMPARE_EXCHANGE_DOUBLE 2
#define PF_MMX_INSTRUCTIONS_AVAILABLE 3
#define PF_PPC_MOVEMEM_64BIT_OK 4
#define PF_ALPHA_BYTE_INSTRUCTIONS 5
#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
#define PF_RDTSC_INSTRUCTION_AVAILABLE 8
#define PF_PAE_ENABLED 9
#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE {
StandardDesign, // None == 0 == standard design
NEC98x86, // NEC PC98xx series on X86
EndAlternatives // past end of known alternatives
// correctly define these run-time definitions for non X86 machines
#ifndef _X86_
#ifndef IsNEC_98
#endif
#ifndef IsNotNEC_98
#define IsNotNEC_98 (TRUE)
#endif
#ifndef SetNEC_98
#define SetNEC_98
#endif
#ifndef SetNotNEC_98
#define SetNotNEC_98
#endif
#endif
#define PROCESSOR_FEATURE_MAX 64
#if defined(REMOTE_BOOT)
//
// Defined system flags.
//
/* the following two lines should be tagged with "winnt" when REMOTE_BOOT is on. */
#define SYSTEM_FLAG_REMOTE_BOOT_CLIENT 0x00000001
#define SYSTEM_FLAG_DISKLESS_CLIENT 0x00000002
#endif // defined(REMOTE_BOOT)
//
// Define data shared between kernel and user mode.
//
// N.B. User mode has read only access to this data
//
#ifdef _MAC
#endif
//
// WARNING: This structure must have exactly the same layout for 32- and
// 64-bit systems. The layout of this structure cannot change and new
// fields can only be added to the end of the structure. Deprecated
// fields cannot be deleted. Platform specific fields are included on
// all systems.
//
// Layout exactness is required for Wow64 support of 32bit applications
// on Win64 systems.
//
// The layout itself cannot change since this structure has been exported
//
typedef struct _KUSER_SHARED_DATA {
//
// Current low 32-bit of tick count and tick count multiplier.
//
// N.B. The tick count is updated each time the clock ticks.
//
//
// Current 64-bit interrupt time in 100ns units.
//
volatile KSYSTEM_TIME InterruptTime;
//
// Current 64-bit system time in 100ns units.
//
volatile KSYSTEM_TIME SystemTime;
//
// Current 64-bit time zone bias.
//
volatile KSYSTEM_TIME TimeZoneBias;
//
// Support image magic number range for the host system.
//
// N.B. This is an inclusive range.
//
//
// Copy of system root in Unicode
//
//
// Maximum stack trace depth if tracing enabled.
//
//
// Crypto Exponent
//
//
// TimeZoneId
//
//
// product type
//
//
// NT Version. Note that each process sees a version from its PEB, but
// if the process is running with an altered view of the system version,
// the following two fields are used to correctly identify the version
//
//
// Processor Feature Bits
//
//
// Reserved fields - do not use
//
//
// Time slippage while in debugger
//
//
// Alternative system architecture. Example: NEC PC98xx on x86
//
//
// If the system is an evaluation unit, the following field contains the
// date and time that the evaluation unit expires. A value of 0 indicates
// that there is no expiration. A non-zero value is the UTC absolute time
// that the system expires.
//
//
// Suite Support
//
//
//
//
// Current console session Id. Always zero on non-TS systems
//
volatile ULONG ActiveConsoleId;
//
// Force-dismounts cause handles to become invalid. Rather than
// always probe handles, we maintain a serial number of
// dismounts that clients can use to see if they need to probe
// handles.
//
volatile ULONG DismountCount;
//
// This field indicates the status of the 64-bit COM+ package on the system.
// It indicates whether the Intermediate Language (IL) COM+ images need to
// use the 64-bit COM+ runtime or the 32-bit COM+ runtime.
//
//
// Time in tick count for system-wide last user input across all
// terminal sessions. For MP performance, it is not updated all
// the time (e.g. once a minute per session). It is used for idle
// detection.
//
//
// Number of physical pages in the system. This can dynamically
// change as physical memory can be added or removed from a running
// system.
//
//
// True if the system was booted in safe boot mode.
//
//
// The following field is used for Heap and CritSec Tracing
// The last bit is set for Critical Sec Collision tracing and
// second Last bit is for Heap Tracing
// Also the first 16 bits are used as counter.
//
//
// Depending on the processor, the code for fast system call
// will differ, the following buffer is filled with the appropriate
// code sequence and user mode code will branch through it.
//
// (32 bytes, using ULONGLONG for alignment).
//
// N.B. The following two fields are only used on 32-bit systems.
//
//
// The 64-bit tick count.
//
union {
volatile KSYSTEM_TIME TickCount;
volatile ULONG64 TickCountQuad;
};
#ifdef _MAC
#pragma warning( default : 4121 )
#endif
//
// Predefined Value Types.
//
#define REG_NONE ( 0 ) // No value type
// (with environment variable references)
#define REG_RESOURCE_REQUIREMENTS_LIST ( 10 )
//
// Service Types (Bit Mask)
//
#define SERVICE_KERNEL_DRIVER 0x00000001
#define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
#define SERVICE_ADAPTER 0x00000004
#define SERVICE_RECOGNIZER_DRIVER 0x00000008
#define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \
#define SERVICE_WIN32_OWN_PROCESS 0x00000010
#define SERVICE_WIN32_SHARE_PROCESS 0x00000020
#define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \
#define SERVICE_INTERACTIVE_PROCESS 0x00000100
#define SERVICE_TYPE_ALL (SERVICE_WIN32 | \
SERVICE_ADAPTER | \
SERVICE_DRIVER | \
//
// Start Type
//
#define SERVICE_BOOT_START 0x00000000
#define SERVICE_SYSTEM_START 0x00000001
#define SERVICE_AUTO_START 0x00000002
#define SERVICE_DEMAND_START 0x00000003
#define SERVICE_DISABLED 0x00000004
//
// Error control type
//
#define SERVICE_ERROR_IGNORE 0x00000000
#define SERVICE_ERROR_NORMAL 0x00000001
#define SERVICE_ERROR_SEVERE 0x00000002
#define SERVICE_ERROR_CRITICAL 0x00000003
//
//
// Define the registry driver node enumerations
//
typedef enum _CM_SERVICE_NODE_TYPE {
typedef enum _CM_SERVICE_LOAD_TYPE {
typedef enum _CM_ERROR_CONTROL_TYPE {
//
// Resource List definitions
//
//
// Defines the Type in the RESOURCE_DESCRIPTOR
//
// NOTE: For all CM_RESOURCE_TYPE values, there must be a
// corresponding ResType value in the 32-bit ConfigMgr headerfile
// (cfgmgr32.h). Values in the range [0x6,0x80) use the same values
// as their ConfigMgr counterparts. CM_RESOURCE_TYPE values with
// the high bit set (i.e., in the range [0x80,0xFF]), are
// non-arbitrated resources. These correspond to the same values
// in cfgmgr32.h that have their high bit set (however, since
// cfgmgr32.h uses 16 bits for ResType values, these values are in
// the range [0x8000,0x807F). Note that ConfigMgr ResType values
// cannot be in the range [0x8080,0xFFFF), because they would not
// be able to map into CM_RESOURCE_TYPE values. (0xFFFF itself is
// a special value, because it maps to CmResourceTypeDeviceSpecific.)
//
typedef int CM_RESOURCE_TYPE;
// CmResourceTypeNull is reserved
#define CmResourceTypeNull 0 // ResType_All or ResType_None (0x0000)
#define CmResourceTypeMaximum 7
//
// Defines the ShareDisposition in the RESOURCE_DESCRIPTOR
//
typedef enum _CM_SHARE_DISPOSITION {
CmResourceShareUndetermined = 0, // Reserved
//
// Define the bit masks for Flags when type is CmResourceTypeInterrupt
//
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0
#define CM_RESOURCE_INTERRUPT_LATCHED 1
//
// Define the bit masks for Flags when type is 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_PREFETCHABLE 0x0004
#define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
#define CM_RESOURCE_MEMORY_24 0x0010
#define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
//
// Define the bit masks for Flags when type is 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 the bit masks for Flags when type is 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
//
// This structure defines one type of resource used by a driver.
//
// There can only be *1* DeviceSpecificData block. It must be located at
// the end of all resource descriptors in a full descriptor block.
//
//
// Make sure alignment is made properly by compiler; otherwise move
// flags back to the top of the structure (common to all members of the
// union).
//
#include "pshpack4.h"
typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
union {
//
// Range of resources, inclusive. These are physical, bus relative.
// It is known that Port and Memory below have the exact same layout
// as Generic.
//
struct {
} Generic;
//
// Range of port numbers, inclusive. These are physical, bus
// relative. The value should be the same as the one passed to
// HalTranslateBusAddress().
//
struct {
} Port;
//
// IRQL and vector. Should be same values as were passed to
// HalGetInterruptVector().
//
struct {
} Interrupt;
//
// Range of memory addresses, inclusive. These are physical, bus
// relative. The value should be the same as the one passed to
// HalTranslateBusAddress().
//
struct {
} Memory;
//
// Physical DMA channel.
//
struct {
} Dma;
//
// Device driver private data, usually used to help it figure
// what the resource assignments decisions that were made.
//
struct {
//
// Bus Number information.
//
struct {
} BusNumber;
//
// Device Specific information defined by the driver.
// The DataSize field indicates the size of the data in bytes. The
// data is located immediately after the DeviceSpecificData field in
// the structure.
//
struct {
} u;
#include "poppack.h"
//
// A Partial Resource List is what can be found in the ARC firmware
// or will be generated by ntdetect.com.
// The configuration manager will transform this structure into a Full
// resource descriptor when it is about to store it in the registry.
//
// Note: There must a be a convention to the order of fields of same type,
// (defined on a device by device basis) so that the fields can make sense
// to a driver (i.e. when multiple memory ranges are necessary).
//
typedef struct _CM_PARTIAL_RESOURCE_LIST {
//
// A Full Resource Descriptor is what can be found in the registry.
// This is what will be returned to a driver when it queries the registry
// to get device information; it will be stored under a key in the hardware
// description tree.
//
// Note: The BusNumber and Type are redundant information, but we will keep
// it since it allows the driver _not_ to append it when it is creating
// a resource list which could possibly span multiple buses.
//
// Note: There must a be a convention to the order of fields of same type,
// (defined on a device by device basis) so that the fields can make sense
// to a driver (i.e. when multiple memory ranges are necessary).
//
typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
//
// The Resource list is what will be stored by the drivers into the
// resource map via the IO API.
//
typedef struct _CM_RESOURCE_LIST {
//
// Define the structures used to interpret configuration data of
// \\Registry\machine\hardware\description tree.
// Basically, these structures are used to interpret component
// specific data.
//
//
// Define DEVICE_FLAGS
//
typedef struct _DEVICE_FLAGS {
//
// Define Component Information structure
//
typedef struct _CM_COMPONENT_INFORMATION {
//
// The following structures are used to interpret x86
// DeviceSpecificData of CM_PARTIAL_RESOURCE_DESCRIPTOR.
// (Most of the structures are defined by BIOS. They are
// not aligned on word (or dword) boundary.
//
//
// Define the Rom Block structure
//
typedef struct _CM_ROM_BLOCK {
#include "pshpack1.h"
//
// Define INT13 driver parameter block
//
typedef struct _CM_INT13_DRIVE_PARAMETER {
//
// Define Mca POS data block for slot
//
typedef struct _CM_MCA_POS_DATA {
//
// Memory configuration of eisa data block structure
//
typedef struct _EISA_MEMORY_TYPE {
typedef struct _EISA_MEMORY_CONFIGURATION {
//
// Interrupt configuration of eisa data block structure
//
typedef struct _EISA_IRQ_DESCRIPTOR {
typedef struct _EISA_IRQ_CONFIGURATION {
//
// DMA description of eisa data block structure
//
typedef struct _DMA_CONFIGURATION_BYTE0 {
typedef struct _DMA_CONFIGURATION_BYTE1 {
typedef struct _EISA_DMA_CONFIGURATION {
//
// Port description of eisa data block structure
//
typedef struct _EISA_PORT_DESCRIPTOR {
typedef struct _EISA_PORT_CONFIGURATION {
//
// Eisa slot information definition
// N.B. This structure is different from the one defined
// in ARC eisa addendum.
//
typedef struct _CM_EISA_SLOT_INFORMATION {
//
// Eisa function information definition
//
typedef struct _CM_EISA_FUNCTION_INFORMATION {
//
// The following defines the way pnp bios information is stored in
// the registry \\HKEY_LOCAL_MACHINE\HARDWARE\Description\System\MultifunctionAdapter\x
// key, where x is an integer number indicating adapter instance. The
// "Identifier" of the key must equal to "PNP BIOS" and the
// "ConfigurationData" is organized as follow:
//
// CM_PNP_BIOS_INSTALLATION_CHECK +
// CM_PNP_BIOS_DEVICE_NODE for device 1 +
// CM_PNP_BIOS_DEVICE_NODE for device 2 +
// ...
// CM_PNP_BIOS_DEVICE_NODE for device n
//
//
// Pnp BIOS device node structure
//
typedef struct _CM_PNP_BIOS_DEVICE_NODE {
// followed by AllocatedResourceBlock, PossibleResourceBlock
// and CompatibleDeviceId
//
// Pnp BIOS Installation check
//
typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
#include "poppack.h"
//
// Masks for EISA function information
//
#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 + \
//
// Masks for EISA memory configuration
//
#define EISA_MORE_ENTRIES 0x80
#define EISA_SYSTEM_MEMORY 0x00
#define EISA_MEMORY_TYPE_RAM 0x01
//
// Returned error code for EISA bios call
//
#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
//
// The following structures are used to interpret mips
// DeviceSpecificData of CM_PARTIAL_RESOURCE_DESCRIPTOR.
//
//
// Device data records for adapters.
//
//
// The device data record for the Emulex SCSI controller.
//
typedef struct _CM_SCSI_DEVICE_DATA {
//
// Device data records for controllers.
//
//
// The device data record for the Video controller.
//
typedef struct _CM_VIDEO_DEVICE_DATA {
//
// The device data record for the SONIC network controller.
//
typedef struct _CM_SONIC_DEVICE_DATA {
//
// The device data record for the serial controller.
//
typedef struct _CM_SERIAL_DEVICE_DATA {
//
// Device data records for peripherals.
//
//
// The device data record for the Monitor peripheral.
//
typedef struct _CM_MONITOR_DEVICE_DATA {
//
// The device data record for the Floppy peripheral.
//
typedef struct _CM_FLOPPY_DEVICE_DATA {
//
// New data fields for version >= 2.0
//
//
// The device data record for the Keyboard peripheral.
// The KeyboardFlags is defined (by x86 BIOS INT 16h, function 02) as:
// bit 7 : Insert on
// bit 6 : Caps Lock on
// bit 5 : Num Lock on
// bit 4 : Scroll Lock on
// bit 3 : Alt Key is down
// bit 2 : Ctrl Key is down
// bit 1 : Left shift key is down
// bit 0 : Right shift key is down
//
typedef struct _CM_KEYBOARD_DEVICE_DATA {
//
// Declaration of the structure for disk geometries
//
typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA {
//
// Declaration of the structure for the PcCard ISA IRQ map
//
typedef struct _CM_PCCARD_DEVICE_DATA {
// Definitions for Flags
#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
//
// Defines Resource Options
//
#define IO_RESOURCE_PREFERRED 0x01
#define IO_RESOURCE_DEFAULT 0x02
#define IO_RESOURCE_ALTERNATIVE 0x08
//
// This structure defines one type of resource requested by the driver
//
typedef struct _IO_RESOURCE_DESCRIPTOR {
union {
struct {
} Port;
struct {
} Memory;
struct {
} Interrupt;
struct {
} Dma;
struct {
} Generic;
struct {
//
// Bus Number information.
//
struct {
} BusNumber;
struct {
} ConfigData;
} u;
typedef struct _IO_RESOURCE_LIST {
typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
//
// Exception flag definitions.
//
//
// Define maximum number of exception parameters.
//
//
// Exception record definition.
//
typedef struct _EXCEPTION_RECORD {
struct _EXCEPTION_RECORD *ExceptionRecord;
typedef EXCEPTION_RECORD *PEXCEPTION_RECORD;
typedef struct _EXCEPTION_RECORD32 {
typedef struct _EXCEPTION_RECORD64 {
//
// Typedef for pointer returned by exception_info()
//
typedef struct _EXCEPTION_POINTERS {
//
// Define configuration routine types.
//
// Configuration information.
//
typedef enum _CONFIGURATION_TYPE {
//
#if defined(_X86_)
#else
#define PAUSE_PROCESSOR
#endif
//
// Interrupt modes.
//
typedef enum _KINTERRUPT_MODE {
//
// Wait reasons
//
typedef enum _KWAIT_REASON {
} KWAIT_REASON;
typedef struct _KWAIT_BLOCK {
//
// Thread start function
//
typedef
(*PKSTART_ROUTINE) (
);
//
// Kernel object structure definitions
//
//
// Device Queue object and entry
//
typedef struct _KDEVICE_QUEUE {
typedef struct _KDEVICE_QUEUE_ENTRY {
//
// Define the interrupt service function type and the empty struct
// type.
//
typedef
(*PKSERVICE_ROUTINE) (
);
//
// Mutant object
//
typedef struct _KMUTANT {
} KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
//
//
// Semaphore object
//
typedef struct _KSEMAPHORE {
//
// DPC object
//
);
);
);
);
);
);
//
// Device queue object
//
);
);
);
);
);
);
);
);
);
);
//
// Kernel dispatcher object functions
//
// Event Object
//
);
);
);
);
);
);
//
// Mutex object
//
);
);
);
//
// Semaphore object
//
);
);
);
);
);
);
);
);
#if ((defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) ||defined(_NTHAL_)) && !defined(_NTSYSTEM_DRIVER_) || defined(_NTOSP_))
);
);
);
#endif
//
// Timer object
//
);
);
);
);
);
);
);
);
//
// Define interprocess interrupt generic call types.
//
typedef
);
);
//
// On X86 the following routines are defined in the HAL and imported by
// all other modules.
//
#else
#define _DECL_HAL_KE_IMPORT
#endif
//
// spin lock functions
//
);
#else
)
{
*SpinLock = 0;
}
#endif
#if defined(_X86_)
);
);
#define KeAcquireSpinLockAtDpcLevel(a) KefAcquireSpinLockAtDpcLevel(a)
#define KeReleaseSpinLockFromDpcLevel(a) KefReleaseSpinLockFromDpcLevel(a)
);
);
#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
);
);
#else
//
// These functions are imported for IA64, ntddk, ntifs, nthal, ntosp, and wdm.
// They can be inlined for the system on AMD64.
//
#if defined(_IA64_) || defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_) || defined(_WDMDDK_)
);
);
);
);
);
);
#else
#if defined(_AMD64_)
//
// The system version of these functions are defined in amd64.h for AMD64.
//
#endif
#endif
#endif
#if defined(_X86_)
);
);
);
#define KeLowerIrql(a) KfLowerIrql(a)
#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
//
// These function are defined in IA64.h for the IA64 platform.
//
//
// These function are defined in amd64.h for the AMD64 platform.
//
#else
#error "no target architecture"
#endif
//
// Queued spin lock functions for "in stack" lock handles.
//
// The following three functions RAISE and LOWER IRQL when a queued
// in stack spin lock is acquired or released using these routines.
//
);
);
//
// The following two functions do NOT raise or lower IRQL when a queued
// in stack spin lock is acquired or released using these functions.
//
);
);
//
// Miscellaneous kernel functions
//
typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
typedef
);
typedef struct _KBUGCHECK_CALLBACK_RECORD {
#define KeInitializeCallbackRecord(CallbackRecord) \
);
);
typedef enum _KBUGCHECK_CALLBACK_REASON {
typedef
);
typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA {
typedef enum _KBUGCHECK_DUMP_IO_TYPE
{
typedef struct _KBUGCHECK_DUMP_IO {
);
);
typedef
(*PNMI_CALLBACK)(
);
);
);
);
);
);
#endif
#if !defined(_AMD64_)
);
);
#endif
);
);
);
#if defined(_IA64_)
extern volatile LARGE_INTEGER KeTickCount;
extern volatile KSYSTEM_TIME KeTickCount;
#endif
typedef enum _MEMORY_CACHING_TYPE_ORIG {
typedef enum _MEMORY_CACHING_TYPE {
MmNonCached = FALSE,
MmNonCachedUnordered, // IA64
//
// Define external data.
// because of indirection for all drivers external to ntoskrnl these are actually ptrs
//
#if defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_)
extern PBOOLEAN KdDebuggerNotPresent;
extern PBOOLEAN KdDebuggerEnabled;
#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled
#else
extern BOOLEAN KdDebuggerNotPresent;
extern BOOLEAN KdDebuggerEnabled;
#define KD_DEBUGGER_ENABLED KdDebuggerEnabled
#endif
);
);
//
// KdRefreshDebuggerPresent attempts to communicate with
// the debugger host machine to refresh the state of
// KdDebuggerNotPresent. It returns the state of
// KdDebuggerNotPresent while the kd locks are held.
// KdDebuggerNotPresent may immediately change state
// after the kd locks are released so it may not
// match the return value.
//
);
//
// Pool Allocation routines (in pool.c)
//
typedef enum _POOL_TYPE {
,
//
// Note these per session types are carefully chosen so that the appropriate
// masking still applies as well as MaxPoolType above.
//
NonPagedPoolSession = 32,
} POOL_TYPE;
DECLSPEC_DEPRECATED_DDK // Use ExAllocatePoolWithTag
);
DECLSPEC_DEPRECATED_DDK // Use ExAllocatePoolWithQuotaTag
);
);
//
// _EX_POOL_PRIORITY_ provides a method for the system to handle requests
// intelligently in low resource conditions.
//
// LowPoolPriority should be used when it is acceptable to the driver for the
// mapping request to fail if the system is low on resources. An example of
// this could be for a non-critical network connection where the driver can
// handle the failure case when system resources are close to being depleted.
//
// NormalPoolPriority should be used when it is acceptable to the driver for the
// mapping request to fail if the system is very low on resources. An example
// of this could be for a non-critical local filesystem request.
//
// HighPoolPriority should be used when it is unacceptable to the driver for the
// mapping request to fail unless the system is completely out of resources.
// An example of this would be the paging file path in a driver.
//
// SpecialPool can be specified to bound the allocation at a page end (or
// beginning). This should only be done on systems being debugged as the
// memory cost is expensive.
//
// N.B. These values are very carefully chosen so that the pool allocation
// code can quickly crack the priority request.
//
typedef enum _EX_POOL_PRIORITY {
NormalPoolPriority = 16,
HighPoolPriority = 32,
);
#ifndef POOL_TAGGING
#define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b)
#endif //POOL_TAGGING
);
#ifndef POOL_TAGGING
#define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b)
#endif //POOL_TAGGING
);
#if defined(POOL_TAGGING)
#define ExFreePool(a) ExFreePoolWithTag(a,0)
#endif
//
// If high order bit in Pool tag is set, then must use ExFreePoolWithTag to free
//
#define PROTECTED_POOL 0x80000000
);
//
// Routines to support fast mutexes.
//
typedef struct _FAST_MUTEX {
} FAST_MUTEX, *PFAST_MUTEX;
#define ExInitializeFastMutex(_FastMutex) \
(_FastMutex)->Contention = 0; \
FALSE);
);
);
);
);
);
);
);
);
#else
#error "Target architecture not defined"
#endif
//
#if defined(_WIN64)
#else
#ifdef __cplusplus
extern "C" {
#endif
);
#ifdef __cplusplus
}
#endif
#pragma intrinsic (_InterlockedAddLargeStatistic)
#endif
);
);
#else
#endif
);
);
);
);
);
//
// Define interlocked sequenced listhead functions.
//
// A sequenced interlocked list is a singly linked list with a header that
// contains the current depth and a sequence number. Each time an entry is
// inserted or removed from the list the depth is updated and the sequence
// number is incremented. This enables AMD64, IA64, and Pentium and later
// machines to insert and remove from the list without the use of spinlocks.
//
#if !defined(_WINBASE_)
/*++
Routine Description:
This function initializes a sequenced singly linked listhead.
Arguments:
SListHead - Supplies a pointer to a sequenced singly linked listhead.
Return Value:
None.
--*/
#if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
);
#else
)
{
#ifdef _WIN64
//
// Slist headers must be 16 byte aligned.
//
DbgPrint( "InitializeSListHead unaligned Slist header. Address = %p, Caller = %p\n", SListHead, _ReturnAddress());
}
#endif
//
// For IA-64 we save the region number of the elements of the list in a
// separate field. This imposes the requirement that all elements stored
// in the list are from the same region.
#if defined(_IA64_)
#endif
return;
}
#endif
#endif // !defined(_WINBASE_)
);
/*++
Routine Description:
This function queries the current number of entries contained in a
sequenced single linked list.
Arguments:
SListHead - Supplies a pointer to the sequenced listhead which is
be queried.
Return Value:
The current number of entries in the sequenced singly linked list is
returned as the function value.
--*/
#if defined(_WIN64)
#if (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
);
#else
)
{
}
#endif
#else
#endif
#if defined(_WIN64)
#define ExInterlockedFlushSList(Head) \
#if !defined(_WINBASE_)
#define InterlockedPopEntrySList(Head) \
#define InterlockedFlushSList(Head) \
#define QueryDepthSList(Head) \
#endif // !defined(_WINBASE_)
);
);
);
#else
#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
);
);
#else
#endif
);
#if !defined(_WINBASE_)
);
);
#define InterlockedFlushSList(Head) \
#define QueryDepthSList(Head) \
#endif // !defined(_WINBASE_)
#endif // defined(_WIN64)
typedef
(*PALLOCATE_FUNCTION) (
);
typedef
(*PFREE_FUNCTION) (
);
typedef struct _GENERAL_LOOKASIDE {
#else
typedef struct DECLSPEC_CACHEALIGN _GENERAL_LOOKASIDE {
#endif
union {
};
union {
};
union {
};
typedef struct _NPAGED_LOOKASIDE_LIST {
#else
typedef struct DECLSPEC_CACHEALIGN _NPAGED_LOOKASIDE_LIST {
#endif
#endif
);
);
)
/*++
Routine Description:
This function removes (pops) the first entry from the specified
nonpaged lookaside list.
Arguments:
Lookaside - Supplies a pointer to a nonpaged lookaside list structure.
Return Value:
If an entry is removed from the specified lookaside list, then the
address of the entry is returned as the function value. Otherwise,
NULL is returned.
--*/
{
#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
#else
#endif
}
return Entry;
}
)
/*++
Routine Description:
This function inserts (pushes) the specified entry into the specified
nonpaged lookaside list.
Arguments:
Lookaside - Supplies a pointer to a nonpaged lookaside list structure.
Entry - Supplies a pointer to the entry that is inserted in the
lookaside list.
Return Value:
None.
--*/
{
} else {
#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
#else
#endif
}
return;
}
typedef struct _PAGED_LOOKASIDE_LIST {
#else
typedef struct DECLSPEC_CACHEALIGN _PAGED_LOOKASIDE_LIST {
#endif
#endif
);
);
#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
);
#else
)
/*++
Routine Description:
This function removes (pops) the first entry from the specified
paged lookaside list.
Arguments:
Lookaside - Supplies a pointer to a paged lookaside list structure.
Return Value:
If an entry is removed from the specified lookaside list, then the
address of the entry is returned as the function value. Otherwise,
NULL is returned.
--*/
{
}
return Entry;
}
#endif
#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
);
#else
)
/*++
Routine Description:
This function inserts (pushes) the specified entry into the specified
paged lookaside list.
Arguments:
Lookaside - Supplies a pointer to a nonpaged lookaside list structure.
Entry - Supplies a pointer to the entry that is inserted in the
lookaside list.
Return Value:
None.
--*/
{
} else {
}
return;
}
#endif
);
//
// Common probe for write functions.
//
);
//
// Worker Thread
//
typedef enum _WORK_QUEUE_TYPE {
typedef
);
typedef struct _WORK_QUEUE_ITEM {
#endif
DECLSPEC_DEPRECATED_DDK // Use IoQueueWorkItem
);
);
//
// Zone Allocation
//
typedef struct _ZONE_SEGMENT_HEADER {
typedef struct _ZONE_HEADER {
} ZONE_HEADER, *PZONE_HEADER;
);
);
);
//++
//
// PVOID
// ExAllocateFromZone(
// IN PZONE_HEADER Zone
// )
//
// Routine Description:
//
// This routine removes an entry from the zone and returns a pointer to it.
//
// Arguments:
//
// Zone - Pointer to the zone header controlling the storage from which the
// entry is to be allocated.
//
// Return Value:
//
// The function value is a pointer to the storage allocated from the zone.
//
//--
#pragma deprecated(ExAllocateFromZone)
#endif
#define ExAllocateFromZone(Zone) \
//++
//
// PVOID
// ExFreeToZone(
// IN PZONE_HEADER Zone,
// IN PVOID Block
// )
//
// Routine Description:
//
// This routine places the specified block of storage back onto the free
// list in the specified zone.
//
// Arguments:
//
// Zone - Pointer to the zone header controlling the storage to which the
// entry is to be inserted.
//
// Block - Pointer to the block of storage to be freed back to the zone.
//
// Return Value:
//
// Pointer to previous block of storage that was at the head of the free
// list. NULL implies the zone went from no available free blocks to
// at least one free block.
//
//--
#pragma deprecated(ExFreeToZone)
#endif
)
//++
//
// BOOLEAN
// ExIsFullZone(
// IN PZONE_HEADER Zone
// )
//
// Routine Description:
//
// This routine determines if the specified zone is full or not. A zone
// is considered full if the free list is empty.
//
// Arguments:
//
// Zone - Pointer to the zone header to be tested.
//
// Return Value:
//
// TRUE if the zone is full and FALSE otherwise.
//
//--
#pragma deprecated(ExIsFullZone)
#endif
#define ExIsFullZone(Zone) \
//++
//
// PVOID
// ExInterlockedAllocateFromZone(
// IN PZONE_HEADER Zone,
// IN PKSPIN_LOCK Lock
// )
//
// Routine Description:
//
// This routine removes an entry from the zone and returns a pointer to it.
// The removal is performed with the specified lock owned for the sequence
// to make it MP-safe.
//
// Arguments:
//
// Zone - Pointer to the zone header controlling the storage from which the
// entry is to be allocated.
//
// Lock - Pointer to the spin lock which should be obtained before removing
// the entry from the allocation list. The lock is released before
// returning to the caller.
//
// Return Value:
//
// The function value is a pointer to the storage allocated from the zone.
//
//--
#pragma deprecated(ExInterlockedAllocateFromZone)
#endif
//++
//
// PVOID
// ExInterlockedFreeToZone(
// IN PZONE_HEADER Zone,
// IN PVOID Block,
// IN PKSPIN_LOCK Lock
// )
//
// Routine Description:
//
// This routine places the specified block of storage back onto the free
// list in the specified zone. The insertion is performed with the lock
// owned for the sequence to make it MP-safe.
//
// Arguments:
//
// Zone - Pointer to the zone header controlling the storage to which the
// entry is to be inserted.
//
// Block - Pointer to the block of storage to be freed back to the zone.
//
// Lock - Pointer to the spin lock which should be obtained before inserting
// the entry onto the free list. The lock is released before returning
// to the caller.
//
// Return Value:
//
// Pointer to previous block of storage that was at the head of the free
// list. NULL implies the zone went from no available free blocks to
// at least one free block.
//
//--
#pragma deprecated(ExInterlockedFreeToZone)
#endif
//++
//
// BOOLEAN
// ExIsObjectInFirstZoneSegment(
// IN PZONE_HEADER Zone,
// IN PVOID Object
// )
//
// Routine Description:
//
// This routine determines if the specified pointer lives in the zone.
//
// Arguments:
//
// Zone - Pointer to the zone header controlling the storage to which the
// object may belong.
//
// Object - Pointer to the object in question.
//
// Return Value:
//
// TRUE if the Object came from the first segment of zone.
//
//--
#pragma deprecated(ExIsObjectInFirstZoneSegment)
#endif
(Zone)->TotalSegmentSize)) \
)
//
// Define executive resource data structures.
//
typedef ULONG_PTR ERESOURCE_THREAD;
typedef ERESOURCE_THREAD *PERESOURCE_THREAD;
typedef struct _OWNER_ENTRY {
union {
};
} OWNER_ENTRY, *POWNER_ENTRY;
typedef struct _ERESOURCE {
union {
};
} ERESOURCE, *PERESOURCE;
//
// Values for ERESOURCE.Flag
//
#define ResourceNeverExclusive 0x10
#define ResourceReleaseByOtherThread 0x20
#define ResourceOwnedExclusive 0x80
#define RESOURCE_HASH_TABLE_SIZE 64
typedef struct _RESOURCE_HASH_ENTRY {
typedef struct _RESOURCE_PERFORMANCE_DATA {
//
// Define executive resource function prototypes.
//
);
);
);
);
);
);
);
//
// VOID
// ExReleaseResource(
// IN PERESOURCE Resource
// );
//
#endif
#define ExReleaseResource(R) (ExReleaseResourceLite(R))
);
);
);
);
);
);
);
//
// ERESOURCE_THREAD
// ExGetCurrentResourceThread(
// );
//
);
);
//
// An acquired resource is always owned shared, as shared ownership is a subset
// of exclusive ownership.
//
//
// ntddk.h stole the entrypoints we wanted so fix them up here.
//
#endif
#define ExDeleteResource ExDeleteResourceLite
//
// Get previous mode
//
);
//
// Raise status from kernel mode.
//
);
);
);
//
// Set timer resolution.
//
);
//
// Subtract time zone bias from system time to get local time.
//
);
//
// Add time zone bias to local time to get system time.
//
);
//
// Define the type for Callback function.
//
typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
typedef VOID (*PCALLBACK_FUNCTION ) (
);
);
);
);
);
//
// UUID Generation
//
);
//
// suite support
//
);
//
// Define a block to hold the actual routine registration.
//
typedef NTSTATUS (*PEX_CALLBACK_FUNCTION ) (
);
//
// Registry kernel mode callbacks
//
//
// Hook selector
//
typedef enum _REG_NOTIFY_CLASS {
//
// .Net only
//
//
// Parameter description for each notify class
//
typedef struct _REG_DELETE_KEY_INFORMATION {
typedef struct _REG_SET_VALUE_KEY_INFORMATION {
typedef struct _REG_DELETE_VALUE_KEY_INFORMATION {
typedef struct _REG_SET_INFORMATION_KEY_INFORMATION {
typedef struct _REG_ENUMERATE_KEY_INFORMATION {
typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION {
typedef struct _REG_QUERY_KEY_INFORMATION {
typedef struct _REG_QUERY_VALUE_KEY_INFORMATION {
typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION {
typedef struct _REG_RENAME_KEY_INFORMATION {
typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION {
/* .Net Only */
typedef struct _REG_CREATE_KEY_INFORMATION {
} REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION;
typedef struct _REG_POST_OPERATION_INFORMATION {
/* end .Net Only */
/* XP only */
typedef struct _REG_PRE_CREATE_KEY_INFORMATION {
} 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 {
} REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
/* end XP only */
);
//
// Priority increment definitions. The comment for each definition gives
// the names of the system services that use the definition when satisfying
// a wait.
//
//
// Priority increment used when satisfying a wait on an executive event
// (NtPulseEvent and NtSetEvent)
//
#define EVENT_INCREMENT 1
//
// Priority increment when no I/O has been done. This is used by device
// and file system drivers when completing an IRP (IoCompleteRequest).
//
#define IO_NO_INCREMENT 0
//
// Priority increment for completing CD-ROM I/O. This is used by CD-ROM device
// and file system drivers when completing an IRP (IoCompleteRequest)
//
#define IO_CD_ROM_INCREMENT 1
//
// Priority increment for completing disk I/O. This is used by disk device
// and file system drivers when completing an IRP (IoCompleteRequest)
//
#define IO_DISK_INCREMENT 1
//
// Priority increment for completing keyboard I/O. This is used by keyboard
// device drivers when completing an IRP (IoCompleteRequest)
//
#define IO_KEYBOARD_INCREMENT 6
//
// Priority increment for completing mailslot I/O. This is used by the mail-
// slot file system driver when completing an IRP (IoCompleteRequest).
//
#define IO_MAILSLOT_INCREMENT 2
//
// Priority increment for completing mouse I/O. This is used by mouse device
// drivers when completing an IRP (IoCompleteRequest)
//
#define IO_MOUSE_INCREMENT 6
//
// Priority increment for completing named pipe I/O. This is used by the
// named pipe file system driver when completing an IRP (IoCompleteRequest).
//
#define IO_NAMED_PIPE_INCREMENT 2
//
// Priority increment for completing network I/O. This is used by network
// device and network file system drivers when completing an IRP
// (IoCompleteRequest).
//
#define IO_NETWORK_INCREMENT 2
//
// Priority increment for completing parallel I/O. This is used by parallel
// device drivers when completing an IRP (IoCompleteRequest)
//
#define IO_PARALLEL_INCREMENT 1
//
// Priority increment for completing serial I/O. This is used by serial device
// drivers when completing an IRP (IoCompleteRequest)
//
#define IO_SERIAL_INCREMENT 2
//
// Priority increment for completing sound I/O. This is used by sound device
// drivers when completing an IRP (IoCompleteRequest)
//
#define IO_SOUND_INCREMENT 8
//
// Priority increment for completing video I/O. This is used by video device
// drivers when completing an IRP (IoCompleteRequest)
//
#define IO_VIDEO_INCREMENT 1
//
// Priority increment used when satisfying a wait on an executive semaphore
// (NtReleaseSemaphore)
//
#define SEMAPHORE_INCREMENT 1
//
// Indicates the system may do I/O to physical addresses above 4 GB.
//
extern PBOOLEAN Mm64BitPhysicalAddress;
//
// Define maximum disk transfer size to be used by MM and Cache Manager,
// so that packet-oriented disk drivers can optimize their packet allocation
// to this size.
//
#define MM_MAXIMUM_DISK_IO_SIZE (0x10000)
//++
//
// ULONG_PTR
// ROUND_TO_PAGES (
// IN ULONG_PTR Size
// )
//
// Routine Description:
//
// The ROUND_TO_PAGES macro takes a size in bytes and rounds it up to a
// multiple of the page size.
//
// NOTE: This macro fails for values 0xFFFFFFFF - (PAGE_SIZE - 1).
//
// Arguments:
//
// Size - Size in bytes to round up to a page multiple.
//
// Return Value:
//
// Returns the size rounded up to a multiple of the page size.
//
//--
//++
//
// ULONG
// BYTES_TO_PAGES (
// IN ULONG Size
// )
//
// Routine Description:
//
// The BYTES_TO_PAGES macro takes the size in bytes and calculates the
// number of pages required to contain the bytes.
//
// Arguments:
//
// Size - Size in bytes.
//
// Return Value:
//
// Returns the number of pages required to contain the specified size.
//
//--
//++
//
// ULONG
// BYTE_OFFSET (
// IN PVOID Va
// )
//
// Routine Description:
//
// The BYTE_OFFSET macro takes a virtual address and returns the byte offset
// of that address within the page.
//
// Arguments:
//
// Va - Virtual address.
//
// Return Value:
//
// Returns the byte offset portion of the virtual address.
//
//--
//++
//
// PVOID
// PAGE_ALIGN (
// IN PVOID Va
// )
//
// Routine Description:
//
// The PAGE_ALIGN macro takes a virtual address and returns a page-aligned
// virtual address for that page.
//
// Arguments:
//
// Va - Virtual address.
//
// Return Value:
//
// Returns the page aligned virtual address.
//
//--
//++
//
// ULONG
// ADDRESS_AND_SIZE_TO_SPAN_PAGES (
// IN PVOID Va,
// IN ULONG Size
// )
//
// Routine Description:
//
// The ADDRESS_AND_SIZE_TO_SPAN_PAGES macro takes a virtual address and
// size and returns the number of pages spanned by the size.
//
// Arguments:
//
// Va - Virtual address.
//
// Size - Size in bytes.
//
// Return Value:
//
// Returns the number of pages spanned by the size.
//
//--
#endif
//++
// PPFN_NUMBER
// MmGetMdlPfnArray (
// IN PMDL Mdl
// )
//
// Routine Description:
//
// The MmGetMdlPfnArray routine returns the virtual address of the
// first element of the array of physical page numbers associated with
// the MDL.
//
// Arguments:
//
// Mdl - Pointer to an MDL.
//
// Return Value:
//
// Returns the virtual address of the first element of the array of
// physical page numbers associated with the MDL.
//
//--
//++
//
// PVOID
// MmGetMdlVirtualAddress (
// IN PMDL Mdl
// )
//
// Routine Description:
//
// The MmGetMdlVirtualAddress returns the virtual address of the buffer
// described by the Mdl.
//
// Arguments:
//
// Mdl - Pointer to an MDL.
//
// Return Value:
//
// Returns the virtual address of the buffer described by the Mdl
//
//--
#define MmGetMdlVirtualAddress(Mdl) \
//++
//
// ULONG
// MmGetMdlByteCount (
// IN PMDL Mdl
// )
//
// Routine Description:
//
// The MmGetMdlByteCount returns the length in bytes of the buffer
// described by the Mdl.
//
// Arguments:
//
// Mdl - Pointer to an MDL.
//
// Return Value:
//
// Returns the byte count of the buffer described by the Mdl
//
//--
//++
//
// ULONG
// MmGetMdlByteOffset (
// IN PMDL Mdl
// )
//
// Routine Description:
//
// The MmGetMdlByteOffset returns the byte offset within the page
// of the buffer described by the Mdl.
//
// Arguments:
//
// Mdl - Pointer to an MDL.
//
// Return Value:
//
// Returns the byte offset within the page of the buffer described by the Mdl
//
//--
//++
//
// PVOID
// MmGetMdlStartVa (
// IN PMDL Mdl
// )
//
// Routine Description:
//
// The MmGetMdlBaseVa returns the virtual address of the buffer
// described by the Mdl rounded down to the nearest page.
//
// Arguments:
//
// Mdl - Pointer to an MDL.
//
// Return Value:
//
// Returns the returns the starting virtual address of the MDL.
//
//
//--
typedef enum _MM_SYSTEM_SIZE {
);
);
);
);
);
//
// I/O support routines.
//
);
);
);
);
);
);
);
);
);
//
// _MM_PAGE_PRIORITY_ provides a method for the system to handle requests
// intelligently in low resource conditions.
//
// LowPagePriority should be used when it is acceptable to the driver for the
// mapping request to fail if the system is low on resources. An example of
// this could be for a non-critical network connection where the driver can
// handle the failure case when system resources are close to being depleted.
//
// NormalPagePriority should be used when it is acceptable to the driver for the
// mapping request to fail if the system is very low on resources. An example
// of this could be for a non-critical local filesystem request.
//
// HighPagePriority should be used when it is unacceptable to the driver for the
// mapping request to fail unless the system is completely out of resources.
// An example of this would be the paging file path in a driver.
//
typedef enum _MM_PAGE_PRIORITY {
NormalPagePriority = 16,
HighPagePriority = 32
//
// Note: This function is not available in WDM 1.0
//
);
);
);
);
);
);
typedef struct _PHYSICAL_MEMORY_RANGE {
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
DECLSPEC_DEPRECATED_DDK // Use IoAllocateMdl
);
);
);
);
);
);
//
// Note that even though this function prototype
// says "HANDLE", MmSecureVirtualMemory does NOT return
// anything resembling a Win32-style handle. The return
// value from this function can ONLY be used with MmUnsecureVirtualMemory.
//
);
);
);
);
);
);
//++
//
// VOID
// MmInitializeMdl (
// IN PMDL MemoryDescriptorList,
// IN PVOID BaseVa,
// IN SIZE_T Length
// )
//
// Routine Description:
//
// This routine initializes the header of a Memory Descriptor List (MDL).
//
// Arguments:
//
// MemoryDescriptorList - Pointer to the MDL to initialize.
//
// BaseVa - Base virtual address mapped by the MDL.
//
// Length - Length, in bytes, of the buffer mapped by the MDL.
//
// Return Value:
//
// None.
//
//--
(MemoryDescriptorList)->MdlFlags = 0; \
}
//++
//
// PVOID
// MmGetSystemAddressForMdlSafe (
// IN PMDL MDL,
// IN MM_PAGE_PRIORITY PRIORITY
// )
//
// Routine Description:
//
// This routine returns the mapped address of an MDL. If the
// Mdl is not already mapped or a system address, it is mapped.
//
// Arguments:
//
// MemoryDescriptorList - Pointer to the MDL to map.
//
// Priority - Supplies an indication as to how important it is that this
// request succeed under low available PTE conditions.
//
// Return Value:
//
// Returns the base address where the pages are mapped. The base address
// has the same offset as the virtual address in the MDL.
//
// Unlike MmGetSystemAddressForMdl, Safe guarantees that it will always
// return NULL on failure instead of bugchecking the system.
//
// This macro is not usable by WDM 1.0 drivers as 1.0 did not include
// MmMapLockedPagesSpecifyCache. The solution for WDM 1.0 drivers is to
//
//--
((MDL)->MappedSystemVa) : \
KernelMode, \
MmCached, \
NULL, \
FALSE, \
(PRIORITY))))
//++
//
// PVOID
// MmGetSystemAddressForMdl (
// IN PMDL MDL
// )
//
// Routine Description:
//
// This routine returns the mapped address of an MDL, if the
// Mdl is not already mapped or a system address, it is mapped.
//
// Arguments:
//
// MemoryDescriptorList - Pointer to the MDL to map.
//
// Return Value:
//
// Returns the base address where the pages are mapped. The base address
// has the same offset as the virtual address in the MDL.
//
//--
//#define MmGetSystemAddressForMdl(MDL)
// (((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA)) ?
// ((MDL)->MappedSystemVa) :
// ((((MDL)->MdlFlags & (MDL_SOURCE_IS_NONPAGED_POOL)) ?
// ((PVOID)((ULONG)(MDL)->StartVa | (MDL)->ByteOffset)) :
// (MmMapLockedPages((MDL),KernelMode)))))
#endif
#define MmGetSystemAddressForMdl(MDL) \
((MDL)->MappedSystemVa) : \
//++
//
// VOID
// MmPrepareMdlForReuse (
// IN PMDL MDL
// )
//
// Routine Description:
//
// This routine will take all of the steps necessary to allow an MDL to be
// re-used.
//
// Arguments:
//
// MemoryDescriptorList - Pointer to the MDL that will be re-used.
//
// Return Value:
//
// None.
//
//--
#define MmPrepareMdlForReuse(MDL) \
}
typedef NTSTATUS (*PMM_DLL_INITIALIZE)(
);
typedef NTSTATUS (*PMM_DLL_UNLOAD)(
);
);
//
// Define an empty typedef for the _DRIVER_OBJECT structure so it may be
// referenced by function types before it is actually defined.
//
struct _DRIVER_OBJECT;
);
//
// Security operation codes
//
typedef enum _SECURITY_OPERATION_CODE {
//
// Data structure used to capture subject security context
// for access validations and auditing.
//
// THE FIELDS OF THIS DATA STRUCTURE SHOULD BE CONSIDERED OPAQUE
// BY ALL EXCEPT THE SECURITY ROUTINES.
//
typedef struct _SECURITY_SUBJECT_CONTEXT {
///////////////////////////////////////////////////////////////////////////////
// //
// ACCESS_STATE and related structures //
// //
///////////////////////////////////////////////////////////////////////////////
//
// Initial Privilege Set - Room for three privileges, which should
// be enough for most applications. This structure exists so that
// it can be embedded in an ACCESS_STATE structure. Use PRIVILEGE_SET
// for all other references to Privilege sets.
//
#define INITIAL_PRIVILEGE_COUNT 3
typedef struct _INITIAL_PRIVILEGE_SET {
//
// Combine the information that describes the state
// of an access-in-progress into a single structure
//
typedef struct _ACCESS_STATE {
union {
} Privileges;
);
);
);
);
#ifdef SE_NTFS_WORLD_CACHE
);
#endif
);
);
//
// System Thread and Process Creation and Termination
//
);
);
typedef
);
);
typedef
);
);
);
//
// Structures for Load Image Notify
//
typedef struct _IMAGE_INFO {
union {
struct {
};
};
} IMAGE_INFO, *PIMAGE_INFO;
#define IMAGE_ADDRESSING_MODE_32BIT 3
typedef
);
);
);
);
//
// Define I/O system data structure type codes. Each major data structure in
// the I/O system has a type code The type field in each structure is at the
// same offset. The following values can be used to determine which type of
// data structure a pointer refers to.
//
#define IO_TYPE_ADAPTER 0x00000001
#define IO_TYPE_CONTROLLER 0x00000002
#define IO_TYPE_DEVICE 0x00000003
#define IO_TYPE_DRIVER 0x00000004
#define IO_TYPE_FILE 0x00000005
#define IO_TYPE_IRP 0x00000006
#define IO_TYPE_MASTER_ADAPTER 0x00000007
#define IO_TYPE_OPEN_PACKET 0x00000008
#define IO_TYPE_TIMER 0x00000009
#define IO_TYPE_VPB 0x0000000a
#define IO_TYPE_ERROR_LOG 0x0000000b
#define IO_TYPE_ERROR_MESSAGE 0x0000000c
#define IO_TYPE_DEVICE_OBJECT_EXTENSION 0x0000000d
//
// Define the major function codes for IRPs.
//
#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_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_MAXIMUM_FUNCTION 0x1b
//
// Make the Scsi major code the same as internal device control.
//
//
// Define the minor function codes for IRPs. The lower 128 codes, from 0x00 to
// 0x7f are reserved to Microsoft. The upper 128 codes, from 0x80 to 0xff, are
// reserved to customers of Microsoft.
//
//
// Directory control minor function codes
//
#define IRP_MN_QUERY_DIRECTORY 0x01
#define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
//
// File system control minor function codes. Note that "user request" is
// assumed to be zero by both the I/O system and file systems. Do not change
// this value.
//
#define IRP_MN_USER_FS_REQUEST 0x00
#define IRP_MN_MOUNT_VOLUME 0x01
#define IRP_MN_VERIFY_VOLUME 0x02
#define IRP_MN_LOAD_FILE_SYSTEM 0x03
#define IRP_MN_KERNEL_CALL 0x04
//
// Lock control minor function codes
//
#define IRP_MN_LOCK 0x01
#define IRP_MN_UNLOCK_SINGLE 0x02
#define IRP_MN_UNLOCK_ALL 0x03
#define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
//
// Read and Write minor function codes for file systems supporting Lan Manager
// software. All of these subfunction codes are invalid if the file has been
// opened with FO_NO_INTERMEDIATE_BUFFERING. They are also invalid in combi-
// nation with synchronous calls (Irp Flag or file open option).
//
// Note that "normal" is assumed to be zero by both the I/O system and file
// systems. Do not change this value.
//
#define IRP_MN_NORMAL 0x00
#define IRP_MN_DPC 0x01
#define IRP_MN_MDL 0x02
#define IRP_MN_COMPLETE 0x04
#define IRP_MN_COMPRESSED 0x08
//
// Device Control Request minor function codes for SCSI support. Note that
// user requests are assumed to be zero.
//
#define IRP_MN_SCSI_CLASS 0x01
//
// PNP minor function codes.
//
#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
#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
#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
#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
//
// POWER minor function codes
//
#define IRP_MN_WAIT_WAKE 0x00
#define IRP_MN_POWER_SEQUENCE 0x01
#define IRP_MN_SET_POWER 0x02
#define IRP_MN_QUERY_POWER 0x03
//
// WMI minor function codes under IRP_MJ_SYSTEM_CONTROL
//
#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
// Minor code 0x0a is reserved
#define IRP_MN_REGINFO_EX 0x0b
//
// Define option flags for IoCreateFile. Note that these values must be
// exactly the same as the SL_... flags for a create function. Note also
// that there are flags that may be passed to IoCreateFile that are not
// placed in the stack location for the create IRP. These flags start in
// the next byte.
//
#define IO_FORCE_ACCESS_CHECK 0x0001
#define IO_NO_PARAMETER_CHECKING 0x0100
//
// Define Information fields for whether or not a REPARSE or a REMOUNT has
// occurred in the file system.
//
#define IO_REPARSE 0x0
#define IO_REMOUNT 0x1
//
// Define callout routine type for use in IoQueryDeviceDescription().
//
typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(
);
// Defines the order of the information in the array of
// PKEY_VALUE_FULL_INFORMATION.
//
typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
//
// Define the objects that can be created by IoCreateFile.
//
typedef enum _CREATE_FILE_TYPE {
//
// Define the structures used by the I/O system
//
//
// Define empty typedefs for the _IRP, _DEVICE_OBJECT, and _DRIVER_OBJECT
// structures so they may be referenced by function types before they are
// actually defined.
//
struct _DEVICE_DESCRIPTION;
struct _DEVICE_OBJECT;
struct _DMA_ADAPTER;
struct _DRIVER_OBJECT;
struct _DRIVE_LAYOUT_INFORMATION;
struct _DISK_PARTITION;
struct _FILE_OBJECT;
struct _SCSI_REQUEST_BLOCK;
struct _SCATTER_GATHER_LIST;
//
// Define the I/O version of a DPC routine.
//
typedef
(*PIO_DPC_ROUTINE) (
);
//
// Define driver timer routine type.
//
typedef
(*PIO_TIMER_ROUTINE) (
);
//
// Define driver initialization routine type.
//
typedef
(*PDRIVER_INITIALIZE) (
);
//
// Define driver reinitialization routine type.
//
typedef
(*PDRIVER_REINITIALIZE) (
);
//
// Define driver cancel routine type.
//
typedef
(*PDRIVER_CANCEL) (
);
//
// Define driver dispatch routine type.
//
typedef
(*PDRIVER_DISPATCH) (
);
//
// Define driver start I/O routine type.
//
typedef
(*PDRIVER_STARTIO) (
);
//
// Define driver unload routine type.
//
typedef
(*PDRIVER_UNLOAD) (
);
//
// Define driver AddDevice routine type.
//
typedef
(*PDRIVER_ADD_DEVICE) (
);
//
// Define fast I/O procedure prototypes.
//
// Fast I/O read and write procedures.
//
typedef
);
typedef
(*PFAST_IO_READ) (
);
typedef
(*PFAST_IO_WRITE) (
);
//
// Fast I/O query basic and standard information procedures.
//
typedef
);
typedef
);
//
// Fast I/O lock and unlock procedures.
//
typedef
(*PFAST_IO_LOCK) (
);
typedef
);
typedef
(*PFAST_IO_UNLOCK_ALL) (
);
typedef
);
//
// Fast I/O device control procedure.
//
typedef
);
//
// Define callbacks for NtCreateSection to synchronize correctly with
// the file system. It pre-acquires the resources that will be needed
// when calling to query and set file/allocation size in the file system.
//
typedef
);
typedef
);
//
// Define callback for drivers that have device objects attached to lower-
// level drivers' device objects. This callback is made when the lower-level
// driver is deleting its device object.
//
typedef
);
//
// This structure is used by the server to quickly get the information needed
// to service a server open call. It is takes what would be two fast io calls
// one for basic information and the other for standard information and makes
// it into one call.
//
typedef
);
//
// Define Mdl-based routines for the server to call
//
typedef
(*PFAST_IO_MDL_READ) (
);
typedef
);
typedef
);
typedef
);
//
// If this routine is present, it will be called by FsRtl
// to acquire the file for the mapped page writer.
//
typedef
);
typedef
);
//
// If this routine is present, it will be called by FsRtl
// to acquire the file for the mapped page writer.
//
typedef
);
typedef
);
typedef
);
typedef
);
typedef
);
typedef
);
typedef
(*PFAST_IO_QUERY_OPEN) (
);
//
// Define the structure to describe the Fast I/O dispatch routines. Any
// additions made to this structure MUST be added monotonically to the end
// of the structure, and fields CANNOT be removed from the middle.
//
typedef struct _FAST_IO_DISPATCH {
//
// Define the actions that a driver execution routine may request of the
// adapter/controller allocation routines upon return.
//
typedef enum _IO_ALLOCATION_ACTION {
KeepObject = 1,
//
// Define device driver adapter/controller execution routine.
//
typedef
(*PDRIVER_CONTROL) (
);
//
// Define the I/O system's security context type for use by file system's
// when checking access to volumes, files, and directories.
//
typedef struct _IO_SECURITY_CONTEXT {
//
// Define Volume Parameter Block (VPB) flags.
//
#define VPB_MOUNTED 0x00000001
#define VPB_LOCKED 0x00000002
#define VPB_PERSISTENT 0x00000004
#define VPB_REMOVE_PENDING 0x00000008
#define VPB_RAW_MOUNT 0x00000010
//
// Volume Parameter Block (VPB)
//
typedef struct _VPB {
struct _DEVICE_OBJECT *DeviceObject;
struct _DEVICE_OBJECT *RealDevice;
#if defined(_WIN64)
//
// Use __inline DMA macros (hal.h)
//
#ifndef USE_DMA_MACROS
#define USE_DMA_MACROS
#endif
//
// Only PnP drivers!
//
#ifndef NO_LEGACY_DRIVERS
#define NO_LEGACY_DRIVERS
#endif
#endif // _WIN64
//
// Define object type specific fields of various objects used by the I/O system
//
typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
#else
//
// Define object type specific fields of various objects used by the I/O system
//
typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
#endif // USE_DMA_MACROS && (_NTDDK_ || _NTDRIVER_ || _NTOSP_)
//
// Define Wait Context Block (WCB)
//
typedef struct _WAIT_CONTEXT_BLOCK {
typedef struct _CONTROLLER_OBJECT {
//
// Define Device Object (DO) 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_HAS_NAME 0x00000040
#define DO_DEVICE_INITIALIZING 0x00000080
#define DO_SYSTEM_BOOT_PARTITION 0x00000100
#define DO_LONG_TERM_REQUESTS 0x00000200
#define DO_NEVER_LAST_DEVICE 0x00000400
#define DO_SHUTDOWN_REGISTERED 0x00000800
#define DO_BUS_ENUMERATED_DEVICE 0x00001000
#define DO_POWER_PAGABLE 0x00002000
#define DO_POWER_INRUSH 0x00004000
#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
//
// Device Object structure definition
//
struct _DRIVER_OBJECT *DriverObject;
struct _DEVICE_OBJECT *NextDevice;
struct _DEVICE_OBJECT *AttachedDevice;
struct _IRP *CurrentIrp;
union {
} Queue;
//
// The following field is for exclusive use by the filesystem to keep
// track of the number of Fsp threads currently using the device
//
struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT;
struct _DEVICE_OBJECT_POWER_EXTENSION;
typedef struct _DEVOBJ_EXTENSION {
//
// Public part of the DeviceObjectExtension structure
//
//
// Define Driver Object (DRVO) flags
//
#define DRVO_UNLOAD_INVOKED 0x00000001
#define DRVO_LEGACY_DRIVER 0x00000002
#define DRVO_REINIT_REGISTERED 0x00000008
#define DRVO_INITIALIZED 0x00000010
#define DRVO_BOOTREINIT_REGISTERED 0x00000020
#define DRVO_LEGACY_RESOURCES 0x00000040
typedef struct _DRIVER_EXTENSION {
//
// Back pointer to Driver Object
//
struct _DRIVER_OBJECT *DriverObject;
//
// The AddDevice entry point is called by the Plug & Play manager
// to inform the driver when a new device instance arrives that this
// driver must control.
//
//
// The count field is used to count the number of times the driver has
// had its registered reinitialization routine invoked.
//
//
// The service name field is used by the pnp manager to determine
// where the driver related info is stored in the registry.
//
//
// Note: any new shared fields get added here.
//
typedef struct _DRIVER_OBJECT {
//
// The following links all of the devices created by a single driver
// together on a list, and the Flags word provides an extensible flag
// location for driver objects.
//
//
// The following section describes where the driver is loaded. The count
// field is used to count the number of times the driver has had its
// registered reinitialization routine invoked.
//
//
// The driver name field is used by the error log thread
//
//
// The following section is for registry support. This is a pointer
// to the path to the hardware information in the registry
//
//
// The following section contains the optional pointer to an array of
// alternate entry points to a driver for "fast I/O" support. Fast I/O
// is performed by invoking the driver routine directly with separate
// parameters, rather than using the standard IRP call mechanism. Note
// that these functions may only be used for synchronous I/O, and when
// the file is cached.
//
//
// The following section describes the entry points to this particular
// driver. Note that the major function dispatch table must be the last
// field in the object so that it remains extensible.
//
typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
//
// The following structure is pointed to by the SectionObject pointer field
// of a file object, and is allocated by the various NT file systems.
//
typedef struct _SECTION_OBJECT_POINTERS {
//
// Define the format of a completion message.
//
typedef struct _IO_COMPLETION_CONTEXT {
//
// Define File Object (FO) 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_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_FILE_OBJECT_HAS_EXTENSION 0x00800000
#define FO_REMOTE_ORIGIN 0x01000000
typedef struct _FILE_OBJECT {
struct _FILE_OBJECT *RelatedFileObject;
} FILE_OBJECT;
typedef struct _FILE_OBJECT *PFILE_OBJECT;
//
// Define I/O Request Packet (IRP) flags
//
#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
//
// Define I/O request packet (IRP) alternate flags for allocation control.
//
#define IRP_QUOTA_CHARGED 0x01
#define IRP_ALLOCATED_MUST_SUCCEED 0x02
#define IRP_ALLOCATED_FIXED_SIZE 0x04
#define IRP_LOOKASIDE_ALLOCATION 0x08
//
// I/O Request Packet (IRP) definition
//
//
// Define the common fields used to control the IRP.
//
//
// Define a pointer to the Memory Descriptor List (MDL) for this I/O
// request. This field is only used if the I/O is "direct I/O".
//
//
// Flags word - used to remember various flags.
//
//
// The following union is used for one of three purposes:
//
// 1. This IRP is an associated IRP. The field is a pointer to a master
// IRP.
//
// 2. This is the master IRP. The field is the count of the number of
// IRPs which must complete (associated IRPs) before the master can
// complete.
//
// 3. This operation is being buffered and the field is the address of
// the system space buffer.
//
union {
//
// Thread list entry - allows queueing the IRP to the thread pending I/O
// request packet list.
//
//
// I/O status - final status of operation.
//
//
// Requestor mode - mode of the original requestor of this operation.
//
//
// Pending returned - TRUE if pending was initially returned as the
// status for this packet.
//
//
// Stack state information.
//
//
// Cancel - packet has been canceled.
//
//
// Cancel Irql - Irql at which the cancel spinlock was acquired.
//
//
// ApcEnvironment - Used to save the APC environment at the time that the
// packet was initialized.
//
//
// Allocation control flags.
//
//
// User parameters.
//
union {
struct {
} Overlay;
//
// CancelRoutine - Used to contain the address of a cancel routine supplied
// by a device driver when the IRP is in a cancelable state.
//
//
// Note that the UserBuffer parameter is outside of the stack so that I/O
// completion can copy data back into the user's address space without
// having to know exactly which service was being invoked. The length
// of the copy is stored in the second half of the I/O status block. If
// the UserBuffer field is NULL, then no copy is performed.
//
//
// Kernel structures
//
// The following section contains kernel structures which the IRP needs
// in order to place various work information in kernel controller system
// queues. Because the size and alignment cannot be controlled, they are
// placed here at the end so they just hang off and do not affect the
// alignment of other fields in the IRP.
//
union {
struct {
union {
//
// DeviceQueueEntry - The device queue entry field is used to
// queue the IRP to the device driver device queue.
//
struct {
//
// The following are available to the driver to use in
// whatever manner is desired, while the driver owns the
// packet.
//
} ;
} ;
//
// Thread - pointer to caller's Thread Control Block.
//
//
// Auxiliary buffer - pointer to any auxiliary buffer that is
// required to pass information to a driver that is not contained
// in a normal buffer.
//
//
// The following unnamed structure must be exactly identical
// to the unnamed structure used in the minipacket header used
// for completion queue entries.
//
struct {
//
// List entry - used to queue the packet to completion queue, among
// others.
//
union {
//
// Current stack location - contains a pointer to the current
// IO_STACK_LOCATION structure in the IRP stack. This field
// should never be directly accessed by drivers. They should
// use the standard functions.
//
struct _IO_STACK_LOCATION *CurrentStackLocation;
//
// Minipacket type.
//
};
};
//
// Original file object - pointer to the original file object
// that was used to open the file. This field is owned by the
// I/O system and should not be used by any other drivers.
//
} Overlay;
//
// APC - This APC control block is used for the special kernel APC as
// well as for the caller's APC, if one was specified in the original
// argument list. If so, then the APC is reused for the normal APC for
// whatever mode the caller was in and the "special" routine that is
// invoked before the APC gets control simply deallocates the IRP.
//
//
// CompletionKey - This is the key that is used to distinguish
// individual I/O operations initiated on a single file handle.
//
} Tail;
//
// Define completion routine types for use in stack locations in an IRP
//
typedef
);
//
// Define stack location control flags
//
#define SL_PENDING_RETURNED 0x01
#define SL_INVOKE_ON_CANCEL 0x20
#define SL_INVOKE_ON_SUCCESS 0x40
#define SL_INVOKE_ON_ERROR 0x80
//
// Define flags for various functions
//
//
// Create / Create Named Pipe
//
// The following flags must exactly match those in the IoCreateFile call's
// options. The case sensitive flag is added in later, by the parse routine,
// and is not an actual option to open. Rather, it is part of the object
// manager's attributes structure.
//
#define SL_FORCE_ACCESS_CHECK 0x01
#define SL_OPEN_PAGING_FILE 0x02
#define SL_OPEN_TARGET_DIRECTORY 0x04
#define SL_CASE_SENSITIVE 0x80
//
// Read / Write
//
#define SL_KEY_SPECIFIED 0x01
#define SL_OVERRIDE_VERIFY_VOLUME 0x02
#define SL_WRITE_THROUGH 0x04
#define SL_FT_SEQUENTIAL_WRITE 0x08
//
// Device I/O Control
//
//
//
#define SL_READ_ACCESS_GRANTED 0x01
//
// Lock
//
#define SL_FAIL_IMMEDIATELY 0x01
#define SL_EXCLUSIVE_LOCK 0x02
//
// QueryDirectory / QueryEa / QueryQuota
//
#define SL_RESTART_SCAN 0x01
#define SL_RETURN_SINGLE_ENTRY 0x02
#define SL_INDEX_SPECIFIED 0x04
//
// NotifyDirectory
//
#define SL_WATCH_TREE 0x01
//
// FileSystemControl
//
//
#define SL_ALLOW_RAW_MOUNT 0x01
//
// Define PNP/POWER types required by IRP_MJ_PNP/IRP_MJ_POWER.
//
typedef enum _DEVICE_RELATION_TYPE {
typedef struct _DEVICE_RELATIONS {
typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
// workaround overloaded definition (rpc generated headers all define INTERFACE
// to match the class name).
typedef struct _INTERFACE {
// interface specific entries go here
} INTERFACE, *PINTERFACE;
typedef struct _DEVICE_CAPABILITIES {
typedef struct _POWER_SEQUENCE {
typedef enum {
BusQueryDeviceID = 0, // <Enumerator>\<Enumerator-specific device id>
#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
typedef enum {
DeviceTextDescription = 0, // DeviceDesc property
//
// Define I/O Request Packet (IRP) stack locations
//
#include "pshpack4.h"
#endif
#if defined(_WIN64)
#else
#define POINTER_ALIGNMENT
#endif
typedef struct _IO_STACK_LOCATION {
//
// The following user parameters are based on the service that is being
// invoked. Drivers and file systems can determine which set to use based
// on the above major and minor function codes.
//
union {
//
// System service parameters for: NtCreateFile
//
struct {
} Create;
//
// System service parameters for: NtReadFile
//
struct {
} Read;
//
// System service parameters for: NtWriteFile
//
struct {
} Write;
//
// System service parameters for: NtQueryInformationFile
//
struct {
} QueryFile;
//
// System service parameters for: NtSetInformationFile
//
struct {
union {
struct {
};
};
} SetFile;
//
// System service parameters for: NtQueryVolumeInformationFile
//
struct {
} QueryVolume;
//
// System service parameters for: NtFlushBuffersFile
//
// No extra user-supplied parameters.
//
//
// System service parameters for: NtDeviceIoControlFile
//
// Note that the user's output buffer is stored in the UserBuffer field
// and the user's input buffer is stored in the SystemBuffer field.
//
struct {
//
// System service parameters for: NtQuerySecurityObject
//
struct {
//
// System service parameters for: NtSetSecurityObject
//
struct {
} SetSecurity;
//
// Non-system service parameters.
//
// Parameters for MountVolume
//
struct {
} MountVolume;
//
// Parameters for VerifyVolume
//
struct {
} VerifyVolume;
//
// Parameters for Scsi with internal device control.
//
struct {
struct _SCSI_REQUEST_BLOCK *Srb;
} Scsi;
//
// Parameters for IRP_MN_QUERY_DEVICE_RELATIONS
//
struct {
//
// Parameters for IRP_MN_QUERY_INTERFACE
//
struct {
//
// Parameters for IRP_MN_QUERY_CAPABILITIES
//
struct {
//
// Parameters for IRP_MN_FILTER_RESOURCE_REQUIREMENTS
//
struct {
//
// Parameters for IRP_MN_READ_CONFIG and IRP_MN_WRITE_CONFIG
//
struct {
//
// Parameters for IRP_MN_SET_LOCK
//
struct {
} SetLock;
//
// Parameters for IRP_MN_QUERY_ID
//
struct {
} QueryId;
//
// Parameters for IRP_MN_QUERY_DEVICE_TEXT
//
struct {
//
// Parameters for IRP_MN_DEVICE_USAGE_NOTIFICATION
//
struct {
//
// Parameters for IRP_MN_WAIT_WAKE
//
struct {
} WaitWake;
//
// Parameter for IRP_MN_POWER_SEQUENCE
//
struct {
//
// Parameters for IRP_MN_SET_POWER and IRP_MN_QUERY_POWER
//
struct {
} Power;
//
// Parameters for StartDevice
//
struct {
} StartDevice;
//
// Parameters for Cleanup
//
// No extra parameters supplied
//
//
// WMI Irps
//
struct {
} WMI;
//
// Others - driver-specific
//
struct {
} Others;
} Parameters;
//
// Save a pointer to this device driver's device object for this request
// so it can be passed to the completion routine if needed.
//
//
// The following location contains a pointer to the file object for this
//
//
// The following routine is invoked depending on the flags in the above
// flags field.
//
//
// The following is used to store the address of the context parameter
// that should be passed to the CompletionRoutine.
//
#include "poppack.h"
#endif
//
// Define the share access structure used by file systems to determine
// whether or not another accessor may open the file.
//
typedef struct _SHARE_ACCESS {
//
// The following structure is used by drivers that are initializing to
// determine the number of devices of a particular type that have already
// been initialized. It is also used to track whether or not the AtDisk
// address range has already been claimed. Finally, it is used by the
// NtQuerySystemInformation system service to return device type counts.
//
typedef struct _CONFIGURATION_INFORMATION {
//
// This field indicates the total number of disks in the system. This
// number should be used by the driver to determine the name of new
// disks. This field should be updated by the driver as it finds new
// disks.
//
//
// These next two fields indicate ownership of one of the two IO address
// spaces that are used by WD1003-compatible disk controllers.
//
//
// Indicates the structure version, as anything value belong this will have been added.
// Use the structure size as the version.
//
//
// Indicates the total number of medium changer devices in the system.
// This field will be updated by the drivers as it determines that
// new devices have been found and will be supported.
//
//
// Public I/O routine definitions
//
);
DECLSPEC_DEPRECATED_DDK // Use AllocateAdapterChannel
);
);
);
);
);
);
//++
//
// VOID
// IoAssignArcName(
// IN PUNICODE_STRING ArcName,
// IN PUNICODE_STRING DeviceName
// )
//
// Routine Description:
//
// This routine is invoked by drivers of bootable media to create a symbolic
// link between the ARC name of their device and its NT name. This allows
// the system to determine which device in the system was actually booted
// from since the ARC firmware only deals in ARC names, and NT only deals
// in NT names.
//
// Arguments:
//
// ArcName - Supplies the Unicode string representing the ARC name.
//
// DeviceName - Supplies the name to which the ARCname refers.
//
// Return Value:
//
// None.
//
//--
DECLSPEC_DEPRECATED_DDK // Use Pnp or IoReprtDetectedDevice
);
typedef enum _IO_PAGING_PRIORITY {
IoPagingPriorityInvalid, // Returned if a non-paging IO IRP is passed.
IoPagingPriorityNormal, // For regular paging IO
IoPagingPriorityHigh, // For high priority paging IO
IoPagingPriorityReserved1, // Reserved for future use.
IoPagingPriorityReserved2 // Reserved for future use.
);
DECLSPEC_DEPRECATED_DDK // Use IoAttachDeviceToDeviceStack
);
);
);
);
);
typedef struct _BOOTDISK_INFORMATION {
//
// This structure should follow the previous structure field for field.
//
typedef struct _BOOTDISK_INFORMATION_EX {
);
);
);
#define IoCallDriver(a,b) \
IofCallDriver(a,b)
);
);
//
// This value should be returned from completion routines to continue
// completing the IRP upwards. Otherwise, STATUS_MORE_PROCESSING_REQUIRED
// should be returned.
//
//
// Completion routines can also use this enumeration in place of status codes.
//
typedef enum _IO_COMPLETION_ROUTINE_RESULT {
);
#define IoCompleteRequest(a,b) \
IofCompleteRequest(a,b)
);
);
);
#define WDM_MAJORVERSION 0x01
#define WDM_MINORVERSION 0x30
);
);
);
);
);
);
//++
//
// VOID
// IoDeassignArcName(
// IN PUNICODE_STRING ArcName
// )
//
// Routine Description:
//
// This routine is invoked by drivers to deassign an ARC name that they
// created to a device. This is generally only called if the driver is
// deleting the device object, which means that the driver is probably
// unloading.
//
// Arguments:
//
// ArcName - Supplies the ARC name to be removed.
//
// Return Value:
//
// None.
//
//--
#define IoDeassignArcName( ArcName ) ( \
IoDeleteSymbolicLink( (ArcName) ) )
);
);
);
);
);
);
);
);
);
//++
//
// PIO_STACK_LOCATION
// IoGetCurrentIrpStackLocation(
// IN PIRP Irp
// )
//
// Routine Description:
//
// This routine is invoked to return a pointer to the current stack location
// in an I/O Request Packet (IRP).
//
// Arguments:
//
// Irp - Pointer to the I/O Request Packet.
//
// Return Value:
//
// The function value is a pointer to the current stack location in the
// packet.
//
//--
);
);
);
);
struct _DMA_ADAPTER *
);
);
);
//++
//
// ULONG
// IoGetFunctionCodeFromCtlCode(
// IN ULONG ControlCode
// )
//
// Routine Description:
//
// This routine extracts the function code from IOCTL and FSCTL function
// control codes.
// This routine should only be used by kernel mode code.
//
// Arguments:
//
// ControlCode - A function control code (IOCTL or FSCTL) from which the
// function code must be extracted.
//
// Return Value:
//
// The extracted function code.
//
// Note:
//
// The CTL_CODE macro, used to create IOCTL and FSCTL function control
// codes, is defined in ntioapi.h
//
//--
#define IoGetFunctionCodeFromCtlCode( ControlCode ) (\
);
);
//
// The following function is used to tell the caller how much stack is available
//
)
{
}
//++
//
// PIO_STACK_LOCATION
// IoGetNextIrpStackLocation(
// IN PIRP Irp
// )
//
// Routine Description:
//
// This routine is invoked to return a pointer to the next stack location
// in an I/O Request Packet (IRP).
//
// Arguments:
//
// Irp - Pointer to the I/O Request Packet.
//
// Return Value:
//
// The function value is a pointer to the next stack location in the packet.
//
//--
#define IoGetNextIrpStackLocation( Irp ) (\
);
//++
//
// VOID
// IoInitializeDpcRequest(
// IN PDEVICE_OBJECT DeviceObject,
// IN PIO_DPC_ROUTINE DpcRoutine
// )
//
// Routine Description:
//
// This routine is invoked to initialize the DPC in a device object for a
// device driver during its initialization routine. The DPC is used later
// when the driver interrupt service routine requests that a DPC routine
// be queued for later execution.
//
// Arguments:
//
// DeviceObject - Pointer to the device object that the request is for.
//
// DpcRoutine - Address of the driver's DPC routine to be executed when
// the DPC is dequeued for processing.
//
// Return Value:
//
// None.
//
//--
(PKDEFERRED_ROUTINE) (DpcRoutine), \
(DeviceObject) ) )
);
);
);
);
//++
//
// BOOLEAN
// IoIsErrorUserInduced(
// IN NTSTATUS Status
// )
//
// Routine Description:
//
// This routine is invoked to determine if an error was as a
// result of user actions. Typically these error are related
// to removable media and will result in a pop-up.
//
// Arguments:
//
// Status - The status value to check.
//
// Return Value:
// The function value is TRUE if the user induced the error,
// otherwise FALSE is returned.
//
//--
(((Status) == STATUS_DEVICE_NOT_READY) || \
((Status) == STATUS_IO_TIMEOUT) || \
((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
((Status) == STATUS_VERIFY_REQUIRED) || \
((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
((Status) == STATUS_WRONG_VOLUME)))
);
//++
//
// VOID
// IoMarkIrpPending(
// IN OUT PIRP Irp
// )
//
// Routine Description:
//
// This routine marks the specified I/O Request Packet (IRP) to indicate
// that an initial status of STATUS_PENDING was returned to the caller.
// This is used so that I/O completion can determine whether or not to
// fully complete the I/O operation requested by the packet.
//
// Arguments:
//
// Irp - Pointer to the I/O Request Packet to be marked pending.
//
// Return Value:
//
// None.
//
//--
#define IoMarkIrpPending( Irp ) ( \
DECLSPEC_DEPRECATED_DDK // Use IoGetDeviceProperty
);
);
);
);
);
);
);
);
);
);
DECLSPEC_DEPRECATED_DDK // Use IoReportResourceForDetection
);
//++
//
// VOID
// IoRequestDpc(
// IN PDEVICE_OBJECT DeviceObject,
// IN PIRP Irp,
// IN PVOID Context
// )
//
// Routine Description:
//
// This routine is invoked by the device driver's interrupt service routine
// to request that a DPC routine be queued for later execution at a lower
// IRQL.
//
// Arguments:
//
// DeviceObject - Device object for which the request is being processed.
//
// Irp - Pointer to the current I/O Request Packet (IRP) for the specified
// device.
//
// Context - Provides a general context parameter to be passed to the
// DPC routine.
//
// Return Value:
//
// None.
//
//--
//++
//
// PDRIVER_CANCEL
// IoSetCancelRoutine(
// IN PIRP Irp,
// IN PDRIVER_CANCEL CancelRoutine
// )
//
// Routine Description:
//
// This routine is invoked to set the address of a cancel routine which
// is to be invoked when an I/O packet has been canceled.
//
// Arguments:
//
// Irp - Pointer to the I/O Request Packet itself.
//
// CancelRoutine - Address of the cancel routine that is to be invoked
// if the IRP is cancelled.
//
// Return Value:
//
// Previous value of CancelRoutine field in the IRP.
//
//--
(PDRIVER_CANCEL) (ULONG_PTR) InterlockedExchangePointer( (PVOID *) &(Irp)->CancelRoutine, (PVOID) (ULONG_PTR)(NewCancelRoutine) ) )
//++
//
// VOID
// IoSetCompletionRoutine(
// IN PIRP Irp,
// IN PIO_COMPLETION_ROUTINE CompletionRoutine,
// IN PVOID Context,
// IN BOOLEAN InvokeOnSuccess,
// IN BOOLEAN InvokeOnError,
// IN BOOLEAN InvokeOnCancel
// )
//
// Routine Description:
//
// This routine is invoked to set the address of a completion routine which
// is to be invoked when an I/O packet has been completed by a lower-level
// driver.
//
// Arguments:
//
// Irp - Pointer to the I/O Request Packet itself.
//
// CompletionRoutine - Address of the completion routine that is to be
// invoked once the next level driver completes the packet.
//
// Context - Specifies a context parameter to be passed to the completion
// routine.
//
// InvokeOnSuccess - Specifies that the completion routine is invoked when the
// operation is successfully completed.
//
// InvokeOnError - Specifies that the completion routine is invoked when the
// operation completes with an error status.
//
// InvokeOnCancel - Specifies that the completion routine is invoked when the
// operation is being canceled.
//
// Return Value:
//
// None.
//
//--
);
);
//++
//
// VOID
// IoSetNextIrpStackLocation (
// IN OUT PIRP Irp
// )
//
// Routine Description:
//
// This routine is invoked to set the current IRP stack location to
// the next stack location, i.e. it "pushes" the stack.
//
// Arguments:
//
// Irp - Pointer to the I/O Request Packet (IRP).
//
// Return Value:
//
// None.
//
//--
#define IoSetNextIrpStackLocation( Irp ) { \
(Irp)->CurrentLocation--; \
//++
//
// VOID
// IoCopyCurrentIrpStackLocationToNext(
// IN PIRP Irp
// )
//
// Routine Description:
//
// This routine is invoked to copy the IRP stack arguments and file
// pointer from the current IrpStackLocation to the next
// in an I/O Request Packet (IRP).
//
// If the caller wants to call IoCallDriver with a completion routine
// but does not wish to change the arguments otherwise,
// the caller first calls IoCopyCurrentIrpStackLocationToNext,
// then IoSetCompletionRoutine, then IoCallDriver.
//
// Arguments:
//
// Irp - Pointer to the I/O Request Packet.
//
// Return Value:
//
// None.
//
//--
#define IoCopyCurrentIrpStackLocationToNext( Irp ) { \
__nextIrpSp->Control = 0; }
//++
//
// VOID
// IoSkipCurrentIrpStackLocation (
// IN PIRP Irp
// )
//
// Routine Description:
//
// This routine is invoked to increment the current stack location of
// a given IRP.
//
// If the caller wishes to call the next driver in a stack, and does not
// wish to change the arguments, nor does he wish to set a completion
// routine, then the caller first calls IoSkipCurrentIrpStackLocation
// and the calls IoCallDriver.
//
// Arguments:
//
// Irp - Pointer to the I/O Request Packet.
//
// Return Value:
//
// None
//
//--
#define IoSkipCurrentIrpStackLocation( Irp ) { \
(Irp)->CurrentLocation++; \
);
typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
typedef struct _IO_REMOVE_LOCK {
#if DBG
#endif
);
//
// Initialize a remove lock.
//
// Note: Allocation for remove locks needs to be within the device extension,
// so that the memory for this structure stays allocated until such time as the
// device object itself is deallocated.
//
);
//
// Routine Description:
//
// This routine is called to acquire the remove lock for a device object.
// While the lock is held, the caller can assume that no pending pnp REMOVE
// requests will be completed.
//
// The lock should be acquired immediately upon entering a dispatch routine.
// It should also be acquired before creating any new reference to the
// device object if there's a chance of releasing the reference before the
// new one is done, in addition to references to the driver code itself,
// which is removed from memory when the last device object goes.
//
// Arguments:
//
// RemoveLock - A pointer to an initialized REMOVE_LOCK structure.
//
// Tag - Used for tracking lock allocation and release. The same tag
// specified when acquiring the lock must be used to release the lock.
// Tags are only checked in checked versions of the driver.
//
// File - set to __FILE__ as the location in the code where the lock was taken.
//
// Line - set to __LINE__.
//
// Return Value:
//
// Returns whether or not the remove lock was obtained.
// If successful the caller should continue with work calling
// IoReleaseRemoveLock when finished.
//
// If not successful the lock was not obtained. The caller should abort the
// work but not call IoReleaseRemoveLock.
//
);
//
//
// Routine Description:
//
// This routine is called to release the remove lock on the device object. It
// must be called when finished using a previously locked reference to the
// device object. If an Tag was specified when acquiring the lock then the
// same Tag must be specified when releasing the lock.
//
// When the lock count reduces to zero, this routine will signal the waiting
// event to release the waiting thread deleting the device object protected
// by this lock.
//
// Arguments:
//
// DeviceObject - the device object to lock
//
// Tag - The TAG (if any) specified when acquiring the lock. This is used
// for lock tracking purposes
//
// Return Value:
//
// none
//
);
//
//
// Routine Description:
//
// This routine is called when the client would like to delete the
// remove-locked resource. This routine will block until all the remove
// locks have released.
//
// This routine MUST be called after acquiring the lock.
//
// Arguments:
//
// RemoveLock
//
// Return Value:
//
// none
//
//++
//
// USHORT
// IoSizeOfIrp(
// IN CCHAR StackSize
// )
//
// Routine Description:
//
// Determines the size of an IRP given the number of stack locations
// the IRP will have.
//
// Arguments:
//
// StackSize - Number of stack locations for the IRP.
//
// Return Value:
//
// Size in bytes of the IRP.
//
//--
#define IoSizeOfIrp( StackSize ) \
);
);
);
);
);
);
);
);
);
typedef struct _IO_WORKITEM *PIO_WORKITEM;
typedef
(*PIO_WORKITEM_ROUTINE) (
);
);
);
);
);
//
// Action code for IoWMIRegistrationControl api
//
#define WMIREG_ACTION_REGISTER 1
#define WMIREG_ACTION_DEREGISTER 2
#define WMIREG_ACTION_REREGISTER 3
#define WMIREG_ACTION_UPDATE_GUIDS 4
#define WMIREG_ACTION_BLOCK_IRPS 5
//
// Code passed in IRP_MN_REGINFO WMI irp
//
#define WMIREGISTER 0
#define WMIUPDATE 1
);
);
);
#if defined(_WIN64)
);
#else
#endif
);
);
);
);
);
);
);
);
typedef VOID (*WMI_NOTIFICATION_CALLBACK)(
);
);
);
);
#if defined(_WIN64)
);
#endif
);
DECLSPEC_DEPRECATED_DDK // Use IoReadPartitionTableEx
);
DECLSPEC_DEPRECATED_DDK // Use IoSetPartitionInformationEx
);
DECLSPEC_DEPRECATED_DDK // Use IoWritePartitionTableEx
);
);
);
);
);
);
);
typedef struct _DISK_SIGNATURE {
union {
struct {
} Mbr;
struct {
} Gpt;
};
);
);
);
);
// Cancel SAFE API set start
//
// The following APIs are to help ease the pain of writing queue packages that
// handle the cancellation race well. The idea of this set of APIs is to not
// force a single queue data structure but allow the cancel logic to be hidden
// from the drivers. A driver implements a queue and as part of its header
// includes the IO_CSQ structure. In its initialization routine it calls
// IoInitializeCsq. Then in the dispatch routine when the driver wants to
// insert an IRP into the queue it calls IoCsqInsertIrp. When the driver wants
// to remove something from the queue it calls IoCsqRemoveIrp. Note that Insert
// can fail if the IRP was cancelled in the meantime. Remove can also fail if
// the IRP was already cancelled.
//
// There are typically two modes where drivers queue IRPs. These two modes are
// covered by the cancel safe queue API set.
//
// Mode 1:
// One is where the driver queues the IRP and at some later
// point in time dequeues an IRP and issues the IO request.
// For this mode the driver should use IoCsqInsertIrp and IoCsqRemoveNextIrp.
// The driver in this case is expected to pass NULL to the irp context
// parameter in IoInsertIrp.
//
// Mode 2:
// In this the driver queues theIRP, issues the IO request (like issuing a DMA
// request or writing to a register) and when the IO request completes (either
// using a DPC or timer) the driver dequeues the IRP and completes it. For this
// mode the driver should use IoCsqInsertIrp and IoCsqRemoveIrp. In this case
// the driver should allocate an IRP context and pass it in to IoCsqInsertIrp.
// The cancel API code creates an association between the IRP and the context
// and thus ensures that when the time comes to remove the IRP it can ascertain
// correctly.
//
// Note that the cancel API set assumes that the field DriverContext[3] is
// always available for use and that the driver does not use it.
//
//
// Bookkeeping structure. This should be opaque to drivers.
// Drivers typically include this as part of their queue headers.
// Given a CSQ pointer the driver should be able to get its
// queue header using CONTAINING_RECORD macro
//
#define IO_TYPE_CSQ_IRP_CONTEXT 1
#define IO_TYPE_CSQ 2
#define IO_TYPE_CSQ_EX 3
//
// IRP context structure. This structure is necessary if the driver is using
// the second mode.
//
typedef struct _IO_CSQ_IRP_CONTEXT {
//
//
typedef VOID
);
typedef NTSTATUS
);
typedef VOID
);
//
// Retrieves next entry after Irp from the queue.
// Returns NULL if there are no entries in the queue.
// If Irp is NUL, returns the entry in the head of the queue.
// This routine does not remove the IRP from the queue.
//
typedef PIRP
);
//
// Lock routine that protects the cancel safe queue.
//
typedef VOID
);
typedef VOID
);
//
// Completes the IRP with STATUS_CANCELLED. IRP is guaranteed to be valid
// In most cases this routine just calls IoCompleteRequest(Irp, STATUS_CANCELLED);
//
typedef VOID
);
//
// Bookkeeping structure. This should be opaque to drivers.
// Drivers typically include this as part of their queue headers.
// Given a CSQ pointer the driver should be able to get its
// queue header using CONTAINING_RECORD macro
//
typedef struct _IO_CSQ {
//
// Initializes the cancel queue structure.
//
);
);
//
// The caller calls this routine to insert the IRP and return STATUS_PENDING.
//
);
);
//
// Returns an IRP if one can be found. NULL otherwise.
//
);
//
// This routine is called from timeout or DPCs.
// The context is presumably part of the DPC or timer context.
// If successful returns the IRP associated with context.
//
);
// Cancel SAFE API set end
);
);
#ifdef RUN_WPP
#include <evntrace.h>
#include <stdarg.h>
#endif // #ifdef RUN_WPP
#ifdef RUN_WPP
IN ...
);
);
#endif // #ifdef RUN_WPP
#ifndef TRACE_INFORMATION_CLASS_DEFINE
typedef enum _TRACE_INFORMATION_CLASS {
);
#define TRACE_INFORMATION_CLASS_DEFINE
#endif // TRACE_INFOPRMATION_CLASS_DEFINE
//
// Define PnP Device Property for IoGetDeviceProperty
//
typedef enum {
typedef BOOLEAN (*PTRANSLATE_BUS_ADDRESS)(
);
typedef struct _DMA_ADAPTER *(*PGET_DMA_ADAPTER)(
);
typedef ULONG (*PGET_SET_DEVICE_DATA)(
);
typedef enum _DEVICE_INSTALL_STATE {
//
// Define structure returned in response to IRP_MN_QUERY_BUS_INFORMATION by a
// PDO indicating the type of bus the device exists on.
//
typedef struct _PNP_BUS_INFORMATION {
//
// Define structure returned in response to IRP_MN_QUERY_LEGACY_BUS_INFORMATION
// by an FDO indicating the type of bus it is. This is normally the same bus
// type as the device's children (i.e., as retrieved from the child PDO's via
// IRP_MN_QUERY_BUS_INFORMATION) except for cases like CardBus, which can
// support both 16-bit (PCMCIABus) and 32-bit (PCIBus) cards.
//
typedef struct _LEGACY_BUS_INFORMATION {
//
// Defines for IoGetDeviceProperty(DevicePropertyRemovalPolicy).
//
typedef enum _DEVICE_REMOVAL_POLICY {
typedef struct _BUS_INTERFACE_STANDARD {
//
// generic interface header
//
//
// standard bus interfaces
//
typedef struct _AGP_TARGET_BUS_INTERFACE_STANDARD {
//
// generic interface header
//
//
// config munging routines
//
//
// The following definitions are used in ACPI QueryInterface
//
typedef BOOLEAN (* PGPE_SERVICE_ROUTINE) (
PVOID);
typedef NTSTATUS (* PGPE_CONNECT_VECTOR) (
PVOID);
typedef NTSTATUS (* PGPE_DISCONNECT_VECTOR) (
PVOID);
typedef NTSTATUS (* PGPE_ENABLE_EVENT) (
PVOID);
typedef NTSTATUS (* PGPE_DISABLE_EVENT) (
PVOID);
typedef NTSTATUS (* PGPE_CLEAR_STATUS) (
PVOID);
typedef VOID (* PDEVICE_NOTIFY_CALLBACK) (
ULONG);
typedef NTSTATUS (* PREGISTER_FOR_DEVICE_NOTIFICATIONS) (
PVOID);
typedef void (* PUNREGISTER_FOR_DEVICE_NOTIFICATIONS) (
typedef struct _ACPI_INTERFACE_STANDARD {
//
// Generic interface header
//
//
// ACPI interfaces
//
);
);
);
);
//
// The following definitions are used in IoOpenDeviceRegistryKey
//
#define PLUGPLAY_REGKEY_DEVICE 1
#define PLUGPLAY_REGKEY_DRIVER 2
#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4
);
);
);
);
);
#define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
);
//
// Define PnP notification event categories
//
typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
//
// Define flags that modify the behavior of IoRegisterPlugPlayNotification
// for the various event categories...
//
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
typedef
);
);
);
);
typedef
);
);
if (_paging_) { \
} else { \
} \
}
);
//
// Device location interface declarations
//
typedef
(*PGET_LOCATION_STRING) (
);
typedef struct _PNP_LOCATION_INTERFACE {
//
// generic interface header
//
//
// interface specific entry
//
//
// Resource arbiter declarations
//
typedef enum _ARBITER_ACTION {
typedef struct _ARBITER_CONFLICT_INFO {
//
// The device object owning the device that is causing the conflict
//
//
// The start of the conflicting range
//
//
// The end of the conflicting range
//
//
// The parameters for those actions
//
typedef struct _ARBITER_PARAMETERS {
union {
struct {
//
// Doubly linked list of ARBITER_LIST_ENTRY's
//
//
// The size of the AllocateFrom array
//
//
// Array of resource descriptors describing the resources available
// to the arbiter for it to arbitrate
//
struct {
//
// Doubly linked list of ARBITER_LIST_ENTRY's
//
//
// The size of the AllocateFrom array
//
//
// Array of resource descriptors describing the resources available
// to the arbiter for it to arbitrate
//
struct {
//
// Doubly linked list of ARBITER_LIST_ENTRY's
//
struct {
//
// The resources that are currently allocated
//
struct {
//
// This is the device we are trying to find a conflict for
//
//
// This is the resource to find the conflict for
//
//
// Number of devices conflicting on the resource
//
//
// Pointer to array describing the conflicting device objects and ranges
//
struct {
//
// Doubly linked list of ARBITER_LIST_ENTRY's - should have
// only one entry
//
struct {
//
// Indicates the device whose resources are to be marked as reserved
//
} AddReserved;
} Parameters;
typedef enum _ARBITER_REQUEST_SOURCE {
ArbiterRequestUndefined = -1,
ArbiterRequestLegacyReported, // IoReportResourceUsage
ArbiterRequestHalReported, // IoReportHalResourceUsage
ArbiterRequestLegacyAssigned, // IoAssignResources
ArbiterRequestPnpDetected, // IoReportResourceForDetection
ArbiterRequestPnpEnumerated // IRP_MN_QUERY_RESOURCE_REQUIREMENTS
typedef enum _ARBITER_RESULT {
ArbiterResultUndefined = -1,
ArbiterResultExternalConflict, // This indicates that the request can never be solved for devices in this list
ArbiterResultNullRequest // The request was for length zero and thus no translation should be attempted
//
// ARBITER_FLAG_BOOT_CONFIG - this indicates that the request is for the
// it conflicts with another devices boot config.
//
#define ARBITER_FLAG_BOOT_CONFIG 0x00000001
);
typedef struct _ARBITER_LIST_ENTRY {
//
// This is a doubly linked list of entries for easy sorting
//
//
// The number of alternative allocation
//
//
// Pointer to an array of resource descriptors for the possible allocations
//
//
// The device object of the device requesting these resources.
//
//
// Indicates where the request came from
//
//
// Flags these indicate a variety of things (use ARBITER_FLAG_*)
//
//
// Space to aid the arbiter in processing the list it is initialized to 0 when
// the entry is created. The system will not attempt to interpret it.
//
//
// Interface Type, Slot Number and Bus Number from Resource Requirements list,
// used only for reverse identification.
//
//
// A pointer to a descriptor to indicate the resource that was allocated.
// This is allocated by the system and filled in by the arbiter in response to an
// ArbiterActionTestAllocation.
//
//
// Pointer to the alternative that was chosen from to provide the assignment.
// This is filled in by the arbiter in response to an ArbiterActionTestAllocation.
//
//
// The result of the operation
// This is filled in by the arbiter in response to an ArbiterActionTestAllocation.
//
//
// The arbiter's entry point
//
typedef
(*PARBITER_HANDLER) (
);
//
// Arbiter interface
//
#define ARBITER_PARTIAL 0x00000001
typedef struct _ARBITER_INTERFACE {
//
// Generic interface header
//
//
// Entry point to the arbiter
//
//
// Other information about the arbiter, use ARBITER_* flags
//
//
// The directions translation can take place in
//
typedef enum _RESOURCE_TRANSLATION_DIRECTION { // ntosp
TranslateChildToParent, // ntosp
TranslateParentToChild // ntosp
} RESOURCE_TRANSLATION_DIRECTION; // ntosp
//
// Translation functions
//
typedef
);
typedef
);
//
// Translator Interface
//
typedef struct _TRANSLATOR_INTERFACE {
//
// Header structure for all Plug&Play notification events...
//
typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
//
// Event-specific stuff starts here.
//
//
// Notification structure for all EventCategoryHardwareProfileChange events...
//
typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
//
// (No event-specific data)
//
//
// Notification structure for all EventCategoryDeviceInterfaceChange events...
//
typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
//
// Event-specific data
//
//
// Notification structures for EventCategoryTargetDeviceChange...
//
//
// The following structure is used for TargetDeviceQueryRemove,
// TargetDeviceRemoveCancelled, and TargetDeviceRemoveComplete:
//
typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
//
// Event-specific data
//
//
// The following structure header is used for all other (i.e., 3rd-party)
// target device change events. The structure accommodates both a
// variable-length binary data buffer, and a variable-length unicode text
// buffer. The header must indicate where the text buffer begins, so that
// the data can be delivered in the appropriate format (ANSI or Unicode)
// to user-mode recipients (i.e., that have registered for handle-based
// notification via RegisterDeviceNotification).
//
typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
//
// Event-specific data
//
// IoReportTargetDeviceChange. Clients that
// have registered for target device change
// notification on the affected PDO will be
// called with this field set to the file object
// they specified during registration.
//
// CustomDataBuffer where text begins (-1 if none)
//
// a binary data at the start of the buffer,
// followed by an optional unicode text buffer
// (word-aligned).
//
//
// Define the device description structure.
//
typedef struct _DEVICE_DESCRIPTION {
//
// Define the supported version numbers for the device description structure.
//
#define DEVICE_DESCRIPTION_VERSION 0
#define DEVICE_DESCRIPTION_VERSION1 1
#define DEVICE_DESCRIPTION_VERSION2 2
//
// The following function prototypes are for HAL routines with a prefix of Hal.
//
// General functions.
//
typedef
);
);
#if defined(_IA64_)
DECLSPEC_DEPRECATED_DDK // Use GetDmaRequirement
);
#endif
#define HalGetDmaAlignmentRequirement() 1L
#endif
);
//
// I/O driver configuration functions.
//
#if !defined(NO_LEGACY_DRIVERS)
DECLSPEC_DEPRECATED_DDK // Use Pnp or IoReportDetectedDevice
);
DECLSPEC_DEPRECATED_DDK // Use Pnp or IoReportDetectedDevice
);
DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
);
#endif // NO_LEGACY_DRIVERS
DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
);
DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
);
//
// Values for AddressSpace parameter of HalTranslateBusAddress
//
// 0x0 - Memory space
// 0x1 - Port space
// 0x2 - 0x1F - Address spaces specific for Alpha
// 0x2 - UserMode view of memory space
// 0x3 - UserMode view of port space
// 0x4 - Dense memory space
// 0x5 - reserved
// 0x6 - UserMode view of dense memory space
// 0x7 - 0x1F - reserved
//
);
#if !defined(NO_LEGACY_DRIVERS)
DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
);
#endif // NO_LEGACY_DRIVERS
DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
);
DECLSPEC_DEPRECATED_DDK // Use IoGetDmaAdapter
);
//
// System beep functions.
//
#if !defined(NO_LEGACY_DRIVERS)
);
#endif // NO_LEGACY_DRIVERS
//
// The following function prototypes are for HAL routines with a prefix of Io.
//
// DMA adapter object functions.
//
//
// Performance counter function.
//
);
//
// Stall processor execution function.
//
);
typedef
);
typedef struct _DEVICE_CONTROL_CONTEXT {
typedef
);
typedef
);
//*****************************************************************************
// HAL Function dispatch
//
typedef enum _HAL_QUERY_INFORMATION_CLASS {
HalMcaLogInformation, // Machine Check Abort Information
HalErrorInformation, // General MCA, CMC, CPE Error Information.
HalCmcLogInformation, // Processor Corrected Machine Check Information
HalCpeLogInformation, // Corrected Platform Error Information
// information levels >= 0x8000000 reserved for OEM use
typedef enum _HAL_SET_INFORMATION_CLASS {
HalMcaRegisterDriver, // Registering Machine Check Abort driver
HalCmcRegisterDriver, // Registering Processor Corrected Machine Check driver
HalCpeRegisterDriver, // Registering Corrected Platform Error driver
HalGenerateCmcInterrupt // Used to test CMC
typedef
);
typedef
);
typedef
);
typedef
);
typedef
);
typedef
);
typedef
);
typedef
);
typedef
);
typedef struct _PM_DISPATCH_TABLE {
typedef
);
typedef
struct _DMA_ADAPTER *
);
typedef
);
typedef
);
typedef
);
typedef
(*pHalHaltSystem) (
);
typedef
(*pHalResetDisplay) (
);
typedef struct _MAP_REGISTER_ENTRY {
typedef
(*pHalVectorToIDTEntry) (
);
typedef
);
typedef
);
typedef
(*pHalEndMirroring)(
);
typedef
);
typedef
(*pHalMirrorVerify)(
);
typedef struct {
typedef struct {
typedef struct {
typedef
);
typedef
);
typedef
);
typedef
);
typedef
(*pHalEndOfBoot)(
);
typedef
);
typedef
);
typedef struct {
extern PHAL_DISPATCH HalDispatchTable;
#define HALDISPATCH HalDispatchTable
#else
extern HAL_DISPATCH HalDispatchTable;
#define HALDISPATCH (&HalDispatchTable)
#endif
#define HAL_DISPATCH_VERSION 3
//
// HAL System Information Structures.
//
// for the information class "HalInstalledBusInformation"
typedef struct _HAL_BUS_INFORMATION{
// for the information class "HalProfileSourceInformation"
typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
// for the information class "HalProfileSourceInformation"
typedef struct _HAL_PROFILE_SOURCE_INFORMATION_EX {
// for the information class "HalProfileSourceInterval"
typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
// for the information class "HalQueryProfileSourceList"
typedef struct _HAL_PROFILE_SOURCE_LIST {
// for the information class "HalDispayBiosInformation"
typedef enum _HAL_DISPLAY_BIOS_INFORMATION {
// for the information class "HalPowerInformation"
typedef struct _HAL_POWER_INFORMATION {
// for the information class "HalProcessorSpeedInformation"
typedef struct _HAL_PROCESSOR_SPEED_INFO {
// for the information class "HalCallbackInformation"
typedef struct _HAL_CALLBACKS {
// for the information class "HalProcessorFeatureInformation"
typedef struct _HAL_PROCESSOR_FEATURE {
// for the information class "HalNumaTopologyInterface"
typedef ULONG HALNUMAPAGETONODE;
typedef
);
typedef
);
typedef struct _HAL_NUMA_TOPOLOGY_INTERFACE {
typedef
);
// for the information class "HalQueryIllegalIOPortAddresses"
typedef struct _HAL_AMLI_BAD_IO_ADDRESS_LIST
{
//
// HalQueryMcaInterface
//
typedef
);
typedef
);
typedef
);
typedef struct _HAL_MCA_INTERFACE {
#if defined(_AMD64_)
struct _KTRAP_FRAME;
struct _KEXCEPTION_FRAME;
typedef
);
#endif
typedef
#if defined(_IA64_)
#else
#endif
);
#endif
//
// Structure to record the callbacks from driver
//
typedef struct _MCA_DRIVER_INFO {
typedef struct _HAL_ERROR_INFO {
#define HAL_MCE_DISABLED ((ULONG)0)
//
// Known values for HAL_ERROR_INFO.CmcPollingInterval.
//
#define HAL_CMC_DISABLED HAL_MCE_DISABLED
//
// Known values for HAL_ERROR_INFO.CpePollingInterval.
//
#define HAL_CPE_DISABLED HAL_MCE_DISABLED
#define HAL_MCA_DISABLED HAL_MCE_DISABLED
//
// Driver Callback type for the information class "HalCmcRegisterDriver"
//
typedef
);
//
// Driver Callback type for the information class "HalCpeRegisterDriver"
//
typedef
);
//
//
// Structure to record the callbacks from driver
//
typedef struct _CMC_DRIVER_INFO {
typedef struct _CPE_DRIVER_INFO {
#endif // defined(_X86_) || defined(_IA64_) || defined(_AMD64_)
#if defined(_IA64_)
typedef
);
typedef
);
typedef struct _HAL_CROSS_PARTITION_IPI_INTERFACE {
#endif
typedef struct _HAL_PLATFORM_INFORMATION {
//
// These platform flags are carried over from the IPPT table
// definition if appropriate.
//
#define HAL_PLATFORM_DISABLE_WRITE_COMBINING 0x01L
#define HAL_PLATFORM_DISABLE_PTCG 0x04L
#define HAL_PLATFORM_DISABLE_UC_MAIN_MEMORY 0x08L
#define HAL_PLATFORM_ENABLE_WRITE_COMBINING_MMIO 0x10L
#define HAL_PLATFORM_ACPI_TABLES_CACHED 0x20L
typedef struct _SCATTER_GATHER_ELEMENT {
#if _MSC_VER >= 1200
#endif
typedef struct _SCATTER_GATHER_LIST {
#if _MSC_VER >= 1200
#else
#pragma warning(default:4200)
#endif
typedef struct _DMA_OPERATIONS *PDMA_OPERATIONS;
typedef struct _DMA_ADAPTER {
// Private Bus Device Driver data follows,
} DMA_ADAPTER, *PDMA_ADAPTER;
typedef VOID (*PPUT_DMA_ADAPTER)(
);
typedef PVOID (*PALLOCATE_COMMON_BUFFER)(
);
typedef VOID (*PFREE_COMMON_BUFFER)(
);
typedef NTSTATUS (*PALLOCATE_ADAPTER_CHANNEL)(
);
typedef BOOLEAN (*PFLUSH_ADAPTER_BUFFERS)(
);
typedef VOID (*PFREE_ADAPTER_CHANNEL)(
);
typedef VOID (*PFREE_MAP_REGISTERS)(
);
typedef PHYSICAL_ADDRESS (*PMAP_TRANSFER)(
);
typedef ULONG (*PGET_DMA_ALIGNMENT)(
);
typedef ULONG (*PREAD_DMA_COUNTER)(
);
typedef VOID
);
typedef NTSTATUS
);
typedef VOID
);
typedef NTSTATUS
);
typedef NTSTATUS
);
typedef NTSTATUS
);
typedef struct _DMA_OPERATIONS {
#if defined(_WIN64)
//
// Use __inline DMA macros (hal.h)
//
#ifndef USE_DMA_MACROS
#define USE_DMA_MACROS
#endif
//
// Only PnP drivers!
//
#ifndef NO_LEGACY_DRIVERS
#define NO_LEGACY_DRIVERS
#endif
#endif // _WIN64
DECLSPEC_DEPRECATED_DDK // Use AllocateCommonBuffer
){
CacheEnabled );
return commonBuffer;
}
DECLSPEC_DEPRECATED_DDK // Use FreeCommonBuffer
){
CacheEnabled );
}
DECLSPEC_DEPRECATED_DDK // Use AllocateAdapterChannel
){
Context );
return status;
}
DECLSPEC_DEPRECATED_DDK // Use FlushAdapterBuffers
){
Mdl,
return result;
}
DECLSPEC_DEPRECATED_DDK // Use FreeAdapterChannel
){
}
DECLSPEC_DEPRECATED_DDK // Use FreeMapRegisters
){
}
DECLSPEC_DEPRECATED_DDK // Use MapTransfer
){
Mdl,
return physicalAddress;
}
DECLSPEC_DEPRECATED_DDK // Use GetDmaAlignment
)
{
return alignment;
}
DECLSPEC_DEPRECATED_DDK // Use ReadDmaCounter
)
{
return counter;
}
#else
//
// DMA adapter object functions.
//
DECLSPEC_DEPRECATED_DDK // Use AllocateAdapterChannel
);
DECLSPEC_DEPRECATED_DDK // Use AllocateCommonBuffer
);
DECLSPEC_DEPRECATED_DDK // Use FreeCommonBuffer
);
DECLSPEC_DEPRECATED_DDK // Use ReadDmaCounter
);
DECLSPEC_DEPRECATED_DDK // Use FlushAdapterBuffers
);
DECLSPEC_DEPRECATED_DDK // Use FreeAdapterChannel
);
DECLSPEC_DEPRECATED_DDK // Use FreeMapRegisters
);
DECLSPEC_DEPRECATED_DDK // Use MapTransfer
);
#endif // USE_DMA_MACROS && (_NTDDK_ || _NTDRIVER_)
HalGetScatterGatherList ( // Use GetScatterGatherList
);
DECLSPEC_DEPRECATED_DDK // Use PutScatterGatherList
);
DECLSPEC_DEPRECATED_DDK // Use PutDmaAdapter
);
);
);
typedef
);
);
);
);
);
);
);
);
);
#define PoSetDeviceBusy(IdlePointer) \
*IdlePointer = 0
//
// \Callback\PowerState values
//
#define PO_CB_SYSTEM_POWER_POLICY 0
#define PO_CB_AC_STATUS 1
#define PO_CB_BUTTON_COLLISION 2
#define PO_CB_SYSTEM_STATE_LOCK 3
#define PO_CB_LID_SWITCH_STATE 4
#define PO_CB_PROCESSOR_POWER_POLICY 5
//
// Determine if there is a complete device failure on an error.
//
);
//
// Object Manager types
//
typedef struct _OBJECT_HANDLE_INFORMATION {
);
#define ObDereferenceObject(a) \
);
);
);
);
);
//
// A PCI driver can read the complete 256 bytes of configuration
// information for any PCI device by calling:
//
// ULONG
// HalGetBusData (
// IN BUS_DATA_TYPE PCIConfiguration,
// IN ULONG PciBusNumber,
// IN PCI_SLOT_NUMBER VirtualSlotNumber,
// IN PPCI_COMMON_CONFIG &PCIDeviceConfig,
// IN ULONG sizeof (PCIDeviceConfig)
// );
//
// A return value of 0 means that the specified PCI bus does not exist.
//
// A return value of 2, with a VendorID of PCI_INVALID_VENDORID means
// that the PCI bus does exist, but there is no device at the specified
//
//
typedef struct _PCI_SLOT_NUMBER {
union {
struct {
} bits;
} u;
#define PCI_TYPE0_ADDRESSES 6
#define PCI_TYPE1_ADDRESSES 2
#define PCI_TYPE2_ADDRESSES 5
typedef struct _PCI_COMMON_CONFIG {
union {
struct _PCI_HEADER_TYPE_0 {
} type0;
//
// PCI to PCI Bridge
//
struct _PCI_HEADER_TYPE_1 {
} type1;
//
// PCI to CARDBUS Bridge
//
struct _PCI_HEADER_TYPE_2 {
struct {
} type2;
} u;
#define PCI_MAX_DEVICES 32
#define PCI_MAX_FUNCTION 8
#define PCI_MAX_BRIDGE_NUMBER 0xFF
#define PCI_INVALID_VENDORID 0xFFFF
//
// Bit encodings for 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) \
#define PCI_MULTIFUNCTION_DEVICE(PciData) \
//
// Bit encodings for 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
//
// Bit encodings for PCI_COMMON_CONFIG.Status
//
#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
#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
//
// The NT PCI Driver uses a WhichSpace parameter on its CONFIG_READ/WRITE
// routines. The following values are defined-
//
#define PCI_WHICHSPACE_CONFIG 0x0
#define PCI_WHICHSPACE_ROM 0x52696350
//
// PCI Capability IDs
//
#define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01
#define PCI_CAPABILITY_ID_AGP 0x02
#define PCI_CAPABILITY_ID_MSI 0x05
#define PCI_CAPABILITY_ID_AGP_TARGET 0x0E
//
// All PCI Capability structures have the following header.
//
// CapabilityID is used to identify the type of the structure (is
// one of the PCI_CAPABILITY_ID values above.
//
// Next is the offset in PCI Configuration space (0x40 - 0xfc) of the
// next capability structure in the list, or 0x00 if there are no more
// entries.
//
typedef struct _PCI_CAPABILITIES_HEADER {
//
// Power Management Capability
//
typedef struct _PCI_PMC {
struct _PM_SUPPORT {
} Support;
typedef struct _PCI_PMCSR {
} PCI_PMCSR, *PPCI_PMCSR;
typedef struct _PCI_PMCSR_BSE {
typedef struct _PCI_PM_CAPABILITY {
//
// Power Management Capabilities (Offset = 2)
//
union {
} PMC;
//
//
union {
} PMCSR;
//
// PMCSR PCI-PCI Bridge Support Extensions
//
union {
} PMCSR_BSE;
//
// Optional read only 8 bit Data register. Contents controlled by
// DataSelect and DataScale in ControlStatus.
//
//
// AGP Capability
//
typedef struct _PCI_AGP_CAPABILITY {
struct _PCI_AGP_STATUS {
} AGPStatus;
struct _PCI_AGP_COMMAND {
} AGPCommand;
//
// An AGPv3 Target must have an extended capability,
// but it's only present for a Master when the Isoch
// bit is set in its status register
//
typedef enum _EXTENDED_AGP_REGISTER {
typedef struct _PCI_AGP_ISOCH_STATUS {
typedef struct _PCI_AGP_CONTROL {
typedef struct _PCI_AGP_APERTURE_PAGE_SIZE {
typedef struct _PCI_AGP_ISOCH_COMMAND {
typedef struct PCI_AGP_EXTENDED_CAPABILITY {
//
// Target only ----------------<<-begin->>
//
//
// ------------------------------<<-end->>
//
#define PCI_AGP_RATE_1X 0x1
#define PCI_AGP_RATE_2X 0x2
#define PCI_AGP_RATE_4X 0x4
//
// MSI (Message Signalled Interrupts) Capability
//
typedef struct _PCI_MSI_CAPABILITY {
struct _PCI_MSI_MESSAGE_CONTROL {
union {
struct _PCI_MSI_MESSAGE_ADDRESS {
} Register;
//
// The rest of the Capability structure differs depending on whether
// 32bit or 64bit addressing is being used.
//
// (The CapableOf64Bits bit above determines this)
//
union {
// For 64 bit devices
struct _PCI_MSI_64BIT_DATA {
} Bit64;
// For 32 bit devices
struct _PCI_MSI_32BIT_DATA {
} Bit32;
} Data;
//
// Base Class Code encodings for Base Class (from PCI spec rev 2.1).
//
#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
// 0d thru fe reserved
#define PCI_CLASS_NOT_DEFINED 0xff
//
// Sub Class Code encodings (PCI rev 2.1).
//
// Class 00 - PCI_CLASS_PRE_20
#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
#define PCI_SUBCLASS_PRE_20_VGA 0x01
// Class 01 - PCI_CLASS_MASS_STORAGE_CTLR
#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
// Class 02 - PCI_CLASS_NETWORK_CTLR
#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
// Class 03 - PCI_CLASS_DISPLAY_CTLR
// N.B. Sub Class 00 could be VGA or 8514 depending on Interface byte
#define PCI_SUBCLASS_VID_VGA_CTLR 0x00
#define PCI_SUBCLASS_VID_XGA_CTLR 0x01
#define PCI_SUBLCASS_VID_3D_CTLR 0x02
#define PCI_SUBCLASS_VID_OTHER 0x80
// Class 04 - PCI_CLASS_MULTIMEDIA_DEV
#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
// Class 05 - PCI_CLASS_MEMORY_CTLR
#define PCI_SUBCLASS_MEM_RAM 0x00
#define PCI_SUBCLASS_MEM_FLASH 0x01
#define PCI_SUBCLASS_MEM_OTHER 0x80
// Class 06 - PCI_CLASS_BRIDGE_DEV
#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
// Class 07 - PCI_CLASS_SIMPLE_COMMS_CTLR
// N.B. Sub Class 00 and 01 additional info in Interface byte
#define PCI_SUBCLASS_COM_SERIAL 0x00
#define PCI_SUBCLASS_COM_PARALLEL 0x01
#define PCI_SUBCLASS_COM_MULTIPORT 0x02
#define PCI_SUBCLASS_COM_MODEM 0x03
#define PCI_SUBCLASS_COM_OTHER 0x80
// Class 08 - PCI_CLASS_BASE_SYSTEM_DEV
// N.B. See Interface byte for additional info.
#define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00
#define PCI_SUBCLASS_SYS_DMA_CTLR 0x01
#define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02
#define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03
#define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04
#define PCI_SUBCLASS_SYS_OTHER 0x80
// Class 09 - PCI_CLASS_INPUT_DEV
#define PCI_SUBCLASS_INP_KEYBOARD 0x00
#define PCI_SUBCLASS_INP_DIGITIZER 0x01
#define PCI_SUBCLASS_INP_MOUSE 0x02
#define PCI_SUBCLASS_INP_SCANNER 0x03
#define PCI_SUBCLASS_INP_GAMEPORT 0x04
#define PCI_SUBCLASS_INP_OTHER 0x80
// Class 0a - PCI_CLASS_DOCKING_STATION
#define PCI_SUBCLASS_DOC_GENERIC 0x00
#define PCI_SUBCLASS_DOC_OTHER 0x80
// Class 0b - PCI_CLASS_PROCESSOR
#define PCI_SUBCLASS_PROC_386 0x00
#define PCI_SUBCLASS_PROC_486 0x01
#define PCI_SUBCLASS_PROC_PENTIUM 0x02
#define PCI_SUBCLASS_PROC_ALPHA 0x10
#define PCI_SUBCLASS_PROC_POWERPC 0x20
#define PCI_SUBCLASS_PROC_COPROCESSOR 0x40
// Class 0c - PCI_CLASS_SERIAL_BUS_CTLR
#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
// Class 0d - PCI_CLASS_WIRELESS_CTLR
#define PCI_SUBCLASS_WIRELESS_IRDA 0x00
#define PCI_SUBCLASS_WIRELESS_CON_IR 0x01
#define PCI_SUBCLASS_WIRELESS_RF 0x10
#define PCI_SUBCLASS_WIRELESS_OTHER 0x80
// Class 0e - PCI_CLASS_INTELLIGENT_IO_CTLR
#define PCI_SUBCLASS_INTIO_I2O 0x00
// Class 0f - PCI_CLASS_SATELLITE_CTLR
#define PCI_SUBCLASS_SAT_TV 0x01
#define PCI_SUBCLASS_SAT_AUDIO 0x02
#define PCI_SUBCLASS_SAT_VOICE 0x03
#define PCI_SUBCLASS_SAT_DATA 0x04
// Class 10 - PCI_CLASS_ENCRYPTION_DECRYPTION
#define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00
#define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10
#define PCI_SUBCLASS_CRYPTO_OTHER 0x80
// Class 11 - PCI_CLASS_DATA_ACQ_SIGNAL_PROC
#define PCI_SUBCLASS_DASP_DPIO 0x00
#define PCI_SUBCLASS_DASP_OTHER 0x80
//
// Bit encodes for PCI_COMMON_CONFIG.u.type0.BaseAddresses
//
#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
//
// Bit encodes for PCI_COMMON_CONFIG.u.type0.ROMBaseAddresses
//
#define PCI_ROMADDRESS_ENABLED 0x00000001
//
// Reference notes for PCI configuration fields:
//
// ro these field are read only. changes to these fields are ignored
//
// ro+ these field are intended to be read only and should be initialized
// by the system to their proper values. However, driver may change
// these settings.
//
// ---
//
// All resources consumed by a PCI device start as unitialized
// under NT. An uninitialized memory or I/O base address can be
// determined by checking it's corresponding enabled bit in the
// PCI_COMMON_CONFIG.Command value. An InterruptLine is unitialized
// if it contains the value of -1.
//
//
// Portable portion of HAL & HAL bus extender definitions for BUSHANDLER
// BusData for installed PCI buses.
//
typedef VOID
(*PciPin2Line) (
);
typedef VOID
(*PciLine2Pin) (
);
typedef VOID
(*PciReadWriteConfig) (
);
#define PCI_DATA_TAG ' ICP'
#define PCI_DATA_VERSION 1
typedef struct _PCIBUSDATA {
} PCIBUSDATA, *PPCIBUSDATA;
typedef ULONG (*PCI_READ_WRITE_CONFIG)(
);
typedef VOID (*PCI_PIN_TO_LINE)(
);
typedef VOID (*PCI_LINE_TO_PIN)(
);
typedef struct _PCI_BUS_INTERFACE_STANDARD {
//
// generic interface header
//
//
// standard PCI bus interfaces
//
#define PCI_BUS_INTERFACE_STANDARD_VERSION 1
#define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1
//
// Flags for PCI_DEVICE_PRESENCE_PARAMETERS
//
#define PCI_USE_SUBSYSTEM_IDS 0x00000001
#define PCI_USE_REVISION 0x00000002
// The following flags are only valid for IsDevicePresentEx
#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
//
// Search parameters structure for IsDevicePresentEx
//
typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
typedef
);
typedef
);
typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
//
// generic interface header
//
//
// pci device info
//
#ifdef POOL_TAGGING
#endif
extern POBJECT_TYPE *IoFileObjectType;
extern POBJECT_TYPE *ExEventObjectType;
extern POBJECT_TYPE *ExSemaphoreObjectType;
//
// Define exported ZwXxx routines to device drivers.
//
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
);
#ifdef VERIFIER_DDK_EXTENSIONS
#include <ddk_ext.h>
#endif
#endif // _NTDDK_