MiDereferenceControlAreaPfnList

VOID __stdcall MiDereferenceControlAreaPfnList(
        _CONTROL_AREA *ControlArea,
        _SUBSECTION *Subsection,
        UINT64 NumberOfReferences,
        UINT64 Flags){
  UINT64 inserted; 
  __int64 v5; 
  char v6; 
  _SUBSECTION *v9; 
  unsigned int v10; 
  INT64 *v11; 
  INT64 *v12; 
  KIRQL v13; 
  volatile INT64 *v15; 
  UINT64 v16; 
  inserted = 0i64;
  v5 = *((_QWORD *)ControlArea + 8);
  v6 = Flags;
  if( (*((_DWORD *)ControlArea + 14) & 0x20) != 0 || !v5 )
    v9 = 0i64;
  else
    v9 = Subsection;
  v10 = 0;
  v11 = (INT64 *)((char *)ControlArea + 72);
  if( v5 )
    v10 = 1;
  v12 = (INT64 *)((char *)ControlArea + 72);
  if( (Flags & 2) != 0 )
  {
    v13 = 17;
    ExpAcquireSpinLockExclusive(v12, 0xFFu);
  }
  else
  {
    v13 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)v12);
  }
  if( v9 )
  {
    if( (*((_DWORD *)v9 + 26))-- == 1
      && !*((_QWORD *)v9 + 12)
      && (*((_BYTE *)Subsection + 34) & 1) == 0
      && (*((_BYTE *)v9 + 34) & 8) != 0 )
    {
      MiRemoveUnusedSubsection((_MSUBSECTION *)v9);
      inserted = MiInsertUnusedSubsection((_MSUBSECTION *)v9, v16);
    }
  }
  --*((_QWORD *)ControlArea + 4);
  if( (v6 & 1) != 0 )
    MiCheckForControlAreaDeletion(ControlArea);
  if( inserted )
    v15 = *(volatile INT64 **)(qword_140C4E388 + 8i64 * (*((_WORD *)ControlArea + 30) & 0x3FF));
  else
    v15 = 0i64;
  if( v13 == 17 )
  {
    *(_DWORD *)v11 = 0;
  }
  else
  {
    ExReleaseSpinLockExclusiveFromDpcLevel(v11);
    __writecr8(v13);
  }
  if( inserted )
    MiReturnCrossPartitionSectionCharges(v15, v10, inserted);
}

Referenced by:

MiCopyDataPageToImagePage
MiDeleteTransitionPte
MiGatherMappedPages
MiPurgeImageSection
MiPurgeSubsection
MiReleaseInPageRefs
MiRestoreTransitionPte
MiSplitDirectMapPage