mirror of
https://github.com/reactos/reactos.git
synced 2024-11-18 21:13:52 +00:00
[NTOSKRNL] Store page file minimum size and use it to prevent page file shrinking
This commit is contained in:
parent
bfc6a7957c
commit
2fe4e71383
2 changed files with 27 additions and 5 deletions
|
@ -426,15 +426,15 @@ extern MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
|
|||
/* Page file information */
|
||||
typedef struct _MMPAGING_FILE
|
||||
{
|
||||
PFILE_OBJECT FileObject;
|
||||
HANDLE FileHandle;
|
||||
LARGE_INTEGER MaximumSize;
|
||||
LARGE_INTEGER CurrentSize;
|
||||
LARGE_INTEGER MaximumSize;
|
||||
LARGE_INTEGER MinimumSize;
|
||||
PFN_NUMBER FreePages;
|
||||
PFN_NUMBER UsedPages;
|
||||
PRTL_BITMAP AllocMap;
|
||||
KSPIN_LOCK AllocMapLock;
|
||||
PFILE_OBJECT FileObject;
|
||||
UNICODE_STRING PageFileName;
|
||||
PRTL_BITMAP AllocMap;
|
||||
HANDLE FileHandle;
|
||||
}
|
||||
MMPAGING_FILE, *PMMPAGING_FILE;
|
||||
|
||||
|
|
|
@ -634,6 +634,27 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
|||
return STATUS_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* Don't allow page file shrinking */
|
||||
if (PagingFile->MinimumSize.QuadPart > SafeMinimumSize.QuadPart)
|
||||
{
|
||||
KeReleaseGuardedMutex(&MmPageFileCreationLock);
|
||||
ObDereferenceObject(FileObject);
|
||||
ZwClose(FileHandle);
|
||||
ExFreePoolWithTag(Dacl, 'lcaD');
|
||||
ExFreePoolWithTag(Buffer, TAG_MM);
|
||||
return STATUS_INVALID_PARAMETER_2;
|
||||
}
|
||||
|
||||
if (SafeMaximumSize.QuadPart < PagingFile->MaximumSize.QuadPart)
|
||||
{
|
||||
KeReleaseGuardedMutex(&MmPageFileCreationLock);
|
||||
ObDereferenceObject(FileObject);
|
||||
ZwClose(FileHandle);
|
||||
ExFreePoolWithTag(Dacl, 'lcaD');
|
||||
ExFreePoolWithTag(Buffer, TAG_MM);
|
||||
return STATUS_INVALID_PARAMETER_3;
|
||||
}
|
||||
|
||||
/* FIXME: implement parameters checking and page file extension */
|
||||
UNIMPLEMENTED;
|
||||
|
||||
|
@ -721,6 +742,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
|||
PagingFile->FileObject = FileObject;
|
||||
PagingFile->MaximumSize.QuadPart = SafeMaximumSize.QuadPart;
|
||||
PagingFile->CurrentSize.QuadPart = SafeMinimumSize.QuadPart;
|
||||
PagingFile->MinimumSize.QuadPart = SafeMinimumSize.QuadPart;
|
||||
PagingFile->FreePages = (ULONG)(SafeMinimumSize.QuadPart / PAGE_SIZE);
|
||||
PagingFile->UsedPages = 0;
|
||||
PagingFile->PageFileName = PageFileName;
|
||||
|
|
Loading…
Reference in a new issue