From 87e74cda2147f161cd3daf8f6a8405c5352ac428 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 11 Aug 2008 08:40:52 +0000 Subject: [PATCH] - NDK Fix: DirectoryTableBase member of KPROCESS is ULONG[2] and not LARGE_INTEGER since Windows 2000 ("Inside Windows 2000", Chapter 6), and till Windows 2003. svn path=/trunk/; revision=35269 --- reactos/include/ndk/ketypes.h | 2 +- reactos/ntoskrnl/include/internal/ke.h | 2 +- reactos/ntoskrnl/include/internal/mm.h | 4 +-- reactos/ntoskrnl/ke/i386/kiinit.c | 7 ++--- reactos/ntoskrnl/ke/procobj.c | 5 ++-- reactos/ntoskrnl/mm/i386/page.c | 37 ++++++++++++-------------- reactos/ntoskrnl/mm/mminit.c | 6 ++--- reactos/ntoskrnl/ps/process.c | 8 +++--- 8 files changed, 35 insertions(+), 36 deletions(-) diff --git a/reactos/include/ndk/ketypes.h b/reactos/include/ndk/ketypes.h index ea91b01da36..f7b7b9a3f33 100644 --- a/reactos/include/ndk/ketypes.h +++ b/reactos/include/ndk/ketypes.h @@ -955,7 +955,7 @@ typedef struct _KPROCESS ULONG DirectoryTableBase; ULONG Unused0; #else - LARGE_INTEGER DirectoryTableBase; + ULONG DirectoryTableBase[2]; #endif #if defined(_M_IX86) KGDTENTRY LdtDescriptor; diff --git a/reactos/ntoskrnl/include/internal/ke.h b/reactos/ntoskrnl/include/internal/ke.h index d3f2a5f5efe..4dfb18a0e62 100644 --- a/reactos/ntoskrnl/include/internal/ke.h +++ b/reactos/ntoskrnl/include/internal/ke.h @@ -537,7 +537,7 @@ KeInitializeProcess( struct _KPROCESS *Process, KPRIORITY Priority, KAFFINITY Affinity, - PLARGE_INTEGER DirectoryTableBase, + PULONG DirectoryTableBase, IN BOOLEAN Enable ); diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index fb3ef149bf2..49b336ca92c 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -1275,14 +1275,14 @@ NTAPI MmCreateProcessAddressSpace( IN ULONG MinWs, IN PEPROCESS Dest, - IN PLARGE_INTEGER DirectoryTableBase + IN PULONG DirectoryTableBase ); NTSTATUS NTAPI MmInitializeHandBuiltProcess( IN PEPROCESS Process, - IN PLARGE_INTEGER DirectoryTableBase + IN PULONG DirectoryTableBase ); diff --git a/reactos/ntoskrnl/ke/i386/kiinit.c b/reactos/ntoskrnl/ke/i386/kiinit.c index 3ec1695aa3e..a87d09638f7 100644 --- a/reactos/ntoskrnl/ke/i386/kiinit.c +++ b/reactos/ntoskrnl/ke/i386/kiinit.c @@ -391,7 +391,7 @@ KiInitializeKernel(IN PKPROCESS InitProcess, { BOOLEAN NpxPresent; ULONG FeatureBits; - LARGE_INTEGER PageDirectory; + ULONG PageDirectory[2]; PVOID DpcStack; ULONG Vendor[3]; @@ -503,11 +503,12 @@ KiInitializeKernel(IN PKPROCESS InitProcess, /* Initialize the Idle Process and the Process Listhead */ InitializeListHead(&KiProcessListHead); - PageDirectory.QuadPart = 0; + PageDirectory[0] = 0; + PageDirectory[1] = 0; KeInitializeProcess(InitProcess, 0, 0xFFFFFFFF, - &PageDirectory, + PageDirectory, FALSE); InitProcess->QuantumReset = MAXCHAR; } diff --git a/reactos/ntoskrnl/ke/procobj.c b/reactos/ntoskrnl/ke/procobj.c index 87826d3dd74..114554b1fb1 100644 --- a/reactos/ntoskrnl/ke/procobj.c +++ b/reactos/ntoskrnl/ke/procobj.c @@ -115,7 +115,7 @@ NTAPI KeInitializeProcess(IN OUT PKPROCESS Process, IN KPRIORITY Priority, IN KAFFINITY Affinity, - IN PLARGE_INTEGER DirectoryTableBase, + IN PULONG DirectoryTableBase, IN BOOLEAN Enable) { #ifdef CONFIG_SMP @@ -134,7 +134,8 @@ KeInitializeProcess(IN OUT PKPROCESS Process, Process->Affinity = Affinity; Process->BasePriority = (CHAR)Priority; Process->QuantumReset = 6; - Process->DirectoryTableBase = *DirectoryTableBase; + Process->DirectoryTableBase[0] = DirectoryTableBase[0]; + Process->DirectoryTableBase[1] = DirectoryTableBase[1]; Process->AutoAlignment = Enable; #if defined(_M_IX86) Process->IopmOffset = KiComputeIopmOffset(IO_ACCESS_MAP_NONE); diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index 1fcba4f853e..36713e7deac 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -162,7 +162,7 @@ Mmi386ReleaseMmInfo(PEPROCESS Process) ExFreePool((PVOID) LdtBase); } - PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart)); + PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0])); for (i = 0; i < ADDR_TO_PDE_OFFSET(MmSystemRangeStart); i++) { if (PageDir[i] != 0) @@ -173,16 +173,11 @@ Mmi386ReleaseMmInfo(PEPROCESS Process) } MmReleasePageMemoryConsumer(MC_NPPOOL, PTE_TO_PFN(PageDir[ADDR_TO_PDE_OFFSET(HYPERSPACE)])); MmDeleteHyperspaceMapping(PageDir); - MmReleasePageMemoryConsumer(MC_NPPOOL, PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart)); - -#if defined(__GNUC__) - - Process->Pcb.DirectoryTableBase.QuadPart = 0LL; -#else - - Process->Pcb.DirectoryTableBase.QuadPart = 0; -#endif - + MmReleasePageMemoryConsumer(MC_NPPOOL, PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0])); + + Process->Pcb.DirectoryTableBase[0] = 0; + Process->Pcb.DirectoryTableBase[1] = 0; + DPRINT("Finished Mmi386ReleaseMmInfo()\n"); return(STATUS_SUCCESS); } @@ -190,15 +185,16 @@ Mmi386ReleaseMmInfo(PEPROCESS Process) NTSTATUS NTAPI MmInitializeHandBuiltProcess(IN PEPROCESS Process, - IN PLARGE_INTEGER DirectoryTableBase) + IN PULONG DirectoryTableBase) { /* Share the directory base with the idle process */ - *DirectoryTableBase = PsGetCurrentProcess()->Pcb.DirectoryTableBase; - + DirectoryTableBase[0] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[0]; + DirectoryTableBase[1] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[1]; + /* Initialize the Addresss Space */ KeInitializeGuardedMutex(&Process->AddressCreationLock); Process->VadRoot.BalancedRoot.u1.Parent = NULL; - + /* The process now has an address space */ Process->HasAddressSpace = TRUE; return STATUS_SUCCESS; @@ -208,7 +204,7 @@ BOOLEAN STDCALL MmCreateProcessAddressSpace(IN ULONG MinWs, IN PEPROCESS Process, - IN PLARGE_INTEGER DirectoryTableBase) + IN PULONG DirectoryTableBase) { NTSTATUS Status; ULONG i, j; @@ -243,8 +239,9 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, MmDeleteHyperspaceMapping(PageDirectory); - DirectoryTableBase->QuadPart = PFN_TO_PTE(Pfn[0]); - DPRINT("Finished MmCopyMmInfo(): %I64x\n", DirectoryTableBase->QuadPart); + DirectoryTableBase[0] = PFN_TO_PTE(Pfn[0]); + DirectoryTableBase[1] = 0; + DPRINT("Finished MmCopyMmInfo(): 0x%x\n", DirectoryTableBase[0]); return TRUE; } @@ -329,7 +326,7 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) if (Address < MmSystemRangeStart && Process && Process != PsGetCurrentProcess()) { - PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.LowPart)); + PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0])); if (PageDir == NULL) { KEBUGCHECK(0); @@ -1286,7 +1283,7 @@ MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size) if (Process != NULL && Process != PsGetCurrentProcess()) { - Pde = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart)); + Pde = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0])); } else { diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index b606a086a3b..54634da983a 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -368,13 +368,13 @@ NTAPI MmInit1(VOID) { PLDR_DATA_TABLE_ENTRY LdrEntry; - LARGE_INTEGER Dummy; + ULONG Dummy[2]; /* Dump memory descriptors */ if (MiDbgEnableMdDump) MiDbgDumpMemoryDescriptors(); /* Set the page directory */ - PsGetCurrentProcess()->Pcb.DirectoryTableBase.LowPart = (ULONG)MmGetPageDirectory(); + PsGetCurrentProcess()->Pcb.DirectoryTableBase[0] = (ULONG)MmGetPageDirectory(); /* Get the size of FreeLDR's image allocations */ MmBootImageSize = KeLoaderBlock->Extension->LoaderPagesSpanned; @@ -396,7 +396,7 @@ MmInit1(VOID) DbgPrint("Used memory %dKb\n", (MmNumberOfPhysicalPages * PAGE_SIZE) / 1024); /* Initialize the kernel address space */ - MmInitializeHandBuiltProcess(PsGetCurrentProcess(), &Dummy); + MmInitializeHandBuiltProcess(PsGetCurrentProcess(), Dummy); MmKernelAddressSpace = MmGetCurrentAddressSpace(); MmInitGlobalKernelPageDirectory(); diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index 035efcc02d8..3e549ff9bd8 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -365,7 +365,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, PDEBUG_OBJECT DebugObject; PSECTION_OBJECT SectionObject; NTSTATUS Status, AccessStatus; - PHYSICAL_ADDRESS DirectoryTableBase = {{0}}; + ULONG DirectoryTableBase[2] = {0,0}; KAFFINITY Affinity; HANDLE_TABLE_ENTRY CidEntry; PETHREAD CurrentThread = PsGetCurrentThread(); @@ -562,7 +562,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, /* Create the address space for the child */ if (!MmCreateProcessAddressSpace(MinWs, Process, - &DirectoryTableBase)) + DirectoryTableBase)) { /* Failed */ Status = STATUS_INSUFFICIENT_RESOURCES; @@ -573,7 +573,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, { /* Otherwise, we are the boot process, we're already semi-initialized */ Process->ObjectTable = CurrentProcess->ObjectTable; - Status = MmInitializeHandBuiltProcess(Process, &DirectoryTableBase); + Status = MmInitializeHandBuiltProcess(Process, DirectoryTableBase); if (!NT_SUCCESS(Status)) goto CleanupWithRef; } @@ -587,7 +587,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, KeInitializeProcess(&Process->Pcb, PROCESS_PRIORITY_NORMAL, Affinity, - &DirectoryTableBase, + DirectoryTableBase, (BOOLEAN)(Process->DefaultHardErrorProcessing & 4)); /* Duplicate Parent Token */