CmpAddAliasEntry

INT64 __fastcall CmpAddAliasEntry(VOID *a1, INT64 a2, INT64 a3){
  INT64 v3; 
  int v4; 
  unsigned int v6; 
  NTSTATUS v7; 
  INT64 v8; 
  _UNICODE_STRING *Class; 
  _UNICODE_STRING *Classa; 
  INT64 CreateOptions; 
  UINT64 CreateOptionsa; 
  UINT64 CreateOptionsb; 
  UINT64 *Disposition; 
  UINT64 *Dispositiona; 
  INT64 v17; 
  INT64 v18; 
  VOID *Handle; 
  UINT64 Data; 
  VOID *KeyHandle; 
  _UNICODE_STRING DestinationString; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  char v24; 

  ObjectAttributes.RootDirectory = a1;
  KeyHandle = 0i64;
  v4 = a3;
  Handle = 0i64;
  Data = 0i64;
  ObjectAttributes.ObjectName = (_UNICODE_STRING *)&CmpStrAliasString;
  *(_QWORD *)&ObjectAttributes.Length = 48i64;
  *(_QWORD *)&ObjectAttributes.Attributes = 576i64;
  DestinationString = 0i64;
  v6 = 0;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  v7 = ZwOpenKey(&KeyHandle, 0x2001Fui64, &ObjectAttributes, v3, (INT64)Class, CreateOptions, (INT64)Disposition, v17);
  if( v7 == -1073741772 )
  {
    LODWORD(CreateOptionsa) = 0;
    v7 = ZwCreateKey(&KeyHandle, 0x2001Fui64, &ObjectAttributes, 0i64, 0i64, CreateOptionsa, &Data);
  }
  if( v7 >= 0 )
  {
    while( 1 )
    {
      *(_QWORD *)&DestinationString.Length = 0x1000000i64;
      ++v6;
      DestinationString.Buffer = (wchar_t *)&v24;
      RtlUnicodeStringPrintf(&DestinationString, (WCHAR *)L"%04d");
      ObjectAttributes.RootDirectory = KeyHandle;
      ObjectAttributes.Length = 48;
      ObjectAttributes.ObjectName = &DestinationString;
      ObjectAttributes.Attributes = 576;
      *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
      v7 = ZwOpenKey(
             &Handle,
             0x2001Fui64,
             &ObjectAttributes,
             v8,
             (INT64)Classa,
             CreateOptionsa,
             (INT64)Dispositiona,
             v18);
      if( v7 < 0 )
        break;
      ZwClose((_HANDLE)Handle);
      if( v6 >= 0xC8 )
        goto LABEL_10;
    }
    if( v7 == -1073741772 )
      v7 = 0;
LABEL_10:
    if( v7 < 0
      || (LODWORD(CreateOptionsa) = 0,
          v7 = ZwCreateKey(&Handle, 0x2001Fui64, &ObjectAttributes, 0i64, 0i64, CreateOptionsa, &Data),
          v7 < 0) )
    {
      Handle = 0i64;
    }
    else
    {
      CmpAddDockingInfo(Handle, a2);
      HIDWORD(Data) = v4;
      LODWORD(CreateOptionsb) = 4;
      v7 = ZwSetValueKey(
             Handle,
             (_UNICODE_STRING *)&CmpStrProfileNumberString,
             0i64,
             4ui64,
             (char *)&Data + 4,
             CreateOptionsb);
    }
    if( KeyHandle )
      ZwClose((_HANDLE)KeyHandle);
  }
  else
  {
    KeyHandle = 0i64;
  }
  if( Handle )
    ZwClose((_HANDLE)Handle);
  return(unsigned int)v7;
}

Referenced by:

CmpCreateHardwareProfiles