CmpOpenDevicesControlSet

INT64 __fastcall CmpOpenDevicesControlSet(INT64 a1, HANDLE *a2, _OWORD *a3){
  const UNICODE_STRING *v3; 
  int v6; 
  NTSTATUS v7; 
  void *v8; 
  int v10; 
  void *KeyHandle; 
  struct _UNICODE_STRING DestinationString; 
  struct _OBJECT_ATTRIBUTES ObjectAttributes; 
  char v14[256]; 
  KeyHandle = 0i64;
  v3 = &CmpDevicesHiveNameString;
  DestinationString = 0i64;
  if( !CmStateSeparationEnabled )
    v3 = &CmpSystemHiveNameString;
  DestinationString.MaximumLength = 256;
  DestinationString.Buffer = (wchar_t *)v14;
  memset(&ObjectAttributes, 0, sizeof(ObjectAttributes));
  RtlUnicodeStringPrintf(&DestinationString, L"\\Registry\\Machine\\%wZ\\CurrentControlSet", v3);
  v7 = v6;
  if( v6 < 0 )
    goto LABEL_11;
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.ObjectName = &DestinationString;
  ObjectAttributes.Length = 48;
  ObjectAttributes.Attributes = 576;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  v7 = ZwOpenKey(&KeyHandle, 0x20019u, &ObjectAttributes);
  if( v7 == -1073741772 )
  {
    if( !CmStateSeparationEnabled )
      goto LABEL_11;
    *(_QWORD *)&DestinationString.Length = 0x1000000i64;
    v3 = &CmpSystemHiveNameString;
    DestinationString.Buffer = (wchar_t *)v14;
    RtlUnicodeStringPrintf(&DestinationString, L"\\Registry\\Machine\\%wZ\\CurrentControlSet", &CmpSystemHiveNameString);
    v7 = v10;
    if( v10 < 0 )
      goto LABEL_11;
    v7 = ZwOpenKey(&KeyHandle, 0x20019u, &ObjectAttributes);
  }
  if( v7 < 0 )
  {
LABEL_11:
    v8 = KeyHandle;
    goto LABEL_8;
  }
  v8 = 0i64;
  *a2 = KeyHandle;
  KeyHandle = 0i64;
  if( !a3 )
    return(unsigned int)v7;
  *a3 = *v3;
LABEL_8:
  if( v8 )
    ZwClose(v8);
  return(unsigned int)v7;
}

Referenced by:

CmSetAcpiHwProfile
CmpCreateHardwareProfiles
CmpMarkCurrentProfileDirty
CmpMoveBiosAliasTable