[NTOS:MM] Handle NoChange Vads in NtFreeVirtualMemory

Fixes assertion failure in ntdll_apitest:NtAllocateVirtualMemory on x64, where the user shared page has a NoChange Vad.
This also prevents freeing the PEB and TEB.
This commit is contained in:
Timo Kreuzer
2026-02-25 13:22:37 +02:00
parent c83b29caca
commit fca332046e

View File

@@ -5350,9 +5350,14 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
}
//
// ARM3 does not yet handle protected VM
// Don't allow freeing of protected VADs (PEB/TEB/shared user page)
//
ASSERT(Vad->u.VadFlags.NoChange == 0);
if (Vad->u.VadFlags.NoChange != 0)
{
DPRINT1("Attempt to free protected VAD\n");
Status = STATUS_INVALID_PAGE_PROTECTION;
goto FailPath;
}
//
// Now we can try the operation. First check if this is a RELEASE or a DECOMMIT