MiFindLargePageMemory
NTSTATUS __stdcall MiFindLargePageMemory(
_MI_PARTITION *Partition,
_MI_LARGEPAGE_MEMORY_INFO *LargePageInfoBase,
UINT64 SizeInPages,
UINT64 PreferredNode,
UINT64 ProtectionMask){
unsigned int v5;
UINT64 v6;
NTSTATUS result;
_MI_PFN_CACHE_ATTRIBUTE v8;
UINT64 v9;
_RTL_BALANCED_NODE *Pool;
int v11;
unsigned int v12;
UINT64 v13;
UINT64 v14;
unsigned int v15;
unsigned __int64 v16;
BOOL v17;
_RTL_BALANCED_NODE *v18;
_RTL_BALANCED_NODE *v19;
UINT64 PreferredNodea;
UINT64 Flags;
UINT64 *StartingPfn;
_MI_PFN_CACHE_ATTRIBUTE CacheAttribute;
INT64 v26[2];
__int128 v27;
__int128 v28;
char v29;
_RTL_BALANCED_NODE **v30;
v5 = (unsigned int)LargePageInfoBase;
*(_OWORD *)v26 = 0i64;
v6 = SizeInPages;
v27 = 0i64;
v28 = 0i64;
result = MiSufficientAvailablePages((INT64)Partition, SizeInPages + 160);
if( result )
{
result = MiCreateColorAnchors((INT64)v26, v5);
if( result )
{
v8 = MiProtectionToCacheAttribute((unsigned int)ProtectionMask);
v9 = *(&stru_140C50B28 + 852);
Pool = 0i64;
CacheAttribute = v8;
v11 = 0;
HIDWORD(v26[1]) = v8;
LOBYTE(v12) = MiGetLargestPageIndex();
v15 = v12;
if( v12 < 3 )
{
do
{
v16 = MiLargePageSizes[v15];
if( v6 >= v16 )
{
if( v16 < PreferredNode )
break;
if( !Pool )
{
Pool = (_RTL_BALANCED_NODE *)MiAllocatePool(64i64, 0x30ui64, 0x6C4C6D4Dui64);
if( !Pool )
goto LABEL_25;
}
LODWORD(StartingPfn) = 1611661312;
LODWORD(Flags) = 0x80000000;
LODWORD(PreferredNodea) = v5;
if( MiFindContiguousPages(Partition, v16, v9, v16, v16, CacheAttribute, PreferredNodea, Flags, StartingPfn) >= 0 )
{
v6 -= v16;
if( (v29 & 2) == 0 && MiUpdateLargePagePfns((_COLORED_PAGE_INFO *)v26, 0i64) == 1 )
v11 = 1;
v17 = 0;
Pool->Children[0] = 0i64;
Pool->Children[1] = (_RTL_BALANCED_NODE *)v16;
Pool->_bf_0 = 1;
v18 = *v30;
if( *v30 )
{
while( 1 )
{
if( v18[-1].Children[0] )
{
v19 = v18->Children[0];
if( !v18->Children[0] )
break;
}
else
{
v19 = v18->Children[1];
if( !v19 )
{
v17 = 1;
break;
}
}
v18 = v19;
}
}
RtlAvlInsertNodeEx(v30, (UINT64)v18, v17, Pool + 1);
Pool = 0i64;
if( !v6 )
goto LABEL_25;
v9 = -1i64;
if( v16 != -1i64 )
continue;
}
}
v9 = *(&stru_140C50B28 + 852);
++v15;
}
while( v15 < 3 );
if( Pool )
ExFreePoolWithTag(Pool, 0);
LABEL_25:
if( v11 )
MiZeroInParallel((_COLORED_PAGE_INFO *)v26, v13, v14);
}
MiDeleteColorAnchors((INT64)v26);
}
}
return result;
}Referenced by:
MiAllocateLargeZeroPages