ReactOS 0.4.16-dev-197-g92996da
pagefile.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Paging file functions
5 * COPYRIGHT: Copyright 1998-2003 David Welch <welch@mcmail.com>
6 * Copyright 2010-2018 Pierre Schweitzer <pierre@reactos.org>
7 */
8
9/* INCLUDES *****************************************************************/
10
11#include <ntoskrnl.h>
12#define NDEBUG
13#include <debug.h>
14
15/* GLOBALS *******************************************************************/
16
17/* Minimum pagefile size is 256 pages (1 MB) */
18#define MINIMUM_PAGEFILE_SIZE (256ULL * PAGE_SIZE)
19
20/* Maximum pagefile sizes for different architectures */
21#if defined(_M_IX86) && !defined(_X86PAE_)
22/* Around 4 GB */
23 #define MAXIMUM_PAGEFILE_SIZE ((1ULL * 1024 * 1024 - 1) * PAGE_SIZE)
24 // PAGE_ROUND_DOWN(4ULL * GIGABYTE - 1)
25/* PAE uses the same size as x64 */
26#elif (defined(_M_IX86) && defined(_X86PAE_)) || defined (_M_AMD64) || defined(_M_ARM64)
27/* Around 16 TB */
28 #if (NTDDI_VERSION >= NTDDI_WIN10)
29 #define MAXIMUM_PAGEFILE_SIZE ((4ULL * 1024 * 1024 * 1024 - 2) * PAGE_SIZE)
30 // PAGE_ROUND_DOWN(16ULL * TERABYTE - PAGE_SIZE - 1)
31 #else
32 #define MAXIMUM_PAGEFILE_SIZE ((4ULL * 1024 * 1024 * 1024 - 1) * PAGE_SIZE)
33 // PAGE_ROUND_DOWN(16ULL * TERABYTE - 1)
34 #endif
35#elif defined (_M_IA64)
36/* Around 32 TB */
37 #define MAXIMUM_PAGEFILE_SIZE ((8ULL * 1024 * 1024 * 1024 - 1) * PAGE_SIZE)
38 // PAGE_ROUND_DOWN(32ULL * TERABYTE - 1)
39#elif defined(_M_ARM)
40/* Around 2 GB */
41 #if (NTDDI_VERSION >= NTDDI_WIN10)
42 #define MAXIMUM_PAGEFILE_SIZE ((512ULL * 1024 - 2) * PAGE_SIZE)
43 // PAGE_ROUND_DOWN(2ULL * GIGABYTE - PAGE_SIZE - 1)
44 #elif (NTDDI_VERSION >= NTDDI_WINBLUE) // NTDDI_WIN81
45 #define MAXIMUM_PAGEFILE_SIZE ((512ULL * 1024 - 1) * PAGE_SIZE)
46 // PAGE_ROUND_DOWN(2ULL * GIGABYTE - 1)
47 #else
48/* Around 4 GB */
49 #define MAXIMUM_PAGEFILE_SIZE ((1ULL * 1024 * 1024 - 1) * PAGE_SIZE)
50 // PAGE_ROUND_DOWN(4ULL * GIGABYTE - 1)
51 #endif
52#else
53#error Unknown architecture
54#endif
55
56/* List of paging files, both used and free */
58
59/* Lock for examining the list of paging files */
61
62/* Number of paging files */
64
65/* Number of pages that are available for swapping */
67
68/* Number of pages that have been allocated for swapping */
70
72
73/*
74 * Number of pages that have been reserved for swapping but not yet allocated
75 */
77
78/*
79 * Ratio between reserved and available swap pages, e.g. setting this to five
80 * forces one swap page to be available for every five swap pages that are
81 * reserved. Setting this to zero turns off commit checking altogether.
82 */
83#define MM_PAGEFILE_COMMIT_RATIO (1)
84
85/*
86 * Number of pages that can be used for potentially swapable memory without
87 * pagefile space being reserved. The intention is that this allows smss
88 * to start up and create page files while ordinarily having a commit
89 * ratio of one.
90 */
91#define MM_PAGEFILE_COMMIT_GRACE (256)
92
93/*
94 * Translate between a swap entry and a file and offset pair.
95 */
96#define FILE_FROM_ENTRY(i) ((i) & 0x0f)
97#define OFFSET_FROM_ENTRY(i) ((i) >> 11)
98#define ENTRY_FROM_FILE_OFFSET(i, j) ((i) | ((j) << 11) | 0x400)
99
100/* Make sure there can be only 16 paging files */
102
104
106
107/* FUNCTIONS *****************************************************************/
108
109VOID
110NTAPI
112{
113 memcpy(Mdl + 1, Pages, sizeof(PFN_NUMBER) * (PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGE_SIZE));
114}
115
116
118NTAPI
120{
121 ULONG i;
122
123 /* Loop through all the paging files */
124 for (i = 0; i < MmNumberOfPagingFiles; i++)
125 {
126 /* Check if this is one of them */
127 if (MmPagingFile[i]->FileObject == FileObject) return TRUE;
128 }
129
130 /* Nothing found */
131 return FALSE;
132}
133
134VOID
135NTAPI
137{
139 {
140 DPRINT1("MM: Out of swap space.\n");
142 }
143}
144
146NTAPI
148{
149 ULONG i;
151 LARGE_INTEGER file_offset;
155 UCHAR MdlBase[sizeof(MDL) + sizeof(PFN_NUMBER)];
156 PMDL Mdl = (PMDL)MdlBase;
157
158 DPRINT("MmWriteToSwapPage\n");
159
160 if (SwapEntry == 0)
161 {
162 KeBugCheck(MEMORY_MANAGEMENT);
163 return(STATUS_UNSUCCESSFUL);
164 }
165
166 i = FILE_FROM_ENTRY(SwapEntry);
167 offset = OFFSET_FROM_ENTRY(SwapEntry) - 1;
168
169 if (MmPagingFile[i]->FileObject == NULL ||
170 MmPagingFile[i]->FileObject->DeviceObject == NULL)
171 {
172 DPRINT1("Bad paging file 0x%.8X\n", SwapEntry);
173 KeBugCheck(MEMORY_MANAGEMENT);
174 }
175
178 Mdl->MdlFlags |= MDL_PAGES_LOCKED;
179
180 file_offset.QuadPart = offset * PAGE_SIZE;
181
184 Mdl,
185 &file_offset,
186 &Event,
187 &Iosb);
188 if (Status == STATUS_PENDING)
189 {
191 Status = Iosb.Status;
192 }
193
194 if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
195 {
196 MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
197 }
198 return(Status);
199}
200
201
203NTAPI
205{
206 return MiReadPageFile(Page, FILE_FROM_ENTRY(SwapEntry), OFFSET_FROM_ENTRY(SwapEntry));
207}
208
210NTAPI
213 _In_ ULONG PageFileIndex,
214 _In_ ULONG_PTR PageFileOffset)
215{
216 LARGE_INTEGER file_offset;
220 UCHAR MdlBase[sizeof(MDL) + sizeof(PFN_NUMBER)];
221 PMDL Mdl = (PMDL)MdlBase;
222 PMMPAGING_FILE PagingFile;
223
224 DPRINT("MiReadSwapFile\n");
225
226 if (PageFileOffset == 0)
227 {
228 KeBugCheck(MEMORY_MANAGEMENT);
229 return(STATUS_UNSUCCESSFUL);
230 }
231
232 /* Normalize offset. */
233 PageFileOffset--;
234
235 ASSERT(PageFileIndex < MAX_PAGING_FILES);
236
237 PagingFile = MmPagingFile[PageFileIndex];
238
239 if (PagingFile->FileObject == NULL || PagingFile->FileObject->DeviceObject == NULL)
240 {
241 DPRINT1("Bad paging file %u\n", PageFileIndex);
242 KeBugCheck(MEMORY_MANAGEMENT);
243 }
244
248
249 file_offset.QuadPart = PageFileOffset * PAGE_SIZE;
250
252 Status = IoPageRead(PagingFile->FileObject,
253 Mdl,
254 &file_offset,
255 &Event,
256 &Iosb);
257 if (Status == STATUS_PENDING)
258 {
260 Status = Iosb.Status;
261 }
262 if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
263 {
264 MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
265 }
266 return(Status);
267}
268
269CODE_SEG("INIT")
270VOID
271NTAPI
273{
274 ULONG i;
275
277
278 MiFreeSwapPages = 0;
279 MiUsedSwapPages = 0;
281
282 for (i = 0; i < MAX_PAGING_FILES; i++)
283 {
285 }
287}
288
289VOID
290NTAPI
292{
293 ULONG i;
294 ULONG_PTR off;
295 PMMPAGING_FILE PagingFile;
296
298 off = OFFSET_FROM_ENTRY(Entry) - 1;
299
301
302 PagingFile = MmPagingFile[i];
303 if (PagingFile == NULL)
304 {
305 KeBugCheck(MEMORY_MANAGEMENT);
306 }
307
308 RtlClearBit(PagingFile->Bitmap, off >> 5);
309
310 PagingFile->FreeSpace++;
311 PagingFile->CurrentUsage--;
312
316
318}
319
321NTAPI
323{
324 ULONG i;
325 ULONG off;
327
329
330 if (MiFreeSwapPages == 0)
331 {
333 return(0);
334 }
335
336 for (i = 0; i < MAX_PAGING_FILES; i++)
337 {
338 if (MmPagingFile[i] != NULL &&
339 MmPagingFile[i]->FreeSpace >= 1)
340 {
342 if (off == 0xFFFFFFFF)
343 {
344 KeBugCheck(MEMORY_MANAGEMENT);
346 return(STATUS_UNSUCCESSFUL);
347 }
351
353
354 entry = ENTRY_FROM_FILE_OFFSET(i, off + 1);
355 return(entry);
356 }
357 }
358
360 KeBugCheck(MEMORY_MANAGEMENT);
361 return(0);
362}
363
365NTAPI
368 _In_ PLARGE_INTEGER MinimumSize,
371{
377 PMMPAGING_FILE PagingFile;
378 SIZE_T AllocMapSize;
379 ULONG Count;
381 UNICODE_STRING PageFileName;
382 LARGE_INTEGER SafeMinimumSize, SafeMaximumSize, AllocationSize;
383 FILE_FS_DEVICE_INFORMATION FsDeviceInfo;
385 PACL Dacl;
388
389 PAGED_CODE();
390
391 DPRINT("NtCreatePagingFile(FileName: '%wZ', MinimumSize: %I64d, MaximumSize: %I64d)\n",
392 FileName, MinimumSize->QuadPart, MaximumSize->QuadPart);
393
395 {
397 }
398
400
402 {
404 {
406 }
407
409 {
410 SafeMinimumSize = ProbeForReadLargeInteger(MinimumSize);
411 SafeMaximumSize = ProbeForReadLargeInteger(MaximumSize);
412 PageFileName = ProbeForReadUnicodeString(FileName);
413 }
415 {
416 /* Return the exception code */
418 }
419 _SEH2_END;
420 }
421 else
422 {
423 SafeMinimumSize = *MinimumSize;
424 SafeMaximumSize = *MaximumSize;
425 PageFileName = *FileName;
426 }
427
428 /*
429 * Pagefiles cannot be larger than the platform-specific memory addressable
430 * limits, and of course the minimum should be smaller than the maximum.
431 */
432 if (SafeMinimumSize.QuadPart < MINIMUM_PAGEFILE_SIZE ||
433 SafeMinimumSize.QuadPart > MAXIMUM_PAGEFILE_SIZE)
434 {
436 }
437 if (SafeMaximumSize.QuadPart < SafeMinimumSize.QuadPart ||
438 SafeMaximumSize.QuadPart > MAXIMUM_PAGEFILE_SIZE)
439 {
441 }
442
443 /* Validate the name length */
444 if ((PageFileName.Length == 0) ||
445 (PageFileName.Length > MAXIMUM_FILENAME_LENGTH))
446 {
448 }
449
450 /* Allocate a buffer to keep the name copy. Note that it is kept only
451 * for information purposes, so it gets allocated in the paged pool,
452 * even if it will be stored in the PagingFile structure, that is
453 * allocated from non-paged pool (see below). */
454 PageFileName.MaximumLength = PageFileName.Length;
456 if (Buffer == NULL)
457 {
459 }
460
461 /* Copy the name */
463 {
465 {
466 ProbeForRead(PageFileName.Buffer, PageFileName.Length, sizeof(WCHAR));
467 RtlCopyMemory(Buffer, PageFileName.Buffer, PageFileName.Length);
468 }
470 {
472
473 /* Return the exception code */
475 }
476 _SEH2_END;
477 }
478 else
479 {
480 RtlCopyMemory(Buffer, PageFileName.Buffer, PageFileName.Length);
481 }
482
483 /* Replace caller's buffer with ours */
484 PageFileName.Buffer = Buffer;
485
486 /* Create the security descriptor for the page file */
488 if (!NT_SUCCESS(Status))
489 {
491 return Status;
492 }
493
494 /* Create the DACL: we will only allow two SIDs */
495 Count = sizeof(ACL) + (sizeof(ACE) + RtlLengthSid(SeLocalSystemSid)) +
496 (sizeof(ACE) + RtlLengthSid(SeAliasAdminsSid));
498 if (Dacl == NULL)
499 {
502 }
503
504 /* Initialize the DACL */
506 if (!NT_SUCCESS(Status))
507 goto EarlyQuit;
508
509 /* Grant full access to admins */
511 if (!NT_SUCCESS(Status))
512 goto EarlyQuit;
513
514 /* Grant full access to SYSTEM */
516 if (!NT_SUCCESS(Status))
517 goto EarlyQuit;
518
519 /* Attach the DACL to the security descriptor */
521 if (!NT_SUCCESS(Status))
522 goto EarlyQuit;
523
525 &PageFileName,
527 NULL,
529
530 /* Make sure we can at least store a complete page:
531 * If we have 2048 BytesPerAllocationUnit (FAT16 < 128MB) there is
532 * a problem if the paging file is fragmented. Suppose the first cluster
533 * of the paging file is cluster 3042 but cluster 3043 is NOT part of the
534 * paging file but of another file. We can't write a complete page (4096
535 * bytes) to the physical location of cluster 3042 then. */
536 AllocationSize.QuadPart = SafeMinimumSize.QuadPart + PAGE_SIZE;
537
538 /* First, attempt to replace the page file, if existing */
542 &IoStatus,
548 NULL,
549 0,
551 NULL,
553 /* If we failed, relax a bit constraints, someone may be already holding the
554 * the file, so share write, don't attempt to replace and don't delete on close
555 * (basically, don't do anything conflicting).
556 * This can happen if the caller attempts to extend a page file.
557 */
558 if (!NT_SUCCESS(Status))
559 {
560 ULONG i;
561
565 &IoStatus,
569 FILE_OPEN,
571 NULL,
572 0,
574 NULL,
576 if (!NT_SUCCESS(Status))
577 goto EarlyQuit;
578
579 /* We opened it! Check we are that "someone" ;-)
580 * First, get the opened file object.
581 */
586 (PVOID*)&FileObject,
587 NULL);
588 if (!NT_SUCCESS(Status))
589 {
591 goto EarlyQuit;
592 }
593
594 /* Find if it matches a previous page file */
595 PagingFile = NULL;
596
598
599 for (i = 0; i < MmNumberOfPagingFiles; ++i)
600 {
601 if (MmPagingFile[i]->FileObject->SectionObjectPointer == FileObject->SectionObjectPointer)
602 {
603 /* Same object pointer: this is the matching page file */
604 PagingFile = MmPagingFile[i];
605 break;
606 }
607 }
608
609 /* If we didn't find the page file, fail */
610 if (PagingFile == NULL)
611 {
616 goto EarlyQuit;
617 }
618
619 /* Don't allow page file shrinking */
620 if (PagingFile->MinimumSize > (SafeMinimumSize.QuadPart >> PAGE_SHIFT))
621 {
626 goto EarlyQuit;
627 }
628
629 if ((SafeMaximumSize.QuadPart >> PAGE_SHIFT) < PagingFile->MaximumSize)
630 {
635 goto EarlyQuit;
636 }
637
638 /* FIXME: implement parameters checking and page file extension */
640
645 goto EarlyQuit;
646 }
647
648 if (!NT_SUCCESS(Status))
649 {
650EarlyQuit:
651 DPRINT1("Failed creating page file: %lx\n", Status);
654 return Status;
655 }
656
657 /* Set the security descriptor */
658 if (NT_SUCCESS(IoStatus.Status))
659 {
661 if (!NT_SUCCESS(Status))
662 {
666 return Status;
667 }
668 }
669
670 /* DACL is no longer needed, free it */
672
673 /* FIXME: To enable once page file management is moved to ARM3 */
674#if 0
675 /* Check we won't overflow commit limit with the page file */
677 {
681 }
682#endif
683
684 /* Set its end of file to minimal size */
685 Status = ZwSetInformationFile(FileHandle,
686 &IoStatus,
687 &SafeMinimumSize,
688 sizeof(LARGE_INTEGER),
690 if (!NT_SUCCESS(Status) || !NT_SUCCESS(IoStatus.Status))
691 {
694 return Status;
695 }
696
701 (PVOID*)&FileObject,
702 NULL);
703 if (!NT_SUCCESS(Status))
704 {
707 return Status;
708 }
709
710 /* Only allow page file on a few device types */
716 {
720 return Status;
721 }
722
723 /* Deny page file creation on a floppy disk */
724 FsDeviceInfo.Characteristics = 0;
726 sizeof(FsDeviceInfo), &FsDeviceInfo, &Count);
728 {
733 }
734
735 /*
736 * Missing validation steps TODO:
737 * (see https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/mm/modwrite/create.htm )
738 *
739 * - Verify that no file system driver or any filter driver has done file
740 * I/O while opening the file.
741 * Verify that nothing of the paging file is yet in memory. Specifically,
742 * the file object must either have no SectionObjectPointer or the latter
743 * must have neither a DataSectionObject nor an ImageSectionObject.
744 * Otherwise, we should fail, returning STATUS_INCOMPATIBLE_FILE_MAP.
745 *
746 * - Inform all the applicable drivers to prepare for the possibility of
747 * paging I/O. Much of the point to paging I/O is to resolve page faults.
748 * Especially important is that drivers that handle paging I/O do not
749 * cause more page faults. All the code and data that each driver might
750 * ever use for access to the paging file must be locked into physical
751 * memory. This can’t be left until paging I/O actually occurs.
752 * It must be done in advance.
753 */
754
755 PagingFile = ExAllocatePoolZero(NonPagedPool, sizeof(*PagingFile), TAG_MM);
756 if (PagingFile == NULL)
757 {
762 }
763
764 PagingFile->FileHandle = FileHandle;
765 PagingFile->FileObject = FileObject;
766 PagingFile->Size = (SafeMinimumSize.QuadPart >> PAGE_SHIFT);
767 PagingFile->MinimumSize = PagingFile->Size;
768 PagingFile->MaximumSize = (SafeMaximumSize.QuadPart >> PAGE_SHIFT);
769 /* First page is never used: it's the header
770 * TODO: write it
771 */
772 PagingFile->FreeSpace = PagingFile->Size - 1;
773 PagingFile->CurrentUsage = 0;
774 PagingFile->PageFileName = PageFileName;
775 ASSERT(PagingFile->Size == PagingFile->FreeSpace + PagingFile->CurrentUsage + 1);
776
777 AllocMapSize = sizeof(RTL_BITMAP) + (((PagingFile->MaximumSize + 31) / 32) * sizeof(ULONG));
779 AllocMapSize,
780 TAG_MM);
781 if (PagingFile->Bitmap == NULL)
782 {
783 ExFreePoolWithTag(PagingFile, TAG_MM);
788 }
789
790 RtlInitializeBitMap(PagingFile->Bitmap,
791 (PULONG)(PagingFile->Bitmap + 1),
792 (ULONG)(PagingFile->MaximumSize));
793 RtlClearAllBits(PagingFile->Bitmap);
794
795 /* Insert the new paging file information into the list */
797 /* Ensure the corresponding slot is empty yet */
803
805
807 {
809 }
810
811 return STATUS_SUCCESS;
812}
813
814/* EOF */
SIZE_T MmTotalCommitLimitMaximum
Definition: mminit.c:360
#define PAGED_CODE()
#define CODE_SEG(...)
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DELETE_ON_CLOSE
Definition: constants.h:494
#define DPRINT1
Definition: precomp.h:8
#define MAXIMUM_PAGEFILE_SIZE
Definition: pagefile.c:76
#define MAX_PAGING_FILES
Definition: pagefile.c:23
#define UNIMPLEMENTED
Definition: debug.h:118
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1430
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define RtlInitializeBitMap
Definition: dbgbitmap.h:326
#define RtlClearAllBits
Definition: dbgbitmap.h:329
#define RtlClearBit
Definition: dbgbitmap.h:330
#define RtlFindClearBitsAndSet
Definition: dbgbitmap.h:333
#define RTL_BITMAP
Definition: dbgbitmap.h:323
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define DEVICE_TYPE
Definition: guid.c:10
#define FILE_SHARE_READ
Definition: compat.h:136
return Iosb
Definition: create.c:4402
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define MAXIMUM_FILENAME_LENGTH
Definition: env_spec_w32.h:41
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define DO_SYSTEM_BOOT_PARTITION
Definition: env_spec_w32.h:400
#define NonPagedPool
Definition: env_spec_w32.h:307
#define PagedPool
Definition: env_spec_w32.h:308
#define ExGetPreviousMode
Definition: ex.h:140
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:323
struct _FileName FileName
Definition: fatprocs.h:897
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
@ FileEndOfFileInformation
Definition: from_kernel.h:81
#define FILE_NO_COMPRESSION
Definition: from_kernel.h:43
#define FILE_OPEN
Definition: from_kernel.h:54
@ FileFsDeviceInformation
Definition: from_kernel.h:222
#define FILE_NO_INTERMEDIATE_BUFFERING
Definition: from_kernel.h:28
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
Status
Definition: gdiplustypes.h:25
GLintptr offset
Definition: glext.h:5920
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
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSYSAPI NTSTATUS WINAPI RtlAddAccessAllowedAce(PACL, DWORD, DWORD, PSID)
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
NTSTATUS NTAPI IoPageRead(IN PFILE_OBJECT FileObject, IN PMDL Mdl, IN PLARGE_INTEGER Offset, IN PKEVENT Event, IN PIO_STATUS_BLOCK StatusBlock)
Definition: iofunc.c:1201
NTSTATUS NTAPI IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, IN FS_INFORMATION_CLASS FsInformationClass, IN ULONG Length, OUT PVOID FsInformation, OUT PULONG ReturnedLength)
Definition: iofunc.c:1294
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:1146
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:837
DeviceType
Definition: mmdrv.h:42
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
struct _ACL ACL
#define _In_
Definition: ms_sal.h:308
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define KernelMode
Definition: asm.h:34
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
Definition: mmfuncs.h:362
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1605
NTSYSAPI NTSTATUS NTAPI RtlCreateAcl(PACL Acl, ULONG AclSize, ULONG AclRevision)
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
Definition: sid.c:150
NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Revision)
int Count
Definition: noreturn.cpp:7
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define WRITE_DAC
Definition: nt_native.h:59
#define FILE_READ_DATA
Definition: nt_native.h:628
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
@ NotificationEvent
BOOLEAN NTAPI IoInitializeCrashDump(IN HANDLE PageFileHandle)
Definition: iomgr.c:649
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1306
FORCEINLINE VOID UpdateTotalCommittedPages(LONG Delta)
Definition: mm.h:871
ULONG_PTR SWAPENTRY
Definition: mm.h:57
PSID SeLocalSystemSid
Definition: sid.c:38
PSID SeAliasAdminsSid
Definition: sid.c:41
const LUID SeCreatePagefilePrivilege
Definition: priv.c:34
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
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:3010
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:57
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:60
NTSTATUS NTAPI NtCreatePagingFile(_In_ PUNICODE_STRING FileName, _In_ PLARGE_INTEGER MinimumSize, _In_ PLARGE_INTEGER MaximumSize, _In_ ULONG Reserved)
Definition: pagefile.c:366
NTSTATUS NTAPI MiReadPageFile(_In_ PFN_NUMBER Page, _In_ ULONG PageFileIndex, _In_ ULONG_PTR PageFileOffset)
Definition: pagefile.c:211
static BOOLEAN MmSwapSpaceMessage
Definition: pagefile.c:103
VOID NTAPI MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
Definition: pagefile.c:111
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:66
BOOLEAN NTAPI MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject)
Definition: pagefile.c:119
SWAPENTRY NTAPI MmAllocSwapPage(VOID)
Definition: pagefile.c:322
static BOOLEAN MmSystemPageFileLocated
Definition: pagefile.c:105
NTSTATUS NTAPI MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
Definition: pagefile.c:147
NTSTATUS NTAPI MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
Definition: pagefile.c:204
BOOLEAN MmZeroPageFile
Definition: pagefile.c:71
#define FILE_FROM_ENTRY(i)
Definition: pagefile.c:96
VOID NTAPI MmFreeSwapPage(SWAPENTRY Entry)
Definition: pagefile.c:291
#define MINIMUM_PAGEFILE_SIZE
Definition: pagefile.c:18
#define ENTRY_FROM_FILE_OFFSET(i, j)
Definition: pagefile.c:98
#define OFFSET_FROM_ENTRY(i)
Definition: pagefile.c:97
ULONG MmNumberOfPagingFiles
Definition: pagefile.c:63
PFN_COUNT MiUsedSwapPages
Definition: pagefile.c:69
C_ASSERT(FILE_FROM_ENTRY(0xffffffff)< MAX_PAGING_FILES)
static PFN_COUNT MiReservedSwapPages
Definition: pagefile.c:76
VOID NTAPI MmInitPagingFile(VOID)
Definition: pagefile.c:272
VOID NTAPI MmShowOutOfSpaceMessagePagingFile(VOID)
Definition: pagefile.c:136
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
#define STATUS_FLOPPY_VOLUME
Definition: ntstatus.h:592
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
#define STATUS_TOO_MANY_PAGING_FILES
Definition: ntstatus.h:387
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:494
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:53
#define FILE_DEVICE_NETWORK_FILE_SYSTEM
Definition: winioctl.h:65
#define FILE_DEVICE_DFS_FILE_SYSTEM
Definition: winioctl.h:98
#define FILE_DEVICE_DFS_VOLUME
Definition: winioctl.h:99
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define ProbeForReadUnicodeString(Ptr)
Definition: probe.h:77
#define ProbeForReadLargeInteger(Ptr)
Definition: probe.h:75
ULONG * PPFN_NUMBER
Definition: ke.h:9
ULONG PFN_NUMBER
Definition: ke.h:9
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
Definition: rtltypes.h:993
PFN_NUMBER MinimumSize
Definition: mm.h:503
UNICODE_STRING PageFileName
Definition: mm.h:507
PFN_NUMBER Size
Definition: mm.h:501
PRTL_BITMAP Bitmap
Definition: mm.h:508
PFN_NUMBER CurrentUsage
Definition: mm.h:505
PFN_NUMBER FreeSpace
Definition: mm.h:504
PFILE_OBJECT FileObject
Definition: mm.h:506
PFN_NUMBER MaximumSize
Definition: mm.h:502
HANDLE FileHandle
Definition: mm.h:509
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TAG_DACL
Definition: tag.h:167
#define TAG_MM
Definition: tag.h:113
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONGLONG QuadPart
Definition: typedefs.h:114
PVOID PMDL
Definition: usb.h:39
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
_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:191
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:541
* PFILE_OBJECT
Definition: iotypes.h:1998
@ CreateFileTypeNone
Definition: iotypes.h:535
#define IO_OPEN_PAGING_FILE
Definition: iotypes.h:7351
@ Executive
Definition: ketypes.h:415
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
MDL
Definition: mmtypes.h:117
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
ULONG PFN_COUNT
Definition: mmtypes.h:102
#define MDL_IO_PAGE_READ
Definition: mmtypes.h:24
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
#define ObDereferenceObject
Definition: obfuncs.h:203
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
#define DACL_SECURITY_INFORMATION
Definition: setypes.h:125
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define ACL_REVISION
Definition: setypes.h:39
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180