Revert part of r20493. Created bug 1229 to keep track of the issue.
[reactos.git] / reactos / ntoskrnl / mm / pagefile.c
index 887c5f4..5cccff8 100644 (file)
@@ -1,11 +1,28 @@
-/* $Id$
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
  *
- * COPYRIGHT:       See COPYING in the top level directory
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/*
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/mm/pagefile.c
  * PURPOSE:         Paging file functions
- * 
- * PROGRAMMERS:     David Welch (welch@mcmail.com)
+ * PROGRAMMER:      David Welch (welch@mcmail.com)
+ * UPDATE HISTORY:
+ *                  Created 22/05/98
  */
 
 /* INCLUDES *****************************************************************/
 #define NDEBUG
 #include <internal/debug.h>
 
+#if defined (ALLOC_PRAGMA)
+#pragma alloc_text(INIT, MmInitPagingFile)
+#endif
+
+
 /* TYPES *********************************************************************/
 
 typedef struct _PAGINGFILE
@@ -27,14 +49,14 @@ typedef struct _PAGINGFILE
    PULONG AllocMap;
    KSPIN_LOCK AllocMapLock;
    ULONG AllocMapSize;
-   PGET_RETRIEVAL_DESCRIPTOR RetrievalPointers;
+   PRETRIEVAL_POINTERS_BUFFER RetrievalPointers;
 }
 PAGINGFILE, *PPAGINGFILE;
 
 typedef struct _RETRIEVEL_DESCRIPTOR_LIST
 {
    struct _RETRIEVEL_DESCRIPTOR_LIST* Next;
-   GET_RETRIEVAL_DESCRIPTOR RetrievalPointers;
+   RETRIEVAL_POINTERS_BUFFER RetrievalPointers;
 }
 RETRIEVEL_DESCRIPTOR_LIST, *PRETRIEVEL_DESCRIPTOR_LIST;
 
@@ -60,7 +82,7 @@ ULONG MiFreeSwapPages;
 ULONG MiUsedSwapPages;
 
 /*
- * Number of pages that have been reserved for swapping but not yet allocated 
+ * Number of pages that have been reserved for swapping but not yet allocated
  */
 static ULONG MiReservedSwapPages;
 
@@ -99,7 +121,25 @@ static BOOLEAN MmSwapSpaceMessage = FALSE;
 
 /* FUNCTIONS *****************************************************************/
 
+BOOLEAN
+STDCALL
+MmIsFileAPagingFile(PFILE_OBJECT FileObject)
+{
+    ULONG i;
+
+    /* Loop through all the paging files */
+    for (i = 0; i < MiPagingFileCount; i++)
+    {
+        /* Check if this is one of them */
+        if (PagingFileList[i]->FileObject == FileObject) return TRUE;
+    }
+
+    /* Nothing found */
+    return FALSE;
+}
+
 VOID
+NTAPI
 MmShowOutOfSpaceMessagePagingFile(VOID)
 {
    if (!MmSwapSpaceMessage)
@@ -110,27 +150,27 @@ MmShowOutOfSpaceMessagePagingFile(VOID)
 }
 
 LARGE_INTEGER STATIC
-MmGetOffsetPageFile(PGET_RETRIEVAL_DESCRIPTOR RetrievalPointers, LARGE_INTEGER Offset)
+MmGetOffsetPageFile(PRETRIEVAL_POINTERS_BUFFER RetrievalPointers, LARGE_INTEGER Offset)
 {
    /* Simple binary search */
    ULONG first, last, mid;
    first = 0;
-   last = RetrievalPointers->NumberOfPairs - 1;
+   last = RetrievalPointers->ExtentCount - 1;
    while (first <= last)
    {
       mid = (last - first) / 2 + first;
-      if ((ULONGLONG) Offset.QuadPart < RetrievalPointers->Pair[mid].Vcn)
+      if (Offset.QuadPart < RetrievalPointers->Extents[mid].NextVcn.QuadPart)
       {
          if (mid == 0)
          {
-            Offset.QuadPart += RetrievalPointers->Pair[0].Lcn - RetrievalPointers->StartVcn;
+            Offset.QuadPart += RetrievalPointers->Extents[0].Lcn.QuadPart - RetrievalPointers->StartingVcn.QuadPart;
             return Offset;
          }
          else
          {
-            if ((ULONGLONG) Offset.QuadPart >= RetrievalPointers->Pair[mid-1].Vcn)
+            if (Offset.QuadPart >= RetrievalPointers->Extents[mid-1].NextVcn.QuadPart)
             {
-               Offset.QuadPart += RetrievalPointers->Pair[mid].Lcn  - RetrievalPointers->Pair[mid-1].Vcn;
+               Offset.QuadPart += RetrievalPointers->Extents[mid].Lcn.QuadPart - RetrievalPointers->Extents[mid-1].NextVcn.QuadPart;
                return Offset;
             }
             last = mid - 1;
@@ -138,13 +178,13 @@ MmGetOffsetPageFile(PGET_RETRIEVAL_DESCRIPTOR RetrievalPointers, LARGE_INTEGER O
       }
       else
       {
-         if (mid == RetrievalPointers->NumberOfPairs - 1)
+         if (mid == RetrievalPointers->ExtentCount - 1)
          {
             break;
          }
-         if ((ULONGLONG) Offset.QuadPart < RetrievalPointers->Pair[mid+1].Vcn)
+         if (Offset.QuadPart < RetrievalPointers->Extents[mid+1].NextVcn.QuadPart)
          {
-            Offset.QuadPart += RetrievalPointers->Pair[mid+1].Lcn  - RetrievalPointers->Pair[mid].Vcn;
+            Offset.QuadPart += RetrievalPointers->Extents[mid+1].Lcn.QuadPart  - RetrievalPointers->Extents[mid].NextVcn.QuadPart;
             return Offset;
          }
          first = mid + 1;
@@ -166,7 +206,9 @@ MmGetOffsetPageFile(PGET_RETRIEVAL_DESCRIPTOR RetrievalPointers, LARGE_INTEGER O
 #endif
 }
 
-NTSTATUS MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
+NTSTATUS
+NTAPI
+MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
 {
    ULONG i, offset;
    LARGE_INTEGER file_offset;
@@ -206,21 +248,23 @@ NTSTATUS MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
    file_offset = MmGetOffsetPageFile(PagingFileList[i]->RetrievalPointers, file_offset);
 
    KeInitializeEvent(&Event, NotificationEvent, FALSE);
-   Status = IoPageWrite(PagingFileList[i]->FileObject,
-                        Mdl,
-                        &file_offset,
-                        &Event,
-                        &Iosb);
+   Status = IoSynchronousPageWrite(PagingFileList[i]->FileObject,
+                                   Mdl,
+                                   &file_offset,
+                                   &Event,
+                                   &Iosb);
    if (Status == STATUS_PENDING)
    {
       KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
       Status = Iosb.Status;
    }
-   MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);            
+   MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
    return(Status);
 }
 
-NTSTATUS MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
+NTSTATUS
+NTAPI
+MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
 {
    ULONG i, offset;
    LARGE_INTEGER file_offset;
@@ -270,11 +314,13 @@ NTSTATUS MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
       KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
       Status = Iosb.Status;
    }
-   MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);            
+   MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
    return(Status);
 }
 
-VOID INIT_FUNCTION
+VOID
+INIT_FUNCTION
+NTAPI
 MmInitPagingFile(VOID)
 {
    ULONG i;
@@ -309,6 +355,7 @@ MmInitPagingFile(VOID)
 }
 
 BOOLEAN
+NTAPI
 MmReserveSwapPages(ULONG Nr)
 {
    KIRQL oldIrql;
@@ -328,6 +375,7 @@ MmReserveSwapPages(ULONG Nr)
 }
 
 VOID
+NTAPI
 MmDereserveSwapPages(ULONG Nr)
 {
    KIRQL oldIrql;
@@ -365,6 +413,7 @@ MiAllocPageFromPagingFile(PPAGINGFILE PagingFile)
 }
 
 VOID
+NTAPI
 MmFreeSwapPage(SWAPENTRY Entry)
 {
    ULONG i;
@@ -373,7 +422,7 @@ MmFreeSwapPage(SWAPENTRY Entry)
 
    i = FILE_FROM_ENTRY(Entry);
    off = OFFSET_FROM_ENTRY(Entry);
-   
+
    if (i >= MAX_PAGING_FILES)
    {
        DPRINT1("Bad swap entry 0x%.8X\n", Entry);
@@ -386,9 +435,9 @@ MmFreeSwapPage(SWAPENTRY Entry)
       KEBUGCHECK(0);
    }
    KeAcquireSpinLockAtDpcLevel(&PagingFileList[i]->AllocMapLock);
-   
+
    PagingFileList[i]->AllocMap[off >> 5] &= (~(1 << (off % 32)));
-   
+
    PagingFileList[i]->FreePages++;
    PagingFileList[i]->UsedPages--;
 
@@ -400,12 +449,14 @@ MmFreeSwapPage(SWAPENTRY Entry)
 }
 
 BOOLEAN
+NTAPI
 MmIsAvailableSwapPage(VOID)
 {
    return(MiFreeSwapPages > 0);
 }
 
 SWAPENTRY
+NTAPI
 MmAllocSwapPage(VOID)
 {
    KIRQL oldIrql;
@@ -453,7 +504,7 @@ MmAllocRetrievelDescriptorList(ULONG Pairs)
    ULONG Size;
    PRETRIEVEL_DESCRIPTOR_LIST RetDescList;
 
-   Size = sizeof(RETRIEVEL_DESCRIPTOR_LIST) + Pairs * sizeof(MAPPING_PAIR);
+   Size = sizeof(RETRIEVEL_DESCRIPTOR_LIST) + Pairs * 2 * sizeof(LARGE_INTEGER);
    RetDescList = ExAllocatePool(NonPagedPool, Size);
    if (RetDescList)
    {
@@ -480,7 +531,7 @@ MmDumpToPagingFile(ULONG BugCode,
    PULONG MdlMap;
    LONGLONG NextOffset = 0;
    ULONG i;
-   PGET_RETRIEVAL_DESCRIPTOR RetrievalPointers;
+   PRETRIEVAL_POINTERS_BUFFER RetrievalPointers;
    LARGE_INTEGER DiskOffset;
 
    if (MmCoreDumpPageFile == 0xFFFFFFFF)
@@ -497,7 +548,7 @@ MmDumpToPagingFile(ULONG BugCode,
    Headers->Type = MmCoreDumpType;
    if (TrapFrame != NULL)
    {
-      if (!(TrapFrame->Eflags & (1 << 17)))
+      if (!(TrapFrame->EFlags & (1 << 17)))
       {
          memcpy(&Headers->TrapFrame, TrapFrame,
                 sizeof(KTRAP_FRAME) - (4 * sizeof(DWORD)));
@@ -567,7 +618,7 @@ MmDumpToPagingFile(ULONG BugCode,
       for (i = 0; i < MmStats.NrTotalPages; i++)
       {
          MdlMap[0] = i;
-         MmCreateVirtualMappingForKernel(MmCoreDumpPageFrame, 
+         MmCreateVirtualMappingForKernel(MmCoreDumpPageFrame,
                                         PAGE_READWRITE,
                                          MdlMap,
                                         1);
@@ -613,10 +664,10 @@ MmInitializeCrashDump(HANDLE PageFileHandle, ULONG PageFileNum)
    PIRP Irp;
    KEVENT Event;
    IO_STATUS_BLOCK Iosb;
-   UNICODE_STRING DiskDumpName;
+   UNICODE_STRING DiskDumpName = RTL_CONSTANT_STRING(L"DiskDump");
    ANSI_STRING ProcName;
    PIO_STACK_LOCATION StackPtr;
-   PMODULE_OBJECT ModuleObject;
+   PLDR_DATA_TABLE_ENTRY ModuleObject;
 
    Status = ZwFsControlFile(PageFileHandle,
                             0,
@@ -660,7 +711,7 @@ MmInitializeCrashDump(HANDLE PageFileHandle, ULONG PageFileNum)
                                        FALSE,
                                        &Event,
                                        &Iosb);
-   if(Irp == NULL) 
+   if(Irp == NULL)
    {
       ObDereferenceObject(PageFile);
       return(STATUS_NO_MEMORY);// tMk - is this correct return code ???
@@ -689,14 +740,13 @@ MmInitializeCrashDump(HANDLE PageFileHandle, ULONG PageFileNum)
    }
 
    /* Load the diskdump driver. */
-   RtlRosInitUnicodeStringFromLiteral(&DiskDumpName, L"DiskDump");
    ModuleObject = LdrGetModuleObject(&DiskDumpName);
    if (ModuleObject == NULL)
    {
       return(STATUS_OBJECT_NAME_NOT_FOUND);
    }
    RtlInitAnsiString(&ProcName, "DiskDumpFunctions");
-   Status = LdrGetProcedureAddress(ModuleObject->Base,
+   Status = LdrGetProcedureAddress(ModuleObject->DllBase,
                                    &ProcName,
                                    0,
                                    (PVOID*)&MmCoreDumpFunctions);
@@ -726,6 +776,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
                    IN PLARGE_INTEGER MaximumSize,
                    IN ULONG Reserved)
 {
+   NTSTATUS Status;
    OBJECT_ATTRIBUTES ObjectAttributes;
    HANDLE FileHandle;
    IO_STATUS_BLOCK IoStatus;
@@ -740,13 +791,12 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
    ULONG BytesPerAllocationUnit;
    LARGE_INTEGER Vcn;
    ULONG ExtentCount;
-   ULONG MaxVcn;
+   LARGE_INTEGER MaxVcn;
    ULONG Count;
    ULONG Size;
    KPROCESSOR_MODE PreviousMode;
    UNICODE_STRING CapturedFileName;
    LARGE_INTEGER SafeInitialSize, SafeMaximumSize;
-   NTSTATUS Status = STATUS_SUCCESS;
 
    DPRINT("NtCreatePagingFile(FileName %wZ, InitialSize %I64d)\n",
           FileName, InitialSize->QuadPart);
@@ -758,25 +808,19 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
 
    PreviousMode = ExGetPreviousMode();
 
-   if (PreviousMode == UserMode)
+   if (PreviousMode != KernelMode)
    {
       _SEH_TRY
       {
-         ProbeForRead(InitialSize,
-                      sizeof(LARGE_INTEGER),
-                      sizeof(ULONG));
-         SafeInitialSize = *InitialSize;
-         ProbeForRead(MaximumSize,
-                      sizeof(LARGE_INTEGER),
-                      sizeof(ULONG));
-         SafeMaximumSize = *MaximumSize;
+         SafeInitialSize = ProbeForReadLargeInteger(InitialSize);
+         SafeMaximumSize = ProbeForReadLargeInteger(MaximumSize);
       }
       _SEH_HANDLE
       {
          Status = _SEH_GetExceptionCode();
       }
       _SEH_END;
-    
+
       if (!NT_SUCCESS(Status))
       {
          return Status;
@@ -787,12 +831,25 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
       SafeInitialSize = *InitialSize;
       SafeMaximumSize = *MaximumSize;
    }
-   
-   Status = RtlCaptureUnicodeString(&CapturedFileName,
-                                    PreviousMode,
-                                    PagedPool,
-                                    FALSE,
-                                    FileName);
+
+   /* Pagefiles can't be larger than 4GB and ofcourse the minimum should be
+      smaller than the maximum */
+   if (0 != SafeInitialSize.u.HighPart)
+   {
+      return STATUS_INVALID_PARAMETER_2;
+   }
+   if (0 != SafeMaximumSize.u.HighPart)
+   {
+      return STATUS_INVALID_PARAMETER_3;
+   }
+   if (SafeMaximumSize.u.LowPart < SafeInitialSize.u.LowPart)
+   {
+      return STATUS_INVALID_PARAMETER_MIX;
+   }
+
+   Status = ProbeAndCaptureUnicodeString(&CapturedFileName,
+                                         PreviousMode,
+                                         FileName);
    if (!NT_SUCCESS(Status))
    {
       return(Status);
@@ -818,9 +875,9 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
                          CreateFileTypeNone,
                          NULL,
                          SL_OPEN_PAGING_FILE | IO_NO_PARAMETER_CHECKING);
-   RtlReleaseCapturedUnicodeString(&CapturedFileName,
-                                   PreviousMode,
-                                   FALSE);
+
+   ReleaseCapturedUnicodeString(&CapturedFileName,
+                                PreviousMode);
    if (!NT_SUCCESS(Status))
    {
       return(Status);
@@ -837,9 +894,17 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
       return Status;
    }
 
-   BytesPerAllocationUnit = FsSizeInformation.SectorsPerAllocationUnit * FsSizeInformation.BytesPerSector;
+   BytesPerAllocationUnit = FsSizeInformation.SectorsPerAllocationUnit *
+                            FsSizeInformation.BytesPerSector;
+   /* FIXME: If we have 2048 BytesPerAllocationUnit (FAT16 < 128MB) there is
+    * a problem if the paging file is fragmented. Suppose the first cluster
+    * 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
+    * bytes) to the physical location of cluster 3042 then. */
    if (BytesPerAllocationUnit % PAGE_SIZE)
    {
+      DPRINT1("BytesPerAllocationUnit %d is not a multiple of PAGE_SIZE %d\n",
+              BytesPerAllocationUnit, PAGE_SIZE);
       ZwClose(FileHandle);
       return STATUS_UNSUCCESSFUL;
    }
@@ -884,7 +949,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
 #endif
 
    ExtentCount = 0;
-   MaxVcn = (ULONG)((SafeInitialSize.QuadPart + BytesPerAllocationUnit - 1) / BytesPerAllocationUnit);
+   MaxVcn.QuadPart = (SafeInitialSize.QuadPart + BytesPerAllocationUnit - 1) / BytesPerAllocationUnit;
    while(1)
    {
       Status = ZwFsControlFile(FileHandle,
@@ -896,7 +961,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
                                &Vcn,
                                sizeof(LARGE_INTEGER),
                                &CurrentRetDescList->RetrievalPointers,
-                               sizeof(GET_RETRIEVAL_DESCRIPTOR) + PAIRS_PER_RUN * sizeof(MAPPING_PAIR));
+                               sizeof(RETRIEVAL_POINTERS_BUFFER) + PAIRS_PER_RUN * 2 * sizeof(LARGE_INTEGER));
       if (!NT_SUCCESS(Status))
       {
          while (RetDescList)
@@ -909,8 +974,8 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
          ZwClose(FileHandle);
          return(Status);
       }
-      ExtentCount += CurrentRetDescList->RetrievalPointers.NumberOfPairs;
-      if ((ULONG)CurrentRetDescList->RetrievalPointers.Pair[CurrentRetDescList->RetrievalPointers.NumberOfPairs-1].Vcn < MaxVcn)
+      ExtentCount += CurrentRetDescList->RetrievalPointers.ExtentCount;
+      if (CurrentRetDescList->RetrievalPointers.Extents[CurrentRetDescList->RetrievalPointers.ExtentCount-1].NextVcn.QuadPart < MaxVcn.QuadPart)
       {
          CurrentRetDescList->Next = MmAllocRetrievelDescriptorList(PAIRS_PER_RUN);
          if (CurrentRetDescList->Next == NULL)
@@ -925,7 +990,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
             ZwClose(FileHandle);
             return(STATUS_NO_MEMORY);
          }
-         Vcn.QuadPart = CurrentRetDescList->RetrievalPointers.Pair[CurrentRetDescList->RetrievalPointers.NumberOfPairs-1].Vcn;
+         Vcn = CurrentRetDescList->RetrievalPointers.Extents[CurrentRetDescList->RetrievalPointers.ExtentCount-1].NextVcn;
          CurrentRetDescList = CurrentRetDescList->Next;
       }
       else
@@ -976,7 +1041,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
       return(STATUS_NO_MEMORY);
    }
    DPRINT("ExtentCount: %d\n", ExtentCount);
-   Size = sizeof(GET_RETRIEVAL_DESCRIPTOR) + ExtentCount * sizeof(MAPPING_PAIR);
+   Size = sizeof(RETRIEVAL_POINTERS_BUFFER) + ExtentCount * 2 * sizeof(LARGE_INTEGER);
    PagingFile->RetrievalPointers = ExAllocatePool(NonPagedPool, Size);
    if (PagingFile->RetrievalPointers == NULL)
    {
@@ -997,22 +1062,22 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
    RtlZeroMemory(PagingFile->RetrievalPointers, Size);
 
    Count = 0;
-   PagingFile->RetrievalPointers->NumberOfPairs = ExtentCount;
-   PagingFile->RetrievalPointers->StartVcn = RetDescList->RetrievalPointers.StartVcn;
+   PagingFile->RetrievalPointers->ExtentCount = ExtentCount;
+   PagingFile->RetrievalPointers->StartingVcn = RetDescList->RetrievalPointers.StartingVcn;
    CurrentRetDescList = RetDescList;
    while (CurrentRetDescList)
    {
-      memcpy(&PagingFile->RetrievalPointers->Pair[Count],
-             CurrentRetDescList->RetrievalPointers.Pair,
-             CurrentRetDescList->RetrievalPointers.NumberOfPairs * sizeof(MAPPING_PAIR));
-      Count += CurrentRetDescList->RetrievalPointers.NumberOfPairs;
+      memcpy(&PagingFile->RetrievalPointers->Extents[Count],
+             CurrentRetDescList->RetrievalPointers.Extents,
+             CurrentRetDescList->RetrievalPointers.ExtentCount * 2 * sizeof(LARGE_INTEGER));
+      Count += CurrentRetDescList->RetrievalPointers.ExtentCount;
       RetDescList = CurrentRetDescList;
       CurrentRetDescList = CurrentRetDescList->Next;
       ExFreePool(RetDescList);
    }
 
-   if (PagingFile->RetrievalPointers->NumberOfPairs != ExtentCount ||
-         (ULONG)PagingFile->RetrievalPointers->Pair[ExtentCount - 1].Vcn != MaxVcn)
+   if (PagingFile->RetrievalPointers->ExtentCount != ExtentCount ||
+         PagingFile->RetrievalPointers->Extents[ExtentCount - 1].NextVcn.QuadPart != MaxVcn.QuadPart)
    {
       ExFreePool(PagingFile->RetrievalPointers);
       ExFreePool(PagingFile->AllocMap);
@@ -1025,11 +1090,11 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
    /*
     * Change the entries from lcn's to volume offset's.
     */
-   PagingFile->RetrievalPointers->StartVcn *= BytesPerAllocationUnit;
+   PagingFile->RetrievalPointers->StartingVcn.QuadPart *= BytesPerAllocationUnit;
    for (i = 0; i < ExtentCount; i++)
    {
-      PagingFile->RetrievalPointers->Pair[i].Lcn *= BytesPerAllocationUnit;
-      PagingFile->RetrievalPointers->Pair[i].Vcn *= BytesPerAllocationUnit;
+      PagingFile->RetrievalPointers->Extents[i].Lcn.QuadPart *= BytesPerAllocationUnit;
+      PagingFile->RetrievalPointers->Extents[i].NextVcn.QuadPart *= BytesPerAllocationUnit;
    }
 
    KeAcquireSpinLock(&PagingFileListLock, &oldIrql);