MiForceSectionClosed

__int64 __fastcall MiForceSectionClosed(_QWORD *a1, char a2){
  int v3; 
  unsigned __int64 v5; 
  __int64 v6; 

  v3 = a2 & 1;
  while( 1 )
  {
    v5 = (unsigned __int8)ExAcquireSpinLockExclusive(&SpinLock);
    v6 = v3 ? *a1 : a1[2];
    if( !v6 )
      break;
    if( (unsigned int)ExTryAcquireSpinLockExclusiveAtDpcLevel((INT64 *)(v6 + 72)) )
    {
      ExReleaseSpinLockExclusiveFromDpcLevel(&SpinLock);
      return 2 - (unsigned int)(MiAttemptSectionDelete((_CONTROL_AREA *)v6, v5, a2 & 4) != 0);
    }
    ExReleaseSpinLockExclusiveFromDpcLevel(&SpinLock);
    __writecr8(v5);
  }
  ExReleaseSpinLockExclusiveFromDpcLevel(&SpinLock);
  __writecr8(v5);
  return 0i64;
}

Referenced by:

MiCreateImageOrDataSection
MmForceSectionClosed
MmForceSectionClosedEx