MigrateOOBELanguageToInstallationLanguage

NTSTATUS __stdcall MigrateOOBELanguageToInstallationLanguage(){
  INT64 v0; 
  int v1; 
  unsigned __int16 v2; 
  __int64 i; 
  __int16 v4; 
  unsigned __int16 v5; 
  INT64 Length; 
  UINT64 Lengtha; 
  UINT64 *ResultLength; 
  UINT64 *ResultLengtha; 
  VOID *KeyHandle; 
  INT64 DestinationString; 
  _UNICODE_STRING DestinationString_8; 
  _UNICODE_STRING ValueName_8; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  __int64 Data; 
  __int16 v17; 
  UINT64 KeyValueInformation[66]; 

  *(_QWORD *)&ObjectAttributes.Length = 48i64;
  Data = 0i64;
  v17 = 0;
  *(_QWORD *)&ObjectAttributes.Attributes = 576i64;
  DestinationString_8 = 0i64;
  memset(KeyValueInformation, 0i64, sizeof(KeyValueInformation));
  LODWORD(DestinationString) = 0;
  ValueName_8 = 0i64;
  RtlInitUnicodeString(&DestinationString_8, L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language");
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.ObjectName = &DestinationString_8;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  v1 = ZwOpenKey(&KeyHandle, 0x2001Fui64, &ObjectAttributes, v0, Length, (INT64)ResultLength, 0i64, DestinationString);
  if( v1 >= 0 )
  {
    RtlInitUnicodeString(&DestinationString_8, L"InstallLanguage");
    v2 = PsInstallUILanguageId;
    for( i = 3i64; i >= 0; --i )
    {
      v4 = 55;
      v5 = v2 & 0xF;
      if( v5 <= 9u )
        v4 = 48;
      v2 >>= 4;
      *((_WORD *)&Data + i) = v5 + v4;
    }
    LODWORD(Lengtha) = 528;
    if( ZwQueryValueKey(
           KeyHandle,
           &DestinationString_8,
           KeyValuePartialInformation,
           KeyValueInformation,
           Lengtha,
           (UINT64 *)&DestinationString) >= 0 )
    {
      RtlInitUnicodeString(&ValueName_8, L"PreviousInstallLanguage");
      LODWORD(ResultLengtha) = KeyValueInformation[1];
      ZwSetValueKey(KeyHandle, &ValueName_8, 0i64, 1ui64, (char *)&KeyValueInformation[1] + 4, (UINT64)ResultLengtha);
    }
    LODWORD(ResultLengtha) = 10;
    v1 = ZwSetValueKey(KeyHandle, &DestinationString_8, 0i64, 1ui64, &Data, (UINT64)ResultLengtha);
    if( v1 >= 0 )
      v1 = 0;
  }
  if( KeyHandle )
    ZwClose((_HANDLE)KeyHandle);
  return v1;
}

Referenced by:

NtFlushInstallUILanguage
NtGetMUIRegistryInfo