mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 20:36:35 +00:00
[NTOSKRNL] Page files don't have an init size, but a minimum size
NFC
This commit is contained in:
parent
315867d4ff
commit
bfc6a7957c
1 changed files with 13 additions and 13 deletions
|
@ -345,7 +345,7 @@ MmAllocSwapPage(VOID)
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
IN PLARGE_INTEGER InitialSize,
|
IN PLARGE_INTEGER MinimumSize,
|
||||||
IN PLARGE_INTEGER MaximumSize,
|
IN PLARGE_INTEGER MaximumSize,
|
||||||
IN ULONG Reserved)
|
IN ULONG Reserved)
|
||||||
{
|
{
|
||||||
|
@ -359,14 +359,14 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
ULONG Count;
|
ULONG Count;
|
||||||
KPROCESSOR_MODE PreviousMode;
|
KPROCESSOR_MODE PreviousMode;
|
||||||
UNICODE_STRING PageFileName;
|
UNICODE_STRING PageFileName;
|
||||||
LARGE_INTEGER SafeInitialSize, SafeMaximumSize, AllocationSize;
|
LARGE_INTEGER SafeMinimumSize, SafeMaximumSize, AllocationSize;
|
||||||
FILE_FS_DEVICE_INFORMATION FsDeviceInfo;
|
FILE_FS_DEVICE_INFORMATION FsDeviceInfo;
|
||||||
SECURITY_DESCRIPTOR SecurityDescriptor;
|
SECURITY_DESCRIPTOR SecurityDescriptor;
|
||||||
PACL Dacl;
|
PACL Dacl;
|
||||||
PWSTR Buffer;
|
PWSTR Buffer;
|
||||||
|
|
||||||
DPRINT("NtCreatePagingFile(FileName %wZ, InitialSize %I64d)\n",
|
DPRINT("NtCreatePagingFile(FileName %wZ, MinimumSize %I64d)\n",
|
||||||
FileName, InitialSize->QuadPart);
|
FileName, MinimumSize->QuadPart);
|
||||||
|
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
|
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
SafeInitialSize = ProbeForReadLargeInteger(InitialSize);
|
SafeMinimumSize = ProbeForReadLargeInteger(MinimumSize);
|
||||||
SafeMaximumSize = ProbeForReadLargeInteger(MaximumSize);
|
SafeMaximumSize = ProbeForReadLargeInteger(MaximumSize);
|
||||||
|
|
||||||
PageFileName.Length = FileName->Length;
|
PageFileName.Length = FileName->Length;
|
||||||
|
@ -402,7 +402,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SafeInitialSize = *InitialSize;
|
SafeMinimumSize = *MinimumSize;
|
||||||
SafeMaximumSize = *MaximumSize;
|
SafeMaximumSize = *MaximumSize;
|
||||||
|
|
||||||
PageFileName.Length = FileName->Length;
|
PageFileName.Length = FileName->Length;
|
||||||
|
@ -412,7 +412,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
|
|
||||||
/* Pagefiles can't be larger than 4GB and ofcourse the minimum should be
|
/* Pagefiles can't be larger than 4GB and ofcourse the minimum should be
|
||||||
smaller than the maximum */
|
smaller than the maximum */
|
||||||
if (0 != SafeInitialSize.u.HighPart)
|
if (0 != SafeMinimumSize.u.HighPart)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER_2;
|
return STATUS_INVALID_PARAMETER_2;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER_3;
|
return STATUS_INVALID_PARAMETER_3;
|
||||||
}
|
}
|
||||||
if (SafeMaximumSize.u.LowPart < SafeInitialSize.u.LowPart)
|
if (SafeMaximumSize.u.LowPart < SafeMinimumSize.u.LowPart)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER_MIX;
|
return STATUS_INVALID_PARAMETER_MIX;
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
* of the paging file is cluster 3042 but cluster 3043 is NOT part of the
|
* of the paging file is cluster 3042 but cluster 3043 is NOT part of the
|
||||||
* paging file but of another file. We can't write a complete page (4096
|
* paging file but of another file. We can't write a complete page (4096
|
||||||
* bytes) to the physical location of cluster 3042 then. */
|
* bytes) to the physical location of cluster 3042 then. */
|
||||||
AllocationSize.QuadPart = SafeInitialSize.QuadPart + PAGE_SIZE;
|
AllocationSize.QuadPart = SafeMinimumSize.QuadPart + PAGE_SIZE;
|
||||||
|
|
||||||
/* First, attempt to replace the page file, if existing */
|
/* First, attempt to replace the page file, if existing */
|
||||||
Status = IoCreateFile(&FileHandle,
|
Status = IoCreateFile(&FileHandle,
|
||||||
|
@ -669,10 +669,10 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
/* DACL is no longer needed, free it */
|
/* DACL is no longer needed, free it */
|
||||||
ExFreePoolWithTag(Dacl, 'lcaD');
|
ExFreePoolWithTag(Dacl, 'lcaD');
|
||||||
|
|
||||||
/* Set its end of file to initial size */
|
/* Set its end of file to minimal size */
|
||||||
Status = ZwSetInformationFile(FileHandle,
|
Status = ZwSetInformationFile(FileHandle,
|
||||||
&IoStatus,
|
&IoStatus,
|
||||||
&SafeInitialSize,
|
&SafeMinimumSize,
|
||||||
sizeof(LARGE_INTEGER),
|
sizeof(LARGE_INTEGER),
|
||||||
FileEndOfFileInformation);
|
FileEndOfFileInformation);
|
||||||
if (!NT_SUCCESS(Status) || !NT_SUCCESS(IoStatus.Status))
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(IoStatus.Status))
|
||||||
|
@ -720,8 +720,8 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
PagingFile->FileHandle = FileHandle;
|
PagingFile->FileHandle = FileHandle;
|
||||||
PagingFile->FileObject = FileObject;
|
PagingFile->FileObject = FileObject;
|
||||||
PagingFile->MaximumSize.QuadPart = SafeMaximumSize.QuadPart;
|
PagingFile->MaximumSize.QuadPart = SafeMaximumSize.QuadPart;
|
||||||
PagingFile->CurrentSize.QuadPart = SafeInitialSize.QuadPart;
|
PagingFile->CurrentSize.QuadPart = SafeMinimumSize.QuadPart;
|
||||||
PagingFile->FreePages = (ULONG)(SafeInitialSize.QuadPart / PAGE_SIZE);
|
PagingFile->FreePages = (ULONG)(SafeMinimumSize.QuadPart / PAGE_SIZE);
|
||||||
PagingFile->UsedPages = 0;
|
PagingFile->UsedPages = 0;
|
||||||
PagingFile->PageFileName = PageFileName;
|
PagingFile->PageFileName = PageFileName;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue