[ros-diffs] [ros-arm-bringup] 41658: - Move all the functions from drvlck.c and verifier.c to ARM3's drvmgmt.c: - "Managing driver managing" (by David Welch) is no more... the routines have been properly renamed and cleaned up. - Also moved Driver Verifier helper routines in here, and fixed a couple of bugs: - Do not allow hooking of the kernel or HAL image (tested on Windows Server 2003) - Cleanup some useless variable redefinitions and code complexity. - Documented what some of the Mm Lock/Unlock Pageable Section/Driver functions should do, for later if needed. - Made aliasses so the typo "Pagable" functions redirect to the correct "Pageable" functions. - No functional change -- the Verifier functions were unused, and the drvlock.c functions were unimplemented (and still are). - Also move one more *Pageable* function from wset.c to ARM3's drvmgmt.c -- it seemed to have been a lost orphan (Also unimplemented).
ros-arm-bringup at svn.reactos.org
ros-arm-bringup at svn.reactos.org
Sun Jun 28 10:32:42 CEST 2009
- Previous message: [ros-diffs] [ros-arm-bringup] 41657: - Reimplement MmAllocateContiguousMemory, MmAllocateContiguousMemorySpecifyCache, MmFreeContiguousMemory, MmFreeContiguousMemorySpecifyCache: - Use a smarter algorithm (as described here: http://www.microsoft.com/whdc/Driver/tips/ContigMem.mspx) to first try to satisfy the allocation by a simple nonpaged pool allocation (for cached requests only). - This range is then checked for physical continuity, since it's not guaranteed for non-initial-pool allocations (and right now in ReactOS, it never is). - As a fallback, Windows NT then attempts to scan free nonpaged pool pages. This is not yet implemented since the ReactOS nonpaged pool is not usually contiguous (to the level that NT's is). - When the ARM pool is implemented and replaces nonpaged pool, this code path will have to be implemented. - As a last resort, the actual PFN database is scanned for contiguous free pages. - ReactOS used MmGetContiguousPages for this, which blindly scanned the PFN database. New MiFindContinuousPages will scan the physical memory descriptor block recently implemented, which avoids going over pages we already know are going to be unusable. - The ReactOS function also held the PFN lock for the entire duration of the scan, which is significant on systems with large memory. Instead, we make an initial unsafe scan first, and only lock when we think we've found a correct range (and we'll then reconfirm the ranges). - Finally, the older function actually did a double-scan to try to avoid using memory ranges under 16MB, which was useless on today's systems and also rather inefficient. - Other than that, the actual setup of the PFN entry is copy-pasted from the old ReactOS function, so nothing's changed there -- the page still looks the same, but the selection algorithm is faster and more accurate. - Once the pages are found, we piggyback on the new I/O mapping mechanism (which uses System PTEs) instead of doing it all over by hand as before. - Since the underlying support is still System PTEs, once again, optimizations to that component will yield significant improvements here too.
- Next message: [ros-diffs] [ros-arm-bringup] 41659: - Create mmsup.c in ReactOS memory manager directory. It hosts misc support functions: - Copy kmap.c here, since it's the very definition of "misc support function" - Copy some exported functions in mm.c which were listed as "misc functions" - Warn that current implementation of MmIsNonPagedSystemAddressValid will kill kittens. - Rename mm.c to mmfault.c, since other than the misc functions now in mmsup.c, it was all routines to handle page/access faults. - Warn that MmIsAddressValid, as currently implemented, kills puppies. - Move WriteWatch functions to virtual.c since they're part of the Virtual API system call set already hosted there. - Move the global variables that people had been throwing in here to mminit.c, which is slightly more appropriate. - Move wset.c's MmTrimUserMemory to balance.c, since that's where all other similar functions are located. - Incidentally, kill wset.c, as this was the only function present. - No functional changes, just refactoring and cleanup (other than warning the critter murder the two broken functions will achieve if called).
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: ros-arm-bringup
Date: Sun Jun 28 11:32:52 2009
New Revision: 41658
URL: http://svn.reactos.org/svn/reactos?rev=41658&view=rev
Log:
- Move all the functions from drvlck.c and verifier.c to ARM3's drvmgmt.c:
- "Managing driver managing" (by David Welch) is no more... the routines have been properly renamed and cleaned up.
- Also moved Driver Verifier helper routines in here, and fixed a couple of bugs:
- Do not allow hooking of the kernel or HAL image (tested on Windows Server 2003)
- Cleanup some useless variable redefinitions and code complexity.
- Documented what some of the Mm Lock/Unlock Pageable Section/Driver functions should do, for later if needed.
- Made aliasses so the typo "Pagable" functions redirect to the correct "Pageable" functions.
- No functional change -- the Verifier functions were unused, and the drvlock.c functions were unimplemented (and still are).
- Also move one more *Pageable* function from wset.c to ARM3's drvmgmt.c -- it seemed to have been a lost orphan (Also unimplemented).
Added:
trunk/reactos/ntoskrnl/mm/ARM3/drvmgmt.c
- copied, changed from r41647, trunk/reactos/ntoskrnl/mm/drvlck.c
Removed:
trunk/reactos/ntoskrnl/mm/drvlck.c
trunk/reactos/ntoskrnl/mm/verifier.c
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
trunk/reactos/ntoskrnl/mm/wset.c
trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild
trunk/reactos/ntoskrnl/ntoskrnl.pspec
Copied: trunk/reactos/ntoskrnl/mm/ARM3/drvmgmt.c (from r41647, trunk/reactos/ntoskrnl/mm/drvlck.c)
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/drvmgmt.c?p2=trunk/reactos/ntoskrnl/mm/ARM3/drvmgmt.c&p1=trunk/reactos/ntoskrnl/mm/drvlck.c&r1=41647&r2=41658&rev=41658&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/drvlck.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/drvmgmt.c [iso-8859-1] Sun Jun 28 11:32:52 2009
@@ -1,102 +1,324 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/mm/drvlck.c
- * PURPOSE: Managing driver managing
- *
- * PROGRAMMERS: David Welch (welch at mcmail.com)
- */
-
-/* INCLUDES *****************************************************************/
+ * PROJECT: ReactOS Kernel
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: ntoskrnl/mm/ARM3/drvmgmt.c
+ * PURPOSE: ARM Memory Manager Driver Management
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
#include <ntoskrnl.h>
+#define NDEBUG
#include <debug.h>
-/* FUNCTIONS *****************************************************************/
-
-#undef MmLockPagableDataSection
-
-#if 0
+#line 15 "ARM³::DRVMGMT"
+#define MODULE_INVOLVED_IN_ARM3
+#include "../ARM3/miarm.h"
+
+/* GLOBALS *******************************************************************/
+
+MM_DRIVER_VERIFIER_DATA MmVerifierData;
+LIST_ENTRY MiVerifierDriverAddedThunkListHead;
+KMUTANT MmSystemLoadLock;
+ULONG MiActiveVerifierThunks;
+extern LIST_ENTRY PsLoadedModuleList;
+
+/* PRIVATE FUNCTIONS *********************************************************/
+
+PLDR_DATA_TABLE_ENTRY
+NTAPI
+MiLookupDataTableEntry(IN PVOID Address)
+{
+ PLDR_DATA_TABLE_ENTRY LdrEntry, FoundEntry = NULL;
+ PLIST_ENTRY NextEntry;
+ PAGED_CODE();
+
+ //
+ // Loop entries
+ //
+ NextEntry = PsLoadedModuleList.Flink;
+ do
+ {
+ //
+ // Get the loader entry
+ //
+ LdrEntry = CONTAINING_RECORD(NextEntry,
+ LDR_DATA_TABLE_ENTRY,
+ InLoadOrderLinks);
+
+ //
+ // Check if the address matches
+ //
+ if ((Address >= LdrEntry->DllBase) &&
+ (Address < (PVOID)((ULONG_PTR)LdrEntry->DllBase +
+ LdrEntry->SizeOfImage)))
+ {
+ //
+ // Found a match
+ //
+ FoundEntry = LdrEntry;
+ break;
+ }
+
+ //
+ // Move on
+ //
+ NextEntry = NextEntry->Flink;
+ } while(NextEntry != &PsLoadedModuleList);
+
+ //
+ // Return the entry
+ //
+ return FoundEntry;
+}
+
+/* PUBLIC FUNCTIONS ***********************************************************/
+
+/*
+ * @unimplemented
+ */
VOID
-MmUnlockPagableImageSection(IN PVOID ImageSectionHandle)
-/*
- * FUNCTION: Releases a section of driver code or driver data, previously
- * locked into system space with MmLockPagableCodeSection,
- * MmLockPagableDataSection or MmLockPagableSectionByHandle
- * ARGUMENTS:
- * ImageSectionHandle = Handle returned by MmLockPagableCodeSection or
- * MmLockPagableDataSection
- */
-{
- // MmUnlockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
- UNIMPLEMENTED;
-}
-#endif
-
-
-/*
- * @unimplemented
- */
-VOID NTAPI
-MmLockPagableSectionByHandle(IN PVOID ImageSectionHandle)
-{
- UNIMPLEMENTED;
-}
-
-
-#if 0
+NTAPI
+MmUnlockPageableImageSection(IN PVOID ImageSectionHandle)
+{
+ UNIMPLEMENTED;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+MmLockPageableSectionByHandle(IN PVOID ImageSectionHandle)
+{
+ UNIMPLEMENTED;
+}
+
+/*
+ * @unimplemented
+ */
PVOID
-MmLockPagableCodeSection(IN PVOID AddressWithinSection)
-{
- PVOID Handle;
- Handle = MmLocateMemoryAreaByAddress(NULL,AddressWithinSection);
- MmLockPagableSectionByHandle(Handle);
- return(Handle);
-}
-#endif
-
+NTAPI
+MmLockPageableDataSection(IN PVOID AddressWithinSection)
+{
+ //
+ // We should just find the section and call MmLockPageableSectionByHandle
+ //
+ UNIMPLEMENTED;
+ return AddressWithinSection;
+}
+
+/*
+ * @unimplemented
+ */
+PVOID
+NTAPI
+MmPageEntireDriver(IN PVOID AddressWithinSection)
+{
+ //
+ // We should find the driver loader entry and return its base address
+ //
+ UNIMPLEMENTED;
+ return NULL;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+MmResetDriverPaging(IN PVOID AddressWithinSection)
+{
+ UNIMPLEMENTED;
+}
+
+/*
+ * @unimplemented
+ */
+ULONG
+NTAPI
+MmTrimAllSystemPageableMemory(IN ULONG PurgeTransitionList)
+{
+ UNIMPLEMENTED;
+ return 0;
+}
/*
* @implemented
*/
-PVOID NTAPI
-MmLockPagableDataSection(IN PVOID AddressWithinSection)
-{
- PVOID Handle;
- Handle = MmLocateMemoryAreaByAddress(MmGetKernelAddressSpace(),
- AddressWithinSection);
- MmLockPagableSectionByHandle(Handle);
- return(Handle);
-}
-
-
-/*
- * @unimplemented
- */
-VOID NTAPI
-MmUnlockPagableImageSection(IN PVOID ImageSectionHandle)
-{
- UNIMPLEMENTED;
-}
-
-/*
- * @unimplemented
- */
-PVOID NTAPI
-MmPageEntireDriver(IN PVOID AddressWithinSection)
-{
- UNIMPLEMENTED;
- return NULL;
-}
-
-
-/*
- * @unimplemented
- */
-VOID NTAPI
-MmResetDriverPaging(IN PVOID AddressWithinSection)
-{
- UNIMPLEMENTED;
+NTSTATUS
+NTAPI
+MmAddVerifierThunks(IN PVOID ThunkBuffer,
+ IN ULONG ThunkBufferSize)
+{
+ PDRIVER_VERIFIER_THUNK_PAIRS ThunkTable;
+ ULONG ThunkCount;
+ PDRIVER_SPECIFIED_VERIFIER_THUNKS DriverThunks;
+ PLDR_DATA_TABLE_ENTRY LdrEntry;
+ PVOID ModuleBase, ModuleEnd;
+ ULONG i;
+ NTSTATUS Status = STATUS_SUCCESS;
+ PAGED_CODE();
+
+ //
+ // Make sure the driver verifier is initialized
+ //
+ if (!MiVerifierDriverAddedThunkListHead.Flink) return STATUS_NOT_SUPPORTED;
+
+ //
+ // Get the thunk pairs and count them
+ //
+ ThunkCount = ThunkBufferSize / sizeof(DRIVER_VERIFIER_THUNK_PAIRS);
+ if (!ThunkCount) return STATUS_INVALID_PARAMETER_1;
+
+ //
+ // Now allocate our own thunk table
+ //
+ DriverThunks = ExAllocatePoolWithTag(PagedPool,
+ sizeof(*DriverThunks) +
+ ThunkCount *
+ sizeof(DRIVER_VERIFIER_THUNK_PAIRS),
+ 'tVmM');
+ if (!DriverThunks) return STATUS_INSUFFICIENT_RESOURCES;
+
+ //
+ // Now copy the driver-fed part
+ //
+ ThunkTable = (PDRIVER_VERIFIER_THUNK_PAIRS)(DriverThunks + 1);
+ RtlCopyMemory(ThunkTable,
+ ThunkBuffer,
+ ThunkCount * sizeof(DRIVER_VERIFIER_THUNK_PAIRS));
+
+ //
+ // Acquire the system load lock
+ //
+ KeEnterCriticalRegion();
+ KeWaitForSingleObject(&MmSystemLoadLock,
+ WrVirtualMemory,
+ KernelMode,
+ FALSE,
+ NULL);
+
+ //
+ // Get the loader entry
+ //
+ LdrEntry = MiLookupDataTableEntry(ThunkTable->PristineRoutine);
+ if (!LdrEntry)
+ {
+ //
+ // Fail
+ //
+ Status = STATUS_INVALID_PARAMETER_2;
+ goto Cleanup;
+ }
+
+ //
+ // Get driver base and end
+ //
+ ModuleBase = LdrEntry->DllBase;
+ ModuleEnd = (PVOID)((ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage);
+
+ //
+ // Don't allow hooking the kernel or HAL
+ //
+ if (ModuleBase < (PVOID)(KSEG0_BASE + MmBootImageSize))
+ {
+ //
+ // Fail
+ //
+ Status = STATUS_INVALID_PARAMETER_2;
+ goto Cleanup;
+ }
+
+ //
+ // Loop all the thunks
+ //
+ for (i = 0; i < ThunkCount; i++)
+ {
+ //
+ // Make sure it's in the driver
+ //
+ if (((ULONG_PTR)ThunkTable->PristineRoutine < (ULONG_PTR)ModuleBase) ||
+ ((ULONG_PTR)ThunkTable->PristineRoutine >= (ULONG_PTR)ModuleEnd))
+ {
+ //
+ // Nope, fail
+ //
+ Status = STATUS_INVALID_PARAMETER_2;
+ goto Cleanup;
+ }
+ }
+
+ //
+ // Otherwise, add this entry
+ //
+ DriverThunks->DataTableEntry = LdrEntry;
+ DriverThunks->NumberOfThunks = ThunkCount;
+ MiActiveVerifierThunks++;
+ InsertTailList(&MiVerifierDriverAddedThunkListHead,
+ &DriverThunks->ListEntry);
+ DriverThunks = NULL;
+
+Cleanup:
+ //
+ // Release the lock
+ //
+ KeReleaseMutant(&MmSystemLoadLock, 1, FALSE, FALSE);
+ KeLeaveCriticalRegion();
+
+ //
+ // Free the table if we failed and return status
+ //
+ if (DriverThunks) ExFreePool(DriverThunks);
+ return Status;
+}
+
+/*
+ * @implemented
+ */
+LOGICAL
+NTAPI
+MmIsDriverVerifying(IN PDRIVER_OBJECT DriverObject)
+{
+ PLDR_DATA_TABLE_ENTRY LdrEntry;
+
+ //
+ // Get the loader entry
+ //
+ LdrEntry = (PLDR_DATA_TABLE_ENTRY)DriverObject->DriverSection;
+ if (!LdrEntry) return FALSE;
+
+ //
+ // Check if we're verifying or not
+ //
+ return (LdrEntry->Flags & LDRP_IMAGE_VERIFYING) ? TRUE: FALSE;
+}
+
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+MmIsVerifierEnabled(OUT PULONG VerifierFlags)
+{
+ //
+ // Check if we've actually added anything to the list
+ //
+ if (MiVerifierDriverAddedThunkListHead.Flink)
+ {
+ //
+ // We have, read the verifier level
+ //
+ *VerifierFlags = MmVerifierData.Level;
+ return STATUS_SUCCESS;
+ }
+
+ //
+ // Otherwise, we're disabled
+ //
+ *VerifierFlags = 0;
+ return STATUS_NOT_SUPPORTED;
}
/* EOF */
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Sun Jun 28 11:32:52 2009
@@ -52,6 +52,7 @@
extern PMMPTE MiFirstReservedZeroingPte;
extern MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType];
extern PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock;
+extern ULONG MmBootImageSize;
VOID
NTAPI
Removed: trunk/reactos/ntoskrnl/mm/drvlck.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/drvlck.c?rev=41657&view=auto
==============================================================================
--- trunk/reactos/ntoskrnl/mm/drvlck.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/drvlck.c (removed)
@@ -1,102 +1,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/mm/drvlck.c
- * PURPOSE: Managing driver managing
- *
- * PROGRAMMERS: David Welch (welch at mcmail.com)
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ntoskrnl.h>
-#include <debug.h>
-
-/* FUNCTIONS *****************************************************************/
-
-#undef MmLockPagableDataSection
-
-#if 0
-VOID
-MmUnlockPagableImageSection(IN PVOID ImageSectionHandle)
-/*
- * FUNCTION: Releases a section of driver code or driver data, previously
- * locked into system space with MmLockPagableCodeSection,
- * MmLockPagableDataSection or MmLockPagableSectionByHandle
- * ARGUMENTS:
- * ImageSectionHandle = Handle returned by MmLockPagableCodeSection or
- * MmLockPagableDataSection
- */
-{
- // MmUnlockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
- UNIMPLEMENTED;
-}
-#endif
-
-
-/*
- * @unimplemented
- */
-VOID NTAPI
-MmLockPagableSectionByHandle(IN PVOID ImageSectionHandle)
-{
- UNIMPLEMENTED;
-}
-
-
-#if 0
-PVOID
-MmLockPagableCodeSection(IN PVOID AddressWithinSection)
-{
- PVOID Handle;
- Handle = MmLocateMemoryAreaByAddress(NULL,AddressWithinSection);
- MmLockPagableSectionByHandle(Handle);
- return(Handle);
-}
-#endif
-
-
-/*
- * @implemented
- */
-PVOID NTAPI
-MmLockPagableDataSection(IN PVOID AddressWithinSection)
-{
- PVOID Handle;
- Handle = MmLocateMemoryAreaByAddress(MmGetKernelAddressSpace(),
- AddressWithinSection);
- MmLockPagableSectionByHandle(Handle);
- return(Handle);
-}
-
-
-/*
- * @unimplemented
- */
-VOID NTAPI
-MmUnlockPagableImageSection(IN PVOID ImageSectionHandle)
-{
- UNIMPLEMENTED;
-}
-
-/*
- * @unimplemented
- */
-PVOID NTAPI
-MmPageEntireDriver(IN PVOID AddressWithinSection)
-{
- UNIMPLEMENTED;
- return NULL;
-}
-
-
-/*
- * @unimplemented
- */
-VOID NTAPI
-MmResetDriverPaging(IN PVOID AddressWithinSection)
-{
- UNIMPLEMENTED;
-}
-
-/* EOF */
Removed: trunk/reactos/ntoskrnl/mm/verifier.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/verifier.c?rev=41657&view=auto
==============================================================================
--- trunk/reactos/ntoskrnl/mm/verifier.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/verifier.c (removed)
@@ -1,190 +1,0 @@
-/*
-* PROJECT: ReactOS Kernel
-* LICENSE: GPL - See COPYING in the top level directory
-* FILE: ntoskrnl/mm/verifier.c
-* PURPOSE: Mm Driver Verifier Routines
-* PROGRAMMERS: Alex Ionescu (alex.ionescu at reactos.org)
-*/
-
-/* INCLUDES ******************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <debug.h>
-
-/* GLOBALS *******************************************************************/
-
-MM_DRIVER_VERIFIER_DATA MmVerifierData;
-LIST_ENTRY MiVerifierDriverAddedThunkListHead;
-KMUTANT MmSystemLoadLock;
-ULONG MiActiveVerifierThunks;
-
-extern LIST_ENTRY PsLoadedModuleList;
-
-/* PRIVATE FUNCTIONS *********************************************************/
-
-PLDR_DATA_TABLE_ENTRY
-NTAPI
-MiLookupDataTableEntry(IN PVOID Address)
-{
- PLDR_DATA_TABLE_ENTRY LdrEntry, FoundEntry = NULL;
- PLIST_ENTRY NextEntry;
- PAGED_CODE();
-
- /* Loop entries */
- NextEntry = PsLoadedModuleList.Flink;
- do
- {
- /* Get the loader entry */
- LdrEntry = CONTAINING_RECORD(NextEntry,
- LDR_DATA_TABLE_ENTRY,
- InLoadOrderLinks);
-
- /* Check if the address matches */
- if ((Address >= LdrEntry->DllBase) &&
- (Address < (PVOID)((ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage)))
- {
- /* Found a match */
- FoundEntry = LdrEntry;
- break;
- }
-
- /* Move on */
- NextEntry = NextEntry->Flink;
- } while(NextEntry != &PsLoadedModuleList);
-
- /* Return the entry */
- return FoundEntry;
-}
-
-/* PUBLIC FUNCTIONS **********************************************************/
-
-/*
- * @implemented
- */
-NTSTATUS
-NTAPI
-MmAddVerifierThunks(IN PVOID ThunkBuffer,
- IN ULONG ThunkBufferSize)
-{
- PDRIVER_VERIFIER_THUNK_PAIRS ThunkPairs, DriverThunkTable;
- ULONG ThunkCount;
- PDRIVER_SPECIFIED_VERIFIER_THUNKS ThunkTable;
- PLDR_DATA_TABLE_ENTRY LdrEntry;
- PVOID ModuleBase, ModuleEnd;
- ULONG i;
- NTSTATUS Status = STATUS_SUCCESS;
- PAGED_CODE();
-
- /* Make sure the driver verifier is initialized */
- if (!MiVerifierDriverAddedThunkListHead.Flink) return STATUS_NOT_SUPPORTED;
-
- /* Get the thunk pairs and count them */
- ThunkPairs = (PDRIVER_VERIFIER_THUNK_PAIRS)ThunkBuffer;
- ThunkCount = ThunkBufferSize / sizeof(DRIVER_VERIFIER_THUNK_PAIRS);
- if (!ThunkCount) return STATUS_INVALID_PARAMETER_1;
-
- /* Now allocate our own thunk table */
- ThunkTable = ExAllocatePoolWithTag(PagedPool,
- sizeof(DRIVER_SPECIFIED_VERIFIER_THUNKS) +
- ThunkCount *
- sizeof(DRIVER_VERIFIER_THUNK_PAIRS),
- TAG('M', 'm', 'V', 't'));
- if (!ThunkTable) return STATUS_INSUFFICIENT_RESOURCES;
-
- /* Now copy the driver-fed part */
- DriverThunkTable = (PDRIVER_VERIFIER_THUNK_PAIRS)(ThunkTable + 1);
- RtlCopyMemory(DriverThunkTable,
- ThunkPairs,
- ThunkCount * sizeof(DRIVER_VERIFIER_THUNK_PAIRS));
-
- /* Acquire the system load lock */
- KeEnterCriticalRegion();
- KeWaitForSingleObject(&MmSystemLoadLock,
- WrVirtualMemory,
- KernelMode,
- FALSE,
- NULL);
-
- /* Get the loader entry */
- LdrEntry = MiLookupDataTableEntry(DriverThunkTable->PristineRoutine);
- if (!LdrEntry)
- {
- /* Fail */
- Status = STATUS_INVALID_PARAMETER_2;
- goto Cleanup;
- }
-
- /* Get driver base and end */
- ModuleBase = LdrEntry->DllBase;
- ModuleEnd = (PVOID)((ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage);
-
- /* Loop all the thunks */
- for (i = 0; i < ThunkCount; i++)
- {
- /* Make sure it's in the driver */
- if (((ULONG_PTR)DriverThunkTable->PristineRoutine < (ULONG_PTR)ModuleBase) ||
- ((ULONG_PTR)DriverThunkTable->PristineRoutine >= (ULONG_PTR)ModuleEnd))
- {
- /* Nope, fail */
- Status = STATUS_INVALID_PARAMETER_2;
- goto Cleanup;
- }
- }
-
- /* Otherwise, add this entry */
- ThunkTable->DataTableEntry = LdrEntry;
- ThunkTable->NumberOfThunks = ThunkCount;
- MiActiveVerifierThunks++;
- InsertTailList(&MiVerifierDriverAddedThunkListHead,
- &ThunkTable->ListEntry);
- ThunkTable = NULL;
-
-Cleanup:
- /* Release the lock */
- KeReleaseMutant(&MmSystemLoadLock, 1, FALSE, FALSE);
- KeLeaveCriticalRegion();
-
- /* Free the table if we failed and return status */
- if (ThunkTable) ExFreePool(ThunkTable);
- return Status;
-}
-
-/*
- * @implemented
- */
-LOGICAL
-NTAPI
-MmIsDriverVerifying(IN PDRIVER_OBJECT DriverObject)
-{
- PLDR_DATA_TABLE_ENTRY LdrEntry;
-
- /* Get the loader entry */
- LdrEntry = (PLDR_DATA_TABLE_ENTRY)DriverObject->DriverSection;
- if (!LdrEntry) return FALSE;
-
- /* Check if we're verifying or not */
- return (LdrEntry->Flags & LDRP_IMAGE_VERIFYING) ? TRUE: FALSE;
-}
-
-/*
- * @implemented
- */
-NTSTATUS
-NTAPI
-MmIsVerifierEnabled(OUT PULONG VerifierFlags)
-{
- /* Check if we've actually added anything to the list */
- if (MiVerifierDriverAddedThunkListHead.Flink)
- {
- /* We have, read the verifier level */
- *VerifierFlags = MmVerifierData.Level;
- return STATUS_SUCCESS;
- }
-
- /* Otherwise, we're disabled */
- *VerifierFlags = 0;
- return STATUS_NOT_SUPPORTED;
-}
-
-/* EOF */
Modified: trunk/reactos/ntoskrnl/mm/wset.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/wset.c?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/wset.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/wset.c [iso-8859-1] Sun Jun 28 11:32:52 2009
@@ -46,16 +46,3 @@
}
return(STATUS_SUCCESS);
}
-
-/*
- * @unimplemented
- */
-ULONG
-NTAPI
-MmTrimAllSystemPagableMemory (
- IN ULONG PurgeTransitionList
- )
-{
- UNIMPLEMENTED;
- return 0;
-}
Modified: trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] Sun Jun 28 11:32:52 2009
@@ -361,6 +361,7 @@
</if>
<directory name="ARM3">
<file>contmem.c</file>
+ <file>drvmgmt.c</file>
<file>dynamic.c</file>
<file>hypermap.c</file>
<file>init.c</file>
@@ -372,7 +373,6 @@
<file>anonmem.c</file>
<file>balance.c</file>
<file>dbgpool.c</file>
- <file>drvlck.c</file>
<file>freelist.c</file>
<file>kmap.c</file>
<file>marea.c</file>
@@ -392,7 +392,6 @@
<file>rmap.c</file>
<file>section.c</file>
<file>sysldr.c</file>
- <file>verifier.c</file>
<file>virtual.c</file>
<file>wset.c</file>
<if property="_ELF_" value="1">
Modified: trunk/reactos/ntoskrnl/ntoskrnl.pspec
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.pspec?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ntoskrnl.pspec [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ntoskrnl.pspec [iso-8859-1] Sun Jun 28 11:32:52 2009
@@ -771,9 +771,9 @@
@ stdcall MmIsRecursiveIoFault()
@ stdcall MmIsThisAnNtAsSystem()
@ stdcall MmIsVerifierEnabled(ptr)
-@ stdcall MmLockPagableDataSection(ptr)
-@ stdcall MmLockPagableImageSection(ptr) MmLockPagableDataSection
-@ stdcall MmLockPagableSectionByHandle(ptr)
+@ stdcall MmLockPagableDataSection(ptr) MmLockPageableDataSection
+@ stdcall MmLockPagableImageSection(ptr) MmLockPageableDataSection
+@ stdcall MmLockPagableSectionByHandle(ptr) MmLockPageableSectionByHandle
@ stdcall MmMapIoSpace(long long long long)
@ stdcall MmMapLockedPages(ptr long)
@ stdcall MmMapLockedPagesSpecifyCache(ptr long long ptr long long)
@@ -801,8 +801,8 @@
@ stdcall MmSetBankedSection(long long long long long long)
@ stdcall MmSizeOfMdl(ptr long)
@ extern MmSystemRangeStart
-@ stdcall MmTrimAllSystemPagableMemory(long)
-@ stdcall MmUnlockPagableImageSection(ptr)
+@ stdcall MmTrimAllSystemPagableMemory(long) MmTrimAllSystemPageableMemory
+@ stdcall MmUnlockPagableImageSection(ptr) MmUnlockPageableImageSection
@ stdcall MmUnlockPages(ptr)
@ stdcall MmUnmapIoSpace(ptr long)
@ stdcall MmUnmapLockedPages(ptr ptr)
- Previous message: [ros-diffs] [ros-arm-bringup] 41657: - Reimplement MmAllocateContiguousMemory, MmAllocateContiguousMemorySpecifyCache, MmFreeContiguousMemory, MmFreeContiguousMemorySpecifyCache: - Use a smarter algorithm (as described here: http://www.microsoft.com/whdc/Driver/tips/ContigMem.mspx) to first try to satisfy the allocation by a simple nonpaged pool allocation (for cached requests only). - This range is then checked for physical continuity, since it's not guaranteed for non-initial-pool allocations (and right now in ReactOS, it never is). - As a fallback, Windows NT then attempts to scan free nonpaged pool pages. This is not yet implemented since the ReactOS nonpaged pool is not usually contiguous (to the level that NT's is). - When the ARM pool is implemented and replaces nonpaged pool, this code path will have to be implemented. - As a last resort, the actual PFN database is scanned for contiguous free pages. - ReactOS used MmGetContiguousPages for this, which blindly scanned the PFN database. New MiFindContinuousPages will scan the physical memory descriptor block recently implemented, which avoids going over pages we already know are going to be unusable. - The ReactOS function also held the PFN lock for the entire duration of the scan, which is significant on systems with large memory. Instead, we make an initial unsafe scan first, and only lock when we think we've found a correct range (and we'll then reconfirm the ranges). - Finally, the older function actually did a double-scan to try to avoid using memory ranges under 16MB, which was useless on today's systems and also rather inefficient. - Other than that, the actual setup of the PFN entry is copy-pasted from the old ReactOS function, so nothing's changed there -- the page still looks the same, but the selection algorithm is faster and more accurate. - Once the pages are found, we piggyback on the new I/O mapping mechanism (which uses System PTEs) instead of doing it all over by hand as before. - Since the underlying support is still System PTEs, once again, optimizations to that component will yield significant improvements here too.
- Next message: [ros-diffs] [ros-arm-bringup] 41659: - Create mmsup.c in ReactOS memory manager directory. It hosts misc support functions: - Copy kmap.c here, since it's the very definition of "misc support function" - Copy some exported functions in mm.c which were listed as "misc functions" - Warn that current implementation of MmIsNonPagedSystemAddressValid will kill kittens. - Rename mm.c to mmfault.c, since other than the misc functions now in mmsup.c, it was all routines to handle page/access faults. - Warn that MmIsAddressValid, as currently implemented, kills puppies. - Move WriteWatch functions to virtual.c since they're part of the Virtual API system call set already hosted there. - Move the global variables that people had been throwing in here to mminit.c, which is slightly more appropriate. - Move wset.c's MmTrimUserMemory to balance.c, since that's where all other similar functions are located. - Incidentally, kill wset.c, as this was the only function present. - No functional changes, just refactoring and cleanup (other than warning the critter murder the two broken functions will achieve if called).
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Ros-diffs
mailing list