MiDeleteControlArea

VOID __stdcall MiDeleteControlArea(_CONTROL_AREA *ControlArea){
  int v2; 
  UINT64 v3; 
  volatile INT64 *v4; 
  volatile INT64 *v5; 
  __int64 v6; 
  __int64 v7; 
  __int64 v8; 
  unsigned __int64 v9; 
  v2 = *((_DWORD *)ControlArea + 14);
  v3 = 0i64;
  v4 = *(volatile INT64 **)(qword_140C4E388 + 8i64 * (*((_WORD *)ControlArea + 30) & 0x3FF));
  v5 = v4 + 169;
  if( (v2 & 0x20) != 0 )
  {
    v8 = *((_QWORD *)ControlArea + 12);
    if( (*(_QWORD *)(v8 + 40) & 0xFFFFFFFFFFFFFFF8ui64) > 8 )
      SeReleaseImageValidationContext((VOID *)(*(_QWORD *)(v8 + 40) & 0xFFFFFFFFFFFFFFF8ui64));
    MiFreeRelocations(ControlArea, *(_QWORD **)(v8 + 32));
  }
  else
  {
    if( (v2 & 0x80u) != 0 )
    {
      v6 = *((_QWORD *)ControlArea + 18);
      if( !v6 )
        goto LABEL_6;
      do
      {
        v7 = *(_QWORD *)(v6 + 16);
        if( (*(_BYTE *)(v6 + 34) & 1) != 0 && (*(_DWORD *)(v6 + 48) & 0x3FFFFFFF) != 0 )
        {
          MiUpdateSubsectionCrossPartitionRefs((_DWORD *)v6, 1i64);
          v9 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)ControlArea + 18);
          v3 += MiDecrementSubsectionViewCount((INT64 *)v6, 24);
          ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)ControlArea + 9);
          __writecr8(v9);
          *(_WORD *)(v6 + 34) &= ~1u;
        }
        ExFreePoolWithTag((PVOID)v6, 0);
        v6 = v7;
      }
      while( v7 );
    }
    else
    {
      v5 = v4 + 170;
    }
    if( v3 )
      MiReturnCrossPartitionSectionCharges(v4, 1i64, v3);
  }
LABEL_6:
  MiDecrementControlAreaCount((INT64)v4, v5);
  MiDeleteFileExtents((INT64)ControlArea);
  ExFreePoolWithTag(ControlArea, 0);
}

Referenced by:

MiDeleteCachedSubsection
MiDeleteControlAreaList
MiDereferenceControlAreaProbe
MiFlushControlArea