Fixed MmProbeAndLockPages issues pointed out by Philip Susi

svn path=/trunk/; revision=1621
This commit is contained in:
David Welch 2001-02-14 02:53:54 +00:00
parent 07142de752
commit 727b62c27f
12 changed files with 233 additions and 135 deletions

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.15 2001/02/10 22:51:11 dwelch Exp $
/* $Id: create.c,v 1.16 2001/02/14 02:53:54 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -710,7 +710,7 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
while (Cluster != 0xffffffff && Cluster > 1)
{
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster, TRUE);
// WriteCluster (DeviceExt, Cluster, 0);
WriteCluster (DeviceExt, Cluster, 0);
Cluster = NextCluster;
}
}

View file

@ -1,4 +1,4 @@
/* $Id: dirwr.c,v 1.16 2001/01/16 09:55:02 dwelch Exp $
/* $Id: dirwr.c,v 1.17 2001/02/14 02:53:54 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -446,6 +446,8 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
vfat_wcsncpy (newFCB->PathName, PathFileName, MAX_PATH);
newFCB->ObjectName = newFCB->PathName + (PathFileName - FileName);
newFCB->pDevExt = DeviceExt;
pFileObject->Flags |= FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
pFileObject->SectionObjectPointers = &newFCB->SectionObjectPointers;
pFileObject->FsContext = (PVOID)&newFCB->RFCB;
pFileObject->FsContext2 = newCCB;
if (RequestedOptions & FILE_DIRECTORY_FILE)

View file

@ -42,44 +42,6 @@ typedef struct _LOADER_PARAMETER_BLOCK
ULONG BootLoaderName;
} LOADER_PARAMETER_BLOCK, *PLOADER_PARAMETER_BLOCK;
#if 0
typedef struct _LOADER_PARAMETER_BLOCK
{
/*
* Magic value (useless really)
*/
unsigned int magic;
/*
* Cursor position
*/
unsigned int cursorx;
unsigned int cursory;
/*
* Number of files (including the kernel) loaded
*/
unsigned int nr_files;
/*
* Range of physical memory being used by the system
*/
unsigned int start_mem;
unsigned int end_mem;
/*
* List of module lengths (terminated by a 0)
*/
unsigned int module_length[64];
/*
* Kernel parameter string
*/
char kernel_parameters[256];
} LOADER_PARAMETER_BLOCK, *PLOADER_PARAMETER_BLOCK;
#endif
#ifdef __NTOSKRNL__
extern CHAR EXPORTED KeNumberProcessors;
extern LOADER_PARAMETER_BLOCK EXPORTED KeLoaderBlock;

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.7 2001/01/19 15:09:01 dwelch Exp $
# $Id: Makefile,v 1.8 2001/02/14 02:53:52 dwelch Exp $
#
# ReactOS Operating System
#
@ -9,7 +9,8 @@ TARGETNAME = ntoskrnl
OBJECTS_PATH = objects
ASFLAGS = -Iinclude
CFLAGS = -Iinclude -D__NTOSKRNL__ -DDBG -g -Wall -Werror
CFLAGS = -Iinclude -D__NTOSKRNL__ -DDBG -g -Wall -Werror
#CFLAGS += -DDBGPRINT_FILE_LOG
all: \
$(OBJECTS_PATH) \
@ -278,7 +279,8 @@ OBJECTS_CC = \
# Kernel Debugger Support (Kd)
OBJECTS_KD = \
kd/kdebug.o \
kd/service.o
kd/service.o \
kd/dlog.o
# Resources
OBJECTS_RESOURCE = \

View file

@ -248,16 +248,24 @@ NTSTATUS MmPageFault(ULONG Cs,
ULONG Cr2,
ULONG ErrorCode);
NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
ULONG Address);
NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
ULONG Address);
NTSTATUS MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address);
NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address);
NTSTATUS
MmAccessFault(KPROCESSOR_MODE Mode,
ULONG Address,
BOOLEAN FromMdl);
NTSTATUS
MmNotPresentFault(KPROCESSOR_MODE Mode,
ULONG Address,
BOOLEAN FromMdl);
NTSTATUS
MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address,
BOOLEAN Locked);
NTSTATUS
MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address,
BOOLEAN Locked);
NTSTATUS MmWaitForPage(PVOID Page);
VOID MmClearWaitPage(PVOID Page);
VOID MmSetWaitPage(PVOID Page);
@ -355,8 +363,9 @@ MmGetContinuousPages(ULONG NumberOfBytes,
NTSTATUS
MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address);
MEMORY_AREA* MemoryArea,
PVOID Address,
BOOLEAN Locked);
ULONG
MmGetPageProtect(struct _EPROCESS* Process, PVOID Address);
PVOID

View file

@ -1,4 +1,4 @@
/* $Id: kdebug.c,v 1.18 2001/02/10 22:51:09 dwelch Exp $
/* $Id: kdebug.c,v 1.19 2001/02/14 02:53:53 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -117,10 +117,7 @@ KdInitSystem (
p1 = p2;
}
#ifdef DBGPRINT_FILE_LOG
KdpDebugType |= FileLogDebug;
DebugLogInit();
#endif /* DBGPRINT_FILE_LOG */
/* check for 'BAUDRATE' */
p1 = (PCHAR)LoaderBlock->CommandLine;
@ -203,6 +200,10 @@ KdInitSystem (
p1 = p2;
}
#ifdef DBGPRINT_FILE_LOG
KdpDebugType |= FileLogDebug;
DebugLogInit();
#endif /* DBGPRINT_FILE_LOG */
/* print some information */
if (KdDebuggerEnabled == TRUE)
@ -271,12 +272,12 @@ ULONG KdpPrintString (PANSI_STRING String)
pch++;
}
}
#ifdef DEBUGPRINT_LOG_WRITE
#ifdef DBGPRINT_FILE_LOG
if (KdpDebugType & FileLogDebug)
{
DebugLogWrite(String->Buffer);
}
#endif /* DEBUGPRINT_LOG_WRITE */
#endif /* DBGPRINT_FILE_LOG */
return (ULONG)String->Length;
}

View file

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.78 2001/02/10 22:51:09 dwelch Exp $
/* $Id: main.c,v 1.79 2001/02/14 02:53:53 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -574,17 +574,18 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
LdrProcessDriver((PVOID)start, name);
}
}
#ifdef DEBUGPRINT_FILE_LOG
/* On the assumption that we can now access disks start up the debug
logger thread */
DebugLogInit2();
#endif /* DEBUGPRINT_FILE_LOG */
/* Create the SystemRoot symbolic link */
DbgPrint("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine);
CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine);
#ifdef DBGPRINT_FILE_LOG
/* On the assumption that we can now access disks start up the debug
logger thread */
DebugLogInit2();
#endif /* DBGPRINT_FILE_LOG */
CmInitializeRegistry2();
/*

View file

@ -51,11 +51,11 @@ NTSTATUS MmPageFault(ULONG Cs,
if (ErrorCode & 0x1)
{
Status = MmAccessFault(Mode, Cr2);
Status = MmAccessFault(Mode, Cr2, FALSE);
}
else
{
Status = MmNotPresentFault(Mode, Cr2);
Status = MmNotPresentFault(Mode, Cr2, FALSE);
}
if (KeGetCurrentThread() != NULL &&

View file

@ -1,4 +1,4 @@
/* $Id: mdl.c,v 1.28 2001/02/10 22:51:10 dwelch Exp $
/* $Id: mdl.c,v 1.29 2001/02/14 02:53:53 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -174,10 +174,12 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
*/
{
PULONG MdlPages;
ULONG i;
PMEMORY_AREA MArea;
PMADDRESS_SPACE AddressSpace;
ULONG i, j;
ULONG NrPages;
NTSTATUS Status;
KPROCESSOR_MODE Mode;
PEPROCESS CurrentProcess;
DPRINT("MmProbeAndLockPages(Mdl %x)\n", Mdl);
/*
@ -188,44 +190,74 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
return;
}
if (Mdl->StartVa > (PVOID)KERNEL_BASE)
CurrentProcess = PsGetCurrentProcess();
if (Mdl->Process != CurrentProcess)
{
AddressSpace = MmGetKernelAddressSpace();
KeAttachProcess(Mdl->Process);
}
if (Mdl->StartVa >= (PVOID)KERNEL_BASE)
{
Mode = KernelMode;
}
else
{
AddressSpace = &Mdl->Process->AddressSpace;
}
MmLockAddressSpace(AddressSpace);
MArea = MmOpenMemoryAreaByAddress(AddressSpace,
Mdl->StartVa);
/*
* Check the area is valid
*/
if (MArea == NULL)
{
DbgPrint("(%s:%d) Area is invalid\n",__FILE__,__LINE__);
MmUnlockAddressSpace(AddressSpace);
/* FIXME: ExRaiseStatus doesn't do anything sensible at the moment */
ExRaiseStatus(STATUS_INVALID_PARAMETER);
Mode = UserMode;
}
/*
* Lock the pages
*/
MdlPages = (ULONG *)(Mdl + 1);
for (i=0;i<(PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGESIZE);i++)
MmLockAddressSpace(&Mdl->Process->AddressSpace);
MdlPages = (ULONG *)(Mdl + 1);
NrPages = PAGE_ROUND_UP(Mdl->ByteOffset + Mdl->ByteCount) / PAGESIZE;
for (i = 0; i < NrPages; i++)
{
PVOID Address;
Address = Mdl->StartVa + (i*PAGESIZE);
MdlPages[i] = (MmGetPhysicalAddress(Address)).u.LowPart;
Address = Mdl->StartVa + (i*PAGESIZE);
if (!MmIsPagePresent(NULL, Address))
{
Status = MmNotPresentFault(Mode, (ULONG)Address, TRUE);
if (!NT_SUCCESS(Status))
{
for (j = 0; j < i; j++)
{
MmUnlockPage((PVOID)MdlPages[i]);
MmDereferencePage((PVOID)MdlPages[i]);
}
ExRaiseStatus(Status);
}
}
else
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
if ((Operation == IoWriteAccess || Operation == IoModifyAccess) &&
(!(MmGetPageProtect(NULL, (PVOID)Address) & PAGE_READWRITE)))
{
Status = MmAccessFault(Mode, (ULONG)Address, TRUE);
if (!NT_SUCCESS(Status))
{
for (j = 0; j < i; j++)
{
MmUnlockPage((PVOID)MdlPages[i]);
MmDereferencePage((PVOID)MdlPages[i]);
}
ExRaiseStatus(Status);
}
}
MdlPages[i] = MmGetPhysicalAddressForProcess(NULL, Address);
MmReferencePage((PVOID)MdlPages[i]);
MmLockPage((PVOID)MdlPages[i]);
}
MmUnlockAddressSpace(AddressSpace);
MmUnlockAddressSpace(&Mdl->Process->AddressSpace);
if (Mdl->Process != CurrentProcess)
{
KeDetachProcess();
}
Mdl->MdlFlags = Mdl->MdlFlags | MDL_PAGES_LOCKED;
}

View file

@ -1,4 +1,4 @@
/* $Id: mm.c,v 1.41 2001/02/10 22:51:10 dwelch Exp $
/* $Id: mm.c,v 1.42 2001/02/14 02:53:53 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
@ -129,13 +129,15 @@ BOOLEAN STDCALL MmIsAddressValid(PVOID VirtualAddress)
}
NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
ULONG Address)
ULONG Address,
BOOLEAN FromMdl)
{
PMADDRESS_SPACE AddressSpace;
MEMORY_AREA* MemoryArea;
NTSTATUS Status;
BOOLEAN Locked = FromMdl;
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
DPRINT("MmAccessFault(Mode %d, Address %x)\n", Mode, Address);
if (KeGetCurrentIrql() >= DISPATCH_LEVEL)
{
@ -168,12 +170,18 @@ NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
AddressSpace = &PsGetCurrentProcess()->AddressSpace;
}
MmLockAddressSpace(AddressSpace);
if (!FromMdl)
{
MmLockAddressSpace(AddressSpace);
}
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace, (PVOID)Address);
if (MemoryArea == NULL)
{
DbgPrint("%s:%d\n",__FILE__,__LINE__);
MmUnlockAddressSpace(AddressSpace);
if (!FromMdl)
{
MmUnlockAddressSpace(AddressSpace);
}
return(STATUS_UNSUCCESSFUL);
}
@ -186,7 +194,8 @@ NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
case MEMORY_AREA_SECTION_VIEW_COMMIT:
Status = MmAccessFaultSectionView(AddressSpace,
MemoryArea,
(PVOID)Address);
(PVOID)Address,
Locked);
break;
case MEMORY_AREA_VIRTUAL_MEMORY:
@ -202,16 +211,21 @@ NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
break;
}
DPRINT("Completed page fault handling\n");
MmUnlockAddressSpace(AddressSpace);
if (!FromMdl)
{
MmUnlockAddressSpace(AddressSpace);
}
return(Status);
}
NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
ULONG Address)
ULONG Address,
BOOLEAN FromMdl)
{
PMADDRESS_SPACE AddressSpace;
MEMORY_AREA* MemoryArea;
NTSTATUS Status;
BOOLEAN Locked = FromMdl;
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
@ -246,12 +260,18 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
AddressSpace = &PsGetCurrentProcess()->AddressSpace;
}
MmLockAddressSpace(AddressSpace);
if (!FromMdl)
{
MmLockAddressSpace(AddressSpace);
}
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace, (PVOID)Address);
if (MemoryArea == NULL)
{
DbgPrint("%s:%d\n",__FILE__,__LINE__);
MmUnlockAddressSpace(AddressSpace);
if (!FromMdl)
{
MmUnlockAddressSpace(AddressSpace);
}
return(STATUS_UNSUCCESSFUL);
}
@ -264,20 +284,23 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
case MEMORY_AREA_SECTION_VIEW_COMMIT:
Status = MmNotPresentFaultSectionView(AddressSpace,
MemoryArea,
(PVOID)Address);
(PVOID)Address,
Locked);
break;
case MEMORY_AREA_VIRTUAL_MEMORY:
Status = MmNotPresentFaultVirtualMemory(AddressSpace,
MemoryArea,
(PVOID)Address);
(PVOID)Address,
Locked);
break;
case MEMORY_AREA_SHARED_DATA:
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
(PVOID)PAGE_ROUND_DOWN(Address),
PAGE_READONLY,
(ULONG)MmSharedDataPagePhysicalAddress);
Status =
MmCreateVirtualMapping(PsGetCurrentProcess(),
(PVOID)PAGE_ROUND_DOWN(Address),
PAGE_READONLY,
(ULONG)MmSharedDataPagePhysicalAddress);
break;
default:
@ -285,7 +308,10 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
break;
}
DPRINT("Completed page fault handling\n");
MmUnlockAddressSpace(AddressSpace);
if (!FromMdl)
{
MmUnlockAddressSpace(AddressSpace);
}
return(Status);
}

View file

@ -1,4 +1,4 @@
/* $Id: section.c,v 1.45 2001/02/10 22:51:10 dwelch Exp $
/* $Id: section.c,v 1.46 2001/02/14 02:53:53 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -128,7 +128,8 @@ MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace,
PMM_SECTION_SEGMENT Segment,
LARGE_INTEGER Offset,
ULONG Entry,
ULONG Attributes)
ULONG Attributes,
BOOLEAN Locked)
{
PVOID Page;
NTSTATUS Status;
@ -197,6 +198,10 @@ MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace,
*/
if (MmIsPagePresent(NULL, Address))
{
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
return(STATUS_SUCCESS);
@ -222,6 +227,10 @@ MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace,
DbgPrint("Unable to create virtual mapping\n");
KeBugCheck(0);
}
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
@ -231,7 +240,8 @@ MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace,
NTSTATUS
MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address)
PVOID Address,
BOOLEAN Locked)
{
LARGE_INTEGER Offset;
IO_STATUS_BLOCK IoStatus;
@ -257,6 +267,10 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
if (MmIsPagePresent(NULL, Address))
{
DbgPrint("Page is already present\n");
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
return(STATUS_SUCCESS);
}
@ -284,6 +298,10 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
Address,
MemoryArea->Attributes,
Offset.QuadPart);
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
return(STATUS_SUCCESS);
@ -315,6 +333,10 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
Address,
MemoryArea->Attributes,
(ULONG)Page);
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
return(STATUS_SUCCESS);
@ -376,7 +398,8 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
Segment,
Offset,
Entry1,
Attributes));
Attributes,
Locked));
}
else if (Entry1 != 0)
{
@ -392,6 +415,11 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
DbgPrint("Unable to create virtual mapping\n");
KeBugCheck(0);
}
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL,
Address));
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
@ -481,6 +509,10 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
DbgPrint("Unable to create virtual mapping\n");
KeBugCheck(0);
}
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
DPRINT("MmNotPresentFaultSectionView succeeded\n");
@ -496,7 +528,8 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
Segment,
Offset,
Entry,
Attributes));
Attributes,
Locked));
}
else
{
@ -517,6 +550,10 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
DbgPrint("Unable to create virtual mapping\n");
KeBugCheck(0);
}
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
@ -526,8 +563,9 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
NTSTATUS
MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address)
MEMORY_AREA* MemoryArea,
PVOID Address,
BOOLEAN Locked)
{
PMM_SECTION_SEGMENT Segment;
PSECTION_OBJECT Section;
@ -597,6 +635,10 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
DbgPrint("Unable to create virtual mapping\n");
KeBugCheck(0);
}
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
return(STATUS_SUCCESS);

View file

@ -1,4 +1,4 @@
/* $Id: virtual.c,v 1.38 2001/02/10 22:51:10 dwelch Exp $
/* $Id: virtual.c,v 1.39 2001/02/14 02:53:53 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
@ -201,7 +201,8 @@ ULONG MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
NTSTATUS
MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address)
PVOID Address,
BOOLEAN Locked)
/*
* FUNCTION: Move data into memory to satisfy a page not present fault
* ARGUMENTS:
@ -232,7 +233,11 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
if (MmIsPagePresent(NULL, Address))
{
return(STATUS_SUCCESS);
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
return(STATUS_SUCCESS);
}
/*
@ -246,7 +251,12 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
MmLockAddressSpace(AddressSpace);
if (MmIsPagePresent(NULL, Address))
{
return(STATUS_SUCCESS);
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL,
Address));
}
return(STATUS_SUCCESS);
}
Page = MmAllocPage(0);
}
@ -271,20 +281,31 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
MmLockAddressSpace(AddressSpace);
if (MmIsPagePresent(NULL, Address))
{
MmDereferencePage(Page);
return(STATUS_SUCCESS);
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL,
Address));
}
MmDereferencePage(Page);
return(STATUS_SUCCESS);
}
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
Address,
MemoryArea->Attributes,
(ULONG)Page);
}
}
if (!NT_SUCCESS(Status))
{
return(Status);
}
return(STATUS_SUCCESS);
else
{
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
}
return(STATUS_SUCCESS);
}
}
VOID STATIC