[NTOS:MM] Mark RosMm memory areas

This is to distinguish them from ARM³ memory areas, which we use for some kernel regions, like paged pool.
This commit is contained in:
Timo Kreuzer 2024-04-06 19:46:43 +03:00
parent 42c7e4f66a
commit d0a7e496aa
4 changed files with 12 additions and 0 deletions

View file

@ -271,6 +271,8 @@ typedef struct _MEMORY_AREA
#define MI_SET_MEMORY_AREA_VAD(Vad) do { (Vad)->u.VadFlags.Spare |= 1; } while (0) #define MI_SET_MEMORY_AREA_VAD(Vad) do { (Vad)->u.VadFlags.Spare |= 1; } while (0)
#define MI_IS_MEMORY_AREA_VAD(Vad) (((Vad)->u.VadFlags.Spare & 1) != 0) #define MI_IS_MEMORY_AREA_VAD(Vad) (((Vad)->u.VadFlags.Spare & 1) != 0)
#define MI_SET_ROSMM_VAD(Vad) do { (Vad)->u.VadFlags.Spare |= 2; } while (0)
#define MI_IS_ROSMM_VAD(Vad) (((Vad)->u.VadFlags.Spare & 2) != 0)
typedef struct _MM_RMAP_ENTRY typedef struct _MM_RMAP_ENTRY
{ {

View file

@ -1295,6 +1295,9 @@ MmCleanProcessAddressSpace(IN PEPROCESS Process)
/* Check for old-style memory areas */ /* Check for old-style memory areas */
if (MI_IS_MEMORY_AREA_VAD(Vad)) if (MI_IS_MEMORY_AREA_VAD(Vad))
{ {
/* We do not expect ARM3 memory areas here, those are kernel only */
ASSERT(MI_IS_ROSMM_VAD(Vad));
/* Let RosMm handle this */ /* Let RosMm handle this */
MiRosCleanupMemoryArea(Process, Vad); MiRosCleanupMemoryArea(Process, Vad);
continue; continue;

View file

@ -1569,6 +1569,9 @@ MiGetFileObjectForVad(
{ {
PMEMORY_AREA MemoryArea = (PMEMORY_AREA)Vad; PMEMORY_AREA MemoryArea = (PMEMORY_AREA)Vad;
/* We do not expect ARM3 memory areas here, those are kernel only */
ASSERT(MI_IS_ROSMM_VAD(Vad));
/* Check if it's a section view (RosMm section) */ /* Check if it's a section view (RosMm section) */
if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW) if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW)
{ {

View file

@ -440,6 +440,10 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
MemoryArea->Magic = 'erAM'; MemoryArea->Magic = 'erAM';
MemoryArea->DeleteInProgress = FALSE; MemoryArea->DeleteInProgress = FALSE;
MI_SET_MEMORY_AREA_VAD(&MemoryArea->VadNode); MI_SET_MEMORY_AREA_VAD(&MemoryArea->VadNode);
if (MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3)
{
MI_SET_ROSMM_VAD(&MemoryArea->VadNode);
}
if (*BaseAddress == 0) if (*BaseAddress == 0)
{ {