MiAttemptSectionDelete

char __fastcall MiAttemptSectionDelete(__int64 a1, unsigned __int8 a2, char a3){
  bool v4; 
  unsigned __int64 v6; 
  int v8; 
  __int64 v9; 
  int v10; 
  int v11; 
  __int16 PcValue; 
  char v13; 
  char v14; 
  int v15; 
  __int64 v16[3]; 
  v11 = 0;
  v4 = *(_QWORD *)(a1 + 24) == 0i64;
  v6 = a2;
  v14 = 0;
  if( !v4 || *(_QWORD *)(a1 + 40) || (v8 = *(_DWORD *)(a1 + 56), (v8 & 2) != 0) )
  {
    if( (a3 & 4) != 0 )
      *(_DWORD *)(a1 + 56) |= 0x40000u;
    ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)(a1 + 72));
    __writecr8(v6);
    return 0;
  }
  else if( (v8 & 1) != 0 )
  {
    v15 = 0;
    v16[1] = (__int64)v16;
    v16[0] = (__int64)v16;
    v9 = *(_QWORD *)(a1 + 80);
    *(_QWORD *)(a1 + 80) = &v9;
    v10 = 1;
    PcValue = 263;
    v13 = 6;
    ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)(a1 + 72));
    __writecr8(v6);
    KeWaitForGate(&PcValue, 19);
    return 1;
  }
  else
  {
    MiRemoveUnusedSegment((_CONTROL_AREA *)a1);
    *(_QWORD *)(a1 + 40) = 1i64;
    return MiCleanSection((_CONTROL_AREA *)a1, v6, (a3 & 4) != 0);
  }
}

Referenced by:

MiForceSectionClosed
MmFlushImageSection