MiAddPhysicalMemoryChunks
NTSTATUS __stdcall MiAddPhysicalMemoryChunks(
_MI_PARTITION *Partition,
_LARGE_INTEGER *StartAddress,
_LARGE_INTEGER *NumberOfBytes){
unsigned int v3;
unsigned __int64 QuadPart;
LONGLONG v5;
unsigned __int64 v6;
int v7;
int v8;
unsigned __int64 v9;
unsigned int v10;
NTSTATUS v11;
UINT64 v12;
unsigned __int64 v13;
UINT64 v14;
unsigned __int64 v15;
int v16;
__int64 v17;
unsigned __int64 v18;
_BOOL8 v19;
__int64 v21;
unsigned int v22;
unsigned __int64 v23;
_LARGE_INTEGER v24;
int v25;
unsigned __int64 v26;
unsigned int v27;
unsigned __int64 v28;
unsigned __int64 v29;
unsigned __int64 v30;
unsigned __int64 v31;
__int64 v32;
unsigned int v33;
NTSTATUS v34;
_LARGE_INTEGER NumberOfBytesa;
unsigned __int64 v36;
_LARGE_INTEGER StartAddressa;
_LARGE_INTEGER *v39;
v39 = NumberOfBytes;
QuadPart = StartAddress->QuadPart;
v5 = 0i64;
StartAddressa = *StartAddress;
v6 = NumberOfBytes->QuadPart;
v7 = 0;
v8 = 0;
v36 = 0i64;
v9 = v6;
v10 = v3;
v11 = 0;
while( 1 )
{
while( 1 )
{
v12 = QuadPart >> 12;
MiRestrictRangeToNode(v12, v6 >> 12);
v15 = v13;
if( v12 < 0x100000 && v12 + v13 > 0x100000 )
v15 = 0x100000 - v12;
MiPageToNode(v12, v14);
NumberOfBytesa.QuadPart = qword_140C50AD0
+ 4544i64 * (unsigned int)(MiGetClosestImplicitNode((unsigned int)(v16 + 1)) - 1);
if( v11 < 0 )
{
v15 = v36;
if( v36 > 0x200 )
v15 = 512i64;
switch( v8 )
{
case 0:
if( v36 > 0x200 )
{
v7 = 0;
break;
}
LODWORD(v19) = v12 < 0x100000;
goto LABEL_21;
case 1:
v19 = v36 <= 0x200;
LABEL_21:
v7 = v19 + 1;
break;
case 2:
v7 = 3;
break;
case 3:
v7 = 4;
break;
case 4:
goto LABEL_27;
}
}
else
{
v7 = 0;
LODWORD(v17) = 1;
if( (v12 & 0x1FF) != 0 )
{
LABEL_11:
if( v15 > MiLargePageSizes[(unsigned int)v17] - v12 % MiLargePageSizes[(unsigned int)v17] )
v15 = MiLargePageSizes[(unsigned int)v17] - v12 % MiLargePageSizes[(unsigned int)v17];
}
else
{
v18 = 512i64;
while( v15 >= v18 )
{
v15 &= ~(v18 - 1);
if( !(_DWORD)v17 )
break;
v17 = (unsigned int)(v17 - 1);
v18 = MiLargePageSizes[v17];
if( v12 % v18 )
goto LABEL_11;
}
}
}
v21 = 1i64;
LOBYTE(v22) = MiGetLargestPageIndex();
v25 = v22;
if( v22 <= 1 )
{
while( 1 )
{
v26 = MiLargePageSizes[v25];
if( !(v12 % v26) && !(v15 % v26) )
break;
if( (unsigned int)++v25 > 1 )
goto LABEL_34;
}
v21 = MiLargePageSizes[v25];
}
LABEL_34:
v27 = v10 & 0xFFFFA7FF;
if( v15 >= v23 )
{
if( v7 )
{
LABEL_41:
if( v7 != 1 || (LODWORD(v30) = MiNodeLargeFreeZeroPages2(v24.QuadPart, 1i64), (v29 = v30) == 0) )
{
if( v15 != 512 )
v15 = 512i64;
goto LABEL_58;
}
}
else
{
LODWORD(v28) = MiNodeLargeFreeZeroPages2(v24.QuadPart, 0i64);
v29 = v28;
if( !v28 )
{
if( v15 + v12 > 0x100000 && v15 > 0x200 )
{
v25 = 1;
v15 = 512i64;
v21 = 512i64;
}
v24 = NumberOfBytesa;
v7 = 1;
goto LABEL_41;
}
}
if( v29 < (unsigned __int64)(48 * v21) >> 12 )
{
while( !v25 )
{
v25 = 1;
v21 = MiLargePageSizes[1];
if( v29 >= (unsigned __int64)(48 * v21) >> 12 )
goto LABEL_48;
}
v21 = 1i64;
}
LABEL_48:
if( v21 != 1 )
{
v27 |= 0x4000u;
if( Partition == &Irp )
{
if( v25 == 1 )
v27 |= 0x800u;
else
v27 |= 0x1000u;
}
}
v31 = v29 << 12;
v32 = ~(v21 - 1);
if( v15 > (v32 & (v31 / 0x30)) )
v15 = v32 & (v31 / 0x30);
}
LABEL_58:
v36 = v15;
v33 = v27 & 0xFFFFDFFF;
v10 = v27 | 0x2000;
v8 = v7;
if( v7 > 2 )
v10 = v33;
NumberOfBytesa.QuadPart = v15 << 12;
v34 = MiAddPhysicalMemory(Partition, &StartAddressa, &NumberOfBytesa, v10);
v11 = v34;
if( v34 < 0 )
break;
QuadPart = NumberOfBytesa.QuadPart + StartAddressa.QuadPart;
v5 += NumberOfBytesa.QuadPart;
StartAddressa.QuadPart += NumberOfBytesa.QuadPart;
v6 = v9 - v5;
if( v9 == v5 )
goto LABEL_27;
}
if( v34 != -1073741670 && v34 != -1073741523 || v7 == 4 )
break;
QuadPart = StartAddressa.QuadPart;
v6 = NumberOfBytesa.QuadPart;
}
LABEL_27:
v39->QuadPart = v5;
return v11;
}Referenced by:
MiActOnPartitionNodePages
MiHotAddBootDeferredDescriptors
MmAddPhysicalMemory