PpmRegisterProfiles

INT64 __fastcall PpmRegisterProfiles(UINT8 a1, INT64 a2){
  __int64 v3; 
  __int64 v4; 
  int v5; 
  unsigned __int8 v6; 
  UINT64 v7; 
  UINT64 v8; 
  char v9; 
  VOID *PoolWithTag; 
  INT64 v11; 
  unsigned __int8 v12; 
  INT64 v13; 
  UINT64 v14; 
  INT64 v15; 
  char v16; 
  size_t v17; 
  INT64 v19; 
  size_t pcbLength; 
  UINT64 v21; 
  pcbLength = 0i64;
  v21 = 0i64;
  v3 = a1;
  if( a1 > 0x1Fu )
  {
    return(unsigned int)-1073741811;
  }
  else
  {
    v4 = a1;
    v5 = RtlULongLongMult(a1, 0x15B0ui64, &v21);
    if( v5 >= 0 )
    {
      v6 = 0;
      v7 = (v21 + 1) & 0xFFFFFFFFFFFFFFFEui64;
      v8 = v7;
      if( (_BYTE)v3 )
      {
        while( 1 )
        {
          v5 = RtlStringCbLengthW(*(const WCHAR **)(32i64 * v6 + a2 + 8), 0x7FFFFFFFui64, &pcbLength);
          if( v5 < 0 )
            break;
          v6 = v9 + 1;
          v8 += pcbLength + 2;
          if( v6 >= (unsigned __int8)v3 )
            goto LABEL_6;
        }
      }
      else
      {
LABEL_6:
        PoolWithTag = ExAllocatePoolWithTag(NonPagedPoolNx, v8, 0x664D5050ui64);
        v19 = (INT64)PoolWithTag;
        v11 = (INT64)PoolWithTag;
        if( PoolWithTag )
        {
          memset((INT64)PoolWithTag, 0i64);
          if( (_BYTE)v3 )
          {
            v12 = 0;
            v13 = v11 + 32;
            v14 = v7 + v11;
            v15 = a2 + 8;
            do
            {
              ++v12;
              *(_OWORD *)(v13 - 20) = *(_OWORD *)*(_QWORD *)(v15 - 8);
              v16 = *(_BYTE *)(v15 + 8);
              *(_QWORD *)(v13 + 5504) = -1i64;
              *(_BYTE *)v13 = v16;
              *(_QWORD *)(v13 - 32) = v14;
              *(_BYTE *)(v13 - 24) = v12;
              RtlStringCchLengthW(*(STRSAFE_PCNZWCH *)v15, 0x7FFFFFFFui64, &pcbLength);
              v17 = pcbLength;
              RtlStringCchCopyW(*(PWCHAR *)(v13 - 32), pcbLength + 1, *(PWCHAR *)v15);
              *(_QWORD *)(v15 + 16) = v13 - 32;
              v14 += 2 * v17 + 2;
              v13 += 5552i64;
              v15 += 32i64;
            }
            while( v12 < (unsigned __int8)v3 );
            v11 = v19;
            v4 = v3;
          }
          PpmAcquireLock(&PpmPerfPolicyLock);
          PopAcquireRwLockExclusive((_POP_RW_LOCK *)&PpmIdlePolicyLock);
          PpmProfiles = v11;
          PpmProfileCount = v3;
          if( (_BYTE)v3 )
          {
            do
            {
              PpmResetProfileSettings(v11);
              v11 += 5552i64;
              --v4;
            }
            while( v4 );
          }
          PpmEventTraceProfiles(0);
          PopReleaseRwLock((UINT64)&PpmIdlePolicyLock);
          PpmReleaseLock(&PpmPerfPolicyLock);
          PpmProfileStatus |= 1u;
        }
        else
        {
          return(unsigned int)-1073741670;
        }
      }
    }
  }
  return(unsigned int)v5;
}

Referenced by:

PdcPoPpmRegisterProfiles