mirror of
https://github.com/reactos/reactos.git
synced 2024-09-10 12:54:51 +00:00
![Timo Kreuzer](/assets/img/avatar_default.png)
- add x86/ke.h(mm.h and amd64/mm.h - cleanup ntddk.template.h, moving stuff into approproate headers svn path=/branches/header-work/; revision=46364
439 lines
11 KiB
C
439 lines
11 KiB
C
/*
|
|
* ntddk.h
|
|
*
|
|
* Windows NT Device Driver Kit
|
|
*
|
|
* This file is part of the ReactOS DDK package.
|
|
*
|
|
* Contributors:
|
|
* Amine Khaldi
|
|
* Timo Kreuzer (timo.kreuzer@reactos.org)
|
|
*
|
|
* THIS SOFTWARE IS NOT COPYRIGHTED
|
|
*
|
|
* This source code is offered for use in the public domain. You may
|
|
* use, modify or distribute it freely.
|
|
*
|
|
* This code is distributed in the hope that it will be useful but
|
|
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
|
* DISCLAIMED. This includes but is not limited to warranties of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#define _NTDDK_
|
|
|
|
#if !defined(_NTHAL_) && !defined(_NTIFS_)
|
|
#define _NTDDK_INCLUDED_
|
|
#define _DDK_DRIVER_
|
|
#endif
|
|
|
|
/* Dependencies */
|
|
|
|
#define NT_INCLUDED
|
|
#define _CTYPE_DISABLE_MACROS
|
|
|
|
#include <wdm.h>
|
|
#include <excpt.h>
|
|
#include <ntdef.h>
|
|
#include <ntstatus.h>
|
|
#include <mce.h>
|
|
|
|
/* FIXME
|
|
#include <bugcodes.h>
|
|
#include <ntiologc.h>
|
|
*/
|
|
|
|
#include <stdarg.h> // FIXME
|
|
#include <basetyps.h> // FIXME
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* GUID and UUID */
|
|
#ifndef _NTLSA_IFS_
|
|
#ifndef _NTLSA_AUDIT_
|
|
#define _NTLSA_AUDIT_
|
|
|
|
#ifndef GUID_DEFINED
|
|
#include <guiddef.h>
|
|
#endif
|
|
|
|
#endif /* _NTLSA_AUDIT_ */
|
|
#endif /* _NTLSA_IFS_ */
|
|
|
|
typedef GUID UUID;
|
|
|
|
struct _LOADER_PARAMETER_BLOCK;
|
|
struct _CREATE_DISK;
|
|
struct _DRIVE_LAYOUT_INFORMATION_EX;
|
|
struct _SET_PARTITION_INFORMATION_EX;
|
|
|
|
typedef struct _BUS_HANDLER *PBUS_HANDLER;
|
|
typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
|
|
#if defined(_NTHAL_INCLUDED_)
|
|
typedef struct _KAFFINITY_EX *PKAFFINITY_EX;
|
|
#endif
|
|
typedef struct _PEB *PPEB;
|
|
|
|
#ifndef _NTIMAGE_
|
|
|
|
typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32;
|
|
typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
|
|
|
|
#ifdef _WIN64
|
|
typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
|
|
#else
|
|
typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
|
|
#endif
|
|
|
|
#endif /* _NTIMAGE_ */
|
|
|
|
$define (_NTDDK_)
|
|
$include (extypes.h)
|
|
$include (iotypes.h)
|
|
$include (haltypes.h)
|
|
$include (ketypes.h)
|
|
$include (kdtypes.h)
|
|
$include (mmtypes.h)
|
|
$include (pstypes.h)
|
|
$include (rtltypes.h)
|
|
$include (setypes.h)
|
|
|
|
#if defined(_M_IX86)
|
|
$include(x86/ke.h)
|
|
$include(x86/mm.h)
|
|
#elif defined(_M_AMD64)
|
|
$include(amd64/ke.h)
|
|
$include(amd64/mm.h)
|
|
#elif defined(_M_IA64)
|
|
$include(ia64/ke.h)
|
|
#elif defined(_M_PPC)
|
|
$include(ppc/ke.h)
|
|
#elif defined(_M_MIPS)
|
|
$include(mips/ke.h)
|
|
#elif defined(_M_ARM)
|
|
$include(arm/ke.h)
|
|
#else
|
|
#error Unknown Architecture
|
|
#endif
|
|
|
|
$include (exfuncs.h)
|
|
$include (halfuncs.h)
|
|
$include (iofuncs.h)
|
|
$include (kdfuncs.h)
|
|
$include (kefuncs.h)
|
|
$include (mmfuncs.h)
|
|
$include (psfuncs.h)
|
|
$include (rtlfuncs.h)
|
|
$include (sefuncs.h)
|
|
$include (zwfuncs.h)
|
|
|
|
|
|
/* UNSORTED */
|
|
|
|
#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
|
|
((ConditionMask) = VerSetConditionMask((ConditionMask), \
|
|
(TypeBitMask), (ComparisonType)))
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_WIN2K)
|
|
NTSYSAPI
|
|
ULONGLONG
|
|
NTAPI
|
|
VerSetConditionMask(
|
|
IN ULONGLONG ConditionMask,
|
|
IN ULONG TypeMask,
|
|
IN UCHAR Condition);
|
|
#endif
|
|
|
|
typedef struct _KEY_NAME_INFORMATION {
|
|
ULONG NameLength;
|
|
WCHAR Name[1];
|
|
} KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION;
|
|
|
|
typedef struct _KEY_CACHED_INFORMATION {
|
|
LARGE_INTEGER LastWriteTime;
|
|
ULONG TitleIndex;
|
|
ULONG SubKeys;
|
|
ULONG MaxNameLen;
|
|
ULONG Values;
|
|
ULONG MaxValueNameLen;
|
|
ULONG MaxValueDataLen;
|
|
ULONG NameLength;
|
|
} KEY_CACHED_INFORMATION, *PKEY_CACHED_INFORMATION;
|
|
|
|
typedef struct _KEY_VIRTUALIZATION_INFORMATION {
|
|
ULONG VirtualizationCandidate:1;
|
|
ULONG VirtualizationEnabled:1;
|
|
ULONG VirtualTarget:1;
|
|
ULONG VirtualStore:1;
|
|
ULONG VirtualSource:1;
|
|
ULONG Reserved:27;
|
|
} KEY_VIRTUALIZATION_INFORMATION, *PKEY_VIRTUALIZATION_INFORMATION;
|
|
|
|
#define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
|
|
#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
|
|
#define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
|
|
#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
|
|
#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
|
|
|
|
typedef struct _QUOTA_LIMITS {
|
|
SIZE_T PagedPoolLimit;
|
|
SIZE_T NonPagedPoolLimit;
|
|
SIZE_T MinimumWorkingSetSize;
|
|
SIZE_T MaximumWorkingSetSize;
|
|
SIZE_T PagefileLimit;
|
|
LARGE_INTEGER TimeLimit;
|
|
} QUOTA_LIMITS, *PQUOTA_LIMITS;
|
|
|
|
typedef union _RATE_QUOTA_LIMIT {
|
|
ULONG RateData;
|
|
struct {
|
|
ULONG RatePercent:7;
|
|
ULONG Reserved0:25;
|
|
} DUMMYSTRUCTNAME;
|
|
} RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
|
|
|
|
typedef struct _QUOTA_LIMITS_EX {
|
|
SIZE_T PagedPoolLimit;
|
|
SIZE_T NonPagedPoolLimit;
|
|
SIZE_T MinimumWorkingSetSize;
|
|
SIZE_T MaximumWorkingSetSize;
|
|
SIZE_T PagefileLimit;
|
|
LARGE_INTEGER TimeLimit;
|
|
SIZE_T WorkingSetLimit;
|
|
SIZE_T Reserved2;
|
|
SIZE_T Reserved3;
|
|
SIZE_T Reserved4;
|
|
ULONG Flags;
|
|
RATE_QUOTA_LIMIT CpuRateLimit;
|
|
} QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
|
|
|
|
typedef struct _IO_COUNTERS {
|
|
ULONGLONG ReadOperationCount;
|
|
ULONGLONG WriteOperationCount;
|
|
ULONGLONG OtherOperationCount;
|
|
ULONGLONG ReadTransferCount;
|
|
ULONGLONG WriteTransferCount;
|
|
ULONGLONG OtherTransferCount;
|
|
} IO_COUNTERS, *PIO_COUNTERS;
|
|
|
|
typedef struct _VM_COUNTERS {
|
|
SIZE_T PeakVirtualSize;
|
|
SIZE_T VirtualSize;
|
|
ULONG PageFaultCount;
|
|
SIZE_T PeakWorkingSetSize;
|
|
SIZE_T WorkingSetSize;
|
|
SIZE_T QuotaPeakPagedPoolUsage;
|
|
SIZE_T QuotaPagedPoolUsage;
|
|
SIZE_T QuotaPeakNonPagedPoolUsage;
|
|
SIZE_T QuotaNonPagedPoolUsage;
|
|
SIZE_T PagefileUsage;
|
|
SIZE_T PeakPagefileUsage;
|
|
} VM_COUNTERS, *PVM_COUNTERS;
|
|
|
|
typedef struct _VM_COUNTERS_EX {
|
|
SIZE_T PeakVirtualSize;
|
|
SIZE_T VirtualSize;
|
|
ULONG PageFaultCount;
|
|
SIZE_T PeakWorkingSetSize;
|
|
SIZE_T WorkingSetSize;
|
|
SIZE_T QuotaPeakPagedPoolUsage;
|
|
SIZE_T QuotaPagedPoolUsage;
|
|
SIZE_T QuotaPeakNonPagedPoolUsage;
|
|
SIZE_T QuotaNonPagedPoolUsage;
|
|
SIZE_T PagefileUsage;
|
|
SIZE_T PeakPagefileUsage;
|
|
SIZE_T PrivateUsage;
|
|
} VM_COUNTERS_EX, *PVM_COUNTERS_EX;
|
|
|
|
#define MAX_HW_COUNTERS 16
|
|
#define THREAD_PROFILING_FLAG_DISPATCH 0x00000001
|
|
|
|
typedef enum _HARDWARE_COUNTER_TYPE {
|
|
PMCCounter,
|
|
MaxHardwareCounterType
|
|
} HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE;
|
|
|
|
typedef struct _HARDWARE_COUNTER {
|
|
HARDWARE_COUNTER_TYPE Type;
|
|
ULONG Reserved;
|
|
ULONG64 Index;
|
|
} HARDWARE_COUNTER, *PHARDWARE_COUNTER;
|
|
|
|
typedef struct _POOLED_USAGE_AND_LIMITS {
|
|
SIZE_T PeakPagedPoolUsage;
|
|
SIZE_T PagedPoolUsage;
|
|
SIZE_T PagedPoolLimit;
|
|
SIZE_T PeakNonPagedPoolUsage;
|
|
SIZE_T NonPagedPoolUsage;
|
|
SIZE_T NonPagedPoolLimit;
|
|
SIZE_T PeakPagefileUsage;
|
|
SIZE_T PagefileUsage;
|
|
SIZE_T PagefileLimit;
|
|
} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
|
|
|
|
typedef struct _PROCESS_ACCESS_TOKEN {
|
|
HANDLE Token;
|
|
HANDLE Thread;
|
|
} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
|
|
|
|
#define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL
|
|
#define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1))
|
|
|
|
typedef struct _PROCESS_EXCEPTION_PORT {
|
|
IN HANDLE ExceptionPortHandle;
|
|
IN OUT ULONG StateFlags;
|
|
} PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT;
|
|
|
|
typedef struct _KERNEL_USER_TIMES {
|
|
LARGE_INTEGER CreateTime;
|
|
LARGE_INTEGER ExitTime;
|
|
LARGE_INTEGER KernelTime;
|
|
LARGE_INTEGER UserTime;
|
|
} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
|
|
|
|
/* NtXxx Functions */
|
|
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtOpenProcess(
|
|
OUT PHANDLE ProcessHandle,
|
|
IN ACCESS_MASK DesiredAccess,
|
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
|
IN PCLIENT_ID ClientId OPTIONAL);
|
|
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryInformationProcess(
|
|
IN HANDLE ProcessHandle,
|
|
IN PROCESSINFOCLASS ProcessInformationClass,
|
|
OUT PVOID ProcessInformation OPTIONAL,
|
|
IN ULONG ProcessInformationLength,
|
|
OUT PULONG ReturnLength OPTIONAL);
|
|
|
|
typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION {
|
|
SystemFirmwareTable_Enumerate,
|
|
SystemFirmwareTable_Get
|
|
} SYSTEM_FIRMWARE_TABLE_ACTION;
|
|
|
|
typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION {
|
|
ULONG ProviderSignature;
|
|
SYSTEM_FIRMWARE_TABLE_ACTION Action;
|
|
ULONG TableID;
|
|
ULONG TableBufferLength;
|
|
UCHAR TableBuffer[ANYSIZE_ARRAY];
|
|
} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
|
|
|
|
typedef NTSTATUS
|
|
(__cdecl *PFNFTH)(
|
|
IN OUT PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo);
|
|
|
|
typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER {
|
|
ULONG ProviderSignature;
|
|
BOOLEAN Register;
|
|
PFNFTH FirmwareTableHandler;
|
|
PVOID DriverObject;
|
|
} SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER;
|
|
|
|
typedef ULONG_PTR
|
|
(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
|
|
IN PVOID Context);
|
|
|
|
typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
|
|
PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
|
|
PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
|
|
} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
|
|
|
|
#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
|
|
#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
|
|
#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
|
|
#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
|
|
#define DRIVER_VERIFIER_IO_CHECKING 0x0010
|
|
|
|
#define NX_SUPPORT_POLICY_ALWAYSOFF 0
|
|
#define NX_SUPPORT_POLICY_ALWAYSON 1
|
|
#define NX_SUPPORT_POLICY_OPTIN 2
|
|
#define NX_SUPPORT_POLICY_OPTOUT 3
|
|
|
|
#define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0
|
|
#define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1
|
|
#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2
|
|
#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3
|
|
#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_SPARE_V 0x4
|
|
#define SHARED_GLOBAL_FLAGS_SPARE \
|
|
(1UL << SHARED_GLOBAL_FLAGS_SPARE_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5
|
|
#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6
|
|
#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V)
|
|
|
|
#define EX_INIT_BITS(Flags, Bit) \
|
|
*((Flags)) |= (Bit) // Safe to use before concurrently accessible
|
|
|
|
#define EX_TEST_SET_BIT(Flags, Bit) \
|
|
InterlockedBitTestAndSet ((PLONG)(Flags), (Bit))
|
|
|
|
#define EX_TEST_CLEAR_BIT(Flags, Bit) \
|
|
InterlockedBitTestAndReset ((PLONG)(Flags), (Bit))
|
|
|
|
#define CmResourceTypeMaximum 8
|
|
|
|
typedef struct _CM_PCCARD_DEVICE_DATA {
|
|
UCHAR Flags;
|
|
UCHAR ErrorCode;
|
|
USHORT Reserved;
|
|
ULONG BusData;
|
|
ULONG DeviceId;
|
|
ULONG LegacyBaseAddress;
|
|
UCHAR IRQMap[16];
|
|
} CM_PCCARD_DEVICE_DATA, *PCM_PCCARD_DEVICE_DATA;
|
|
|
|
#define PCCARD_MAP_ERROR 0x01
|
|
#define PCCARD_DEVICE_PCI 0x10
|
|
|
|
#define PCCARD_SCAN_DISABLED 0x01
|
|
#define PCCARD_MAP_ZERO 0x02
|
|
#define PCCARD_NO_TIMER 0x03
|
|
#define PCCARD_NO_PIC 0x04
|
|
#define PCCARD_NO_LEGACY_BASE 0x05
|
|
#define PCCARD_DUP_LEGACY_BASE 0x06
|
|
#define PCCARD_NO_CONTROLLERS 0x07
|
|
|
|
#define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2))
|
|
|
|
/* Filesystem runtime library routines */
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_WIN2K)
|
|
NTKERNELAPI
|
|
BOOLEAN
|
|
NTAPI
|
|
FsRtlIsTotalDeviceFailure(
|
|
IN NTSTATUS Status);
|
|
#endif
|
|
|
|
/* FIXME : These definitions below doesn't belong to NTDDK */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|