[NTOSKRNL] Store page file sizes in pages, not in bytes
authorPierre Schweitzer <pierre@reactos.org>
Thu, 16 Aug 2018 11:50:16 +0000 (13:50 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Thu, 16 Aug 2018 11:50:16 +0000 (13:50 +0200)
ntoskrnl/include/internal/mm.h
ntoskrnl/mm/pagefile.c

index 9739d62..ca82fd8 100644 (file)
@@ -426,9 +426,9 @@ extern MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
 /* Page file information */
 typedef struct _MMPAGING_FILE
 {
-    LARGE_INTEGER CurrentSize;
-    LARGE_INTEGER MaximumSize;
-    LARGE_INTEGER MinimumSize;
+    PFN_NUMBER CurrentSize;
+    PFN_NUMBER MaximumSize;
+    PFN_NUMBER MinimumSize;
     PFN_NUMBER FreePages;
     PFN_NUMBER UsedPages;
     PFILE_OBJECT FileObject;
index 784495d..dd24fe7 100644 (file)
@@ -635,7 +635,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
         }
 
         /* Don't allow page file shrinking */
-        if (PagingFile->MinimumSize.QuadPart > SafeMinimumSize.QuadPart)
+        if (PagingFile->MinimumSize > (SafeMinimumSize.QuadPart >> PAGE_SHIFT))
         {
             KeReleaseGuardedMutex(&MmPageFileCreationLock);
             ObDereferenceObject(FileObject);
@@ -645,7 +645,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
             return STATUS_INVALID_PARAMETER_2;
         }
 
-        if (SafeMaximumSize.QuadPart < PagingFile->MaximumSize.QuadPart)
+        if ((SafeMaximumSize.QuadPart >> PAGE_SHIFT) < PagingFile->MaximumSize)
         {
             KeReleaseGuardedMutex(&MmPageFileCreationLock);
             ObDereferenceObject(FileObject);
@@ -740,9 +740,9 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
 
     PagingFile->FileHandle = FileHandle;
     PagingFile->FileObject = FileObject;
-    PagingFile->MaximumSize.QuadPart = SafeMaximumSize.QuadPart;
-    PagingFile->CurrentSize.QuadPart = SafeMinimumSize.QuadPart;
-    PagingFile->MinimumSize.QuadPart = SafeMinimumSize.QuadPart;
+    PagingFile->MaximumSize = (SafeMaximumSize.QuadPart >> PAGE_SHIFT);
+    PagingFile->CurrentSize = (SafeMinimumSize.QuadPart >> PAGE_SHIFT);
+    PagingFile->MinimumSize = (SafeMinimumSize.QuadPart >> PAGE_SHIFT);
     PagingFile->FreePages = (ULONG)(SafeMinimumSize.QuadPart / PAGE_SIZE);
     PagingFile->UsedPages = 0;
     PagingFile->PageFileName = PageFileName;