mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
[RTL/DPH]
- Do not merge memory blocks if they don't belong to the same VM "region" (ie not allocated from the same NtAllocateVirtualMemory call) Fixes failures of ZwProtectVirtualMemory calls. Bugs see DPH rollin', they hatin' svn path=/trunk/; revision=66336
This commit is contained in:
parent
ddaa717558
commit
52a5043b98
1 changed files with 52 additions and 11 deletions
|
@ -691,7 +691,24 @@ RtlpDphCoalesceNodeIntoAvailable(PDPH_HEAP_ROOT DphRoot,
|
|||
/* Check the previous node and merge if possible */
|
||||
if (PrevNode->pVirtualBlock + PrevNode->nVirtualBlockSize == Node->pVirtualBlock)
|
||||
{
|
||||
/* They are adjacent - merge! */
|
||||
/* Check they actually belong to the same virtual memory block */
|
||||
NTSTATUS Status;
|
||||
MEMORY_BASIC_INFORMATION MemoryBasicInfo;
|
||||
|
||||
Status = ZwQueryVirtualMemory(
|
||||
ZwCurrentProcess(),
|
||||
Node->pVirtualBlock,
|
||||
MemoryBasicInformation,
|
||||
&MemoryBasicInfo,
|
||||
sizeof(MemoryBasicInfo),
|
||||
NULL);
|
||||
|
||||
/* There is no way this can fail, we committed this memory! */
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
|
||||
if ((PUCHAR)MemoryBasicInfo.AllocationBase <= PrevNode->pVirtualBlock)
|
||||
{
|
||||
/* They are adjacent, and from the same VM region. - merge! */
|
||||
PrevNode->nVirtualBlockSize += Node->nVirtualBlockSize;
|
||||
RtlpDphReturnNodeToUnusedList(DphRoot, Node);
|
||||
DphRoot->nAvailableAllocations--;
|
||||
|
@ -703,6 +720,12 @@ RtlpDphCoalesceNodeIntoAvailable(PDPH_HEAP_ROOT DphRoot,
|
|||
/* Insert after PrevNode */
|
||||
InsertTailList(&PrevNode->AvailableEntry, &Node->AvailableEntry);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Insert after PrevNode */
|
||||
InsertTailList(&PrevNode->AvailableEntry, &Node->AvailableEntry);
|
||||
}
|
||||
|
||||
/* Now check the next entry after our one */
|
||||
if (Node->AvailableEntry.Flink != AvailListHead)
|
||||
|
@ -710,6 +733,23 @@ RtlpDphCoalesceNodeIntoAvailable(PDPH_HEAP_ROOT DphRoot,
|
|||
NextNode = CONTAINING_RECORD(Node->AvailableEntry.Flink, DPH_HEAP_BLOCK, AvailableEntry);
|
||||
/* Node is not at the tail of the list, check if it's adjacent */
|
||||
if (Node->pVirtualBlock + Node->nVirtualBlockSize == NextNode->pVirtualBlock)
|
||||
{
|
||||
/* Check they actually belong to the same virtual memory block */
|
||||
NTSTATUS Status;
|
||||
MEMORY_BASIC_INFORMATION MemoryBasicInfo;
|
||||
|
||||
Status = ZwQueryVirtualMemory(
|
||||
ZwCurrentProcess(),
|
||||
NextNode->pVirtualBlock,
|
||||
MemoryBasicInformation,
|
||||
&MemoryBasicInfo,
|
||||
sizeof(MemoryBasicInfo),
|
||||
NULL);
|
||||
|
||||
/* There is no way this can fail, we committed this memory! */
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
|
||||
if ((PUCHAR)MemoryBasicInfo.AllocationBase <= Node->pVirtualBlock)
|
||||
{
|
||||
/* They are adjacent - merge! */
|
||||
Node->nVirtualBlockSize += NextNode->nVirtualBlockSize;
|
||||
|
@ -722,6 +762,7 @@ RtlpDphCoalesceNodeIntoAvailable(PDPH_HEAP_ROOT DphRoot,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID NTAPI
|
||||
RtlpDphCoalesceFreeIntoAvailable(PDPH_HEAP_ROOT DphRoot,
|
||||
|
|
Loading…
Reference in a new issue