CmpCreateControlSetOverride

INT64 __fastcall CmpCreateControlSetOverride(){
  __int64 v0; 
  __int64 v1; 
  __int64 v2; 
  int v3; 
  NTSTATUS v4; 
  UINT64 CreateOptions; 
  void *KeyHandle; 
  HANDLE Handle; 
  struct _UNICODE_STRING DestinationString; 
  struct _OBJECT_ATTRIBUTES ObjectAttributes; 
  char v11; 
  v1 = *(_QWORD *)(v0 + 48);
  v2 = *(_QWORD *)(v0 + 56);
  *(_QWORD *)&DestinationString.Length = 0x1000000i64;
  KeyHandle = 0i64;
  DestinationString.Buffer = (wchar_t *)&v11;
  memset(&ObjectAttributes, 0, sizeof(ObjectAttributes));
  Handle = 0i64;
  RtlUnicodeStringPrintf(&DestinationString, L"\\REGISTRY\\%ws\\%ws", v2, v1);
  v4 = v3;
  if( v3 >= 0 )
  {
    ObjectAttributes.Length = 48;
    ObjectAttributes.ObjectName = &DestinationString;
    ObjectAttributes.RootDirectory = 0i64;
    ObjectAttributes.Attributes = 576;
    *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
    v4 = ZwOpenKey(&KeyHandle, 0x20006u, &ObjectAttributes);
    if( v4 >= 0 )
    {
      ObjectAttributes.RootDirectory = KeyHandle;
      LODWORD(CreateOptions) = 0;
      ObjectAttributes.ObjectName = (_UNICODE_STRING *)L"$&";
      ObjectAttributes.Length = 48;
      ObjectAttributes.Attributes = 576;
      *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
      v4 = ZwCreateKey(&Handle, 0x20006ui64, &ObjectAttributes, 0i64, 0i64, CreateOptions, 0i64);
      if( v4 >= 0 )
        v4 = 0;
    }
  }
  if( Handle )
    ZwClose(Handle);
  if( KeyHandle )
    ZwClose(KeyHandle);
  return(unsigned int)v4;
}

Referenced by:

CmpCreateExtendedControlSets