MiReleaseControlAreaCharges

VOID __fastcall MiReleaseControlAreaCharges(_CONTROL_AREA *ControlArea, UINT64 LockHeld){
  int v3; 
  _CONTROL_AREA *v4; 
  __int64 v5; 
  int v6; 
  __int64 v7; 
  unsigned __int8 v8; 
  __int8 bf_2; 
  union {unsigned int LongFlags;_MMSECTION_FLAGS Flags;} v10; 
  int v11; 
  _CONTROL_AREA *v12; 
  int v13; 
  __int64 v14; 

  LOBYTE(v3) = MiAweControlArea((INT64)ControlArea);
  if( !v3 && MiIncludeSharedCommit(v4) )
  {
    v7 = 0i64;
    if( v6 == 1 )
      v8 = 17;
    else
      v8 = ExAcquireSpinLockExclusive((INT64 *)(v5 + 72));
    bf_2 = ControlArea->u1.Flags._bf_2;
    if( (bf_2 & 2) == 0
      || ((v10.LongFlags = (unsigned int)ControlArea->u,
           ControlArea->u1.Flags._bf_2 = bf_2 & 0xFD,
           (v10.LongFlags & 0x20) != 0)
       || !ControlArea->FilePointer.Value ? (v11 = 1) : (v11 = 0),
          v12 = ControlArea + 1,
          ControlArea == (_CONTROL_AREA *)-128i64) )
    {
LABEL_7:
      if( v8 != 17 )
      {
        ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)&ControlArea->ControlAreaLock);
        __writecr8(v8);
      }
      return;
    }
    v13 = 0x3FFFFFFF;
    while( 1 )
    {
      if( (v12->NumberOfPfnReferences & 0x10000) != 0 )
        goto LABEL_21;
      if( (v13 & v12->NumberOfUserReferences) == v13 || v11 )
        break;
LABEL_22:
      v12 = *(_CONTROL_AREA **)&v12->gap8[8];
      if( !v12 )
        goto LABEL_7;
    }
    LODWORD(v14) = MiComputeCrossPartitionSectionCharges((INT64 *)v12);
    v7 += v14;
LABEL_21:
    if( v11 )
      goto LABEL_7;
    goto LABEL_22;
  }
}

Referenced by:

MiInsertUnusedSegment
MiSegmentDelete