MiReturnCrossPartitionCombineCharges

NTSTATUS __fastcall MiReturnCrossPartitionCombineCharges(volatile INT64 *a1, INT64 a2){
  unsigned __int64 v3; 
  struct _KPRCB *CurrentPrcb; 
  __int64 v5; 
  bool v6; 
  signed __int32 v7; 
  NTSTATUS result; 
  if( !(_DWORD)a2 )
    goto LABEL_14;
  MiReturnCommit((_MI_PARTITION *)a1, 1ui64);
  v3 = 1i64;
  if( a1 != (volatile INT64 *)&MiSystemPartition )
    goto LABEL_13;
  CurrentPrcb = KeGetCurrentPrcb();
  v5 = *((int *)CurrentPrcb + 8391);
  if( (_DWORD)v5 == -1 )
    goto LABEL_13;
  if( (unsigned __int64)(v5 + 1) > 0x100 )
  {
LABEL_8:
    if( (int)v5 > 192
      && (_DWORD)v5 != -1
      && (_DWORD)v5 == _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, 192, v5) )
    {
      v3 = (int)v5 - 192 + 1i64;
    }
    if( !v3 )
      goto LABEL_14;
LABEL_13:
    _InterlockedExchangeAdd64(a1 + 896, v3);
    goto LABEL_14;
  }
  while( 1 )
  {
    v7 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v5 + 1, v5);
    v6 = (_DWORD)v5 == v7;
    LODWORD(v5) = v7;
    if( v6 )
      break;
    if( v7 == -1 || (unsigned __int64)(v7 + 1i64) > 0x100 )
      goto LABEL_8;
  }
LABEL_14:
  MiReturnCrossPartitionCharges((_MI_CROSS_PARTITION_CHARGES *)a1, 2ui64);
  return result;
}

Referenced by:

MiConvertPrivateToProto
MiConvertStandbyToProto
MiDecrementCombinedPte
MiIncrementCombinedPte