PnpProfileUpdateHardwareProfile

__int64 PnpProfileUpdateHardwareProfile(){
  INT64 v0; 
  INT64 v1; 
  int v2; 
  VOID **PoolWithTag; 
  VOID **v4; 
  char *v5; 
  __int64 **i; 
  __int64 *v7; 
  WCHAR **v8; 
  unsigned int v9; 
  VOID *Data; 
  VOID *Dataa; 
  INT64 DataSize; 
  INT64 DataSizea; 
  UINT64 DataSizeb; 
  _UNICODE_STRING ValueName; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  VOID *Handle; 
  VOID *KeyHandle; 
  __int64 ProfileChanged; 

  ProfileChanged = 0i64;
  Handle = 0i64;
  ExAcquireFastMutex((PFAST_MUTEX)((char *)&PnpReplaceEvent + 160));
  *(&ObjectAttributes.Length + 1) = 0;
  memset(&ObjectAttributes.Attributes + 1, 0, 20);
  KeyHandle = 0i64;
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.ObjectName = &ValueName;
  ObjectAttributes.Length = 48;
  ObjectAttributes.Attributes = 576;
  if( ZwOpenKey(
         &KeyHandle,
         0x20019ui64,
         &ObjectAttributes,
         v0,
         (INT64)Data,
         DataSize,
         8126586i64,
         (INT64)L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\IDConfigDB") >= 0 )
  {
    *(&ObjectAttributes.Length + 1) = 0;
    memset(&ObjectAttributes.Attributes + 1, 0, 20);
    ObjectAttributes.RootDirectory = KeyHandle;
    *(_DWORD *)&ValueName.Length = 2097182;
    ObjectAttributes.ObjectName = &ValueName;
    ObjectAttributes.Length = 48;
    ObjectAttributes.Attributes = 576;
    if( ZwOpenKey(
           &Handle,
           0x2001Fui64,
           &ObjectAttributes,
           v1,
           (INT64)Dataa,
           DataSizea,
           *(INT64 *)&ValueName.Length,
           (INT64)L"CurrentDockInfo") >= 0 )
    {
      ValueName.Buffer = L"EjectableDocks";
      LODWORD(DataSizeb) = 4;
      *(_DWORD *)&ValueName.Length = 1966108;
      ZwSetValueKey(Handle, &ValueName, 0i64, 4ui64, (char *)&PnpReplaceEvent + 132, DataSizeb);
      ZwClose((_HANDLE)Handle);
    }
    ZwClose((_HANDLE)KeyHandle);
  }
  v2 = *(&PnpReplaceEvent + 33);
  if( !*(&PnpReplaceEvent + 33) )
    v2 = 1;
  PoolWithTag = ExAllocatePoolWithTag(0x200ui64, (unsigned int)(8 * v2 + 8), 538996816i64);
  v4 = PoolWithTag;
  if( PoolWithTag )
  {
    v5 = (char *)PoolWithTag;
    for( i = (__int64 **)*(&PnpReplaceEvent + 28); i != (__int64 **)((char *)&PnpReplaceEvent + 224); i = (__int64 **)*i )
    {
      v7 = i[2];
      if( v7 )
      {
        *(_QWORD *)v5 = v7;
        v5 += 8;
      }
    }
    KeReleaseGuardedMutex((PKGUARDED_MUTEX)((char *)&PnpReplaceEvent + 160));
    if( v5 == (char *)v4 )
    {
      *(_QWORD *)v5 = 0i64;
      v5 += 8;
    }
    *(_QWORD *)v5 = 0i64;
    v9 = IopExecuteHardwareProfileChange(
           v8,
           (UINT64)v4,
           (VOID **)(unsigned int)((v5 - (char *)v4) >> 3),
           (UINT8 *)&ProfileChanged);
    if( ProfileChanged )
      ZwClose(ProfileChanged);
    ExFreePoolWithTag(v4, 0);
  }
  else
  {
    KeReleaseGuardedMutex((PKGUARDED_MUTEX)((char *)&PnpReplaceEvent + 160));
    return(unsigned int)-1073741670;
  }
  return v9;
}

Referenced by:

PpProfileCancelTransitioningDock
PpProfileCommitTransitioningDock