ReactOS  0.4.15-dev-1384-g878186b
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)
 
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 81 of file pagefile.c.

◆ FILE_FROM_ENTRY

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

Definition at line 79 of file pagefile.c.

◆ MM_PAGEFILE_COMMIT_GRACE

#define MM_PAGEFILE_COMMIT_GRACE   (256)

Definition at line 74 of file pagefile.c.

◆ MM_PAGEFILE_COMMIT_RATIO

#define MM_PAGEFILE_COMMIT_RATIO   (1)

Definition at line 66 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 80 of file pagefile.c.

◆ PAIRS_PER_RUN

#define PAIRS_PER_RUN   (1024)

Definition at line 37 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 197 of file pagefile.c.

201 {
202  LARGE_INTEGER file_offset;
205  KEVENT Event;
206  UCHAR MdlBase[sizeof(MDL) + sizeof(ULONG)];
207  PMDL Mdl = (PMDL)MdlBase;
208  PMMPAGING_FILE PagingFile;
209 
210  DPRINT("MiReadSwapFile\n");
211 
212  if (PageFileOffset == 0)
213  {
214  KeBugCheck(MEMORY_MANAGEMENT);
215  return(STATUS_UNSUCCESSFUL);
216  }
217 
218  ASSERT(PageFileIndex < MAX_PAGING_FILES);
219 
220  PagingFile = MmPagingFile[PageFileIndex];
221 
222  if (PagingFile->FileObject == NULL || PagingFile->FileObject->DeviceObject == NULL)
223  {
224  DPRINT1("Bad paging file %u\n", PageFileIndex);
225  KeBugCheck(MEMORY_MANAGEMENT);
226  }
227 
229  MmBuildMdlFromPages(Mdl, &Page);
230  Mdl->MdlFlags |= MDL_PAGES_LOCKED;
231 
232  file_offset.QuadPart = PageFileOffset * PAGE_SIZE;
233 
235  Status = IoPageRead(PagingFile->FileObject,
236  Mdl,
237  &file_offset,
238  &Event,
239  &Iosb);
240  if (Status == STATUS_PENDING)
241  {
243  Status = Iosb.Status;
244  }
245  if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
246  {
247  MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
248  }
249  return(Status);
250 }
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
VOID NTAPI MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
Definition: pagefile.c:94
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:440
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
#define FALSE
Definition: types.h:117
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:841
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:450
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:45
#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
#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
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:40
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NULL
Definition: types.h:112
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by MiResolvePageFileFault(), and MmReadFromSwapPage().

◆ MmAllocSwapPage()

SWAPENTRY NTAPI MmAllocSwapPage ( VOID  )

Definition at line 304 of file pagefile.c.

305 {
306  ULONG i;
307  ULONG off;
309 
311 
312  if (MiFreeSwapPages == 0)
313  {
315  return(0);
316  }
317 
318  for (i = 0; i < MAX_PAGING_FILES; i++)
319  {
320  if (MmPagingFile[i] != NULL &&
321  MmPagingFile[i]->FreeSpace >= 1)
322  {
324  if (off == 0xFFFFFFFF)
325  {
326  KeBugCheck(MEMORY_MANAGEMENT);
328  return(STATUS_UNSUCCESSFUL);
329  }
330  MiUsedSwapPages++;
331  MiFreeSwapPages--;
333 
334  entry = ENTRY_FROM_FILE_OFFSET(i, off + 1);
335  return(entry);
336  }
337  }
338 
340  KeBugCheck(MEMORY_MANAGEMENT);
341  return(0);
342 }
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
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:81
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:43
uint32_t entry
Definition: isohybrid.c:63
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:40
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
ULONG_PTR SWAPENTRY
Definition: mm.h:47
#define NULL
Definition: types.h:112
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:52
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:49

Referenced by MmPageOutSectionView(), and MmWritePageSectionView().

◆ MmBuildMdlFromPages()

VOID NTAPI MmBuildMdlFromPages ( PMDL  Mdl,
PPFN_NUMBER  Pages 
)

Definition at line 94 of file pagefile.c.

95 {
96  memcpy(Mdl + 1, Pages, sizeof(PFN_NUMBER) * (PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGE_SIZE));
97 
98  /* FIXME: this flag should be set by the caller perhaps? */
99  Mdl->MdlFlags |= MDL_IO_PAGE_READ;
100 }
#define MDL_IO_PAGE_READ
Definition: mmtypes.h:24
ULONG PFN_NUMBER
Definition: ke.h:9
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl

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

◆ MmFreeSwapPage()

VOID NTAPI MmFreeSwapPage ( SWAPENTRY  Entry)

Definition at line 274 of file pagefile.c.

275 {
276  ULONG i;
277  ULONG_PTR off;
278  PMMPAGING_FILE PagingFile;
279 
281  off = OFFSET_FROM_ENTRY(Entry) - 1;
282 
284 
285  PagingFile = MmPagingFile[i];
286  if (PagingFile == NULL)
287  {
288  KeBugCheck(MEMORY_MANAGEMENT);
289  }
290 
291  RtlClearBit(PagingFile->Bitmap, off >> 5);
292 
293  PagingFile->FreeSpace++;
294  PagingFile->CurrentUsage--;
295 
296  MiFreeSwapPages++;
297  MiUsedSwapPages--;
298 
300 }
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
uint32_t ULONG_PTR
Definition: typedefs.h:65
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
PFN_NUMBER FreeSpace
Definition: mm.h:438
#define FILE_FROM_ENTRY(i)
Definition: pagefile.c:79
VOID NTAPI RtlClearBit(_In_ PRTL_BITMAP BitMapHeader, _In_ BITMAP_INDEX BitNumber)
Definition: bitmap.c:294
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:43
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:40
PFN_NUMBER CurrentUsage
Definition: mm.h:439
PRTL_BITMAP Bitmap
Definition: mm.h:442
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
#define NULL
Definition: types.h:112
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:80
PFN_COUNT MiUsedSwapPages
Definition: pagefile.c:52
base of all file and directory entries
Definition: entries.h:82
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:49

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

◆ MmInitPagingFile()

VOID NTAPI MmInitPagingFile ( VOID  )

Definition at line 255 of file pagefile.c.

256 {
257  ULONG i;
258 
260 
261  MiFreeSwapPages = 0;
262  MiUsedSwapPages = 0;
264 
265  for (i = 0; i < MAX_PAGING_FILES; i++)
266  {
267  MmPagingFile[i] = NULL;
268  }
270 }
static PFN_COUNT MiReservedSwapPages
Definition: pagefile.c:59
#define MAX_PAGING_FILES
Definition: mm.h:105
ULONG MmNumberOfPagingFiles
Definition: pagefile.c:46
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:43
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:40
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
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
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
PFN_COUNT MiUsedSwapPages
Definition: pagefile.c:52
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:49

Referenced by MmInitSystem().

◆ MmIsFileObjectAPagingFile()

BOOLEAN NTAPI MmIsFileObjectAPagingFile ( PFILE_OBJECT  FileObject)

Definition at line 105 of file pagefile.c.

106 {
107  ULONG i;
108 
109  /* Loop through all the paging files */
110  for (i = 0; i < MmNumberOfPagingFiles; i++)
111  {
112  /* Check if this is one of them */
113  if (MmPagingFile[i]->FileObject == FileObject) return TRUE;
114  }
115 
116  /* Nothing found */
117  return FALSE;
118 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
ULONG MmNumberOfPagingFiles
Definition: pagefile.c:46
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:40
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
unsigned int ULONG
Definition: retypes.h:1

Referenced by FsRtlIsPagingFile(), and IoPageRead().

◆ MmReadFromSwapPage()

NTSTATUS NTAPI MmReadFromSwapPage ( SWAPENTRY  SwapEntry,
PFN_NUMBER  Page 
)

Definition at line 190 of file pagefile.c.

191 {
192  return MiReadPageFile(Page, FILE_FROM_ENTRY(SwapEntry), OFFSET_FROM_ENTRY(SwapEntry) - 1);
193 }
NTSTATUS NTAPI MiReadPageFile(_In_ PFN_NUMBER Page, _In_ ULONG PageFileIndex, _In_ ULONG_PTR PageFileOffset)
Definition: pagefile.c:197
#define FILE_FROM_ENTRY(i)
Definition: pagefile.c:79
#define OFFSET_FROM_ENTRY(i)
Definition: pagefile.c:80

Referenced by MiSwapInPage(), and MmNotPresentFaultSectionView().

◆ MmShowOutOfSpaceMessagePagingFile()

VOID NTAPI MmShowOutOfSpaceMessagePagingFile ( VOID  )

Definition at line 122 of file pagefile.c.

123 {
124  if (!MmSwapSpaceMessage)
125  {
126  DPRINT1("MM: Out of swap space.\n");
128  }
129 }
#define TRUE
Definition: types.h:120
static BOOLEAN MmSwapSpaceMessage
Definition: pagefile.c:86
#define DPRINT1
Definition: precomp.h:8

Referenced by MmPageOutSectionView().

◆ MmWriteToSwapPage()

NTSTATUS NTAPI MmWriteToSwapPage ( SWAPENTRY  SwapEntry,
PFN_NUMBER  Page 
)

Definition at line 133 of file pagefile.c.

134 {
135  ULONG i;
137  LARGE_INTEGER file_offset;
140  KEVENT Event;
141  UCHAR MdlBase[sizeof(MDL) + sizeof(ULONG)];
142  PMDL Mdl = (PMDL)MdlBase;
143 
144  DPRINT("MmWriteToSwapPage\n");
145 
146  if (SwapEntry == 0)
147  {
148  KeBugCheck(MEMORY_MANAGEMENT);
149  return(STATUS_UNSUCCESSFUL);
150  }
151 
152  i = FILE_FROM_ENTRY(SwapEntry);
153  offset = OFFSET_FROM_ENTRY(SwapEntry) - 1;
154 
155  if (MmPagingFile[i]->FileObject == NULL ||
156  MmPagingFile[i]->FileObject->DeviceObject == NULL)
157  {
158  DPRINT1("Bad paging file 0x%.8X\n", SwapEntry);
159  KeBugCheck(MEMORY_MANAGEMENT);
160  }
161 
163  MmBuildMdlFromPages(Mdl, &Page);
164  Mdl->MdlFlags |= MDL_PAGES_LOCKED;
165 
166  file_offset.QuadPart = offset * PAGE_SIZE;
167 
170  Mdl,
171  &file_offset,
172  &Event,
173  &Iosb);
174  if (Status == STATUS_PENDING)
175  {
177  Status = Iosb.Status;
178  }
179 
180  if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
181  {
182  MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
183  }
184  return(Status);
185 }
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
VOID NTAPI MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
Definition: pagefile.c:94
LONG NTSTATUS
Definition: precomp.h:26
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:65
#define FALSE
Definition: types.h:117
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:841
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:450
void DPRINT(...)
Definition: polytest.cpp:61
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define FILE_FROM_ENTRY(i)
Definition: pagefile.c:79
return Iosb
Definition: create.c:4402
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define STATUS_PENDING
Definition: ntstatus.h:82
GLintptr offset
Definition: glext.h:5920
#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
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:40
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
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 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 NULL
Definition: types.h:112
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define OFFSET_FROM_ENTRY(i)
Definition: pagefile.c:80
LONGLONG QuadPart
Definition: typedefs.h:114

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 345 of file pagefile.c.

349 {
355  PMMPAGING_FILE PagingFile;
356  SIZE_T AllocMapSize;
357  ULONG Count;
359  UNICODE_STRING PageFileName;
360  LARGE_INTEGER SafeMinimumSize, SafeMaximumSize, AllocationSize;
361  FILE_FS_DEVICE_INFORMATION FsDeviceInfo;
363  PACL Dacl;
364  PWSTR Buffer;
366 
367  PAGED_CODE();
368 
369  DPRINT("NtCreatePagingFile(FileName: '%wZ', MinimumSize: %I64d, MaximumSize: %I64d)\n",
370  FileName, MinimumSize->QuadPart, MaximumSize->QuadPart);
371 
373  {
375  }
376 
378 
379  if (PreviousMode != KernelMode)
380  {
382  {
384  }
385 
386  _SEH2_TRY
387  {
388  SafeMinimumSize = ProbeForReadLargeInteger(MinimumSize);
389  SafeMaximumSize = ProbeForReadLargeInteger(MaximumSize);
390  PageFileName = ProbeForReadUnicodeString(FileName);
391  }
393  {
394  /* Return the exception code */
396  }
397  _SEH2_END;
398  }
399  else
400  {
401  SafeMinimumSize = *MinimumSize;
402  SafeMaximumSize = *MaximumSize;
403  PageFileName = *FileName;
404  }
405 
406  /*
407  * Pagefiles can't be larger than 4GB and of course
408  * the minimum should be smaller than the maximum.
409  */
410  // TODO: Actually validate the lower bound of these sizes!
411  if (0 != SafeMinimumSize.u.HighPart)
412  {
414  }
415  if (0 != SafeMaximumSize.u.HighPart)
416  {
418  }
419  if (SafeMaximumSize.u.LowPart < SafeMinimumSize.u.LowPart)
420  {
422  }
423 
424  /* Validate the name length */
425  if ((PageFileName.Length == 0) ||
426  (PageFileName.Length > 128 * sizeof(WCHAR)))
427  {
429  }
430 
431  /* We don't care about any potential UNICODE_NULL */
432  PageFileName.MaximumLength = PageFileName.Length;
433  /* Allocate a buffer to keep the name copy */
435  if (Buffer == NULL)
436  {
438  }
439 
440  /* Copy the name */
441  if (PreviousMode != KernelMode)
442  {
443  _SEH2_TRY
444  {
445  ProbeForRead(PageFileName.Buffer, PageFileName.Length, sizeof(WCHAR));
446  RtlCopyMemory(Buffer, PageFileName.Buffer, PageFileName.Length);
447  }
449  {
451 
452  /* Return the exception code */
454  }
455  _SEH2_END;
456  }
457  else
458  {
459  RtlCopyMemory(Buffer, PageFileName.Buffer, PageFileName.Length);
460  }
461 
462  /* Replace caller's buffer with ours */
463  PageFileName.Buffer = Buffer;
464 
465  /* Create the security descriptor for the page file */
467  if (!NT_SUCCESS(Status))
468  {
470  return Status;
471  }
472 
473  /* Create the DACL: we will only allow two SIDs */
474  Count = sizeof(ACL) + (sizeof(ACE) + RtlLengthSid(SeLocalSystemSid)) +
475  (sizeof(ACE) + RtlLengthSid(SeAliasAdminsSid));
477  if (Dacl == NULL)
478  {
481  }
482 
483  /* Initialize the DACL */
485  if (!NT_SUCCESS(Status))
486  {
487  ExFreePoolWithTag(Dacl, 'lcaD');
489  return Status;
490  }
491 
492  /* Grant full access to admins */
494  if (!NT_SUCCESS(Status))
495  {
496  ExFreePoolWithTag(Dacl, 'lcaD');
498  return Status;
499  }
500 
501  /* Grant full access to SYSTEM */
503  if (!NT_SUCCESS(Status))
504  {
505  ExFreePoolWithTag(Dacl, 'lcaD');
507  return Status;
508  }
509 
510  /* Attach the DACL to the security descriptor */
512  if (!NT_SUCCESS(Status))
513  {
514  ExFreePoolWithTag(Dacl, 'lcaD');
516  return Status;
517  }
518 
520  &PageFileName,
522  NULL,
524 
525  /* Make sure we can at least store a complete page:
526  * If we have 2048 BytesPerAllocationUnit (FAT16 < 128MB) there is
527  * a problem if the paging file is fragmented. Suppose the first cluster
528  * of the paging file is cluster 3042 but cluster 3043 is NOT part of the
529  * paging file but of another file. We can't write a complete page (4096
530  * bytes) to the physical location of cluster 3042 then. */
531  AllocationSize.QuadPart = SafeMinimumSize.QuadPart + PAGE_SIZE;
532 
533  /* First, attempt to replace the page file, if existing */
537  &IoStatus,
543  NULL,
544  0,
546  NULL,
548  /* If we failed, relax a bit constraints, someone may be already holding the
549  * the file, so share write, don't attempt to replace and don't delete on close
550  * (basically, don't do anything conflicting)
551  * This can happen if the caller attempts to extend a page file.
552  */
553  if (!NT_SUCCESS(Status))
554  {
555  ULONG i;
556 
560  &IoStatus,
564  FILE_OPEN,
566  NULL,
567  0,
569  NULL,
571  if (!NT_SUCCESS(Status))
572  {
573  ExFreePoolWithTag(Dacl, 'lcaD');
575  return Status;
576  }
577 
578  /* We opened it! Check we are that "someone" ;-)
579  * First, get the opened file object.
580  */
584  KernelMode,
585  (PVOID*)&FileObject,
586  NULL);
587  if (!NT_SUCCESS(Status))
588  {
590  ExFreePoolWithTag(Dacl, 'lcaD');
592  return Status;
593  }
594 
595  /* Find if it matches a previous page file */
596  PagingFile = NULL;
597 
598  /* FIXME: should be calling unsafe instead,
599  * we should already be in a guarded region
600  */
602  if (MmNumberOfPagingFiles > 0)
603  {
604  i = 0;
605 
606  while (MmPagingFile[i]->FileObject->SectionObjectPointer != FileObject->SectionObjectPointer)
607  {
608  ++i;
609  if (i >= MmNumberOfPagingFiles)
610  {
611  break;
612  }
613  }
614 
615  /* This is the matching page file */
616  PagingFile = MmPagingFile[i];
617  }
618 
619  /* If we didn't find the page file, fail */
620  if (PagingFile == NULL)
621  {
625  ExFreePoolWithTag(Dacl, 'lcaD');
627  return STATUS_NOT_FOUND;
628  }
629 
630  /* Don't allow page file shrinking */
631  if (PagingFile->MinimumSize > (SafeMinimumSize.QuadPart >> PAGE_SHIFT))
632  {
636  ExFreePoolWithTag(Dacl, 'lcaD');
639  }
640 
641  if ((SafeMaximumSize.QuadPart >> PAGE_SHIFT) < PagingFile->MaximumSize)
642  {
646  ExFreePoolWithTag(Dacl, 'lcaD');
649  }
650 
651  /* FIXME: implement parameters checking and page file extension */
653 
657  ExFreePoolWithTag(Dacl, 'lcaD');
659  return STATUS_NOT_IMPLEMENTED;
660  }
661 
662  if (!NT_SUCCESS(Status))
663  {
664  DPRINT1("Failed creating page file: %lx\n", Status);
665  ExFreePoolWithTag(Dacl, 'lcaD');
667  return Status;
668  }
669 
670  /* Set the security descriptor */
671  if (NT_SUCCESS(IoStatus.Status))
672  {
674  if (!NT_SUCCESS(Status))
675  {
676  ExFreePoolWithTag(Dacl, 'lcaD');
679  return Status;
680  }
681  }
682 
683  /* DACL is no longer needed, free it */
684  ExFreePoolWithTag(Dacl, 'lcaD');
685 
686  /* FIXME: To enable once page file managment is moved to ARM3 */
687 #if 0
688  /* Check we won't overflow commit limit with the page file */
690  {
694  }
695 #endif
696 
697  /* Set its end of file to minimal size */
698  Status = ZwSetInformationFile(FileHandle,
699  &IoStatus,
700  &SafeMinimumSize,
701  sizeof(LARGE_INTEGER),
703  if (!NT_SUCCESS(Status) || !NT_SUCCESS(IoStatus.Status))
704  {
707  return Status;
708  }
709 
713  KernelMode,
714  (PVOID*)&FileObject,
715  NULL);
716  if (!NT_SUCCESS(Status))
717  {
720  return Status;
721  }
722 
723  /* Only allow page file on a few device types */
727  {
731  return Status;
732  }
733 
734  /* Deny page file creation on a floppy disk */
735  FsDeviceInfo.Characteristics = 0;
736  IoQueryVolumeInformation(FileObject, FileFsDeviceInformation, sizeof(FsDeviceInfo), &FsDeviceInfo, &Count);
738  {
742  return STATUS_FLOPPY_VOLUME;
743  }
744 
745  PagingFile = ExAllocatePoolWithTag(NonPagedPool, sizeof(*PagingFile), TAG_MM);
746  if (PagingFile == NULL)
747  {
752  }
753 
754  RtlZeroMemory(PagingFile, sizeof(*PagingFile));
755 
756  PagingFile->FileHandle = FileHandle;
757  PagingFile->FileObject = FileObject;
758  PagingFile->MaximumSize = (SafeMaximumSize.QuadPart >> PAGE_SHIFT);
759  PagingFile->Size = (SafeMinimumSize.QuadPart >> PAGE_SHIFT);
760  PagingFile->MinimumSize = (SafeMinimumSize.QuadPart >> PAGE_SHIFT);
761  /* First page is never used: it's the header
762  * TODO: write it
763  */
764  PagingFile->FreeSpace = (ULONG)(SafeMinimumSize.QuadPart / PAGE_SIZE) - 1;
765  PagingFile->CurrentUsage = 0;
766  PagingFile->PageFileName = PageFileName;
767  ASSERT(PagingFile->Size == PagingFile->FreeSpace + PagingFile->CurrentUsage + 1);
768 
769  AllocMapSize = sizeof(RTL_BITMAP) + (((PagingFile->MaximumSize + 31) / 32) * sizeof(ULONG));
771  AllocMapSize,
772  TAG_MM);
773  if (PagingFile->Bitmap == NULL)
774  {
775  ExFreePoolWithTag(PagingFile, TAG_MM);
780  }
781 
782  RtlInitializeBitMap(PagingFile->Bitmap,
783  (PULONG)(PagingFile->Bitmap + 1),
784  (ULONG)(PagingFile->MaximumSize));
785  RtlClearAllBits(PagingFile->Bitmap);
786 
787  /* FIXME: should be calling unsafe instead,
788  * we should already be in a guarded region
789  */
792  MmPagingFile[MmNumberOfPagingFiles] = PagingFile;
794  MiFreeSwapPages = MiFreeSwapPages + PagingFile->FreeSpace;
796 
798 
800  {
802  }
803 
804  return STATUS_SUCCESS;
805 }
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 STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _RTL_BITMAP RTL_BITMAP
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
USHORT MaximumLength
Definition: env_spec_w32.h:370
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define SL_OPEN_PAGING_FILE
Definition: iotypes.h:1797
#define TRUE
Definition: types.h:120
_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:56
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
LONG NTSTATUS
Definition: precomp.h:26
PFN_NUMBER Size
Definition: mm.h:435
SIZE_T MmTotalCommitLimitMaximum
Definition: mminit.c:360
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:520
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3066
PFILE_OBJECT FileObject
Definition: mm.h:440
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:285
#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:136
_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:387
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
return STATUS_NOT_IMPLEMENTED
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:477
#define TAG_MM
Definition: tag.h:136
#define FALSE
Definition: types.h:117
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:524
#define FILE_READ_DATA
Definition: nt_native.h:628
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static BOOLEAN MmSwapSpaceMessage
Definition: pagefile.c:86
#define DO_SYSTEM_BOOT_PARTITION
Definition: env_spec_w32.h:400
struct _ACL ACL
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
Definition: sid.c:150
DeviceType
Definition: mmdrv.h:41
PFN_NUMBER MaximumSize
Definition: mm.h:436
PFN_NUMBER MinimumSize
Definition: mm.h:437
#define FILE_WRITE_DATA
Definition: nt_native.h:631
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
UNICODE_STRING PageFileName
Definition: mm.h:441
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:113
Status
Definition: gdiplustypes.h:24
#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
int Count
Definition: noreturn.cpp:7
const LUID SeCreatePagefilePrivilege
Definition: priv.c:32
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define ASSERT(a)
Definition: mode.c:45
PFN_NUMBER FreeSpace
Definition: mm.h:438
#define MAX_PAGING_FILES
Definition: mm.h:105
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ObDereferenceObject
Definition: obfuncs.h:203
#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:1978
ULONG MmNumberOfPagingFiles
Definition: pagefile.c:46
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:43
#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:43
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
struct _LARGE_INTEGER::@2277 u
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define SYNCHRONIZE
Definition: nt_native.h:61
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define FILE_OPEN
Definition: from_kernel.h:54
HANDLE FileHandle
Definition: mm.h:443
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:40
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:319
ULONG_PTR SIZE_T
Definition: typedefs.h:80
PFN_NUMBER CurrentUsage
Definition: mm.h:439
struct _FileName FileName
Definition: fatprocs.h:893
PRTL_BITMAP Bitmap
Definition: mm.h:442
_SEH2_END
Definition: create.c:4400
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
#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
#define NULL
Definition: types.h:112
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:40
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
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:262
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define STATUS_SUCCESS
Definition: shellext.h:65
#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
Definition: rtltypes.h:990
#define DACL_SECURITY_INFORMATION
Definition: setypes.h:125
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:49
LONGLONG QuadPart
Definition: typedefs.h:114
#define STATUS_FLOPPY_VOLUME
Definition: ntstatus.h:592
#define PAGED_CODE()
static BOOLEAN MmSystemPageFileLocated
Definition: pagefile.c:88

Referenced by SmpCreatePagingFile().

Variable Documentation

◆ MiFreeSwapPages

PFN_COUNT MiFreeSwapPages

◆ MiReservedSwapPages

PFN_COUNT MiReservedSwapPages
static

Definition at line 59 of file pagefile.c.

Referenced by MmInitPagingFile().

◆ MiUsedSwapPages

PFN_COUNT MiUsedSwapPages

Definition at line 52 of file pagefile.c.

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

◆ MmNumberOfPagingFiles

ULONG MmNumberOfPagingFiles

◆ MmPageFileCreationLock

KGUARDED_MUTEX MmPageFileCreationLock

Definition at line 43 of file pagefile.c.

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

◆ MmPagingFile

◆ MmSwapSpaceMessage

BOOLEAN MmSwapSpaceMessage = FALSE
static

Definition at line 86 of file pagefile.c.

Referenced by MmShowOutOfSpaceMessagePagingFile(), and NtCreatePagingFile().

◆ MmSystemPageFileLocated

BOOLEAN MmSystemPageFileLocated = FALSE
static

Definition at line 88 of file pagefile.c.

Referenced by NtCreatePagingFile().

◆ MmZeroPageFile

BOOLEAN MmZeroPageFile

Definition at line 54 of file pagefile.c.