MiInsertUnusedSubsection
NTSTATUS __stdcall MiInsertUnusedSubsection(_MSUBSECTION *MappedSubsection, UINT64 InsertTail){
int v2;
__int64 PtesInSubsection;
unsigned __int64 v5;
__int64 v6;
unsigned __int64 v7;
unsigned __int64 v8;
int v9;
NTSTATUS v10;
_LIST_ENTRY *p_DereferenceList;
_LIST_ENTRY *v12;
_LIST_ENTRY *v14;
int v15;
v2 = 0;
PtesInSubsection = MappedSubsection->Core.PtesInSubsection;
v5 = 8 * PtesInSubsection;
v6 = *(_QWORD *)(*(&stru_140C4DB30 + 267) + 8i64 * (MappedSubsection->Core.ControlArea->u1.Flags._bf_0 & 0x3FF));
if( (unsigned __int64)(8 * PtesInSubsection) > 0xFE0 )
{
if( v5 >= 0x10000 || ((8 * (_WORD)PtesInSubsection) & 0xFFFu) > 0xFC0 )
{
v8 = (v5 + 4095) & 0xFFFFFFFFFFFFF000ui64;
goto LABEL_4;
}
v7 = v5 + 15;
}
else
{
v7 = v5 + 31;
}
v8 = v7 & 0xFFFFFFFFFFFFFFF0ui64;
LABEL_4:
ExAcquireSpinLockExclusiveAtDpcLevel((INT64 *)(v6 + 1344));
MappedSubsection->Core.u.SubsectionFlags._bf_2 |= 8u;
*(_QWORD *)(v6 + 1696) += v8;
_InterlockedExchangeAdd64(&qword_140C4C6D8, v8);
LOBYTE(v9) = MiControlAreaUsingExtents((INT64)MappedSubsection->Core.ControlArea);
v10 = 0;
if( !v9 && (MappedSubsection->Core.u1.e1._bf_0 & 0x3FFFFFFF) != 0 )
{
MiUpdateSubsectionCrossPartitionRefs(MappedSubsection, 0);
v10 = MappedSubsection->Core.PtesInSubsection - (v15 & MappedSubsection->Core._bf_34);
}
p_DereferenceList = &MappedSubsection->DereferenceList;
if( MappedSubsection->NumberOfPfnReferences )
{
v12 = *(_LIST_ENTRY **)(v6 + 1728);
if( v12->Flink == (_LIST_ENTRY *)(v6 + 1720) )
{
p_DereferenceList->Flink = (_LIST_ENTRY *)(v6 + 1720);
MappedSubsection->DereferenceList.Blink = v12;
v12->Flink = p_DereferenceList;
*(_QWORD *)(v6 + 1728) = p_DereferenceList;
goto LABEL_10;
}
LABEL_21:
__fastfail(3u);
}
v14 = *(_LIST_ENTRY **)(v6 + 1744);
if( v14->Flink != (_LIST_ENTRY *)(v6 + 1736) )
goto LABEL_21;
p_DereferenceList->Flink = (_LIST_ENTRY *)(v6 + 1736);
MappedSubsection->DereferenceList.Blink = v14;
v14->Flink = p_DereferenceList;
*(_QWORD *)(v6 + 1744) = p_DereferenceList;
*(_QWORD *)(v6 + 1424) += PtesInSubsection;
if( *(_QWORD *)(v6 + 1424) >= 0x20000ui64 )
v2 = 1;
LABEL_10:
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)(v6 + 1344));
if( v2 == 1 )
KeSetEvent((PRKEVENT)(v6 + 1376), 0, 0);
return v10;
}Referenced by:
MiAppendSubsectionChain
MiDecrementSubsections
MiDeleteCachedSubsection
MiDereferenceControlAreaPfnList
MiFlushSectionInternal
MiRemoveViewsFromSection
MmPurgeSection