OpenGlobalizationUserSettingsKey_ForSingleUserModel

NTSTATUS __stdcall OpenGlobalizationUserSettingsKey_ForSingleUserModel(
        UINT64 flags,
        VOID **pUserSettingsRootKey,
        _UNICODE_STRING *pObjKeyName,
        VOID **a4){
  INT64 v5; 
  int v6; 
  INT64 v7; 
  NTSTATUS v8; 
  VOID *v9; 
  VOID *v10; 
  INT64 v11; 
  VOID *v12; 
  INT64 Length; 
  UINT64 Lengtha; 
  UINT64 Lengthb; 
  INT64 Lengthc; 
  UINT64 *ResultLength; 
  UINT64 *ResultLengtha; 
  _UNICODE_STRING SourceString; 
  _UNICODE_STRING v21; 
  _UNICODE_STRING ValueName; 
  _UNICODE_STRING DestinationString; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  UINT64 v25; 
  VOID *KeyHandle; 
  VOID *v27; 

  LODWORD(v25) = flags;
  if( dword_140CF9E14 )
  {
    DestinationString = 0i64;
    RtlInitUnicodeString(&DestinationString, word_140CF7330);
    *(_QWORD *)&ObjectAttributes.Length = 48i64;
    ObjectAttributes.ObjectName = &DestinationString;
    *(_QWORD *)&ObjectAttributes.Attributes = 576i64;
    ObjectAttributes.RootDirectory = 0i64;
    *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
    return ZwOpenKey(
             pUserSettingsRootKey,
             8ui64,
             &ObjectAttributes,
             v5,
             Length,
             (INT64)ResultLength,
             *(INT64 *)&SourceString.Length,
             (INT64)SourceString.Buffer);
  }
  KeyHandle = 0i64;
  v21 = 0i64;
  RtlInitUnicodeString(&v21, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\CommonGlobUserSettings\\");
  *(_QWORD *)&ObjectAttributes.Length = 48i64;
  ObjectAttributes.ObjectName = &v21;
  *(_QWORD *)&ObjectAttributes.Attributes = 576i64;
  ObjectAttributes.RootDirectory = 0i64;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  v6 = ZwOpenKey(
         &KeyHandle,
         8ui64,
         &ObjectAttributes,
         v7,
         Length,
         (INT64)ResultLength,
         *(INT64 *)&SourceString.Length,
         (INT64)SourceString.Buffer);
  if( v6 >= 0 )
  {
    LODWORD(v25) = 0;
    ValueName = 0i64;
    RtlInitUnicodeString(&ValueName, L"RedirectedKey");
    LODWORD(Lengtha) = 0;
    v8 = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation, 0i64, Lengtha, &v25);
    if( !(_DWORD)v25 || v8 != -1073741789 && v8 != -2147483643 )
    {
      *(_QWORD *)&DestinationString.Length = 11141120i64;
      DestinationString.Buffer = word_140CF7330;
      if( v21.Length <= 0xAAu )
      {
        RtlCopyUnicodeString(&DestinationString, &v21);
        dword_140CF9E14 = 1;
      }
      v6 = 0;
      *pUserSettingsRootKey = KeyHandle;
      KeyHandle = 0i64;
      goto LABEL_21;
    }
    LODWORD(v9) = AllocateMemory(v25);
    v10 = v9;
    if( v9 )
    {
      LODWORD(Lengthb) = v25;
      v6 = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation, v9, Lengthb, &v25);
      if( v6 >= 0 )
      {
        if( *((_DWORD *)v10 + 1) != 1 )
        {
          v12 = KeyHandle;
          KeyHandle = 0i64;
LABEL_15:
          *pUserSettingsRootKey = v12;
          goto LABEL_16;
        }
        v27 = 0i64;
        SourceString = 0i64;
        RtlInitUnicodeString(&SourceString, (PCWSTR)v10 + 6);
        *(_QWORD *)&ObjectAttributes.Length = 48i64;
        ObjectAttributes.ObjectName = &SourceString;
        *(_QWORD *)&ObjectAttributes.Attributes = 576i64;
        ObjectAttributes.RootDirectory = 0i64;
        *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
        v6 = ZwOpenKey(
               &v27,
               8ui64,
               &ObjectAttributes,
               v11,
               Lengthc,
               (INT64)ResultLengtha,
               *(INT64 *)&SourceString.Length,
               (INT64)SourceString.Buffer);
        if( v6 >= 0 )
        {
          *(_QWORD *)&DestinationString.Length = 11141120i64;
          DestinationString.Buffer = word_140CF7330;
          if( SourceString.Length <= 0xAAu )
          {
            RtlCopyUnicodeString(&DestinationString, &SourceString);
            dword_140CF9E14 = 1;
          }
          v12 = v27;
          goto LABEL_15;
        }
      }
LABEL_16:
      ExFreeHeapPool(v10);
      goto LABEL_21;
    }
    v6 = -1073741801;
  }
LABEL_21:
  if( KeyHandle )
    ZwClose((_HANDLE)KeyHandle);
  return v6;
}

Referenced by:

OpenGlobalizationUserSettingsKey
OpenGlobalizationUserSettingsKey_ForMua