mirror of
https://github.com/reactos/reactos.git
synced 2025-04-25 16:10:29 +00:00
[NTOS:MM] Add MmIsAddressRangeFree helper function
Use this instead of MmLocateMemoryAreaByRegion to determine whether we can inert a section at the requested base address. This will be required to get rid of fake memory areas allocated for each ARM³ VAD.
This commit is contained in:
parent
48027a8058
commit
d27f5971c5
3 changed files with 31 additions and 5 deletions
|
@ -618,6 +618,13 @@ MmLocateMemoryAreaByRegion(
|
|||
SIZE_T Length
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
MmIsAddressRangeFree(
|
||||
_In_ PMMSUPPORT AddressSpace,
|
||||
_In_ PVOID Address,
|
||||
_In_ ULONG_PTR Length);
|
||||
|
||||
PVOID
|
||||
NTAPI
|
||||
MmFindGap(
|
||||
|
|
|
@ -115,6 +115,28 @@ MmLocateMemoryAreaByRegion(
|
|||
return MemoryArea;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
MmIsAddressRangeFree(
|
||||
_In_ PMMSUPPORT AddressSpace,
|
||||
_In_ PVOID Address,
|
||||
_In_ 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;
|
||||
TABLE_SEARCH_RESULT Result;
|
||||
|
||||
Process = MmGetAddressSpaceOwner(AddressSpace);
|
||||
Table = (Process != NULL) ? &Process->VadRoot : &MiRosKernelVadRoot;
|
||||
|
||||
Result = MiCheckForConflictingNode(StartVpn, EndVpn, Table, &Node);
|
||||
|
||||
return (Result != TableFoundNode);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
MiInsertVad(IN PMMVAD Vad,
|
||||
|
@ -460,9 +482,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
|
|||
/* No need to check ARM3 owned memory areas, the range MUST be free */
|
||||
if (MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3)
|
||||
{
|
||||
if (MmLocateMemoryAreaByRegion(AddressSpace,
|
||||
*BaseAddress,
|
||||
tmpLength) != NULL)
|
||||
if (!MmIsAddressRangeFree(AddressSpace, *BaseAddress, tmpLength))
|
||||
{
|
||||
DPRINT("Memory area already occupied\n");
|
||||
if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA);
|
||||
|
|
|
@ -4104,8 +4104,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
|||
}
|
||||
|
||||
/* Check there is enough space to map the section at that point. */
|
||||
if (MmLocateMemoryAreaByRegion(AddressSpace, (PVOID)ImageBase,
|
||||
PAGE_ROUND_UP(ImageSize)) != NULL)
|
||||
if (!MmIsAddressRangeFree(AddressSpace, (PVOID)ImageBase, PAGE_ROUND_UP(ImageSize)))
|
||||
{
|
||||
/* Fail if the user requested a fixed base address. */
|
||||
if ((*BaseAddress) != NULL)
|
||||
|
|
Loading…
Reference in a new issue