EtwpUpdatePmcCounters

INT64 __fastcall EtwpUpdatePmcCounters(INT64 a1, INT64 a2, UINT64 a3){
  unsigned int v3; 
  unsigned int v6; 
  INT64 result; 
  __int64 v8; 
  __int64 i; 
  unsigned int v10; 
  unsigned int j; 
  __int64 k; 
  signed __int32 v13[22]; 
  v3 = a3;
  v6 = KeNumberProcessors_0;
  if( !(_DWORD)a3 || (unsigned int)a3 > EtwpMaxPmcCounter || *(_DWORD *)(a1 + 316) == 1 )
    return 3221225485i64;
  if( *(_QWORD *)(a1 + 1000) || (result = EtwpAllocatePmcData((_WMI_LOGGER_CONTEXT *)a1), !(_DWORD)result) )
  {
    v8 = *(_QWORD *)(a1 + 1000);
    if( *(_DWORD *)(v8 + 20) )
    {
      return 3221226243i64;
    }
    else
    {
      for( i = 0i64; ; i = (unsigned int)(i + 1) )
      {
        v13[12] = i;
        if( (unsigned int)i >= v3 )
          break;
        *(_DWORD *)(*(_QWORD *)v8 + 4 * i) = *(_DWORD *)(a2 + 4 * i);
      }
      v10 = 0;
      for( j = 0; j < v6; ++j )
      {
        v10 = ((__int64(__fastcall *)(_QWORD, _QWORD, _QWORD, __int64))off_140C007D0[0])(
                j,
                *(_QWORD *)v8,
                v3,
                v8 + 8 * (j + 3i64));
        if( v10 )
          break;
      }
      if( v10 )
      {
        for( k = 0i64; (unsigned int)k < j; k = (unsigned int)(k + 1) )
        {
          ((void(__fastcall *)(_QWORD))off_140C007E0[0])(*(_QWORD *)(v8 + 8 * k + 24));
          *(_QWORD *)(v8 + 8 * k + 24) = 0i64;
        }
      }
      else
      {
        *(_DWORD *)(v8 + 20) = v3;
        _InterlockedOr(v13, 0);
        _InterlockedOr((volatile signed __int32 *)(a1 + 832), 0x800u);
      }
      return v10;
    }
  }
  return result;
}

Referenced by:

EtwSetPerformanceTraceInformation