MiSetDeleteOnClose

VOID __stdcall MiSetDeleteOnClose(_CONTROL_AREA *ControlArea, UINT64 FailAllIo){
  int v3; 
  UINT64 inserted; 
  unsigned __int64 v5; 
  int v6; 
  v3 = FailAllIo;
  inserted = 0i64;
  v5 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)ControlArea + 18);
  v6 = *((_DWORD *)ControlArea + 14);
  if( (v6 & 0x40000) == 0 )
  {
    if( (v6 & 0x8000000) != 0 )
    {
      MiRemoveUnusedSegment(ControlArea);
      *((_DWORD *)ControlArea + 14) |= 0x40000u;
      inserted = MiInsertUnusedSegment(ControlArea);
    }
    else
    {
      *((_DWORD *)ControlArea + 14) = v6 | 0x40000;
    }
  }
  if( v3 == 1 )
    *((_DWORD *)ControlArea + 14) |= 0x10u;
  ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)ControlArea + 9);
  __writecr8(v5);
  if( inserted )
    MiReturnCrossPartitionSectionCharges(
      *(volatile INT64 **)(qword_140C4E388 + 8i64 * (*((_WORD *)ControlArea + 30) & 0x3FF)),
      1i64,
      inserted);
}

Referenced by:

MiRelocateImage
MiWriteComplete