MiDecrementSubsectionViewCount

INT64 __fastcall MiDecrementSubsectionViewCount(INT64 *P2, CHAR a2){
  INT64 v2; 
  INT64 *v3; 
  INT64 v4; 
  INT64 v5; 
  __int16 v7; 
  __int64 v8; 
  ULONG_PTR *v9; 
  INT64 SubsectionHoldingCrossPartitionReferences; 
  INT64 v11; 
  int v12; 
  INT64 *v13; 
  v2 = *P2;
  v3 = P2;
  if( *(_QWORD *)(*P2 + 64) && (*(_DWORD *)(v2 + 56) & 0x20) == 0 && (*((_BYTE *)P2 + 34) & 1) == 0 && !P2[12] )
    KeBugCheckEx(0x1Au, 0x42001ui64, (ULONG_PTR)P2, 0i64, 0i64);
  v4 = 0i64;
  if( (a2 & 4) == 0 && (a2 & 8) != 0 && !MiControlAreaExemptFromCrossPartitionCharges(*P2) )
  {
    if( (v7 & 0x10) != 0 )
    {
      v9 = 0i64;
    }
    else if( (v7 & 0x80u) != 0 )
    {
      v9 = &MiSystemPartition;
    }
    else
    {
      v8 = *((_QWORD *)KeGetCurrentThread() + 23);
      v9 = (v7 & 0x100) != 0 ? *(ULONG_PTR **)(qword_140C4E388
                                             + 8i64 * *(unsigned __int16 *)(*(_QWORD *)(v8 + 1368) + 430i64)) : *(ULONG_PTR **)(qword_140C4E388 + 8i64 * *(unsigned __int16 *)(v8 + 1838));
    }
    if( v9 != *(ULONG_PTR **)(qword_140C4E388 + 8i64 * (*(_WORD *)(v2 + 60) & 0x3FF)) )
    {
      SubsectionHoldingCrossPartitionReferences = MiGetSubsectionHoldingCrossPartitionReferences((INT64)v3);
      v11 = MiGetSubsectionHoldingCrossPartitionReferences(SubsectionHoldingCrossPartitionReferences);
      v12 = *(_DWORD *)(v11 + 48) & 0x3FFFFFFF;
      if( v12 != 0x3FFFFFFF )
      {
        MiUpdateSubsectionCrossPartitionRefs(v3, (unsigned int)(v12 - 1));
        if( v12 == 1 )
          v4 = MiComputeCrossPartitionSectionCharges(v13);
      }
    }
  }
  if( *(_QWORD *)(v2 + 64) && (*(_DWORD *)(v2 + 56) & 0x20) == 0 && (*((_BYTE *)v3 + 34) & 1) == 0 )
  {
    v5 = v3[12];
    if( !v5 )
      KeBugCheckEx(0x1Au, 0x42001ui64, (ULONG_PTR)v3, 0i64, 0i64);
    v3[12] = v5 - 1;
  }
  return v4;
}

Referenced by:

MiAppendSubsectionChain
MiCreatePrototypePtes
MiDecrementSubsections
MiDeleteCachedSubsection
MiDeleteControlArea
MiDeleteSubsectionPages
MiExtendSection
MiFlushSectionInternal
MiRemoveViewsFromSection
MiReturnCrossPartitionControlAreaCharges
MiUpControlAreaRefs
MmPurgeSection