mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 00:25:41 +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 */
|
/* Page file information */
|
||||||
typedef struct _MMPAGING_FILE
|
typedef struct _MMPAGING_FILE
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject;
|
|
||||||
HANDLE FileHandle;
|
|
||||||
LARGE_INTEGER MaximumSize;
|
|
||||||
LARGE_INTEGER CurrentSize;
|
LARGE_INTEGER CurrentSize;
|
||||||
|
LARGE_INTEGER MaximumSize;
|
||||||
|
LARGE_INTEGER MinimumSize;
|
||||||
PFN_NUMBER FreePages;
|
PFN_NUMBER FreePages;
|
||||||
PFN_NUMBER UsedPages;
|
PFN_NUMBER UsedPages;
|
||||||
PRTL_BITMAP AllocMap;
|
PFILE_OBJECT FileObject;
|
||||||
KSPIN_LOCK AllocMapLock;
|
|
||||||
UNICODE_STRING PageFileName;
|
UNICODE_STRING PageFileName;
|
||||||
|
PRTL_BITMAP AllocMap;
|
||||||
|
HANDLE FileHandle;
|
||||||
}
|
}
|
||||||
MMPAGING_FILE, *PMMPAGING_FILE;
|
MMPAGING_FILE, *PMMPAGING_FILE;
|
||||||
|
|
||||||
|
|
|
@ -634,6 +634,27 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
return STATUS_NOT_FOUND;
|
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 */
|
/* FIXME: implement parameters checking and page file extension */
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
|
||||||
|
@ -721,6 +742,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
PagingFile->FileObject = FileObject;
|
PagingFile->FileObject = FileObject;
|
||||||
PagingFile->MaximumSize.QuadPart = SafeMaximumSize.QuadPart;
|
PagingFile->MaximumSize.QuadPart = SafeMaximumSize.QuadPart;
|
||||||
PagingFile->CurrentSize.QuadPart = SafeMinimumSize.QuadPart;
|
PagingFile->CurrentSize.QuadPart = SafeMinimumSize.QuadPart;
|
||||||
|
PagingFile->MinimumSize.QuadPart = SafeMinimumSize.QuadPart;
|
||||||
PagingFile->FreePages = (ULONG)(SafeMinimumSize.QuadPart / PAGE_SIZE);
|
PagingFile->FreePages = (ULONG)(SafeMinimumSize.QuadPart / PAGE_SIZE);
|
||||||
PagingFile->UsedPages = 0;
|
PagingFile->UsedPages = 0;
|
||||||
PagingFile->PageFileName = PageFileName;
|
PagingFile->PageFileName = PageFileName;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue