ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
May 2015
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
15 participants
500 discussions
Start a n
N
ew thread
[tkreuzer] 67794: [NTOSKRNL] Implement MiRosCleanupMemoryArea to cleanup memory areas from MmCleanProcessAddressSpace, since later when we remove the old-style memory area links, we will not be abl...
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sun May 17 00:34:59 2015 New Revision: 67794 URL:
http://svn.reactos.org/svn/reactos?rev=67794&view=rev
Log: [NTOSKRNL] Implement MiRosCleanupMemoryArea to cleanup memory areas from MmCleanProcessAddressSpace, since later when we remove the old-style memory area links, we will not be able to retrieve those. Modified: trunk/reactos/ntoskrnl/include/internal/mm.h trunk/reactos/ntoskrnl/mm/ARM3/procsup.c trunk/reactos/ntoskrnl/mm/marea.c Modified: trunk/reactos/ntoskrnl/include/internal/mm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sun May 17 00:34:59 2015 @@ -507,6 +507,12 @@ PVOID FreePageContext ); +VOID +NTAPI +MiRosCleanupMemoryArea( + PEPROCESS Process, + PMMVAD Vad); + NTSTATUS NTAPI MmFreeMemoryAreaByPtr( Modified: trunk/reactos/ntoskrnl/mm/ARM3/procsup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/procsup.c…
============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] Sun May 17 00:34:59 2015 @@ -1279,6 +1279,14 @@ /* Grab the current VAD */ Vad = (PMMVAD)VadTree->BalancedRoot.RightChild; + /* Check for old-style memory areas */ + if (Vad->u.VadFlags.Spare == 1) + { + /* Let RosMm handle this */ + MiRosCleanupMemoryArea(Process, Vad); + continue; + } + /* Lock the working set */ MiLockProcessWorkingSetUnsafe(Process, Thread); @@ -1306,7 +1314,7 @@ MiUnlockProcessWorkingSetUnsafe(Process, Thread); } - /* Skip ARM3 fake VADs, they'll be freed by MmDeleteProcessAddresSpace */ + /* Skip ARM3 fake VADs, they'll be freed by MmDeleteProcessAddresSpace */ if (Vad->u.VadFlags.Spare == 1) { /* Set a flag so MmDeleteMemoryArea knows to free, but not to remove */ Modified: trunk/reactos/ntoskrnl/mm/marea.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=67…
============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sun May 17 00:34:59 2015 @@ -1103,6 +1103,50 @@ return STATUS_SUCCESS; } +VOID +NTAPI +MiRosCleanupMemoryArea( + PEPROCESS Process, + PMMVAD Vad) +{ + PMEMORY_AREA MemoryArea; + PVOID BaseAddress; + NTSTATUS Status; + + /* We must be called from MmCleanupAddressSpace and nowhere else! + Make sure things are as expected... */ + ASSERT(Process == PsGetCurrentProcess()); + ASSERT(Process->VmDeleted == TRUE); + ASSERT(((PsGetCurrentThread()->ThreadsProcess == Process) && + (Process->ActiveThreads == 1)) || + (Process->ActiveThreads == 0)); + + /* We are in cleanup, we don't need to synchronize */ + MmUnlockAddressSpace(&Process->Vm); + + MemoryArea = (PMEMORY_AREA)Vad; + BaseAddress = (PVOID)MA_GetStartingAddress(MemoryArea); + + if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW) + { + Status = MiRosUnmapViewOfSection(Process, BaseAddress, 0); + } + else if (MemoryArea->Type == MEMORY_AREA_CACHE) + { + Status = MmUnmapViewOfCacheSegment(&Process->Vm, BaseAddress); + } + else + { + /* There shouldn't be anything else! */ + ASSERT(FALSE); + } + + /* Make sure this worked! */ + ASSERT(NT_SUCCESS(Status)); + + /* Lock the address space again */ + MmLockAddressSpace(&Process->Vm); +} VOID NTAPI @@ -1125,32 +1169,13 @@ while ((MemoryArea = (PMEMORY_AREA)Process->Vm.WorkingSetExpansionLinks.Flink) != NULL) { - switch (MemoryArea->Type) - { - case MEMORY_AREA_SECTION_VIEW: - Address = (PVOID)MA_GetStartingAddress(MemoryArea); - MmUnlockAddressSpace(&Process->Vm); - MmUnmapViewOfSection(Process, Address); - MmLockAddressSpace(&Process->Vm); - break; - - case MEMORY_AREA_CACHE: - Address = (PVOID)MA_GetStartingAddress(MemoryArea); - MmUnlockAddressSpace(&Process->Vm); - MmUnmapViewOfCacheSegment(&Process->Vm, Address); - MmLockAddressSpace(&Process->Vm); - break; - - case MEMORY_AREA_OWNED_BY_ARM3: - MmFreeMemoryArea(&Process->Vm, - MemoryArea, - NULL, - NULL); - break; - - default: - KeBugCheck(MEMORY_MANAGEMENT); - } + /* There should be nothing else left */ + ASSERT(MemoryArea->Type == MEMORY_AREA_OWNED_BY_ARM3); + + MmFreeMemoryArea(&Process->Vm, + MemoryArea, + NULL, + NULL); } #if (_MI_PAGING_LEVELS == 2) @@ -1176,6 +1201,7 @@ MiQueryPageTableReferences(Address)); ASSERT(MiQueryPageTableReferences(Address) == 0); } + pointerPde = MiAddressToPde(Address); /* Unlike in ARM3, we don't necesarrily free the PDE page as soon as reference reaches 0, * so we must clean up a bit when process closes */ @@ -1183,6 +1209,7 @@ MiDeletePte(pointerPde, MiPdeToPte(pointerPde), Process, NULL); ASSERT(pointerPde->u.Hard.Valid == 0); } + /* Release lock */ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
9 years, 7 months
1
0
0
0
[tkreuzer] 67793: [NTOSKRNL] Use the VAD tree to search for MEMORY_AREAS, except when inserting an ARM3 based MA. In this case we still need to use the old tables, since the related VAD is already ...
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sun May 17 00:34:45 2015 New Revision: 67793 URL:
http://svn.reactos.org/svn/reactos?rev=67793&view=rev
Log: [NTOSKRNL] Use the VAD tree to search for MEMORY_AREAS, except when inserting an ARM3 based MA. In this case we still need to use the old tables, since the related VAD is already inserted into the VAD tree. Modified: trunk/reactos/ntoskrnl/mm/marea.c Modified: trunk/reactos/ntoskrnl/mm/marea.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=67…
============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sun May 17 00:34:45 2015 @@ -51,6 +51,9 @@ MEMORY_AREA MiStaticMemoryAreas[MI_STATIC_MEMORY_AREAS]; ULONG MiStaticMemoryAreaCount; +MM_AVL_TABLE MiRosKernelVadRoot; +BOOLEAN MiRosKernelVadRootInitialized; + /* FUNCTIONS *****************************************************************/ /** @@ -188,8 +191,58 @@ return NULL; } -PMEMORY_AREA NTAPI +PMEMORY_AREA +NTAPI MmLocateMemoryAreaByRegion( + PMMSUPPORT AddressSpace, + PVOID Address_, + ULONG_PTR Length) +{ + ULONG_PTR StartVpn = (ULONG_PTR)Address_ / PAGE_SIZE; + ULONG_PTR EndVpn = ((ULONG_PTR)Address_ + Length - 1) / PAGE_SIZE; + PEPROCESS Process; + PMM_AVL_TABLE Table; + PMMADDRESS_NODE Node; + PMEMORY_AREA MemoryArea; + TABLE_SEARCH_RESULT Result; + PMMVAD_LONG Vad; + + Process = MmGetAddressSpaceOwner(AddressSpace); + Table = (Process != NULL) ? &Process->VadRoot : &MiRosKernelVadRoot; + + Result = MiCheckForConflictingNode(StartVpn, EndVpn, Table, &Node); + if (Result != TableFoundNode) + { + return NULL; + } + + Vad = (PMMVAD_LONG)Node; + if (Vad->u.VadFlags.Spare == 0) + { + /* Check if this is VM VAD */ + if (Vad->ControlArea == NULL) + { + /* We store the reactos MEMORY_AREA here */ + MemoryArea = (PMEMORY_AREA)Vad->FirstPrototypePte; + } + else + { + /* This is a section VAD. Store the MAREA here for now */ + MemoryArea = (PMEMORY_AREA)Vad->u4.Banked; + } + } + else + { + MemoryArea = (PMEMORY_AREA)Node; + } + + ASSERT(MemoryArea != NULL); + return MemoryArea; +} + +PMEMORY_AREA +NTAPI +MmLocateMemoryAreaByRegionOld( PMMSUPPORT AddressSpace, PVOID Address_, ULONG_PTR Length) @@ -367,8 +420,6 @@ IN ULONG Protect ); -MM_AVL_TABLE MiRosKernelVadRoot; -BOOLEAN MiRosKernelVadRootInitialized; static VOID MmInsertMemoryArea( @@ -1016,13 +1067,29 @@ return STATUS_ACCESS_VIOLATION; } - if (MmLocateMemoryAreaByRegion(AddressSpace, - *BaseAddress, - tmpLength) != NULL) - { - DPRINT("Memory area already occupied\n"); - if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA); - return STATUS_CONFLICTING_ADDRESSES; + /* Check if this is a region owned by ARM3 */ + if (MemoryArea->Type == MEMORY_AREA_OWNED_BY_ARM3) + { + /* ARM3 is inserting this MA to synchronize the old tree, use the old tree */ + if (MmLocateMemoryAreaByRegionOld(AddressSpace, + *BaseAddress, + tmpLength) != NULL) + { + DPRINT("Memory area already occupied\n"); + if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA); + return STATUS_CONFLICTING_ADDRESSES; + } + } + else + { + if (MmLocateMemoryAreaByRegion(AddressSpace, + *BaseAddress, + tmpLength) != NULL) + { + DPRINT("Memory area already occupied\n"); + if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA); + return STATUS_CONFLICTING_ADDRESSES; + } } MemoryArea->StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT;
9 years, 7 months
1
0
0
0
[tkreuzer] 67792: [NTOSKRNL] Insert kernel memory areas into a "kernel VAD table".
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sat May 16 23:36:42 2015 New Revision: 67792 URL:
http://svn.reactos.org/svn/reactos?rev=67792&view=rev
Log: [NTOSKRNL] Insert kernel memory areas into a "kernel VAD table". Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c trunk/reactos/ntoskrnl/mm/marea.c Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?r…
============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Sat May 16 23:36:42 2015 @@ -2039,13 +2039,6 @@ IN ULONG ProtectionMask ); -VOID -NTAPI -MiInsertVad( - IN PMMVAD Vad, - IN PEPROCESS Process -); - NTSTATUS NTAPI MiInsertVadEx( Modified: trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c…
============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c [iso-8859-1] Sat May 16 23:36:42 2015 @@ -181,24 +181,22 @@ VOID NTAPI MiInsertVad(IN PMMVAD Vad, - IN PEPROCESS Process) + IN PMM_AVL_TABLE VadRoot) { TABLE_SEARCH_RESULT Result; PMMADDRESS_NODE Parent = NULL; /* Validate the VAD and set it as the current hint */ ASSERT(Vad->EndingVpn >= Vad->StartingVpn); - Process->VadRoot.NodeHint = Vad; + VadRoot->NodeHint = Vad; /* Find the parent VAD and where this child should be inserted */ - Result = RtlpFindAvlTableNodeOrParent(&Process->VadRoot, (PVOID)Vad->StartingVpn, &Parent); + Result = RtlpFindAvlTableNodeOrParent(VadRoot, (PVOID)Vad->StartingVpn, &Parent); ASSERT(Result != TableFoundNode); ASSERT((Parent != NULL) || (Result == TableEmptyTree)); /* Do the actual insert operation */ - MiLockProcessWorkingSetUnsafe(PsGetCurrentProcess(), PsGetCurrentThread()); - MiInsertNode(&Process->VadRoot, (PVOID)Vad, Parent, Result); - MiUnlockProcessWorkingSetUnsafe(PsGetCurrentProcess(), PsGetCurrentThread()); + MiInsertNode(VadRoot, (PVOID)Vad, Parent, Result); } NTSTATUS Modified: trunk/reactos/ntoskrnl/mm/marea.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=67…
============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sat May 16 23:36:42 2015 @@ -359,7 +359,7 @@ VOID NTAPI MiInsertVad(IN PMMVAD Vad, - IN PEPROCESS Process); + IN PMM_AVL_TABLE VadRoot); ULONG NTAPI @@ -367,6 +367,9 @@ IN ULONG Protect ); +MM_AVL_TABLE MiRosKernelVadRoot; +BOOLEAN MiRosKernelVadRootInitialized; + static VOID MmInsertMemoryArea( PMMSUPPORT AddressSpace, @@ -377,23 +380,37 @@ ULONG Depth = 0; PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace); + marea->VadNode.StartingVpn = marea->StartingVpn; + marea->VadNode.EndingVpn = marea->EndingVpn; + marea->VadNode.u.VadFlags.Spare = 1; + marea->VadNode.u.VadFlags.Protection = MiMakeProtectionMask(marea->Protect); + /* Build a lame VAD if this is a user-space allocation */ - if ((MA_GetEndingAddress(marea) < (ULONG_PTR)MmSystemRangeStart) && - (marea->Type != MEMORY_AREA_OWNED_BY_ARM3)) - { - ASSERT(marea->Type == MEMORY_AREA_SECTION_VIEW || marea->Type == MEMORY_AREA_CACHE); - - marea->VadNode.StartingVpn = marea->StartingVpn; - marea->VadNode.EndingVpn = marea->EndingVpn; - marea->VadNode.u.VadFlags.Spare = 1; - marea->VadNode.u.VadFlags.Protection = MiMakeProtectionMask(marea->Protect); + if (MA_GetEndingAddress(marea) < (ULONG_PTR)MmSystemRangeStart) + { + if (marea->Type != MEMORY_AREA_OWNED_BY_ARM3) + { + ASSERT(marea->Type == MEMORY_AREA_SECTION_VIEW || marea->Type == MEMORY_AREA_CACHE); + + /* Insert the VAD */ + MiLockProcessWorkingSetUnsafe(PsGetCurrentProcess(), PsGetCurrentThread()); + MiInsertVad(&marea->VadNode, &Process->VadRoot); + MiUnlockProcessWorkingSetUnsafe(PsGetCurrentProcess(), PsGetCurrentThread()); + marea->Vad = &marea->VadNode; + } + } + else + { + if (!MiRosKernelVadRootInitialized) + { + MiRosKernelVadRoot.BalancedRoot.u1.Parent = &MiRosKernelVadRoot.BalancedRoot; + MiRosKernelVadRootInitialized = TRUE; + } /* Insert the VAD */ - MiInsertVad(&marea->VadNode, Process); - marea->Vad = &marea->VadNode; - } - else - { + MiLockWorkingSet(PsGetCurrentThread(), &MmSystemCacheWs); + MiInsertVad(&marea->VadNode, &MiRosKernelVadRoot); + MiUnlockWorkingSet(PsGetCurrentThread(), &MmSystemCacheWs); marea->Vad = NULL; } @@ -797,19 +814,24 @@ KeDetachProcess(); } + //if (MemoryArea->VadNode.StartingVpn < (ULONG_PTR)MmSystemRangeStart >> PAGE_SHIFT if (MemoryArea->Vad) { ASSERT(MA_GetEndingAddress(MemoryArea) < (ULONG_PTR)MmSystemRangeStart); ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW || MemoryArea->Type == MEMORY_AREA_CACHE); /* MmCleanProcessAddressSpace might have removed it (and this would be MmDeleteProcessAdressSpace) */ - ASSERT(((PMMVAD)MemoryArea->Vad)->u.VadFlags.Spare != 0); + ASSERT(MemoryArea->VadNode.u.VadFlags.Spare != 0); if (((PMMVAD)MemoryArea->Vad)->u.VadFlags.Spare == 1) { - MiRemoveNode(MemoryArea->Vad, &Process->VadRoot); + MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &Process->VadRoot); } MemoryArea->Vad = NULL; + } + else + { + MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &MiRosKernelVadRoot); } }
9 years, 7 months
1
0
0
0
[tkreuzer] 67791: [NTOSKRNL] - Allocate Memory area before trying to insert it in different pathes of MmCreateMemoryArea. This change is a preparation for upcoming changes. - Cleanup MmInsertMemory...
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sat May 16 21:30:52 2015 New Revision: 67791 URL:
http://svn.reactos.org/svn/reactos?rev=67791&view=rev
Log: [NTOSKRNL] - Allocate Memory area before trying to insert it in different pathes of MmCreateMemoryArea. This change is a preparation for upcoming changes. - Cleanup MmInsertMemoryArea from useless stuff Modified: trunk/reactos/ntoskrnl/mm/marea.c Modified: trunk/reactos/ntoskrnl/mm/marea.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=67…
============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sat May 16 21:30:52 2015 @@ -381,32 +381,16 @@ if ((MA_GetEndingAddress(marea) < (ULONG_PTR)MmSystemRangeStart) && (marea->Type != MEMORY_AREA_OWNED_BY_ARM3)) { - PMMVAD Vad; - ASSERT(marea->Type == MEMORY_AREA_SECTION_VIEW || marea->Type == MEMORY_AREA_CACHE); - Vad = &marea->VadNode; - - RtlZeroMemory(Vad, sizeof(MMVAD)); - Vad->StartingVpn = PAGE_ROUND_DOWN(MA_GetStartingAddress(marea)) >> PAGE_SHIFT; - /* - * For some strange reason, it is perfectly valid to create a MAREA from 0x1000 to... 0x1000. - * In a normal OS/Memory Manager, this would be retarded, but ReactOS allows this (how it works - * I don't even want to know). - */ - if (MA_GetEndingAddress(marea) != MA_GetStartingAddress(marea)) - { - Vad->EndingVpn = PAGE_ROUND_DOWN((ULONG_PTR)MA_GetEndingAddress(marea) - 1) >> PAGE_SHIFT; - } - else - { - Vad->EndingVpn = Vad->StartingVpn; - } - Vad->u.VadFlags.Spare = 1; - Vad->u.VadFlags.Protection = MiMakeProtectionMask(marea->Protect); + + marea->VadNode.StartingVpn = marea->StartingVpn; + marea->VadNode.EndingVpn = marea->EndingVpn; + marea->VadNode.u.VadFlags.Spare = 1; + marea->VadNode.u.VadFlags.Protection = MiMakeProtectionMask(marea->Protect); /* Insert the VAD */ - MiInsertVad(Vad, Process); - marea->Vad = Vad; + MiInsertVad(&marea->VadNode, Process); + marea->Vad = &marea->VadNode; } else { @@ -936,6 +920,41 @@ Type, BaseAddress, *BaseAddress, Length, AllocationFlags, Result); + // + // Is this a static memory area? + // + if (Type & MEMORY_AREA_STATIC) + { + // + // Use the static array instead of the pool + // + ASSERT(MiStaticMemoryAreaCount < MI_STATIC_MEMORY_AREAS); + MemoryArea = &MiStaticMemoryAreas[MiStaticMemoryAreaCount++]; + } + else + { + // + // Allocate the memory area from nonpaged pool + // + MemoryArea = ExAllocatePoolWithTag(NonPagedPool, + sizeof(MEMORY_AREA), + TAG_MAREA); + } + + if (!MemoryArea) + { + DPRINT1("Not enough memory.\n"); + return STATUS_NO_MEMORY; + } + + RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA)); + MemoryArea->Type = Type & ~MEMORY_AREA_STATIC; + MemoryArea->Protect = Protect; + MemoryArea->Flags = AllocationFlags; + //MemoryArea->LockCount = 0; + MemoryArea->Magic = 'erAM'; + MemoryArea->DeleteInProgress = FALSE; + if (*BaseAddress == 0) { tmpLength = (ULONG_PTR)MM_ROUND_UP(Length, PAGE_SIZE); @@ -946,8 +965,13 @@ if ((*BaseAddress) == 0) { DPRINT("No suitable gap\n"); + if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA); return STATUS_NO_MEMORY; } + + MemoryArea->StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT; + MemoryArea->EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT; + MmInsertMemoryArea(AddressSpace, MemoryArea); } else { @@ -957,6 +981,8 @@ if (!MmGetAddressSpaceOwner(AddressSpace) && *BaseAddress < MmSystemRangeStart) { + ASSERT(FALSE); + if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA); return STATUS_ACCESS_VIOLATION; } @@ -964,6 +990,7 @@ (ULONG_PTR)(*BaseAddress) + tmpLength > (ULONG_PTR)MmSystemRangeStart) { DPRINT("Memory area for user mode address space exceeds MmSystemRangeStart\n"); + if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA); return STATUS_ACCESS_VIOLATION; } @@ -972,49 +999,14 @@ tmpLength) != NULL) { DPRINT("Memory area already occupied\n"); + if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA); return STATUS_CONFLICTING_ADDRESSES; } - } - - // - // Is this a static memory area? - // - if (Type & MEMORY_AREA_STATIC) - { - // - // Use the static array instead of the pool - // - ASSERT(MiStaticMemoryAreaCount < MI_STATIC_MEMORY_AREAS); - MemoryArea = &MiStaticMemoryAreas[MiStaticMemoryAreaCount++]; - Type &= ~MEMORY_AREA_STATIC; - } - else - { - // - // Allocate the memory area from nonpaged pool - // - MemoryArea = ExAllocatePoolWithTag(NonPagedPool, - sizeof(MEMORY_AREA), - TAG_MAREA); - } - - if (!MemoryArea) - { - DPRINT1("Not enough memory.\n"); - return STATUS_NO_MEMORY; - } - - RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA)); - MemoryArea->Type = Type; - MemoryArea->StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT; - MemoryArea->EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT; - MemoryArea->Protect = Protect; - MemoryArea->Flags = AllocationFlags; - //MemoryArea->LockCount = 0; - MemoryArea->Magic = 'erAM'; - MemoryArea->DeleteInProgress = FALSE; - - MmInsertMemoryArea(AddressSpace, MemoryArea); + + MemoryArea->StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT; + MemoryArea->EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT; + MmInsertMemoryArea(AddressSpace, MemoryArea); + } *Result = MemoryArea;
9 years, 7 months
1
0
0
0
[tkreuzer] 67790: [NTOSKRNL] Use 1 as base address parameter to MmCreateMemoryArea, when 0 is the actual base and remove FixedAddress parameter in MmCreateMemoryArea
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sat May 16 21:30:28 2015 New Revision: 67790 URL:
http://svn.reactos.org/svn/reactos?rev=67790&view=rev
Log: [NTOSKRNL] Use 1 as base address parameter to MmCreateMemoryArea, when 0 is the actual base and remove FixedAddress parameter in MmCreateMemoryArea Modified: trunk/reactos/ntoskrnl/cache/section/data.c trunk/reactos/ntoskrnl/cc/view.c trunk/reactos/ntoskrnl/include/internal/mm.h trunk/reactos/ntoskrnl/mm/ARM3/procsup.c trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c trunk/reactos/ntoskrnl/mm/marea.c trunk/reactos/ntoskrnl/mm/mminit.c trunk/reactos/ntoskrnl/mm/section.c Modified: trunk/reactos/ntoskrnl/cache/section/data.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/dat…
============================================================================== --- trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] Sat May 16 21:30:28 2015 @@ -551,7 +551,6 @@ ViewSize, Protect, &MArea, - FALSE, AllocationType, *BaseAddress ? PAGE_SIZE : MM_ALLOCATION_GRANULARITY); Modified: trunk/reactos/ntoskrnl/cc/view.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=677…
============================================================================== --- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Sat May 16 21:30:28 2015 @@ -595,7 +595,6 @@ VACB_MAPPING_GRANULARITY, PAGE_READWRITE, (PMEMORY_AREA*)&Vacb->MemoryArea, - FALSE, 0, PAGE_SIZE); MmUnlockAddressSpace(MmGetKernelAddressSpace()); Modified: trunk/reactos/ntoskrnl/include/internal/mm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sat May 16 21:30:28 2015 @@ -487,7 +487,6 @@ SIZE_T Length, ULONG Protection, PMEMORY_AREA *Result, - BOOLEAN FixedAddress, ULONG AllocationFlags, ULONG AllocationGranularity ); Modified: trunk/reactos/ntoskrnl/mm/ARM3/procsup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/procsup.c…
============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] Sat May 16 21:30:28 2015 @@ -38,7 +38,6 @@ PAGE_SIZE, PAGE_READWRITE, &MemoryArea, - TRUE, 0, PAGE_SIZE); ASSERT(NT_SUCCESS(Status)); Modified: trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c…
============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/vadnode.c [iso-8859-1] Sat May 16 21:30:28 2015 @@ -146,13 +146,19 @@ PVOID AllocatedBase = (PVOID)(Vad->StartingVpn << PAGE_SHIFT); Size = ((Vad->EndingVpn + 1) - Vad->StartingVpn) << PAGE_SHIFT; + + if (AllocatedBase == NULL) + { + AllocatedBase = (PVOID)(ULONG_PTR)1; + Size -= 1; + } + Status = MmCreateMemoryArea(&Process->Vm, MEMORY_AREA_OWNED_BY_ARM3, &AllocatedBase, Size, PAGE_READWRITE, &MemoryArea, - TRUE, 0, PAGE_SIZE); ASSERT(NT_SUCCESS(Status)); Modified: trunk/reactos/ntoskrnl/mm/marea.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=67…
============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sat May 16 21:30:28 2015 @@ -923,7 +923,6 @@ ULONG_PTR Length, ULONG Protect, PMEMORY_AREA *Result, - BOOLEAN FixedAddress, ULONG AllocationFlags, ULONG Granularity) { @@ -933,11 +932,11 @@ DPRINT("MmCreateMemoryArea(Type 0x%lx, BaseAddress %p, " "*BaseAddress %p, Length %p, AllocationFlags %x, " - "FixedAddress %x, Result %p)\n", + "Result %p)\n", Type, BaseAddress, *BaseAddress, Length, AllocationFlags, - FixedAddress, Result); - - if ((*BaseAddress) == 0 && !FixedAddress) + Result); + + if (*BaseAddress == 0) { tmpLength = (ULONG_PTR)MM_ROUND_UP(Length, PAGE_SIZE); *BaseAddress = MmFindGap(AddressSpace, Modified: trunk/reactos/ntoskrnl/mm/mminit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=6…
============================================================================== --- trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] Sat May 16 21:30:28 2015 @@ -57,7 +57,6 @@ MmBootImageSize, PAGE_EXECUTE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -72,7 +71,6 @@ PTE_TOP - PTE_BASE + 1, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -87,7 +85,6 @@ HYPER_SPACE_END - HYPER_SPACE + 1, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -102,7 +99,6 @@ (MxPfnAllocation << PAGE_SHIFT), PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -117,7 +113,6 @@ MmSizeOfNonPagedPoolInBytes, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -132,7 +127,6 @@ MiNonPagedSystemSize, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -147,7 +141,6 @@ MmSystemViewSize, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -163,7 +156,6 @@ (ULONG_PTR)MmSessionBase, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -178,7 +170,6 @@ MmSizeOfPagedPoolInBytes, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -193,7 +184,6 @@ PAGE_SIZE * KeNumberProcessors, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -208,7 +198,6 @@ PAGE_SIZE, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -223,7 +212,6 @@ PAGE_SIZE, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); @@ -239,7 +227,6 @@ PAGE_SIZE * 2, PAGE_READWRITE, &MArea, - TRUE, 0, PAGE_SIZE); ASSERT(Status == STATUS_SUCCESS); Modified: trunk/reactos/ntoskrnl/mm/section.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Sat May 16 21:30:28 2015 @@ -3965,7 +3965,6 @@ ViewSize, Protect, &MArea, - FALSE, AllocationType, Granularity); if (!NT_SUCCESS(Status))
9 years, 7 months
1
0
0
0
[pschweitzer] 67789: [NTOSKRNL] Formatting. No code change!
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Sat May 16 21:13:22 2015 New Revision: 67789 URL:
http://svn.reactos.org/svn/reactos?rev=67789&view=rev
Log: [NTOSKRNL] Formatting. No code change! Modified: trunk/reactos/ntoskrnl/wmi/wmidrv.c Modified: trunk/reactos/ntoskrnl/wmi/wmidrv.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/wmi/wmidrv.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/wmi/wmidrv.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/wmi/wmidrv.c [iso-8859-1] Sat May 16 21:13:22 2015 @@ -435,7 +435,9 @@ static NTSTATUS -WmiSetMark(PWMI_SET_MARK Buffer, ULONG Length) +WmiSetMark( + PWMI_SET_MARK Buffer, + ULONG Length) { UNIMPLEMENTED_DBGBREAK(); return STATUS_SUCCESS;
9 years, 7 months
1
0
0
0
[dreimer] 67788: [MAZE*] Loading from ini file works flawless, even on ROS, so... ENABLE it.
by dreimer@svn.reactos.org
Author: dreimer Date: Sat May 16 21:00:03 2015 New Revision: 67788 URL:
http://svn.reactos.org/svn/reactos?rev=67788&view=rev
Log: [MAZE*] Loading from ini file works flawless, even on ROS, so... ENABLE it. Modified: trunk/rosapps/applications/screensavers/mazescr/maze.c trunk/rosapps/demos/maze/maze.c Modified: trunk/rosapps/applications/screensavers/mazescr/maze.c URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/screensavers/…
============================================================================== --- trunk/rosapps/applications/screensavers/mazescr/maze.c [iso-8859-1] (original) +++ trunk/rosapps/applications/screensavers/mazescr/maze.c [iso-8859-1] Sat May 16 21:00:03 2015 @@ -524,18 +524,10 @@ srand((unsigned) time(NULL)); -#if 0 - /* FIXME GetPrivateProfileInt not yet implemented in ReactOS */ - size = GetPrivateProfileInt("maze", "gridsize", 0, "maze.ini"); - pre_solve_delay = GetPrivateProfileInt("maze", "predelay", 5000, "maze.ini"); - post_solve_delay = GetPrivateProfileInt("maze", "postdelay", 5000, "maze.ini"); - solve_delay = GetPrivateProfileInt("maze", "solvedelay", 10, "maze.ini"); -#else - size = 10; - pre_solve_delay = 5000; - post_solve_delay = 5000; - solve_delay = 1; -#endif + size = GetPrivateProfileIntW(L"maze", L"gridsize", 10, L"maze.ini"); + pre_solve_delay = GetPrivateProfileIntW(L"maze", L"predelay", 5000, L"maze.ini"); + post_solve_delay = GetPrivateProfileIntW(L"maze", L"postdelay", 5000, L"maze.ini"); + solve_delay = GetPrivateProfileIntW(L"maze", L"solvedelay", 1, L"maze.ini"); if (size < 2) { size = 7 + (rand() % 30); Modified: trunk/rosapps/demos/maze/maze.c URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/demos/maze/maze.c?rev=6778…
============================================================================== --- trunk/rosapps/demos/maze/maze.c [iso-8859-1] (original) +++ trunk/rosapps/demos/maze/maze.c [iso-8859-1] Sat May 16 21:00:03 2015 @@ -830,21 +830,10 @@ srand((unsigned) time(NULL)); -#if 0 - /* FIXME GetPrivateProfileInt not yet implemented in ReactOS */ - size = GetPrivateProfileInt("maze", "gridsize", 0, "maze.ini"); - pre_solve_delay = GetPrivateProfileInt("maze", "predelay", 5000, - "maze.ini"); - post_solve_delay = GetPrivateProfileInt("maze", "postdelay", 5000, - "maze.ini"); - solve_delay = GetPrivateProfileInt("maze", "solvedelay", 10, - "maze.ini"); -#else - size = 10; - pre_solve_delay = 5000; - post_solve_delay = 5000; - solve_delay = 20; -#endif + size = GetPrivateProfileIntA("maze", "gridsize", 10, "maze.ini"); + pre_solve_delay = GetPrivateProfileIntA("maze", "predelay", 5000, "maze.ini"); + post_solve_delay = GetPrivateProfileIntA("maze", "postdelay", 5000, "maze.ini"); + solve_delay = GetPrivateProfileIntA("maze", "solvedelay", 1, "maze.ini"); if (size < 2) { size = 7 + (rand() % 30);
9 years, 7 months
1
0
0
0
[tkreuzer] 67787: [NTOSKRNL] Add an MMVAD to the MEMORY_AREA structure, instead of allocating a new one to synchronize with the process VAD tree
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sat May 16 20:10:41 2015 New Revision: 67787 URL:
http://svn.reactos.org/svn/reactos?rev=67787&view=rev
Log: [NTOSKRNL] Add an MMVAD to the MEMORY_AREA structure, instead of allocating a new one to synchronize with the process VAD tree Modified: trunk/reactos/ntoskrnl/include/internal/mm.h trunk/reactos/ntoskrnl/mm/marea.c Modified: trunk/reactos/ntoskrnl/include/internal/mm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sat May 16 20:10:41 2015 @@ -204,6 +204,7 @@ typedef struct _MEMORY_AREA { + MMVAD VadNode; ULONG_PTR StartingVpn; ULONG_PTR EndingVpn; struct _MEMORY_AREA *Parent; Modified: trunk/reactos/ntoskrnl/mm/marea.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=67…
============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sat May 16 20:10:41 2015 @@ -384,8 +384,8 @@ PMMVAD Vad; ASSERT(marea->Type == MEMORY_AREA_SECTION_VIEW || marea->Type == MEMORY_AREA_CACHE); - Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD), TAG_MVAD); - ASSERT(Vad); + Vad = &marea->VadNode; + RtlZeroMemory(Vad, sizeof(MMVAD)); Vad->StartingVpn = PAGE_ROUND_DOWN(MA_GetStartingAddress(marea)) >> PAGE_SHIFT; /* @@ -825,7 +825,6 @@ MiRemoveNode(MemoryArea->Vad, &Process->VadRoot); } - ExFreePoolWithTag(MemoryArea->Vad, TAG_MVAD); MemoryArea->Vad = NULL; } }
9 years, 7 months
1
0
0
0
[tkreuzer] 67786: [NTOSKRNL] Convert MEMORY_AREA::EndingAddress to EndingVpn
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sat May 16 20:10:26 2015 New Revision: 67786 URL:
http://svn.reactos.org/svn/reactos?rev=67786&view=rev
Log: [NTOSKRNL] Convert MEMORY_AREA::EndingAddress to EndingVpn Modified: trunk/reactos/ntoskrnl/cache/section/data.c trunk/reactos/ntoskrnl/cache/section/fault.c trunk/reactos/ntoskrnl/cache/section/swapout.c trunk/reactos/ntoskrnl/include/internal/mm.h trunk/reactos/ntoskrnl/mm/ARM3/virtual.c trunk/reactos/ntoskrnl/mm/marea.c trunk/reactos/ntoskrnl/mm/section.c Modified: trunk/reactos/ntoskrnl/cache/section/data.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/dat…
============================================================================== --- trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] Sat May 16 20:10:26 2015 @@ -161,7 +161,7 @@ return STATUS_NOT_MAPPED_DATA; } BeginningAddress = PAGE_ROUND_DOWN(MA_GetStartingAddress(MemoryArea)); - EndingAddress = PAGE_ROUND_UP((ULONG_PTR)MemoryArea->EndingAddress); + EndingAddress = PAGE_ROUND_UP(MA_GetEndingAddress(MemoryArea)); Segment = MemoryArea->Data.SectionData.Segment; ViewOffset.QuadPart = MemoryArea->Data.SectionData.ViewOffset.QuadPart; Modified: trunk/reactos/ntoskrnl/cache/section/fault.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/fau…
============================================================================== --- trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] Sat May 16 20:10:26 2015 @@ -123,7 +123,7 @@ AddressSpace, Address, MA_GetStartingAddress(MemoryArea), - MemoryArea->EndingAddress); + MA_GetEndingAddress(MemoryArea)); /* * There is a window between taking the page fault and locking the @@ -585,7 +585,7 @@ DPRINT("Type %x (%p -> %p)\n", MemoryArea->Type, MA_GetStartingAddress(MemoryArea), - MemoryArea->EndingAddress); + MA_GetEndingAddress(MemoryArea)); Resources.DoAcquisition = NULL; @@ -661,7 +661,7 @@ DPRINT1("Type %x (%p -> %p)\n", MemoryArea->Type, MA_GetStartingAddress(MemoryArea), - MemoryArea->EndingAddress); + MA_GetEndingAddress(MemoryArea)); } if (!FromMdl) @@ -790,7 +790,7 @@ MemoryArea->Type, MA_GetStartingAddress(MemoryArea), Address, - MemoryArea->EndingAddress, + MA_GetEndingAddress(MemoryArea), PsGetCurrentThread()); Resources.DoAcquisition = NULL; Modified: trunk/reactos/ntoskrnl/cache/section/swapout.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/swa…
============================================================================== --- trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] Sat May 16 20:10:26 2015 @@ -458,7 +458,7 @@ DPRINTC("Type %x (%p -> %p)\n", MemoryArea->Type, MA_GetStartingAddress(MemoryArea), - MemoryArea->EndingAddress); + MA_GetEndingAddress(MemoryArea)); Resources.DoAcquisition = NULL; Resources.Page[0] = Page; Modified: trunk/reactos/ntoskrnl/include/internal/mm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sat May 16 20:10:26 2015 @@ -205,7 +205,7 @@ typedef struct _MEMORY_AREA { ULONG_PTR StartingVpn; - ULONG_PTR EndingAddress; + ULONG_PTR EndingVpn; struct _MEMORY_AREA *Parent; struct _MEMORY_AREA *LeftChild; struct _MEMORY_AREA *RightChild; Modified: trunk/reactos/ntoskrnl/mm/ARM3/virtual.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/virtual.c…
============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] Sat May 16 20:10:26 2015 @@ -1886,7 +1886,7 @@ if (!NT_SUCCESS(Status)) { DPRINT1("MmQuerySectionView failed. MemoryArea=%p (%p-%p), BaseAddress=%p\n", - MemoryArea, MA_GetStartingAddress(MemoryArea), MemoryArea->EndingAddress, BaseAddress); + MemoryArea, MA_GetStartingAddress(MemoryArea), MA_GetEndingAddress(MemoryArea), BaseAddress); NT_ASSERT(NT_SUCCESS(Status)); } } @@ -5317,10 +5317,10 @@ Vad->u.VadFlags.CommitCharge -= CommitReduction; // For ReactOS: shrink the corresponding memory area MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, (PVOID)StartingAddress); - ASSERT(Vad->StartingVpn << PAGE_SHIFT == MA_GetStartingAddress(MemoryArea)); - ASSERT((Vad->EndingVpn + 1) << PAGE_SHIFT == MemoryArea->EndingAddress); + ASSERT(Vad->StartingVpn == MemoryArea->StartingVpn); + ASSERT(Vad->EndingVpn == MemoryArea->EndingVpn); Vad->EndingVpn = (StartingAddress - 1) >> PAGE_SHIFT; - MemoryArea->EndingAddress = StartingAddress; + MemoryArea->EndingVpn = Vad->EndingVpn; } else { Modified: trunk/reactos/ntoskrnl/mm/marea.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=67…
============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sat May 16 20:10:26 2015 @@ -174,12 +174,12 @@ { if (Address < MA_GetStartingAddress(Node)) Node = Node->LeftChild; - else if (Address >= Node->EndingAddress) + else if (Address >= MA_GetEndingAddress(Node)) Node = Node->RightChild; else { DPRINT("MmLocateMemoryAreaByAddress(%p): %p [%p - %p]\n", - Address, Node, MA_GetStartingAddress(Node), Node->EndingAddress); + Address, Node, MA_GetStartingAddress(Node), MA_GetEndingAddress(Node)); return Node; } } @@ -212,23 +212,23 @@ { DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n", Address, (ULONG_PTR)Address + Length, MA_GetStartingAddress(Node), - Node->EndingAddress); + MA_GetEndingAddress(Node)); return Node; } - if (Node->EndingAddress > Address && - Node->EndingAddress < Extent) + if (MA_GetEndingAddress(Node) > Address && + MA_GetEndingAddress(Node) < Extent) { DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n", Address, (ULONG_PTR)Address + Length, MA_GetStartingAddress(Node), - Node->EndingAddress); + MA_GetEndingAddress(Node)); return Node; } if (MA_GetStartingAddress(Node) <= Address && - Node->EndingAddress >= Extent) + MA_GetEndingAddress(Node) >= Extent) { DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n", Address, (ULONG_PTR)Address + Length, MA_GetStartingAddress(Node), - Node->EndingAddress); + MA_GetEndingAddress(Node)); return Node; } if (MA_GetStartingAddress(Node) >= Extent) @@ -378,7 +378,7 @@ PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace); /* Build a lame VAD if this is a user-space allocation */ - if ((marea->EndingAddress < (ULONG_PTR)MmSystemRangeStart) && + if ((MA_GetEndingAddress(marea) < (ULONG_PTR)MmSystemRangeStart) && (marea->Type != MEMORY_AREA_OWNED_BY_ARM3)) { PMMVAD Vad; @@ -393,9 +393,9 @@ * In a normal OS/Memory Manager, this would be retarded, but ReactOS allows this (how it works * I don't even want to know). */ - if (marea->EndingAddress != MA_GetStartingAddress(marea)) - { - Vad->EndingVpn = PAGE_ROUND_DOWN((ULONG_PTR)marea->EndingAddress - 1) >> PAGE_SHIFT; + if (MA_GetEndingAddress(marea) != MA_GetStartingAddress(marea)) + { + Vad->EndingVpn = PAGE_ROUND_DOWN((ULONG_PTR)MA_GetEndingAddress(marea) - 1) >> PAGE_SHIFT; } else { @@ -423,12 +423,12 @@ Node = (PMEMORY_AREA)AddressSpace->WorkingSetExpansionLinks.Flink; do { - DPRINT("marea->EndingAddress: %p Node->StartingAddress: %p\n", - marea->EndingAddress, MA_GetStartingAddress(Node)); - DPRINT("marea->StartingAddress: %p Node->EndingAddress: %p\n", - MA_GetStartingAddress(marea), Node->EndingAddress); - ASSERT(marea->EndingAddress <= MA_GetStartingAddress(Node) || - MA_GetStartingAddress(marea) >= Node->EndingAddress); + DPRINT("MA_GetEndingAddress(marea): %p Node->StartingAddress: %p\n", + MA_GetEndingAddress(marea), MA_GetStartingAddress(Node)); + DPRINT("marea->StartingAddress: %p MA_GetEndingAddress(Node): %p\n", + MA_GetStartingAddress(marea), MA_GetEndingAddress(Node)); + ASSERT(MA_GetEndingAddress(marea) <= MA_GetStartingAddress(Node) || + MA_GetStartingAddress(marea) >= MA_GetEndingAddress(Node)); ASSERT(MA_GetStartingAddress(marea) != MA_GetStartingAddress(Node)); PreviousNode = Node; @@ -490,13 +490,13 @@ /* Go to the node with lowest address in the tree. */ Node = Root ? MmIterateFirstNode(Root) : NULL; - while (Node && ((ULONG_PTR)Node->EndingAddress < LowestAddress)) + while (Node && ((ULONG_PTR)MA_GetEndingAddress(Node) < LowestAddress)) { Node = MmIterateNextNode(Node); } /* Traverse the tree from low to high addresses */ - while (Node && ((ULONG_PTR)Node->EndingAddress < HighestAddress)) + while (Node && ((ULONG_PTR)MA_GetEndingAddress(Node) < HighestAddress)) { /* Check if the memory area fits before the current node */ if (MA_GetStartingAddress(Node) >= (Candidate + Length)) @@ -507,10 +507,10 @@ } /* Calculate next possible adress above this node */ - Candidate = ALIGN_UP_BY((ULONG_PTR)Node->EndingAddress, Granularity); + Candidate = ALIGN_UP_BY((ULONG_PTR)MA_GetEndingAddress(Node), Granularity); /* Check for overflow */ - if ((Candidate + Length) < (ULONG_PTR)Node->EndingAddress) return NULL; + if ((Candidate + Length) < (ULONG_PTR)MA_GetEndingAddress(Node)) return NULL; /* Go to the next higher node */ Node = MmIterateNextNode(Node); @@ -570,7 +570,7 @@ while (Node && (MA_GetStartingAddress(Node) > LowestAddress)) { /* Check if the memory area fits after the current node */ - if ((ULONG_PTR)Node->EndingAddress <= Candidate) + if ((ULONG_PTR)MA_GetEndingAddress(Node) <= Candidate) { DPRINT("MmFindGapTopDown: %p\n", Candidate); return (PVOID)Candidate; @@ -631,9 +631,9 @@ /* Check some fields */ ASSERT(Node->Magic == 'erAM'); ASSERT(PAGE_ALIGN(MA_GetStartingAddress(Node)) == (PVOID)MA_GetStartingAddress(Node)); - ASSERT(Node->EndingAddress != 0); - ASSERT(PAGE_ALIGN(Node->EndingAddress) == (PVOID)Node->EndingAddress); - ASSERT(MA_GetStartingAddress(Node) < Node->EndingAddress); + ASSERT(MA_GetEndingAddress(Node) != 0); + ASSERT(PAGE_ALIGN(MA_GetEndingAddress(Node)) == (PVOID)MA_GetEndingAddress(Node)); + ASSERT(MA_GetStartingAddress(Node) < MA_GetEndingAddress(Node)); ASSERT((Node->Type == 0) || (Node->Type == MEMORY_AREA_CACHE) || // (Node->Type == MEMORY_AREA_CACHE_SEGMENT) || @@ -765,7 +765,7 @@ KeAttachProcess(&Process->Pcb); } - EndAddress = MM_ROUND_UP(MemoryArea->EndingAddress, PAGE_SIZE); + EndAddress = MM_ROUND_UP(MA_GetEndingAddress(MemoryArea), PAGE_SIZE); for (Address = MA_GetStartingAddress(MemoryArea); Address < (ULONG_PTR)EndAddress; Address += PAGE_SIZE) @@ -815,7 +815,7 @@ if (MemoryArea->Vad) { - ASSERT(MemoryArea->EndingAddress < (ULONG_PTR)MmSystemRangeStart); + ASSERT(MA_GetEndingAddress(MemoryArea) < (ULONG_PTR)MmSystemRangeStart); ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW || MemoryArea->Type == MEMORY_AREA_CACHE); /* MmCleanProcessAddressSpace might have removed it (and this would be MmDeleteProcessAdressSpace) */ @@ -1009,7 +1009,7 @@ RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA)); MemoryArea->Type = Type; MemoryArea->StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT; - MemoryArea->EndingAddress = ((ULONG_PTR)*BaseAddress + tmpLength); + MemoryArea->EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT; MemoryArea->Protect = Protect; MemoryArea->Flags = AllocationFlags; //MemoryArea->LockCount = 0; Modified: trunk/reactos/ntoskrnl/mm/section.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Sat May 16 20:10:26 2015 @@ -2520,7 +2520,7 @@ NTSTATUS Status; ULONG_PTR MaxLength; - MaxLength = MemoryArea->EndingAddress - (ULONG_PTR)BaseAddress; + MaxLength = MA_GetEndingAddress(MemoryArea) - (ULONG_PTR)BaseAddress; if (Length > MaxLength) Length = (ULONG)MaxLength;
9 years, 7 months
1
0
0
0
[tkreuzer] 67785: [NTOSKRNL] Convert MEMORY_AREA::StartingAddress to StaringVpn
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sat May 16 20:10:03 2015 New Revision: 67785 URL:
http://svn.reactos.org/svn/reactos?rev=67785&view=rev
Log: [NTOSKRNL] Convert MEMORY_AREA::StartingAddress to StaringVpn Modified: trunk/reactos/ntoskrnl/cache/section/data.c trunk/reactos/ntoskrnl/cache/section/fault.c trunk/reactos/ntoskrnl/cache/section/swapout.c trunk/reactos/ntoskrnl/include/internal/mm.h trunk/reactos/ntoskrnl/mm/ARM3/virtual.c trunk/reactos/ntoskrnl/mm/marea.c trunk/reactos/ntoskrnl/mm/rmap.c trunk/reactos/ntoskrnl/mm/section.c Modified: trunk/reactos/ntoskrnl/cache/section/data.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/dat…
============================================================================== --- trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] Sat May 16 20:10:03 2015 @@ -160,7 +160,7 @@ DPRINT("STATUS_NOT_MAPPED_DATA\n"); return STATUS_NOT_MAPPED_DATA; } - BeginningAddress = PAGE_ROUND_DOWN((ULONG_PTR)MemoryArea->StartingAddress); + BeginningAddress = PAGE_ROUND_DOWN(MA_GetStartingAddress(MemoryArea)); EndingAddress = PAGE_ROUND_UP((ULONG_PTR)MemoryArea->EndingAddress); Segment = MemoryArea->Data.SectionData.Segment; ViewOffset.QuadPart = MemoryArea->Data.SectionData.ViewOffset.QuadPart; @@ -681,7 +681,7 @@ Process = MmGetAddressSpaceOwner(AddressSpace); Address = (PVOID)PAGE_ROUND_DOWN(Address); Segment = ContextData[1]; - Offset.QuadPart = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress + + Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea) + MemoryArea->Data.SectionData.ViewOffset.QuadPart; Entry = MmGetPageEntrySectionSegment(Segment, &Offset); @@ -732,7 +732,7 @@ DPRINT("MmFreeMemoryArea(%p,%p)\n", MmGetAddressSpaceOwner(AddressSpace), - MemoryArea->StartingAddress); + MA_GetStartingAddress(MemoryArea)); MmLockAddressSpace(AddressSpace); Modified: trunk/reactos/ntoskrnl/cache/section/fault.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/fau…
============================================================================== --- trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] Sat May 16 20:10:03 2015 @@ -122,7 +122,7 @@ DPRINT("Not Present: %p %p (%p-%p)\n", AddressSpace, Address, - MemoryArea->StartingAddress, + MA_GetStartingAddress(MemoryArea), MemoryArea->EndingAddress); /* @@ -138,7 +138,7 @@ PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE); TotalOffset.QuadPart = (ULONG_PTR)PAddress - - (ULONG_PTR)MemoryArea->StartingAddress; + MA_GetStartingAddress(MemoryArea); Segment = MemoryArea->Data.SectionData.Segment; @@ -345,7 +345,7 @@ /* Find the offset of the page */ PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE); - Offset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress + + Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea) + MemoryArea->Data.SectionData.ViewOffset.QuadPart; if (!Segment->WriteCopy /*&& @@ -584,7 +584,7 @@ DPRINT("Type %x (%p -> %p)\n", MemoryArea->Type, - MemoryArea->StartingAddress, + MA_GetStartingAddress(MemoryArea), MemoryArea->EndingAddress); Resources.DoAcquisition = NULL; @@ -660,7 +660,7 @@ DPRINT1("Completed page fault handling %Ix %x\n", Address, Status); DPRINT1("Type %x (%p -> %p)\n", MemoryArea->Type, - MemoryArea->StartingAddress, + MA_GetStartingAddress(MemoryArea), MemoryArea->EndingAddress); } @@ -788,7 +788,7 @@ DPRINTC("Type %x (%p -> %08Ix -> %p) in %p\n", MemoryArea->Type, - MemoryArea->StartingAddress, + MA_GetStartingAddress(MemoryArea), Address, MemoryArea->EndingAddress, PsGetCurrentThread()); Modified: trunk/reactos/ntoskrnl/cache/section/swapout.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/swa…
============================================================================== --- trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] Sat May 16 20:10:03 2015 @@ -289,7 +289,8 @@ PMM_SECTION_SEGMENT Segment; PVOID PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE); - TotalOffset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress + + TotalOffset.QuadPart = (ULONG_PTR)PAddress - + MA_GetStartingAddress(MemoryArea) + MemoryArea->Data.SectionData.ViewOffset.QuadPart; Segment = MemoryArea->Data.SectionData.Segment; @@ -456,7 +457,7 @@ DPRINTC("Type %x (%p -> %p)\n", MemoryArea->Type, - MemoryArea->StartingAddress, + MA_GetStartingAddress(MemoryArea), MemoryArea->EndingAddress); Resources.DoAcquisition = NULL; Modified: trunk/reactos/ntoskrnl/include/internal/mm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sat May 16 20:10:03 2015 @@ -199,9 +199,12 @@ }; } ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT; +#define MA_GetStartingAddress(_MemoryArea) ((_MemoryArea)->StartingVpn << PAGE_SHIFT) +#define MA_GetEndingAddress(_MemoryArea) (((_MemoryArea)->EndingVpn + 1) << PAGE_SHIFT) + typedef struct _MEMORY_AREA { - ULONG_PTR StartingAddress; + ULONG_PTR StartingVpn; ULONG_PTR EndingAddress; struct _MEMORY_AREA *Parent; struct _MEMORY_AREA *LeftChild; Modified: trunk/reactos/ntoskrnl/mm/ARM3/virtual.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/virtual.c…
============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] Sat May 16 20:10:03 2015 @@ -1886,7 +1886,7 @@ if (!NT_SUCCESS(Status)) { DPRINT1("MmQuerySectionView failed. MemoryArea=%p (%p-%p), BaseAddress=%p\n", - MemoryArea, MemoryArea->StartingAddress, MemoryArea->EndingAddress, BaseAddress); + MemoryArea, MA_GetStartingAddress(MemoryArea), MemoryArea->EndingAddress, BaseAddress); NT_ASSERT(NT_SUCCESS(Status)); } } @@ -5317,7 +5317,7 @@ Vad->u.VadFlags.CommitCharge -= CommitReduction; // For ReactOS: shrink the corresponding memory area MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, (PVOID)StartingAddress); - ASSERT(Vad->StartingVpn << PAGE_SHIFT == MemoryArea->StartingAddress); + ASSERT(Vad->StartingVpn << PAGE_SHIFT == MA_GetStartingAddress(MemoryArea)); ASSERT((Vad->EndingVpn + 1) << PAGE_SHIFT == MemoryArea->EndingAddress); Vad->EndingVpn = (StartingAddress - 1) >> PAGE_SHIFT; MemoryArea->EndingAddress = StartingAddress; Modified: trunk/reactos/ntoskrnl/mm/marea.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=67…
============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sat May 16 20:10:03 2015 @@ -172,14 +172,14 @@ while (Node != NULL) { - if (Address < Node->StartingAddress) + if (Address < MA_GetStartingAddress(Node)) Node = Node->LeftChild; else if (Address >= Node->EndingAddress) Node = Node->RightChild; else { DPRINT("MmLocateMemoryAreaByAddress(%p): %p [%p - %p]\n", - Address, Node, Node->StartingAddress, Node->EndingAddress); + Address, Node, MA_GetStartingAddress(Node), Node->EndingAddress); return Node; } } @@ -207,11 +207,11 @@ Node != NULL; Node = MmIterateNextNode(Node)) { - if (Node->StartingAddress >= Address && - Node->StartingAddress < Extent) + if (MA_GetStartingAddress(Node) >= Address && + MA_GetStartingAddress(Node) < Extent) { DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n", - Address, (ULONG_PTR)Address + Length, Node->StartingAddress, + Address, (ULONG_PTR)Address + Length, MA_GetStartingAddress(Node), Node->EndingAddress); return Node; } @@ -219,19 +219,19 @@ Node->EndingAddress < Extent) { DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n", - Address, (ULONG_PTR)Address + Length, Node->StartingAddress, + Address, (ULONG_PTR)Address + Length, MA_GetStartingAddress(Node), Node->EndingAddress); return Node; } - if (Node->StartingAddress <= Address && + if (MA_GetStartingAddress(Node) <= Address && Node->EndingAddress >= Extent) { DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n", - Address, (ULONG_PTR)Address + Length, Node->StartingAddress, + Address, (ULONG_PTR)Address + Length, MA_GetStartingAddress(Node), Node->EndingAddress); return Node; } - if (Node->StartingAddress >= Extent) + if (MA_GetStartingAddress(Node) >= Extent) { DPRINT("Finished MmLocateMemoryAreaByRegion() = NULL\n"); return NULL; @@ -387,13 +387,13 @@ Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD), TAG_MVAD); ASSERT(Vad); RtlZeroMemory(Vad, sizeof(MMVAD)); - Vad->StartingVpn = PAGE_ROUND_DOWN(marea->StartingAddress) >> PAGE_SHIFT; + Vad->StartingVpn = PAGE_ROUND_DOWN(MA_GetStartingAddress(marea)) >> PAGE_SHIFT; /* * For some strange reason, it is perfectly valid to create a MAREA from 0x1000 to... 0x1000. * In a normal OS/Memory Manager, this would be retarded, but ReactOS allows this (how it works * I don't even want to know). */ - if (marea->EndingAddress != marea->StartingAddress) + if (marea->EndingAddress != MA_GetStartingAddress(marea)) { Vad->EndingVpn = PAGE_ROUND_DOWN((ULONG_PTR)marea->EndingAddress - 1) >> PAGE_SHIFT; } @@ -424,16 +424,16 @@ do { DPRINT("marea->EndingAddress: %p Node->StartingAddress: %p\n", - marea->EndingAddress, Node->StartingAddress); + marea->EndingAddress, MA_GetStartingAddress(Node)); DPRINT("marea->StartingAddress: %p Node->EndingAddress: %p\n", - marea->StartingAddress, Node->EndingAddress); - ASSERT(marea->EndingAddress <= Node->StartingAddress || - marea->StartingAddress >= Node->EndingAddress); - ASSERT(marea->StartingAddress != Node->StartingAddress); + MA_GetStartingAddress(marea), Node->EndingAddress); + ASSERT(marea->EndingAddress <= MA_GetStartingAddress(Node) || + MA_GetStartingAddress(marea) >= Node->EndingAddress); + ASSERT(MA_GetStartingAddress(marea) != MA_GetStartingAddress(Node)); PreviousNode = Node; - if (marea->StartingAddress < Node->StartingAddress) + if (MA_GetStartingAddress(marea) < MA_GetStartingAddress(Node)) Node = Node->LeftChild; else Node = Node->RightChild; @@ -452,7 +452,7 @@ marea->LeftChild = marea->RightChild = NULL; marea->Parent = PreviousNode; - if (marea->StartingAddress < PreviousNode->StartingAddress) + if (MA_GetStartingAddress(marea) < MA_GetStartingAddress(PreviousNode)) PreviousNode->LeftChild = marea; else PreviousNode->RightChild = marea; @@ -499,7 +499,7 @@ while (Node && ((ULONG_PTR)Node->EndingAddress < HighestAddress)) { /* Check if the memory area fits before the current node */ - if ((ULONG_PTR)Node->StartingAddress >= (Candidate + Length)) + if (MA_GetStartingAddress(Node) >= (Candidate + Length)) { DPRINT("MmFindGapBottomUp: %p\n", Candidate); ASSERT(Candidate >= LowestAddress); @@ -561,13 +561,13 @@ /* Go to the node with highest address in the tree. */ Node = Root ? MmIterateLastNode(Root) : NULL; - while (Node && ((ULONG_PTR)Node->StartingAddress > HighestAddress)) + while (Node && (MA_GetStartingAddress(Node) > HighestAddress)) { Node = MmIteratePrevNode(Node); } /* Traverse the tree from high to low addresses */ - while (Node && ((ULONG_PTR)Node->StartingAddress > LowestAddress)) + while (Node && (MA_GetStartingAddress(Node) > LowestAddress)) { /* Check if the memory area fits after the current node */ if ((ULONG_PTR)Node->EndingAddress <= Candidate) @@ -577,11 +577,11 @@ } /* Calculate next possible adress below this node */ - Candidate = ALIGN_DOWN_BY((ULONG_PTR)Node->StartingAddress - Length, + Candidate = ALIGN_DOWN_BY(MA_GetStartingAddress(Node) - Length, Granularity); /* Check for overflow. */ - if (Candidate > (ULONG_PTR)Node->StartingAddress) + if (Candidate > MA_GetStartingAddress(Node)) return NULL; /* Go to the next lower node */ @@ -630,10 +630,10 @@ /* Check some fields */ ASSERT(Node->Magic == 'erAM'); - ASSERT(PAGE_ALIGN(Node->StartingAddress) == (PVOID)Node->StartingAddress); + ASSERT(PAGE_ALIGN(MA_GetStartingAddress(Node)) == (PVOID)MA_GetStartingAddress(Node)); ASSERT(Node->EndingAddress != 0); ASSERT(PAGE_ALIGN(Node->EndingAddress) == (PVOID)Node->EndingAddress); - ASSERT(Node->StartingAddress < Node->EndingAddress); + ASSERT(MA_GetStartingAddress(Node) < Node->EndingAddress); ASSERT((Node->Type == 0) || (Node->Type == MEMORY_AREA_CACHE) || // (Node->Type == MEMORY_AREA_CACHE_SEGMENT) || @@ -766,7 +766,7 @@ } EndAddress = MM_ROUND_UP(MemoryArea->EndingAddress, PAGE_SIZE); - for (Address = (ULONG_PTR)MemoryArea->StartingAddress; + for (Address = MA_GetStartingAddress(MemoryArea); Address < (ULONG_PTR)EndAddress; Address += PAGE_SIZE) { @@ -1008,7 +1008,7 @@ RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA)); MemoryArea->Type = Type; - MemoryArea->StartingAddress = (ULONG_PTR)*BaseAddress; + MemoryArea->StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT; MemoryArea->EndingAddress = ((ULONG_PTR)*BaseAddress + tmpLength); MemoryArea->Protect = Protect; MemoryArea->Flags = AllocationFlags; @@ -1049,14 +1049,14 @@ switch (MemoryArea->Type) { case MEMORY_AREA_SECTION_VIEW: - Address = (PVOID)MemoryArea->StartingAddress; + Address = (PVOID)MA_GetStartingAddress(MemoryArea); MmUnlockAddressSpace(&Process->Vm); MmUnmapViewOfSection(Process, Address); MmLockAddressSpace(&Process->Vm); break; case MEMORY_AREA_CACHE: - Address = (PVOID)MemoryArea->StartingAddress; + Address = (PVOID)MA_GetStartingAddress(MemoryArea); MmUnlockAddressSpace(&Process->Vm); MmUnmapViewOfCacheSegment(&Process->Vm, Address); MmLockAddressSpace(&Process->Vm); Modified: trunk/reactos/ntoskrnl/mm/rmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/rmap.c?rev=677…
============================================================================== --- trunk/reactos/ntoskrnl/mm/rmap.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/rmap.c [iso-8859-1] Sat May 16 20:10:03 2015 @@ -137,7 +137,7 @@ { ULONG_PTR Entry; Offset = MemoryArea->Data.SectionData.ViewOffset.QuadPart + - ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress); + ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)); MmLockSectionSegment(MemoryArea->Data.SectionData.Segment); Modified: trunk/reactos/ntoskrnl/mm/section.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Sat May 16 20:10:03 2015 @@ -1323,12 +1323,12 @@ } PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE); - Offset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress + Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea) + MemoryArea->Data.SectionData.ViewOffset.QuadPart; Segment = MemoryArea->Data.SectionData.Segment; Section = MemoryArea->Data.SectionData.Section; - Region = MmFindRegion((PVOID)MemoryArea->StartingAddress, + Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), &MemoryArea->Data.SectionData.RegionListHead, Address, NULL); ASSERT(Region != NULL); @@ -1700,12 +1700,12 @@ * Find the offset of the page */ PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE); - Offset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress + Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea) + MemoryArea->Data.SectionData.ViewOffset.QuadPart; Segment = MemoryArea->Data.SectionData.Segment; Section = MemoryArea->Data.SectionData.Section; - Region = MmFindRegion((PVOID)MemoryArea->StartingAddress, + Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), &MemoryArea->Data.SectionData.RegionListHead, Address, NULL); ASSERT(Region != NULL); @@ -1895,7 +1895,7 @@ Context.SectionEntry = Entry; Context.CallingProcess = Process; - Context.Offset.QuadPart = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress + Context.Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea) + MemoryArea->Data.SectionData.ViewOffset.QuadPart; DirectMapped = FALSE; @@ -2294,7 +2294,7 @@ Address = (PVOID)PAGE_ROUND_DOWN(Address); - Offset.QuadPart = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress + Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea) + MemoryArea->Data.SectionData.ViewOffset.QuadPart; /* @@ -2478,7 +2478,7 @@ ULONG_PTR Entry; PFN_NUMBER Page; - Offset.QuadPart = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress + Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea) + MemoryArea->Data.SectionData.ViewOffset.QuadPart; Entry = MmGetPageEntrySectionSegment(Segment, &Offset); /* @@ -2524,7 +2524,7 @@ if (Length > MaxLength) Length = (ULONG)MaxLength; - Region = MmFindRegion((PVOID)MemoryArea->StartingAddress, + Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), &MemoryArea->Data.SectionData.RegionListHead, BaseAddress, NULL); ASSERT(Region != NULL); @@ -2536,7 +2536,7 @@ } *OldProtect = Region->Protect; - Status = MmAlterRegion(AddressSpace, (PVOID)MemoryArea->StartingAddress, + Status = MmAlterRegion(AddressSpace, (PVOID)MA_GetStartingAddress(MemoryArea), &MemoryArea->Data.SectionData.RegionListHead, BaseAddress, Length, Region->Type, Protect, MmAlterViewAttributes); @@ -2555,7 +2555,7 @@ PROS_SECTION_OBJECT Section; PMM_SECTION_SEGMENT Segment; - Region = MmFindRegion((PVOID)MemoryArea->StartingAddress, + Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), &MemoryArea->Data.SectionData.RegionListHead, Address, &RegionBaseAddress); if (Region == NULL) @@ -2567,12 +2567,12 @@ if (Section->AllocationAttributes & SEC_IMAGE) { Segment = MemoryArea->Data.SectionData.Segment; - Info->AllocationBase = (PUCHAR)MemoryArea->StartingAddress - Segment->Image.VirtualAddress; + Info->AllocationBase = (PUCHAR)MA_GetStartingAddress(MemoryArea) - Segment->Image.VirtualAddress; Info->Type = MEM_IMAGE; } else { - Info->AllocationBase = (PVOID)MemoryArea->StartingAddress; + Info->AllocationBase = (PVOID)MA_GetStartingAddress(MemoryArea); Info->Type = MEM_MAPPED; } Info->BaseAddress = RegionBaseAddress; @@ -4008,7 +4008,7 @@ Address = (PVOID)PAGE_ROUND_DOWN(Address); - Offset.QuadPart = ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) + + Offset.QuadPart = ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)) + MemoryArea->Data.SectionData.ViewOffset.QuadPart; Section = MemoryArea->Data.SectionData.Section;
9 years, 7 months
1
0
0
0
← Newer
1
...
17
18
19
20
21
22
23
...
50
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Results per page:
10
25
50
100
200