mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
Check the length of the gap if this starts at the begin or end of the area in MmFindGap.
svn path=/trunk/; revision=4099
This commit is contained in:
parent
f0fd058aef
commit
f979d1b237
1 changed files with 23 additions and 4 deletions
|
@ -212,6 +212,7 @@ PVOID MmFindGap(PMADDRESS_SPACE AddressSpace, ULONG Length)
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
MEMORY_AREA* next;
|
MEMORY_AREA* next;
|
||||||
ULONG Gap;
|
ULONG Gap;
|
||||||
|
PVOID Address;
|
||||||
|
|
||||||
DPRINT("MmFindGap(Length %x)\n",Length);
|
DPRINT("MmFindGap(Length %x)\n",Length);
|
||||||
|
|
||||||
|
@ -232,11 +233,29 @@ PVOID MmFindGap(PMADDRESS_SPACE AddressSpace, ULONG Length)
|
||||||
|
|
||||||
if (current_entry == ListHead)
|
if (current_entry == ListHead)
|
||||||
{
|
{
|
||||||
return((PVOID)AddressSpace->LowestAddress);
|
Address = (PVOID)AddressSpace->LowestAddress;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||||
return(current->BaseAddress + PAGE_ROUND_UP(current->Length));
|
Address = current->BaseAddress + PAGE_ROUND_UP(current->Length);
|
||||||
|
}
|
||||||
|
/* Check if enough space for the block */
|
||||||
|
if (AddressSpace->LowestAddress < KERNEL_BASE)
|
||||||
|
{
|
||||||
|
if ((ULONG)Address >= KERNEL_BASE || Length > KERNEL_BASE - (ULONG)Address)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Length >= 0xFFFFFFFF - (ULONG)Address)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmInitMemoryAreas(VOID)
|
NTSTATUS MmInitMemoryAreas(VOID)
|
||||||
|
|
Loading…
Reference in a new issue