MiMapNewPfns
VOID __stdcall MiMapNewPfns(UINT64 StartPage, UINT64 LastPage, UINT16 PartitionId, UINT64 Flags){
unsigned int v5;
INT64 PteAddress;
__int64 v7;
__int64 v8;
INT64 v9;
UINT64 v10;
INT64 v11;
UINT64 v12;
unsigned __int64 v13;
unsigned __int64 v14;
int v15;
NTSTATUS ClosestImplicitNode;
unsigned int v17;
_ETHREAD *CurrentThread;
VOID *v19;
INT64 v20;
v5 = Flags;
PteAddress = (INT64)MiGetPteAddress(&MmGetPfnDb()[StartPage]);
v9 = (INT64)MiGetPteAddress((VOID *)(v8 - 1 + 48 * v7));
v11 = v9;
v12 = v10 - StartPage;
if( v10 - StartPage >= 0x40000 && *(&stru_140C50B28 + 853) >= 0x200000ui64 )
{
v10 = -4096i64;
v13 = PteAddress & 0xFFFFFFFFFFFFF000ui64;
if( PteAddress == (PteAddress & 0xFFFFFFFFFFFFF000ui64) )
v13 = PteAddress;
v14 = (v9 & 0xFFFFFFFFFFFFF000ui64) + 4088;
PteAddress = v13;
if( v11 != v14 )
v11 = v14;
}
MiPageToNode(StartPage, v10);
ClosestImplicitNode = MiGetClosestImplicitNode((unsigned int)(v15 + 1));
v17 = ((v5 & 0x2000 | 0x1508) >> 3) | 0x100;
if( (v5 & 0x4000) == 0 )
v17 = (v5 & 0x2000 | 0x1508) >> 3;
if( (v5 & 2) != 0 )
{
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
MiLockDynamicMemoryShared((INT64)&Irp, (INT64)CurrentThread);
}
else
{
CurrentThread = 0i64;
}
LODWORD(v20) = ClosestImplicitNode;
if( !MiMakeZeroedPageTablesEx(PteAddress, v11, v17, 4i64, v20) )
{
if( CurrentThread )
MiUnlockDynamicMemoryShared((INT64)&Irp, (INT64)CurrentThread);
return;
}
v19 = 0i64;
if( (v5 & 2) == 0 )
{
if( (v5 & 0x200) != 0 )
{
v19 = MmMapIoSpaceEx((_LARGE_INTEGER)(StartPage << 12), v12 << 12, 4ui64);
if( !v19 )
return;
}
if( !MiIncreaseCommitLimits(&Irp, v12, v12, (v5 & 4) != 0, 0i64) )
{
if( v19 )
MmUnmapIoSpace(v19, v12 << 12);
return;
}
if( (v5 & 0x404) == 0 )
KeConfigureDynamicMemory(StartPage, LastPage - 1, 1ui64);
}
MiInitializeDynamicPfns(StartPage, v12, PartitionId, v5);
if( CurrentThread )
MiUnlockDynamicMemoryShared((INT64)&Irp, (INT64)CurrentThread);
if( v19 )
MmUnmapIoSpace(v19, v12 << 12);
}Referenced by:
MiAddPhysicalMemory