ReactOS  0.4.15-dev-499-g1f31905
pagefile.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for pagefile.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define PAIRS_PER_RUN   (1024)
 
#define MM_PAGEFILE_COMMIT_RATIO   (1)
 
#define MM_PAGEFILE_COMMIT_GRACE   (256)
 
#define FILE_FROM_ENTRY(i)   ((i) & 0x0f)
 
#define OFFSET_FROM_ENTRY(i)   ((i) >> 11)
 
#define ENTRY_FROM_FILE_OFFSET(i, j)   ((i) | ((j) << 11) | 0x400)
 

Functions

 C_ASSERT (FILE_FROM_ENTRY(0xffffffff)< MAX_PAGING_FILES)
 
VOID NTAPI MmBuildMdlFromPages (PMDL Mdl, PPFN_NUMBER Pages)
 
BOOLEAN NTAPI MmIsFileObjectAPagingFile (PFILE_OBJECT FileObject)
 
VOID NTAPI MmShowOutOfSpaceMessagePagingFile (VOID)
 
NTSTATUS NTAPI MmWriteToSwapPage (SWAPENTRY SwapEntry, PFN_NUMBER Page)
 
NTSTATUS NTAPI MmReadFromSwapPage (SWAPENTRY SwapEntry, PFN_NUMBER Page)
 
NTSTATUS NTAPI MiReadPageFile (_In_ PFN_NUMBER Page, _In_ ULONG PageFileIndex, _In_ ULONG_PTR PageFileOffset)
 
INIT_FUNCTION VOID NTAPI MmInitPagingFile (VOID)
 
VOID NTAPI MmFreeSwapPage (SWAPENTRY Entry)
 
SWAPENTRY NTAPI MmAllocSwapPage (VOID)
 
NTSTATUS NTAPI NtCreatePagingFile (IN PUNICODE_STRING FileName, IN PLARGE_INTEGER MinimumSize, IN PLARGE_INTEGER MaximumSize, IN ULONG Reserved)
 

Variables

PMMPAGING_FILE MmPagingFile [MAX_PAGING_FILES]
 
KGUARDED_MUTEX MmPageFileCreationLock
 
ULONG MmNumberOfPagingFiles
 
PFN_COUNT MiFreeSwapPages
 
PFN_COUNT MiUsedSwapPages
 
BOOLEAN MmZeroPageFile
 
static PFN_COUNT MiReservedSwapPages
 
static BOOLEAN MmSwapSpaceMessage = FALSE
 
static BOOLEAN MmSystemPageFileLocated = FALSE
 

Macro Definition Documentation

◆ ENTRY_FROM_FILE_OFFSET

#define ENTRY_FROM_FILE_OFFSET (   i,
  j 
)    ((i) | ((j) << 11) | 0x400)

Definition at line 85 of file pagefile.c.

◆ FILE_FROM_ENTRY

#define FILE_FROM_ENTRY (   i)    ((i) & 0x0f)

Definition at line 83 of file pagefile.c.

◆ MM_PAGEFILE_COMMIT_GRACE

#define MM_PAGEFILE_COMMIT_GRACE   (256)

Definition at line 78 of file pagefile.c.

◆ MM_PAGEFILE_COMMIT_RATIO

#define MM_PAGEFILE_COMMIT_RATIO   (1)

Definition at line 70 of file pagefile.c.

◆ NDEBUG

#define NDEBUG

Definition at line 32 of file pagefile.c.

◆ OFFSET_FROM_ENTRY

#define OFFSET_FROM_ENTRY (   i)    ((i) >> 11)

Definition at line 84 of file pagefile.c.

◆ PAIRS_PER_RUN

#define PAIRS_PER_RUN   (1024)

Definition at line 41 of file pagefile.c.

Function Documentation

◆ C_ASSERT()

C_ASSERT ( )

◆ MiReadPageFile()

NTSTATUS NTAPI MiReadPageFile ( _In_ PFN_NUMBER  Page,
_In_ ULONG  PageFileIndex,
_In_ ULONG_PTR  PageFileOffset 
)

Definition at line 201 of file pagefile.c.

205 {
206  LARGE_INTEGER file_offset;
209  KEVENT Event;
210  UCHAR MdlBase[sizeof(MDL) + sizeof(ULONG)];
211  PMDL Mdl = (PMDL)MdlBase;
212  PMMPAGING_FILE PagingFile;
213 
214  DPRINT("MiReadSwapFile\n");
215 
216  if (PageFileOffset == 0)
217  {
218  KeBugCheck(MEMORY_MANAGEMENT);
219  return(STATUS_UNSUCCESSFUL);
220  }
221 
222  ASSERT(PageFileIndex < MAX_PAGING_FILES);
223 
224  PagingFile = MmPagingFile[PageFileIndex];
225 
226  if (PagingFile->FileObject == NULL || PagingFile->FileObject->DeviceObject == NULL)
227  {
228  DPRINT1("Bad paging file %u\n", PageFileIndex);
229  KeBugCheck(MEMORY_MANAGEMENT);
230  }
231 
233  MmBuildMdlFromPages(Mdl, &Page);
234  Mdl->MdlFlags |= MDL_PAGES_LOCKED;
235 
236  file_offset.QuadPart = PageFileOffset * PAGE_SIZE;
237 
239  Status = IoPageRead(PagingFile->FileObject,
240  Mdl,
241  &file_offset,
242  &Event,
243  &Iosb);
244  if (Status == STATUS_PENDING)
245  {
247  Status = Iosb.Status;
248  }
249  if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
250  {
251  MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
252  }
253  return(Status);
254 }
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
VOID NTAPI MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
Definition: pagefile.c:98
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoPageRead(IN PFILE_OBJECT FileObject, IN PMDL Mdl, IN PLARGE_INTEGER Offset, IN PKEVENT Event, IN PIO_STATUS_BLOCK StatusBlock)
Definition: iofunc.c:1199
PFILE_OBJECT FileObject
Definition: mm.h:434
PVOID PMDL
Definition: usb.h:39
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1431
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:841
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:437
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define MAX_PAGING_FILES
Definition: mm.h:105
return Iosb
Definition: create.c:4402
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char UCHAR
Definition: xmlstorage.h:181
MDL
Definition: mmtypes.h:117
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:24
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:44
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
LONGLONG QuadPart
Definition: typedefs.h:113

Referenced by MiResolvePageFileFault(), and MmReadFromSwapPage().

◆ MmAllocSwapPage()

SWAPENTRY NTAPI MmAllocSwapPage ( VOID  )

Definition at line 308 of file pagefile.c.

309 {
310  ULONG i;
311  ULONG off;
313 
315 
316  if (MiFreeSwapPages == 0)
317  {
319  return(0);
320  }
321 
322  for (i = 0; i < MAX_PAGING_FILES; i++)
323  {
324  if (MmPagingFile[i] != NULL &&
325  MmPagingFile[i]->FreeSpace >= 1)
326  {
328  if (off == 0xFFFFFFFF)
329  {
330  KeBugCheck(MEMORY_MANAGEMENT);
332  return(STATUS_UNSUCCESSFUL);
333  }
334  MiUsedSwapPages++;
335  MiFreeSwapPages--;
337 
339  return(entry);
340  }
341  }
342 
344  KeBugCheck(MEMORY_MANAGEMENT);
345  return(0);
346 }
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
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
Definition: glfuncs.h:248
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1431
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI ULONG WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP, ULONG, ULONG)
#define MAX_PAGING_FILES
Definition: mm.h:105
#define ENTRY_FROM_FILE_OFFSET(i, j)
Definition: pagefile.c:85
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:47
uint32_t entry
Definition: isohybrid.c:63
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:44
ULONG_PTR SWAPENTRY
Definition: mm.h:47
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
unsigned int ULONG
Definition: retypes.h:1
PFN_COUNT MiUsedSwapPages
Definition: pagefile.c:56
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:53
off
Definition: i386-dis.c:3909

Referenced by MmPageOutSectionView(), and MmWritePageSectionView().

◆ MmBuildMdlFromPages()

VOID NTAPI MmBuildMdlFromPages ( PMDL  Mdl,
PPFN_NUMBER  Pages 
)

Definition at line 98 of file pagefile.c.

99 {
100  memcpy(Mdl + 1, Pages, sizeof(PFN_NUMBER) * (PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGE_SIZE));
101 
102  /* FIXME: this flag should be set by the caller perhaps? */
103  Mdl->MdlFlags |= MDL_IO_PAGE_READ;
104 }
#define MDL_IO_PAGE_READ
Definition: mmtypes.h:24
#define PAGE_ROUND_UP(x)
Definition: scsiport_int.h:13
ULONG PFN_NUMBER
Definition: ke.h:8
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define PAGE_SIZE
Definition: env_spec_w32.h:49

Referenced by MiReadFilePage(), MiReadPageFile(), and MmWriteToSwapPage().

◆ MmFreeSwapPage()

VOID NTAPI MmFreeSwapPage ( SWAPENTRY  Entry)

Definition at line 278 of file pagefile.c.

279 {
280  ULONG i;
281  ULONG_PTR off;
282  PMMPAGING_FILE PagingFile;
283 
285  off = OFFSET_FROM_ENTRY(Entry) - 1;
286 
288 
289  PagingFile = MmPagingFile[i];
290  if (PagingFile == NULL)
291  {
292  KeBugCheck(MEMORY_MANAGEMENT);
293  }
294 
295  RtlClearBit(PagingFile->Bitmap, off >> 5);
296 
297  PagingFile->FreeSpace++;
298  PagingFile->CurrentUsage--;
299 
300  MiFreeSwapPages++;
301  MiUsedSwapPages--;
302 
304 }
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
uint32_t ULONG_PTR
Definition: typedefs.h:64
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
Definition: glfuncs.h:248
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1431
smooth NULL
Definition: ftsmooth.c:416
PFN_NUMBER FreeSpace
Definition: mm.h:432
#define FILE_FROM_ENTRY(i)
Definition: pagefile.c:83
VOID NTAPI RtlClearBit(_In_ PRTL_BITMAP BitMapHeader, _In_ BITMAP_INDEX BitNumber)
Definition: bitmap.c:294
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:47
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:44
PFN_NUMBER CurrentUsage
Definition: mm.h:433
PRTL_BITMAP Bitmap
Definition: mm.h:436
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
unsigned int ULONG
Definition: retypes.h:1
#define OFFSET_FROM_ENTRY(i)
Definition: pagefile.c:84
PFN_COUNT MiUsedSwapPages
Definition: pagefile.c:56
base of all file and directory entries
Definition: entries.h:82
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:53
off
Definition: i386-dis.c:3909

Referenced by MiFreeSegmentPage(), MmFreeCacheSectionPage(), MmFreeSectionPage(), and MmpFreePageFileSegment().

◆ MmInitPagingFile()

INIT_FUNCTION VOID NTAPI MmInitPagingFile ( VOID  )

Definition at line 259 of file pagefile.c.

260 {
261  ULONG i;
262 
264 
265  MiFreeSwapPages = 0;
266  MiUsedSwapPages = 0;
268 
269  for (i = 0; i < MAX_PAGING_FILES; i++)
270  {
271  MmPagingFile[i] = NULL;
272  }
274 }
static PFN_COUNT MiReservedSwapPages
Definition: pagefile.c:63
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
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PAGING_FILES
Definition: mm.h:105
ULONG MmNumberOfPagingFiles
Definition: pagefile.c:50
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:47
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:44
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
unsigned int ULONG
Definition: retypes.h:1
PFN_COUNT MiUsedSwapPages
Definition: pagefile.c:56
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:53

Referenced by MmInitSystem().

◆ MmIsFileObjectAPagingFile()

BOOLEAN NTAPI MmIsFileObjectAPagingFile ( PFILE_OBJECT  FileObject)

Definition at line 109 of file pagefile.c.

110 {
111  ULONG i;
112 
113  /* Loop through all the paging files */
114  for (i = 0; i < MmNumberOfPagingFiles; i++)
115  {
116  /* Check if this is one of them */
117  if (MmPagingFile[i]->FileObject == FileObject) return TRUE;
118  }
119 
120  /* Nothing found */
121  return FALSE;
122 }
#define TRUE
Definition: types.h:120
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
Definition: glfuncs.h:248
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
ULONG MmNumberOfPagingFiles
Definition: pagefile.c:50
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:44
unsigned int ULONG
Definition: retypes.h:1

Referenced by FsRtlIsPagingFile(), and IoPageRead().

◆ MmReadFromSwapPage()

NTSTATUS NTAPI MmReadFromSwapPage ( SWAPENTRY  SwapEntry,
PFN_NUMBER  Page 
)

Definition at line 194 of file pagefile.c.

195 {
196  return MiReadPageFile(Page, FILE_FROM_ENTRY(SwapEntry), OFFSET_FROM_ENTRY(SwapEntry) - 1);
197 }
NTSTATUS NTAPI MiReadPageFile(_In_ PFN_NUMBER Page, _In_ ULONG PageFileIndex, _In_ ULONG_PTR PageFileOffset)
Definition: pagefile.c:201
#define FILE_FROM_ENTRY(i)
Definition: pagefile.c:83
#define OFFSET_FROM_ENTRY(i)
Definition: pagefile.c:84

Referenced by MiSwapInPage(), and MmNotPresentFaultSectionView().

◆ MmShowOutOfSpaceMessagePagingFile()

VOID NTAPI MmShowOutOfSpaceMessagePagingFile ( VOID  )

Definition at line 126 of file pagefile.c.

127 {
128  if (!MmSwapSpaceMessage)
129  {
130  DPRINT1("MM: Out of swap space.\n");
132  }
133 }
#define TRUE
Definition: types.h:120
static BOOLEAN MmSwapSpaceMessage
Definition: pagefile.c:90
#define DPRINT1
Definition: precomp.h:8

Referenced by MmPageOutSectionView().

◆ MmWriteToSwapPage()

NTSTATUS NTAPI MmWriteToSwapPage ( SWAPENTRY  SwapEntry,
PFN_NUMBER  Page 
)

Definition at line 137 of file pagefile.c.

138 {
139  ULONG i;
141  LARGE_INTEGER file_offset;
144  KEVENT Event;
145  UCHAR MdlBase[sizeof(MDL) + sizeof(ULONG)];
146  PMDL Mdl = (PMDL)MdlBase;
147 
148  DPRINT("MmWriteToSwapPage\n");
149 
150  if (SwapEntry == 0)
151  {
152  KeBugCheck(MEMORY_MANAGEMENT);
153  return(STATUS_UNSUCCESSFUL);
154  }
155 
156  i = FILE_FROM_ENTRY(SwapEntry);
157  offset = OFFSET_FROM_ENTRY(SwapEntry) - 1;
158 
159  if (MmPagingFile[i]->FileObject == NULL ||
160  MmPagingFile[i]->FileObject->DeviceObject == NULL)
161  {
162  DPRINT1("Bad paging file 0x%.8X\n", SwapEntry);
163  KeBugCheck(MEMORY_MANAGEMENT);
164  }
165 
167  MmBuildMdlFromPages(Mdl, &Page);
168  Mdl->MdlFlags |= MDL_PAGES_LOCKED;
169 
170  file_offset.QuadPart = offset * PAGE_SIZE;
171 
174  Mdl,
175  &file_offset,
176  &Event,
177  &Iosb);
178  if (Status == STATUS_PENDING)
179  {
181  Status = Iosb.Status;
182  }
183 
184  if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
185  {
186  MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
187  }
188  return(Status);
189 }
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
VOID NTAPI MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
Definition: pagefile.c:98
LONG NTSTATUS
Definition: precomp.h:26
GLintptr offset
Definition: glext.h:5920
PVOID PMDL
Definition: usb.h:39
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
uint32_t ULONG_PTR
Definition: typedefs.h:64
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
Definition: glfuncs.h:248
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1431
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:841
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:437
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
#define FILE_FROM_ENTRY(i)
Definition: pagefile.c:83
return Iosb
Definition: create.c:4402
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char UCHAR
Definition: xmlstorage.h:181
MDL
Definition: mmtypes.h:117
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:24
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:44
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoSynchronousPageWrite(IN PFILE_OBJECT FileObject, IN PMDL Mdl, IN PLARGE_INTEGER Offset, IN PKEVENT Event, IN PIO_STATUS_BLOCK StatusBlock)
Definition: iofunc.c:1144
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define OFFSET_FROM_ENTRY(i)
Definition: pagefile.c:84
LONGLONG QuadPart
Definition: typedefs.h:113

Referenced by MmPageOutSectionView(), MmUnsharePageEntrySectionSegment(), and MmWritePageSectionView().

◆ NtCreatePagingFile()

NTSTATUS NTAPI NtCreatePagingFile ( IN PUNICODE_STRING  FileName,
IN PLARGE_INTEGER  MinimumSize,
IN PLARGE_INTEGER  MaximumSize,
IN ULONG  Reserved 
)

Definition at line 349 of file pagefile.c.

353 {
359  PMMPAGING_FILE PagingFile;
360  SIZE_T AllocMapSize;
361  ULONG Count;
363  UNICODE_STRING PageFileName;
364  LARGE_INTEGER SafeMinimumSize, SafeMaximumSize, AllocationSize;
365  FILE_FS_DEVICE_INFORMATION FsDeviceInfo;
367  PACL Dacl;
368  PWSTR Buffer;
370 
371  PAGED_CODE();
372 
373  DPRINT("NtCreatePagingFile(FileName: '%wZ', MinimumSize: %I64d, MaximumSize: %I64d)\n",
374  FileName, MinimumSize->QuadPart, MaximumSize->QuadPart);
375 
377  {
379  }
380 
382 
383  if (PreviousMode != KernelMode)
384  {
386  {
388  }
389 
390  _SEH2_TRY
391  {
392  SafeMinimumSize = ProbeForReadLargeInteger(MinimumSize);
393  SafeMaximumSize = ProbeForReadLargeInteger(MaximumSize);
394  PageFileName = ProbeForReadUnicodeString(FileName);
395  }
397  {
398  /* Return the exception code */
400  }
401  _SEH2_END;
402  }
403  else
404  {
405  SafeMinimumSize = *MinimumSize;
406  SafeMaximumSize = *MaximumSize;
407  PageFileName = *FileName;
408  }
409 
410  /*
411  * Pagefiles can't be larger than 4GB and of course
412  * the minimum should be smaller than the maximum.
413  */
414  // TODO: Actually validate the lower bound of these sizes!
415  if (0 != SafeMinimumSize.u.HighPart)
416  {
418  }
419  if (0 != SafeMaximumSize.u.HighPart)
420  {
422  }
423  if (SafeMaximumSize.u.LowPart < SafeMinimumSize.u.LowPart)
424  {
426  }
427 
428  /* Validate the name length */
429  if ((PageFileName.Length == 0) ||
430  (PageFileName.Length > 128 * sizeof(WCHAR)))
431  {
433  }
434 
435  /* We don't care about any potential UNICODE_NULL */
436  PageFileName.MaximumLength = PageFileName.Length;
437  /* Allocate a buffer to keep the name copy */
439  if (Buffer == NULL)
440  {
442  }
443 
444  /* Copy the name */
445  if (PreviousMode != KernelMode)
446  {
447  _SEH2_TRY
448  {
449  ProbeForRead(PageFileName.Buffer, PageFileName.Length, sizeof(WCHAR));
450  RtlCopyMemory(Buffer, PageFileName.Buffer, PageFileName.Length);
451  }
453  {
455 
456  /* Return the exception code */
458  }
459  _SEH2_END;
460  }
461  else
462  {
463  RtlCopyMemory(Buffer, PageFileName.Buffer, PageFileName.Length);
464  }
465 
466  /* Replace caller's buffer with ours */
467  PageFileName.Buffer = Buffer;
468 
469  /* Create the security descriptor for the page file */
471  if (!NT_SUCCESS(Status))
472  {
474  return Status;
475  }
476 
477  /* Create the DACL: we will only allow two SIDs */
478  Count = sizeof(ACL) + (sizeof(ACE) + RtlLengthSid(SeLocalSystemSid)) +
479  (sizeof(ACE) + RtlLengthSid(SeAliasAdminsSid));
481  if (Dacl == NULL)
482  {
485  }
486 
487  /* Initialize the DACL */
489  if (!NT_SUCCESS(Status))
490  {
491  ExFreePoolWithTag(Dacl, 'lcaD');
493  return Status;
494  }
495 
496  /* Grant full access to admins */
498  if (!NT_SUCCESS(Status))
499  {
500  ExFreePoolWithTag(Dacl, 'lcaD');
502  return Status;
503  }
504 
505  /* Grant full access to SYSTEM */
507  if (!NT_SUCCESS(Status))
508  {
509  ExFreePoolWithTag(Dacl, 'lcaD');
511  return Status;
512  }
513 
514  /* Attach the DACL to the security descriptor */
516  if (!NT_SUCCESS(Status))
517  {
518  ExFreePoolWithTag(Dacl, 'lcaD');
520  return Status;
521  }
522 
524  &PageFileName,
526  NULL,
528 
529  /* Make sure we can at least store a complete page:
530  * If we have 2048 BytesPerAllocationUnit (FAT16 < 128MB) there is
531  * a problem if the paging file is fragmented. Suppose the first cluster
532  * of the paging file is cluster 3042 but cluster 3043 is NOT part of the
533  * paging file but of another file. We can't write a complete page (4096
534  * bytes) to the physical location of cluster 3042 then. */
535  AllocationSize.QuadPart = SafeMinimumSize.QuadPart + PAGE_SIZE;
536 
537  /* First, attempt to replace the page file, if existing */
541  &IoStatus,
547  NULL,
548  0,
550  NULL,
552  /* If we failed, relax a bit constraints, someone may be already holding the
553  * the file, so share write, don't attempt to replace and don't delete on close
554  * (basically, don't do anything conflicting)
555  * This can happen if the caller attempts to extend a page file.
556  */
557  if (!NT_SUCCESS(Status))
558  {
559  ULONG i;
560 
564  &IoStatus,
568  FILE_OPEN,
570  NULL,
571  0,
573  NULL,
575  if (!NT_SUCCESS(Status))
576  {
577  ExFreePoolWithTag(Dacl, 'lcaD');
579  return Status;
580  }
581 
582  /* We opened it! Check we are that "someone" ;-)
583  * First, get the opened file object.
584  */
588  KernelMode,
589  (PVOID*)&FileObject,
590  NULL);
591  if (!NT_SUCCESS(Status))
592  {
594  ExFreePoolWithTag(Dacl, 'lcaD');
596  return Status;
597  }
598 
599  /* Find if it matches a previous page file */
600  PagingFile = NULL;
601 
602  /* FIXME: should be calling unsafe instead,
603  * we should already be in a guarded region
604  */
606  if (MmNumberOfPagingFiles > 0)
607  {
608  i = 0;
609 
610  while (MmPagingFile[i]->FileObject->SectionObjectPointer != FileObject->SectionObjectPointer)
611  {
612  ++i;
613  if (i >= MmNumberOfPagingFiles)
614  {
615  break;
616  }
617  }
618 
619  /* This is the matching page file */
620  PagingFile = MmPagingFile[i];
621  }
622 
623  /* If we didn't find the page file, fail */
624  if (PagingFile == NULL)
625  {
629  ExFreePoolWithTag(Dacl, 'lcaD');
631  return STATUS_NOT_FOUND;
632  }
633 
634  /* Don't allow page file shrinking */
635  if (PagingFile->MinimumSize > (SafeMinimumSize.QuadPart >> PAGE_SHIFT))
636  {
640  ExFreePoolWithTag(Dacl, 'lcaD');
643  }
644 
645  if ((SafeMaximumSize.QuadPart >> PAGE_SHIFT) < PagingFile->MaximumSize)
646  {
650  ExFreePoolWithTag(Dacl, 'lcaD');
653  }
654 
655  /* FIXME: implement parameters checking and page file extension */
657 
661  ExFreePoolWithTag(Dacl, 'lcaD');
663  return STATUS_NOT_IMPLEMENTED;
664  }
665 
666  if (!NT_SUCCESS(Status))
667  {
668  DPRINT1("Failed creating page file: %lx\n", Status);
669  ExFreePoolWithTag(Dacl, 'lcaD');
671  return Status;
672  }
673 
674  /* Set the security descriptor */
675  if (NT_SUCCESS(IoStatus.Status))
676  {
678  if (!NT_SUCCESS(Status))
679  {
680  ExFreePoolWithTag(Dacl, 'lcaD');
683  return Status;
684  }
685  }
686 
687  /* DACL is no longer needed, free it */
688  ExFreePoolWithTag(Dacl, 'lcaD');
689 
690  /* FIXME: To enable once page file managment is moved to ARM3 */
691 #if 0
692  /* Check we won't overflow commit limit with the page file */
694  {
698  }
699 #endif
700 
701  /* Set its end of file to minimal size */
702  Status = ZwSetInformationFile(FileHandle,
703  &IoStatus,
704  &SafeMinimumSize,
705  sizeof(LARGE_INTEGER),
707  if (!NT_SUCCESS(Status) || !NT_SUCCESS(IoStatus.Status))
708  {
711  return Status;
712  }
713 
717  KernelMode,
718  (PVOID*)&FileObject,
719  NULL);
720  if (!NT_SUCCESS(Status))
721  {
724  return Status;
725  }
726 
727  /* Only allow page file on a few device types */
731  {
735  return Status;
736  }
737 
738  /* Deny page file creation on a floppy disk */
739  FsDeviceInfo.Characteristics = 0;
740  IoQueryVolumeInformation(FileObject, FileFsDeviceInformation, sizeof(FsDeviceInfo), &FsDeviceInfo, &Count);
742  {
746  return STATUS_FLOPPY_VOLUME;
747  }
748 
749  PagingFile = ExAllocatePoolWithTag(NonPagedPool, sizeof(*PagingFile), TAG_MM);
750  if (PagingFile == NULL)
751  {
756  }
757 
758  RtlZeroMemory(PagingFile, sizeof(*PagingFile));
759 
760  PagingFile->FileHandle = FileHandle;
761  PagingFile->FileObject = FileObject;
762  PagingFile->MaximumSize = (SafeMaximumSize.QuadPart >> PAGE_SHIFT);
763  PagingFile->Size = (SafeMinimumSize.QuadPart >> PAGE_SHIFT);
764  PagingFile->MinimumSize = (SafeMinimumSize.QuadPart >> PAGE_SHIFT);
765  /* First page is never used: it's the header
766  * TODO: write it
767  */
768  PagingFile->FreeSpace = (ULONG)(SafeMinimumSize.QuadPart / PAGE_SIZE) - 1;
769  PagingFile->CurrentUsage = 0;
770  PagingFile->PageFileName = PageFileName;
771  ASSERT(PagingFile->Size == PagingFile->FreeSpace + PagingFile->CurrentUsage + 1);
772 
773  AllocMapSize = sizeof(RTL_BITMAP) + (((PagingFile->MaximumSize + 31) / 32) * sizeof(ULONG));
775  AllocMapSize,
776  TAG_MM);
777  if (PagingFile->Bitmap == NULL)
778  {
779  ExFreePoolWithTag(PagingFile, TAG_MM);
784  }
785 
786  RtlInitializeBitMap(PagingFile->Bitmap,
787  (PULONG)(PagingFile->Bitmap + 1),
788  (ULONG)(PagingFile->MaximumSize));
789  RtlClearAllBits(PagingFile->Bitmap);
790 
791  /* FIXME: should be calling unsafe instead,
792  * we should already be in a guarded region
793  */
796  MmPagingFile[MmNumberOfPagingFiles] = PagingFile;
798  MiFreeSwapPages = MiFreeSwapPages + PagingFile->FreeSpace;
800 
802 
804  {
806  }
807 
808  return STATUS_SUCCESS;
809 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define FILE_NO_COMPRESSION
Definition: from_kernel.h:43
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _RTL_BITMAP RTL_BITMAP
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
USHORT MaximumLength
Definition: env_spec_w32.h:370
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2659
#define SL_OPEN_PAGING_FILE
Definition: iotypes.h:1776
_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
Definition: wsk.h:182
#define FILE_DEVICE_DFS_FILE_SYSTEM
Definition: winioctl.h:158
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
uint16_t * PWSTR
Definition: typedefs.h:55
DeviceType
Definition: mmdrv.h:41
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
LONG NTSTATUS
Definition: precomp.h:26
PFN_NUMBER Size
Definition: mm.h:429
SIZE_T MmTotalCommitLimitMaximum
Definition: mminit.c:360
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1173
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:524
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3066
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PFILE_OBJECT FileObject
Definition: mm.h:434
NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Revision)
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
#define STATUS_INVALID_PARAMETER_MIX
Definition: ntstatus.h:271
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
NTSYSAPI NTSTATUS WINAPI RtlAddAccessAllowedAce(PACL, DWORD, DWORD, PSID)
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define FILE_SHARE_READ
Definition: compat.h:125
_SEH2_TRY
Definition: create.c:4226
BOOLEAN NTAPI IoInitializeCrashDump(IN HANDLE PageFileHandle)
Definition: iomgr.c:656
#define STATUS_TOO_MANY_PAGING_FILES
Definition: ntstatus.h:373
NTSYSAPI NTSTATUS NTAPI RtlCreateAcl(PACL Acl, ULONG AclSize, ULONG AclRevision)
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define FILE_DEVICE_DFS_VOLUME
Definition: winioctl.h:159
HANDLE FileHandle
Definition: stats.c:38
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
Definition: glfuncs.h:248
NTSTATUS NTAPI IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, IN FS_INFORMATION_CLASS FsInformationClass, IN ULONG Length, OUT PVOID FsInformation, OUT PULONG ReturnedLength)
Definition: iofunc.c:1292
#define FILE_NO_INTERMEDIATE_BUFFERING
Definition: from_kernel.h:28
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)
Definition: obref.c:496
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:463
#define TAG_MM
Definition: tag.h:136
struct _LARGE_INTEGER::@2241 u
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:511
#define FILE_READ_DATA
Definition: nt_native.h:628
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static BOOLEAN MmSwapSpaceMessage
Definition: pagefile.c:90
#define DO_SYSTEM_BOOT_PARTITION
Definition: env_spec_w32.h:400
struct _ACL ACL
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
Definition: sid.c:150
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
PFN_NUMBER MaximumSize
Definition: mm.h:430
PFN_NUMBER MinimumSize
Definition: mm.h:431
#define FILE_WRITE_DATA
Definition: nt_native.h:631
UNICODE_STRING PageFileName
Definition: mm.h:435
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:113
#define FILE_DELETE_ON_CLOSE
Definition: constants.h:494
#define STATUS_NOT_FOUND
Definition: shellext.h:72
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
const LUID SeCreatePagefilePrivilege
Definition: priv.c:36
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
PFN_NUMBER FreeSpace
Definition: mm.h:432
#define MAX_PAGING_FILES
Definition: mm.h:105
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define WRITE_DAC
Definition: nt_native.h:59
#define ProbeForReadLargeInteger(Ptr)
Definition: probe.h:75
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
* PFILE_OBJECT
Definition: iotypes.h:1957
ULONG MmNumberOfPagingFiles
Definition: pagefile.c:50
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:47
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1552
PSID SeAliasAdminsSid
Definition: sid.c:47
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define SYNCHRONIZE
Definition: nt_native.h:61
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
HANDLE FileHandle
Definition: mm.h:437
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:44
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:319
ULONG_PTR SIZE_T
Definition: typedefs.h:79
PFN_NUMBER CurrentUsage
Definition: mm.h:433
struct _FileName FileName
Definition: fatprocs.h:893
PRTL_BITMAP Bitmap
Definition: mm.h:436
_SEH2_END
Definition: create.c:4400
#define DEVICE_TYPE
Definition: guid.c:10
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
unsigned int * PULONG
Definition: retypes.h:1
#define FILE_DEVICE_NETWORK_FILE_SYSTEM
Definition: winioctl.h:125
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP)
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
Definition: mmfuncs.h:360
#define ProbeForReadUnicodeString(Ptr)
Definition: probe.h:77
#define DPRINT1
Definition: precomp.h:8
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)
Definition: file.c:3009
#define ACL_REVISION
Definition: setypes.h:39
PSID SeLocalSystemSid
Definition: sid.c:44
unsigned int ULONG
Definition: retypes.h:1
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
#define UNIMPLEMENTED
Definition: debug.h:115
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:3014
Definition: rtltypes.h:990
#define DACL_SECURITY_INFORMATION
Definition: setypes.h:125
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:53
LONGLONG QuadPart
Definition: typedefs.h:113
#define STATUS_FLOPPY_VOLUME
Definition: ntstatus.h:578
#define PAGED_CODE()
static BOOLEAN MmSystemPageFileLocated
Definition: pagefile.c:92

Referenced by SmpCreatePagingFile().

Variable Documentation

◆ MiFreeSwapPages

PFN_COUNT MiFreeSwapPages

◆ MiReservedSwapPages

PFN_COUNT MiReservedSwapPages
static

Definition at line 63 of file pagefile.c.

Referenced by MmInitPagingFile().

◆ MiUsedSwapPages

PFN_COUNT MiUsedSwapPages

Definition at line 56 of file pagefile.c.

Referenced by MmAllocSwapPage(), MmFreeSwapPage(), MmInitPagingFile(), and QSI_DEF().

◆ MmNumberOfPagingFiles

ULONG MmNumberOfPagingFiles

◆ MmPageFileCreationLock

KGUARDED_MUTEX MmPageFileCreationLock

Definition at line 47 of file pagefile.c.

Referenced by MmAllocSwapPage(), MmFreeSwapPage(), MmInitPagingFile(), and NtCreatePagingFile().

◆ MmPagingFile

◆ MmSwapSpaceMessage

BOOLEAN MmSwapSpaceMessage = FALSE
static

Definition at line 90 of file pagefile.c.

Referenced by MmShowOutOfSpaceMessagePagingFile(), and NtCreatePagingFile().

◆ MmSystemPageFileLocated

BOOLEAN MmSystemPageFileLocated = FALSE
static

Definition at line 92 of file pagefile.c.

Referenced by NtCreatePagingFile().

◆ MmZeroPageFile

BOOLEAN MmZeroPageFile

Definition at line 58 of file pagefile.c.