IopExecuteHardwareProfileChange

INT64 __stdcall IopExecuteHardwareProfileChange(
        WCHAR **ProfileSerialNumbers,
        UINT64 SerialNumbersCount,
        PVOID *NewProfile,
        UINT8 *ProfileChanged){
  __int64 v5; 
  struct _UNICODE_STRING *PoolWithTag; 
  WCHAR v7; 
  struct _UNICODE_STRING *v8; 
  unsigned int v9; 
  __int16 v10; 
  struct _UNICODE_STRING *v11; 
  __int64 v12; 
  __int64 v13; 
  UNICODE_STRING *v14; 
  __int64 v15; 
  UNICODE_STRING *v16; 
  UNICODE_STRING v17; 
  int v18; 
  struct _UNICODE_STRING *v19; 
  __int64 v20; 
  int Length; 
  unsigned int v22; 
  unsigned __int16 *v23; 
  __int64 v24; 
  unsigned __int16 *v25; 
  _WORD *v26; 
  UINT8 *v27; 
  UINT8 **v28; 
  __int64 v29; 
  UINT64 v30; 
  struct _UNICODE_STRING *v32; 
  _BYTE *v34; 
  v5 = (unsigned int)NewProfile;
  PoolWithTag = (struct _UNICODE_STRING *)ExAllocatePoolWithTag(
                                            NonPagedPoolNx,
                                            (unsigned int)(16 * (_DWORD)NewProfile),
                                            0x33706E50ui64);
  v32 = PoolWithTag;
  v8 = PoolWithTag;
  if( PoolWithTag )
  {
    v10 = 1;
    if( (_DWORD)v5 )
    {
      v11 = PoolWithTag;
      v12 = v5;
      v13 = v5;
      do
      {
        RtlInitUnicodeString(v11++, *(PCWSTR *)SerialNumbersCount, v7);
        SerialNumbersCount += 8i64;
        --v13;
      }
      while( v13 );
      do
      {
        if( (_DWORD)v5 != 1 )
        {
          v14 = v8;
          v15 = (unsigned int)(v5 - 1);
          v16 = v8 + 1;
          do
          {
            if( (int)RtlCompareUnicodeString(v16 - 1, v16, 0) > 0 )
            {
              v17 = *v16;
              *v16 = *v14;
              *v14 = v17;
            }
            ++v16;
            ++v14;
            --v15;
          }
          while( v15 );
        }
        --v12;
      }
      while( v12 );
    }
    v18 = 0;
    if( (_DWORD)v5 )
    {
      v19 = v8;
      v20 = v5;
      do
      {
        Length = v19->Length;
        ++v19;
        v18 += Length;
        --v20;
      }
      while( v20 );
    }
    v22 = v18 + 2;
    v23 = (unsigned __int16 *)ExAllocatePoolWithTag(NonPagedPoolNx, v22 + 6i64, 0x33706E50ui64);
    v25 = v23;
    if( v23 )
    {
      v26 = v23 + 2;
      v27 = (UINT8 *)(v23 + 2);
      if( (_DWORD)v5 )
      {
        v28 = (UINT8 **)v8;
        v29 = v5;
        do
        {
          v30 = *(unsigned __int16 *)v28;
          memmove(v27, v28[1], v30);
          v27 += v30;
          v28 += 2;
          --v29;
        }
        while( v29 );
        v8 = v32;
        v26 = v25 + 2;
      }
      *(_WORD *)v27 = 0;
      v25[1] = v22;
      if( (unsigned int)v5 > 1 || *v26 )
        v10 = 2;
      *v25 = v10;
      v9 = CmSetAcpiHwProfile(
             v25,
             (__int64(__fastcall *)(PVOID, unsigned int *, _QWORD))IopExecuteHwpDefaultSelect,
             v24,
             (__int64)ProfileChanged,
             v34);
    }
    else
    {
      v9 = -1073741670;
    }
    ExFreePoolWithTag(v8, 0x33706E50u);
    if( v25 )
      ExFreePoolWithTag(v25, 0x33706E50u);
  }
  else
  {
    return(unsigned int)-1073741670;
  }
  return v9;
}

Referenced by:

PnpProfileUpdateHardwareProfile