diff --git a/reactos/drivers/fs/vfat/create.c b/reactos/drivers/fs/vfat/create.c index b8b63ffeaea..02f1885ba70 100644 --- a/reactos/drivers/fs/vfat/create.c +++ b/reactos/drivers/fs/vfat/create.c @@ -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; } } diff --git a/reactos/drivers/fs/vfat/dirwr.c b/reactos/drivers/fs/vfat/dirwr.c index e4bd9f1c8a6..e1460d87fe8 100644 --- a/reactos/drivers/fs/vfat/dirwr.c +++ b/reactos/drivers/fs/vfat/dirwr.c @@ -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) diff --git a/reactos/include/ddk/ketypes.h b/reactos/include/ddk/ketypes.h index d470042b706..925a954f024 100644 --- a/reactos/include/ddk/ketypes.h +++ b/reactos/include/ddk/ketypes.h @@ -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; diff --git a/reactos/ntoskrnl/Makefile b/reactos/ntoskrnl/Makefile index 3929d250fcf..dabb6ae0089 100644 --- a/reactos/ntoskrnl/Makefile +++ b/reactos/ntoskrnl/Makefile @@ -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 = \ diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index 3acfa2996e7..998fe9fc86d 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -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 diff --git a/reactos/ntoskrnl/kd/kdebug.c b/reactos/ntoskrnl/kd/kdebug.c index 757f9b052cf..137a0cb5f38 100644 --- a/reactos/ntoskrnl/kd/kdebug.c +++ b/reactos/ntoskrnl/kd/kdebug.c @@ -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; } diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index 5d7213e9594..f8642d9b563 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -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(); /* diff --git a/reactos/ntoskrnl/mm/i386/pfault.c b/reactos/ntoskrnl/mm/i386/pfault.c index 99feb83fee6..556e026f510 100644 --- a/reactos/ntoskrnl/mm/i386/pfault.c +++ b/reactos/ntoskrnl/mm/i386/pfault.c @@ -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 && diff --git a/reactos/ntoskrnl/mm/mdl.c b/reactos/ntoskrnl/mm/mdl.c index e1e7a8a02ee..87de1bddb65 100644 --- a/reactos/ntoskrnl/mm/mdl.c +++ b/reactos/ntoskrnl/mm/mdl.c @@ -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; } diff --git a/reactos/ntoskrnl/mm/mm.c b/reactos/ntoskrnl/mm/mm.c index b7049867858..4f3f40289ba 100644 --- a/reactos/ntoskrnl/mm/mm.c +++ b/reactos/ntoskrnl/mm/mm.c @@ -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); } diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 9d4fc371ad6..9f08c663e49 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -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); diff --git a/reactos/ntoskrnl/mm/virtual.c b/reactos/ntoskrnl/mm/virtual.c index 7072727c0d1..3d699b8e655 100644 --- a/reactos/ntoskrnl/mm/virtual.c +++ b/reactos/ntoskrnl/mm/virtual.c @@ -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