MiPfnsWorthTrying
UINT64 __stdcall MiPfnsWorthTrying(
_MI_PARTITION *Partition,
_MMPFN *FirstPfn,
UINT64 SizeInPages,
UINT64 Flags,
UINT64 *DrainStacks,
UINT64 *ZeroFreeCount){
__int16 v7;
_MMPFN *v8;
int v9;
UINT64 v10;
_MMPFN *PfnDb;
unsigned __int64 v13;
int v14;
int v15;
int PfnPageSizeIndexUnsynchronized;
signed __int64 v17;
__int64 v18;
PVOID *v19;
unsigned int v20;
unsigned int v21;
UINT64 *v22;
__int64 v23;
unsigned __int64 v24;
bool v25;
unsigned __int64 v26;
char v27;
int v28;
bool v29;
__int64 v30;
UNICODE_STRING *v31;
__int64 v32;
int v33;
UINT64 LeafPfnBuddy;
int v35;
UINT64 active;
__int64 v37;
int v39;
unsigned __int64 v40;
__int16 v41;
INT64 v42;
INT64 v43;
v7 = *(_WORD *)Partition;
v8 = (_MMPFN *)((char *)FirstPfn + 48 * SizeInPages);
v41 = *(_WORD *)Partition;
v9 = Flags;
*(_DWORD *)DrainStacks = 0;
v10 = -1i64;
v40 = -1i64;
if( FirstPfn >= v8 )
return 0i64;
PfnDb = MmGetPfnDb();
while( 1 )
{
v13 = *((_QWORD *)FirstPfn + 5);
if( ((v13 >> 39) & 0x3FF) != v7 )
{
v39 = MiPfnLargeBitSet((UINT64)&MiSystemPartition);
if( v39 != -1 )
FirstPfn = (_MMPFN *)((char *)PfnDb + 48 * (((FirstPfn - PfnDb) / 48) & -MiLargePageSizes[v39]));
goto LABEL_75;
}
v14 = -1;
v15 = *((_BYTE *)FirstPfn + 34) & 7;
LODWORD(v42) = v15;
if( (v13 & 0x1000000000i64) != 0 )
{
LODWORD(v43) = 0;
PfnPageSizeIndexUnsynchronized = MiGetPfnPageSizeIndexUnsynchronized((INT64)FirstPfn, &v42, &v43);
v14 = PfnPageSizeIndexUnsynchronized;
if( PfnPageSizeIndexUnsynchronized == -1 )
goto LABEL_67;
v15 = v42;
v17 = FirstPfn - PfnDb;
if( (_DWORD)v42 == 6 )
{
v37 = (_MMPFN *)((char *)v8
- 48 * (((FirstPfn - PfnDb) / 48) & -MiLargePageSizes[PfnPageSizeIndexUnsynchronized]))
- PfnDb;
return v37 / 48;
}
v10 = v40;
}
else
{
v17 = FirstPfn - PfnDb;
}
if( v15 == 5 )
break;
if( v15 <= 1 )
{
if( v14 == -1 )
goto LABEL_67;
goto LABEL_22;
}
v27 = *((_BYTE *)FirstPfn + 35);
v28 = 0;
if( v27 < 0 )
{
if( v15 != 2 )
{
if( v15 != 6
|| (*((_BYTE *)FirstPfn + 34) & 0x10) != 0
|| *((_WORD *)FirstPfn + 16) != 1
|| ((*((_QWORD *)FirstPfn + 5) >> 60) & 7) == 2
|| (v27 & 8) != 0
|| (*(_BYTE *)FirstPfn & 1) == 0 )
{
goto LABEL_75;
}
goto LABEL_62;
}
v29 = *((_WORD *)FirstPfn + 16) == 0;
LABEL_32:
if( !v29 )
goto LABEL_75;
goto LABEL_66;
}
if( v15 <= 4 )
{
if( *((_WORD *)FirstPfn + 16) )
goto LABEL_75;
if( (v9 & 0x4000000) != 0 )
goto LABEL_66;
if( (*((_QWORD *)FirstPfn + 5) & 0x1000000000i64) != 0 )
goto LABEL_66;
v30 = *((_QWORD *)FirstPfn + 1);
v29 = v30 == 0;
if( v30 < 0 )
goto LABEL_66;
goto LABEL_32;
}
v31 = (UNICODE_STRING *)((unsigned __int128)(v17 * (__int128)0x2AAAAAAAAAAAAAABi64) >> 64);
v32 = v17 / 48;
if( ((v17 / 48) & 0xFFFFFFFFFFFFFE00ui64) != v10 )
{
v40 = v32 & 0xFFFFFFFFFFFFFE00ui64;
v33 = MiPfnLargeBitSet((UINT64)Partition);
if( v33 != -1 )
{
v37 = (_MMPFN *)((char *)v8 - 48 * (v32 & -MiLargePageSizes[v33])) - MmGetPfnDb();
return v37 / 48;
}
}
if( v15 != 6 )
goto LABEL_75;
if( ((*((_QWORD *)FirstPfn + 5) >> 60) & 7) != 2 )
{
if( (v9 & 0x800000) != 0 )
{
LOBYTE(v35) = MI_PFN_IS_PROTO((UNICODE_STRING *)FirstPfn, v31, v14, (PWCHAR)v10);
if( v35 )
{
if( (*((_QWORD *)FirstPfn + 3) & 0x3FFFFFFFFFFFFFFFui64) > 1 )
goto LABEL_75;
}
else if( v32 == (v32 & 0xFFFFFFFFFFFFFFF0ui64) && v8 - FirstPfn >= 768 )
{
v28 = 1;
}
}
LABEL_62:
active = MiActivePageClaimCandidate(Partition, FirstPfn, 0i64, v10);
if( active )
return(v8 - MmGetPfnDb()) / 48 - (~(active - 1) & (v17 / 48));
if( (v9 & 8) != 0 || v28 == 1 && (unsigned int)MiClusterVadFull(FirstPfn, 0i64) == 1 )
goto LABEL_75;
LABEL_66:
PfnDb = MmGetPfnDb();
goto LABEL_67;
}
if( (v9 & 8) != 0 )
goto LABEL_75;
LeafPfnBuddy = MiGetLeafPfnBuddy(FirstPfn);
if( LeafPfnBuddy == -32i64 )
goto LABEL_75;
PfnDb = MmGetPfnDb();
if( !LeafPfnBuddy )
*(_DWORD *)DrainStacks = 1;
LABEL_67:
FirstPfn = (_MMPFN *)((char *)FirstPfn + 48);
if( FirstPfn >= v8 )
return 0i64;
v10 = v40;
v7 = v41;
}
if( MiIsPageOnBadList((INT64)FirstPfn) )
goto LABEL_75;
if( v14 != -1 )
{
LABEL_22:
v23 = v17 / 48;
v24 = MiLargePageSizes[v14];
if( v24 < 0x200 )
v25 = (v9 & 0x1000000) == 0;
else
v25 = (v9 & 0x2000000) == 0;
if( !v25 )
{
v37 = (_MMPFN *)((char *)v8 - 48 * (v23 & -(__int64)v24)) - PfnDb;
return v37 / 48;
}
v26 = v24 - (v23 & (v24 - 1));
if( v26 > (v8 - FirstPfn) / 48 )
v26 = (v8 - FirstPfn) / 48;
FirstPfn = (_MMPFN *)((char *)FirstPfn + 48 * v26 - 48);
goto LABEL_67;
}
if( (*(_BYTE *)FirstPfn & 1) != 0 )
goto LABEL_67;
v18 = v17 / 48;
v19 = &qword_140C4EB08;
v20 = 0;
while( (PVOID)v18 != *v19 )
{
++v20;
++v19;
if( v20 >= 4 )
{
v21 = 0;
v22 = &GapFrames;
while( v18 != *v22 )
{
++v21;
++v22;
if( v21 >= 4 )
goto LABEL_67;
}
break;
}
}
LABEL_75:
v37 = v8 - FirstPfn;
return v37 / 48;
}Referenced by:
MiFindContiguousPages
MiFindRebuildCandidate
MiScrubNode
MmRelocatePfnList