[NTOS:MM] Acquire MmSystemLoadLock in MiFindInitializationCode. CORE-16449

We might otherwise free the INIT section for an image that's in the
process of being loaded by Mm.
This commit is contained in:
Thomas Faber
2020-10-15 13:40:42 +02:00
parent a385a78cf0
commit a30edc324e

View File

@@ -1466,8 +1466,13 @@ MiFindInitializationCode(OUT PVOID *StartVa,
/* Assume failure */
*StartVa = NULL;
/* Enter a critical region while we loop the list */
/* Acquire the necessary lock while we loop the list */
KeEnterCriticalRegion();
KeWaitForSingleObject(&MmSystemLoadLock,
WrVirtualMemory,
KernelMode,
FALSE,
NULL);
/* Loop all loaded modules */
NextEntry = PsLoadedModuleList.Flink;
@@ -1615,7 +1620,8 @@ MiFindInitializationCode(OUT PVOID *StartVa,
NextEntry = NextEntry->Flink;
}
/* Leave the critical region and return */
/* Release the lock and return */
KeReleaseMutant(&MmSystemLoadLock, 1, FALSE, FALSE);
KeLeaveCriticalRegion();
}