MiReleaseWriteInProgressCharges

VOID __stdcall MiReleaseWriteInProgressCharges(_MI_PARTITION *Partition, UINT64 NumberOfPages, UINT64 ReleaseCommit){
  unsigned __int64 v3; 
  struct _KPRCB *CurrentPrcb; 
  __int64 v6; 
  bool v7; 
  signed __int32 v8; 
  signed __int32 v9; 
  v3 = NumberOfPages;
  if( (_DWORD)ReleaseCommit )
  {
    MiReturnCommit(Partition, NumberOfPages);
    if( Partition == (_MI_PARTITION *)&MiSystemPartition )
    {
      CurrentPrcb = KeGetCurrentPrcb();
      v6 = *((int *)CurrentPrcb + 8391);
      if( (_DWORD)v6 != -1 )
      {
        if( v3 + v6 <= 0x100 )
        {
          do
          {
            if( v3 >= 0x80000 )
              break;
            v8 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v6 + v3, v6);
            v7 = (_DWORD)v6 == v8;
            LODWORD(v6) = v8;
            if( v7 )
              return;
          }
          while( v8 != -1 && v3 + v8 <= 0x100 );
        }
LABEL_8:
        if( (int)v6 > 192
          && (_DWORD)v6 != -1
          && (_DWORD)v6 == _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, 192, v6) )
        {
          v3 += (int)v6 - 192;
        }
      }
    }
  }
  else if( Partition == (_MI_PARTITION *)&MiSystemPartition )
  {
    CurrentPrcb = KeGetCurrentPrcb();
    v6 = *((int *)CurrentPrcb + 8391);
    if( (_DWORD)v6 != -1 )
    {
      if( v3 + v6 <= 0x100 )
      {
        do
        {
          if( v3 >= 0x80000 )
            break;
          v9 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v6 + v3, v6);
          v7 = (_DWORD)v6 == v9;
          LODWORD(v6) = v9;
          if( v7 )
            return;
        }
        while( v9 != -1 && v3 + v9 <= 0x100 );
      }
      goto LABEL_8;
    }
  }
  if( v3 )
    _InterlockedExchangeAdd64((volatile signed __int64 *)Partition + 896, v3);
}

Referenced by:

MiBuildMappedCluster
MiFreeModWriterEntry
MiGatherPagefilePages
MiWriteComplete