18#define MINIMUM_PAGEFILE_SIZE (256ULL * PAGE_SIZE)
21#if defined(_M_IX86) && !defined(_X86PAE_)
23 #define MAXIMUM_PAGEFILE_SIZE ((1ULL * 1024 * 1024 - 1) * PAGE_SIZE)
26#elif (defined(_M_IX86) && defined(_X86PAE_)) || defined (_M_AMD64) || defined(_M_ARM64)
28 #if (NTDDI_VERSION >= NTDDI_WIN10)
29 #define MAXIMUM_PAGEFILE_SIZE ((4ULL * 1024 * 1024 * 1024 - 2) * PAGE_SIZE)
32 #define MAXIMUM_PAGEFILE_SIZE ((4ULL * 1024 * 1024 * 1024 - 1) * PAGE_SIZE)
35#elif defined (_M_IA64)
37 #define MAXIMUM_PAGEFILE_SIZE ((8ULL * 1024 * 1024 * 1024 - 1) * PAGE_SIZE)
41 #if (NTDDI_VERSION >= NTDDI_WIN10)
42 #define MAXIMUM_PAGEFILE_SIZE ((512ULL * 1024 - 2) * PAGE_SIZE)
44 #elif (NTDDI_VERSION >= NTDDI_WINBLUE)
45 #define MAXIMUM_PAGEFILE_SIZE ((512ULL * 1024 - 1) * PAGE_SIZE)
49 #define MAXIMUM_PAGEFILE_SIZE ((1ULL * 1024 * 1024 - 1) * PAGE_SIZE)
53#error Unknown architecture
83#define MM_PAGEFILE_COMMIT_RATIO (1)
91#define MM_PAGEFILE_COMMIT_GRACE (256)
96#define FILE_FROM_ENTRY(i) ((i) & 0x0f)
97#define OFFSET_FROM_ENTRY(i) ((i) >> 11)
98#define ENTRY_FROM_FILE_OFFSET(i, j) ((i) | ((j) << 11) | 0x400)
140 DPRINT1(
"MM: Out of swap space.\n");
158 DPRINT(
"MmWriteToSwapPage\n");
172 DPRINT1(
"Bad paging file 0x%.8X\n", SwapEntry);
224 DPRINT(
"MiReadSwapFile\n");
226 if (PageFileOffset == 0)
241 DPRINT1(
"Bad paging file %u\n", PageFileIndex);
303 if (PagingFile ==
NULL)
342 if (off == 0xFFFFFFFF)
391 DPRINT(
"NtCreatePagingFile(FileName: '%wZ', MinimumSize: %I64d, MaximumSize: %I64d)\n",
423 SafeMinimumSize = *MinimumSize;
444 if ((PageFileName.
Length == 0) ||
610 if (PagingFile ==
NULL)
726 sizeof(FsDeviceInfo), &FsDeviceInfo, &
Count);
756 if (PagingFile ==
NULL)
SIZE_T MmTotalCommitLimitMaximum
#define STATUS_PRIVILEGE_NOT_HELD
#define FILE_DELETE_ON_CLOSE
#define MAXIMUM_PAGEFILE_SIZE
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define STATUS_NOT_IMPLEMENTED
#define RtlInitializeBitMap
#define RtlFindClearBitsAndSet
#define NT_SUCCESS(StatCode)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define MAXIMUM_FILENAME_LENGTH
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define DO_SYSTEM_BOOT_PARTITION
#define ExGetPreviousMode
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
#define BooleanFlagOn(F, SF)
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
struct _FileName FileName
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
@ FileEndOfFileInformation
#define FILE_NO_COMPRESSION
@ FileFsDeviceInformation
#define FILE_NO_INTERMEDIATE_BUFFERING
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
#define EXCEPTION_EXECUTE_HANDLER
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
NTSYSAPI NTSTATUS WINAPI RtlAddAccessAllowedAce(PACL, DWORD, DWORD, PSID)
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
NTSTATUS NTAPI IoPageRead(IN PFILE_OBJECT FileObject, IN PMDL Mdl, IN PLARGE_INTEGER Offset, IN PKEVENT Event, IN PIO_STATUS_BLOCK StatusBlock)
NTSTATUS NTAPI IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, IN FS_INFORMATION_CLASS FsInformationClass, IN ULONG Length, OUT PVOID FsInformation, OUT PULONG ReturnedLength)
NTSTATUS NTAPI IoSynchronousPageWrite(IN PFILE_OBJECT FileObject, IN PMDL Mdl, IN PLARGE_INTEGER Offset, IN PKEVENT Event, IN PIO_STATUS_BLOCK StatusBlock)
POBJECT_TYPE IoFileObjectType
#define memcpy(s1, s2, n)
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
#define ExFreePoolWithTag(_P, _T)
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
#define InitializeObjectAttributes(p, n, a, r, s)
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
NTSYSAPI NTSTATUS NTAPI RtlCreateAcl(PACL Acl, ULONG AclSize, ULONG AclRevision)
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Revision)
#define FILE_ATTRIBUTE_HIDDEN
#define FILE_ATTRIBUTE_SYSTEM
#define FILE_FLOPPY_DISKETTE
BOOLEAN NTAPI IoInitializeCrashDump(IN HANDLE PageFileHandle)
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
FORCEINLINE VOID UpdateTotalCommittedPages(LONG Delta)
const LUID SeCreatePagefilePrivilege
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
NTSTATUS NTAPI IoCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength, IN CREATE_FILE_TYPE CreateFileType, IN PVOID ExtraCreateParameters OPTIONAL, IN ULONG Options)
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
KGUARDED_MUTEX MmPageFileCreationLock
NTSTATUS NTAPI NtCreatePagingFile(_In_ PUNICODE_STRING FileName, _In_ PLARGE_INTEGER MinimumSize, _In_ PLARGE_INTEGER MaximumSize, _In_ ULONG Reserved)
NTSTATUS NTAPI MiReadPageFile(_In_ PFN_NUMBER Page, _In_ ULONG PageFileIndex, _In_ ULONG_PTR PageFileOffset)
static BOOLEAN MmSwapSpaceMessage
VOID NTAPI MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
PFN_COUNT MiFreeSwapPages
BOOLEAN NTAPI MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject)
SWAPENTRY NTAPI MmAllocSwapPage(VOID)
static BOOLEAN MmSystemPageFileLocated
NTSTATUS NTAPI MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
NTSTATUS NTAPI MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
#define FILE_FROM_ENTRY(i)
VOID NTAPI MmFreeSwapPage(SWAPENTRY Entry)
#define MINIMUM_PAGEFILE_SIZE
#define ENTRY_FROM_FILE_OFFSET(i, j)
#define OFFSET_FROM_ENTRY(i)
ULONG MmNumberOfPagingFiles
PFN_COUNT MiUsedSwapPages
C_ASSERT(FILE_FROM_ENTRY(0xffffffff)< MAX_PAGING_FILES)
static PFN_COUNT MiReservedSwapPages
VOID NTAPI MmInitPagingFile(VOID)
VOID NTAPI MmShowOutOfSpaceMessagePagingFile(VOID)
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
#define STATUS_FLOPPY_VOLUME
#define STATUS_INVALID_PARAMETER_2
#define STATUS_INVALID_PARAMETER_3
#define STATUS_TOO_MANY_PAGING_FILES
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
#define FILE_DEVICE_DISK_FILE_SYSTEM
#define FILE_DEVICE_NETWORK_FILE_SYSTEM
#define FILE_DEVICE_DFS_FILE_SYSTEM
#define FILE_DEVICE_DFS_VOLUME
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define _SEH2_YIELD(__stmt)
#define ProbeForReadUnicodeString(Ptr)
#define ProbeForReadLargeInteger(Ptr)
base of all file and directory entries
UNICODE_STRING PageFileName
#define RtlCopyMemory(Destination, Source, Length)
#define STATUS_UNSUCCESSFUL
#define STATUS_OBJECT_NAME_INVALID
#define STATUS_INSUFFICIENT_RESOURCES
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_Reserved_ PVOID Reserved
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
#define IO_NO_PARAMETER_CHECKING
#define IO_OPEN_PAGING_FILE
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
#define MDL_MAPPED_TO_SYSTEM_VA
#define ObDereferenceObject
_In_ KPROCESSOR_MODE PreviousMode
#define DACL_SECURITY_INFORMATION
#define SECURITY_DESCRIPTOR_REVISION