MiIncrementSubsectionViewCount

NTSTATUS __fastcall MiIncrementSubsectionViewCount(_MSUBSECTION *MappedSubsection, UINT64 Flags){
  _CONTROL_AREA *ControlArea; 
  _MSUBSECTION *v3; 
  NTSTATUS v4; 
  int v7; 
  __int16 v8; 
  _MI_PARTITION *v9; 
  INT64 v10; 
  __int64 v11; 
  char v12; 
  int v13; 

  ControlArea = MappedSubsection->Core.ControlArea;
  v3 = MappedSubsection;
  v4 = 2;
  if( (Flags & 8) != 0 )
  {
    LOBYTE(v7) = MiControlAreaExemptFromCrossPartitionCharges((INT64)MappedSubsection->Core.ControlArea);
    if( !v7 )
    {
      if( (v8 & 0x80u) != 0 )
      {
        v9 = &Irp;
      }
      else if( (v8 & 0x100) != 0 )
      {
        v9 = *(_MI_PARTITION **)(*(&stru_140C4DB30 + 267)
                               + 8i64 * *((unsigned __int16 *)KeGetCurrentThread()->ApcState.Process->Session + 215));
      }
      else
      {
        v9 = (v8 & 0x10) != 0 ? 0i64 : *(_MI_PARTITION **)(*(&stru_140C4DB30 + 267)
                                                         + 8i64
                                                         * KeGetCurrentThread()->ApcState.Process->Vm.Instance.PartitionId);
      }
      if( v9 != *(_MI_PARTITION **)(*(&stru_140C4DB30 + 267) + 8i64 * (ControlArea->u1.Flags._bf_0 & 0x3FF)) )
      {
        if( (((v8 & 0x200) == 0) & ControlArea->u1.Flags._bf_2) != 0 )
        {
          ++*(&stru_140C4DB30 + 538);
          return 0;
        }
        LODWORD(v10) = MiGetSubsectionHoldingCrossPartitionReferences((INT64)v3);
        LODWORD(v11) = MiGetSubsectionHoldingCrossPartitionReferences(v10);
        v13 = *(_DWORD *)(v11 + 48) & 0x3FFFFFFF;
        if( v13 != 0x3FFFFFFF )
        {
          if( !v13 && (v12 & 0x20) == 0 )
            return 1;
          MiUpdateSubsectionCrossPartitionRefs(v3, v13 + 1);
        }
      }
    }
  }
  if( (ControlArea->u.LongFlags & 0x20) == 0
    && ControlArea->FilePointer.Value
    && (v3->Core.u.SubsectionFlags._bf_2 & 1) == 0
    && v3->NumberOfMappedViews++ == -1i64 )
  {
    KeBugCheckEx(0x1Au, (PVOID)0x42000, v3, 0i64, 0i64);
  }
  return v4;
}

Referenced by:

MiCreatePrototypePtes
MiExtendSection
MiFlushSectionInternal
MiPrepareSegmentForDeletion
MiReferenceActiveSubsection
MiReferenceSubsection
MiRetainSubsection
MiSetSubsectionBase
MmPurgeSection