PpmCheckComputeEnergy

INT64 __fastcall PpmCheckComputeEnergy(){
  INT64 result; 
  unsigned __int64 v1; 
  unsigned __int16 v2; 
  unsigned __int64 v3; 
  __int64 v4; 
  __int64 v5; 
  __int64 v6; 
  __int64 v7; 
  __int64 v8; 
  __int64 v9; 
  __int64 v10; 
  unsigned int v11; 
  unsigned int v12; 
  unsigned int v13; 
  __int64 v14; 
  __int64 v15; 
  unsigned int v16; 
  EVENT_DESCRIPTOR *v17; 
  UINT64 v18; 
  UINT64 UserDataCount; 
  unsigned int v20; 
  UINT64 ProcessorNumber; 
  __int64 v22[3]; 
  __int64 v23; 
  __int128 v24; 
  __int128 v25; 
  struct _EVENT_DATA_DESCRIPTOR UserData; 
  __int64 *v27; 
  __int64 v28; 
  v22[0] = 0i64;
  if( PopComputeEnergy )
  {
    v1 = KeActiveProcessors.Bitmap[0];
    v2 = 0;
    ProcessorNumber = 0x4000000040i64;
    v25 = 0i64;
    v24 = 0i64;
    while( v1 )
    {
LABEL_4:
      _BitScanForward64(&v3, v1);
      v1 &= ~(1i64 << v3);
      v4 = (unsigned int)KiProcessorNumberToIndexMappingTable[64 * v2 + (unsigned __int8)v3];
      if( (unsigned int)v4 >= (unsigned int)KeNumberProcessors_0 )
      {
        v5 = 0i64;
      }
      else
      {
        _mm_lfence();
        v5 = (__int64)*(&KiProcessorBlock + v4);
      }
      v6 = *(unsigned __int8 *)(v5 + 33208);
      v7 = 4 * v6;
      *((_DWORD *)&v22[-1] + v6) = v4;
      v8 = 8 * v6;
      *(_QWORD *)((char *)&v25 + v8) += *(_QWORD *)(v5 + 33224);
      *(_QWORD *)((char *)&v24 + v8) += *(_QWORD *)(v5 + 33232);
      v9 = *(_QWORD *)(v5 + 33128);
      v10 = *(_QWORD *)(v5 + 33136);
      if( v9 && v10 )
      {
        if( *(_BYTE *)(v10 + 100) )
        {
          v11 = *(_DWORD *)(v10 + 116);
        }
        else
        {
          v11 = *(_DWORD *)(v10 + 72);
          v12 = *(_DWORD *)(v9 + 368);
          if( v11 >= v12 )
            v11 = v12;
        }
      }
      else
      {
        v11 = 100;
      }
      *(_DWORD *)((char *)&v22[2] + v7) = v11;
      *(_QWORD *)(v5 + 33224) = 0i64;
      *(_QWORD *)(v5 + 33232) = 0i64;
    }
    while( 1 )
    {
      result = ++v2;
      if( v2 >= (unsigned int)KeActiveProcessors.Count )
        break;
      v1 = KeActiveProcessors.Bitmap[v2];
      if( v1 )
        goto LABEL_4;
    }
    v13 = 0;
    v14 = 0i64;
    v15 = 0i64;
    do
    {
      v16 = *(_DWORD *)((char *)&v22[-1] + v14);
      if( v16 != 64 )
      {
        ((void(__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD, __int64 *))PopComputeEnergy)(
          v13,
          *(_QWORD *)((char *)&v25 + v15),
          *(_QWORD *)((char *)&v24 + v15),
          *(unsigned int *)((char *)&v22[2] + v14),
          v22);
        v23 = v22[0];
        v20 = v13;
        if( PpmEtwRegistered )
        {
          v18 = PpmEtwHandle;
          if( EtwEventEnabled(PpmEtwHandle, (EVENT_DESCRIPTOR *)&PPM_ETW_COMPUTE_ENERGY, v17) )
          {
            *(_QWORD *)&UserData.Size = 4i64;
            UserData.Ptr = (unsigned __int64)&v20;
            v28 = 8i64;
            v27 = &v23;
            LODWORD(UserDataCount) = 2;
            EtwWriteEx(
              v18,
              (EVENT_DESCRIPTOR *)&PPM_ETW_COMPUTE_ENERGY,
              0i64,
              0i64,
              0i64,
              0i64,
              UserDataCount,
              &UserData);
          }
        }
        KeGetPrcb(v16);
        *(_QWORD *)(result + 33216) += v22[0];
      }
      ++v13;
      v14 += 4i64;
      v15 += 8i64;
    }
    while( v13 < 2 );
  }
  LOBYTE(result) = 1;
  return result;
}

Referenced by:

No references.