From ff318c3207694c680dc013a55fe5d54169c3878a Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Sat, 24 Oct 2009 20:35:10 +0000 Subject: [PATCH] - Don't put PAGED_CODE() before variable declarations -- this makes MSVC very, very sad. Reformat and clean up the code a bit too. svn path=/trunk/; revision=43722 --- reactos/ntoskrnl/mm/ARM3/drvmgmt.c | 71 ++++++++++++++++-------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/drvmgmt.c b/reactos/ntoskrnl/mm/ARM3/drvmgmt.c index 8b52c749aab..11ecbc1822d 100644 --- a/reactos/ntoskrnl/mm/ARM3/drvmgmt.c +++ b/reactos/ntoskrnl/mm/ARM3/drvmgmt.c @@ -116,44 +116,49 @@ PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection) { - PAGED_CODE(); - // - // We should find the driver loader entry and return its base address - // //PMMPTE StartPte, EndPte; - PLDR_DATA_TABLE_ENTRY pLdrDataTabEntry = - MiLookupDataTableEntry(AddressWithinSection); - if (pLdrDataTabEntry) + PLDR_DATA_TABLE_ENTRY LdrEntry; + PAGED_CODE(); + + // + // Get the loader entry + // + LdrEntry = MiLookupDataTableEntry(AddressWithinSection); + if (!LdrEntry) return NULL; + + // + // Check if paging of kernel mode is disabled or if the driver is mapped as + // an image + // + if ((MmDisablePagingExecutive & 0x1) || (LdrEntry->SectionPointer)) { // - // Is Paging disabled or it's mapped as an image + // Don't do anything, just return the base address // - if ((MmDisablePagingExecutive & 1) || pLdrDataTabEntry->SectionPointer) - return pLdrDataTabEntry->DllBase; - - // - // Flush all queued DPCs. - // - KeFlushQueuedDpcs(); - - // - // Get PTE range for this section - // - //StartPte = MiGetPteAddress(pLdrDataTabEntry->DllBase); - //EndPte = MiGetPteAddress(pLdrDataTabEntry->DllBase + - // pLdrDataTabEntry->SizeOfImage); - - // - // Set paging for specified PTE range - // - //MiSetPagingOfDriver(StartPte, EndPte); - - // - // Return base address - // - return pLdrDataTabEntry->DllBase; + return LdrEntry->DllBase; } - return NULL; + + // + // Wait for active DPCs to finish before we page out the driver + // + KeFlushQueuedDpcs(); + + // + // Get the PTE range for the whole driver image + // + //StartPte = MiGetPteAddress(LdrEntry->DllBase); + //EndPte = MiGetPteAddress(LdrEntry->DllBase + + // LdrEntry->SizeOfImage); + + // + // Enable paging for the PTE range + // + //MiSetPagingOfDriver(StartPte, EndPte); + + // + // Return the base address + // + return LdrEntry->DllBase; } /*