https://git.reactos.org/?p=reactos.git;a=commitdiff;h=57e8684bc60e9cf54105e0dcf6c3a13a621cde41
commit 57e8684bc60e9cf54105e0dcf6c3a13a621cde41 Author: Jérôme Gardou <jerome.gar...@reactos.org> AuthorDate: Fri Jan 22 09:31:34 2021 +0100 Commit: Jérôme Gardou <jerome.gar...@reactos.org> CommitDate: Fri Jan 22 09:32:36 2021 +0100 [NTOS:MM] Allow "creating" a PDE in legacy Mm for foreign process --- ntoskrnl/mm/i386/page.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c index 336e65a3c45..83c52423d5a 100644 --- a/ntoskrnl/mm/i386/page.c +++ b/ntoskrnl/mm/i386/page.c @@ -219,10 +219,6 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) PMMPDE PdeBase; ULONG PdeOffset = MiGetPdeOffset(Address); - /* Nobody but page fault should ask for creating the PDE, - * Which imples that Process is the current one */ - ASSERT(Create == FALSE); - PdeBase = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0])); if (PdeBase == NULL) { @@ -231,13 +227,32 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) PointerPde = PdeBase + PdeOffset; if (PointerPde->u.Hard.Valid == 0) { - MmDeleteHyperspaceMapping(PdeBase); - return NULL; - } - else - { - Pfn = PointerPde->u.Hard.PageFrameNumber; + KAPC_STATE ApcState; + NTSTATUS Status; + + if (!Create) + { + MmDeleteHyperspaceMapping(PdeBase); + return NULL; + } + + KeStackAttachProcess(&Process->Pcb, &ApcState); + + Status = MiDispatchFault(0x1, + MiAddressToPte(Address), + MiAddressToPde(Address), + NULL, + FALSE, + Process, + NULL, + NULL); + + KeUnstackDetachProcess(&ApcState); + if (!NT_SUCCESS(Status)) + return NULL; } + + Pfn = PointerPde->u.Hard.PageFrameNumber; MmDeleteHyperspaceMapping(PdeBase); Pt = MmCreateHyperspaceMapping(Pfn); if (Pt == NULL)