CmpOpenDevicesControlSet

__int64 __fastcall CmpOpenDevicesControlSet(__int64 a1, VOID **a2, _UNICODE_STRING *a3){
  _UNICODE_STRING *v3; 
  NTSTATUS v6; 
  INT64 v7; 
  VOID *v8; 
  INT64 v10; 
  VOID *KeyHandle; 
  _UNICODE_STRING DestinationString; 
  _OBJECT_ATTRIBUTES v13; 
  INT64 v14[32]; 

  KeyHandle = 0i64;
  v3 = (_UNICODE_STRING *)&CmpDevicesHiveNameString;
  DestinationString = 0i64;
  if( !*(&stru_140CF2E80 + 1656) )
    v3 = (_UNICODE_STRING *)&CmpSystemHiveNameString;
  DestinationString.MaximumLength = 256;
  DestinationString.Buffer = (wchar_t *)v14;
  memset(&v13, 0, sizeof(v13));
  v6 = RtlUnicodeStringPrintf(&DestinationString, (WCHAR *)L"\\Registry\\Machine\\%wZ\\CurrentControlSet");
  if( v6 < 0 )
    goto LABEL_11;
  v13.RootDirectory = 0i64;
  v13.ObjectName = &DestinationString;
  v13.Length = 48;
  v13.Attributes = 576;
  *(_OWORD *)&v13.SecurityDescriptor = 0i64;
  v6 = ZwOpenKey(
         &KeyHandle,
         0x20019ui64,
         &v13,
         v7,
         (INT64)KeyHandle,
         *(INT64 *)&DestinationString.Length,
         (INT64)DestinationString.Buffer,
         *(INT64 *)&v13.Length);
  if( v6 == -1073741772 )
  {
    if( !*(&stru_140CF2E80 + 1656) )
      goto LABEL_11;
    *(_QWORD *)&DestinationString.Length = 0x1000000i64;
    v3 = (_UNICODE_STRING *)&CmpSystemHiveNameString;
    DestinationString.Buffer = (wchar_t *)v14;
    v6 = RtlUnicodeStringPrintf(&DestinationString, (WCHAR *)L"\\Registry\\Machine\\%wZ\\CurrentControlSet");
    if( v6 < 0 )
      goto LABEL_11;
    v6 = ZwOpenKey(
           &KeyHandle,
           0x20019ui64,
           &v13,
           v10,
           (INT64)KeyHandle,
           *(INT64 *)&DestinationString.Length,
           (INT64)DestinationString.Buffer,
           *(INT64 *)&v13.Length);
  }
  if( v6 < 0 )
  {
LABEL_11:
    v8 = KeyHandle;
    goto LABEL_8;
  }
  v8 = 0i64;
  *a2 = KeyHandle;
  KeyHandle = 0i64;
  if( !a3 )
    return(unsigned int)v6;
  *a3 = *v3;
LABEL_8:
  if( v8 )
    ZwClose((_HANDLE)v8);
  return(unsigned int)v6;
}

Referenced by:

CmSetAcpiHwProfile
CmpCreateHardwareProfiles
CmpMarkCurrentProfileDirty
CmpMoveBiosAliasTable