MiReferenceActiveSubsection
NTSTATUS __fastcall MiReferenceActiveSubsection(ULONG_PTR BugCheckParameter2, int a2, KIRQL a3){
__int64 v3;
UINT64 v4;
int v5;
KIRQL v6;
BOOL v9;
__int64 v10;
BOOL v11;
int v12;
NTSTATUS result;
INT64 CommittedPages;
__int64 v15;
__int64 v16;
NTSTATUS v17;
INT64 a3a;
v3 = *(_QWORD *)BugCheckParameter2;
v4 = 0i64;
a3a = 0i64;
v5 = 0;
v16 = *(_QWORD *)BugCheckParameter2;
v6 = a3;
v9 = *(_QWORD *)(*(_QWORD *)BugCheckParameter2 + 64i64) != 0i64;
if( a3 == 17 )
{
v5 = 1;
v6 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)(v3 + 72));
}
while( 1 )
{
v10 = *(_QWORD *)BugCheckParameter2;
if( !*(_QWORD *)(BugCheckParameter2 + 8) )
goto LABEL_19;
v11 = *(_QWORD *)(v10 + 64) != 0i64;
v12 = MiIncrementSubsectionViewCount((INT64 *)BugCheckParameter2, a2);
if( v12 > 1 && v11 && (*(_DWORD *)(v10 + 56) & 0x20) == 0 )
{
if( (*(_BYTE *)(BugCheckParameter2 + 34) & 8) != 0 )
MiRemoveUnusedSubsection((_MSUBSECTION *)BugCheckParameter2);
*(_WORD *)(BugCheckParameter2 + 32) |= 1u;
}
if( v12 >= 2 )
{
if( v12 == 2 && (a2 & 0x20) != 0 && a3a )
{
v15 = v16;
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)(v16 + 72));
__writecr8(v6);
MiReturnCrossPartitionSectionCharges(
*(volatile INT64 **)(qword_140C4E388 + 8i64 * (*(_WORD *)(v15 + 60) & 0x3FF)),
v9,
a3a);
if( !v5 )
ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)(v16 + 72));
}
else if( v5 )
{
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)(v16 + 72));
__writecr8(v6);
}
return 0;
}
if( !v12 )
break;
v3 = v16;
v4 = a3a;
LABEL_19:
if( (a2 & 0x20) != 0 )
{
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)(v3 + 72));
__writecr8(v6);
MiReturnCrossPartitionSectionCharges(
*(volatile INT64 **)(qword_140C4E388 + 8i64 * (*(_WORD *)(v3 + 60) & 0x3FF)),
v9,
v4);
if( !v5 )
ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)(v3 + 72));
return -1073741523;
}
a3a = MiComputeCrossPartitionSectionCharges((INT64 *)BugCheckParameter2);
v4 = a3a;
if( a3a )
{
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)(v3 + 72));
__writecr8(v6);
result = MiGetSubsectionCharges(BugCheckParameter2);
v17 = result;
if( result < 0 )
{
if( !v5 )
{
ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)(v3 + 72));
return v17;
}
return result;
}
a2 |= 0x20u;
ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)(v3 + 72));
if( (*(_DWORD *)(v3 + 56) & 0x20) == 0 )
{
if( v9 )
{
if( !*(_QWORD *)(BugCheckParameter2 + 8) )
{
LABEL_27:
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)(v3 + 72));
__writecr8(v6);
MiReturnCrossPartitionSectionCharges(
*(volatile INT64 **)(qword_140C4E388 + 8i64 * (*(_WORD *)(v3 + 60) & 0x3FF)),
v9,
a3a);
if( !v5 )
ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)(v3 + 72));
return -1073741302;
}
CommittedPages = *(_DWORD *)(BugCheckParameter2 + 44) - (*(_DWORD *)(BugCheckParameter2 + 52) & 0x3FFFFFFFu);
}
else
{
CommittedPages = MiGetCommittedPages((_QWORD *)v3);
}
if( a3a != CommittedPages )
goto LABEL_27;
}
}
else
{
a2 |= 0x20u;
}
}
if( v5 )
{
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)(v16 + 72));
__writecr8(v6);
}
return -1073740277;
}Referenced by:
MiAddViewsForSection
MiApplyHotPatchToLoadedDriver
MiInsertInSystemSpace
MiMapImageInSystemSpace
MiMapViewOfImageSection
MiSessionInsertImage
MiUpControlAreaRefs
MmLoadSystemImageEx