MiAttemptSectionDelete

UINT8 __stdcall MiAttemptSectionDelete(_CONTROL_AREA *ControlArea, UINT8 OldIrql, UINT8 DelayClose){
  bool v4; 
  unsigned __int64 v6; 
  union {unsigned int LongFlags;_MMSECTION_FLAGS Flags;} v8; 
  CHAR v9; 
  _MI_CONTROL_AREA_WAIT_BLOCK *WaitList; 
  int v11; 
  int v12; 
  __int16 v13; 
  char v14; 
  char v15; 
  int v16; 
  __int64 v17[3]; 

  v12 = 0;
  v4 = ControlArea->NumberOfSectionReferences == 0;
  v6 = OldIrql;
  v15 = 0;
  if( !v4 || ControlArea->NumberOfMappedViews || (v8.LongFlags = (unsigned int)ControlArea->u, (v8.LongFlags & 2) != 0) )
  {
    if( (DelayClose & 4) != 0 )
      ControlArea->u.LongFlags |= 0x40000u;
    ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)&ControlArea->ControlAreaLock);
    __writecr8(v6);
    return 0;
  }
  else if( (v8.LongFlags & 1) != 0 )
  {
    v16 = 0;
    v17[1] = (__int64)v17;
    v17[0] = (__int64)v17;
    WaitList = ControlArea->WaitList;
    ControlArea->WaitList = (_MI_CONTROL_AREA_WAIT_BLOCK *)&WaitList;
    v11 = 1;
    v13 = 263;
    v14 = 6;
    ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)&ControlArea->ControlAreaLock);
    __writecr8(v6);
    KeWaitForGate((_KGATE *)&v13, WrPageOut, v9);
    return 1;
  }
  else
  {
    MiRemoveUnusedSegment(ControlArea);
    ControlArea->NumberOfMappedViews = 1i64;
    return MiCleanSection(ControlArea, v6, (DelayClose & 4) != 0);
  }
}

Referenced by:

MiForceSectionClosed
MmFlushImageSection