RtlpMuiRegGetInstalledLanguageIndex

NTSTATUS __stdcall RtlpMuiRegGetInstalledLanguageIndex(
        _MUIREGISTRYINFO *RegInfo,
        UINT64 LangType,
        INT16 LangSpec,
        INT16 *ResultIndexRtrn){
  NTSTATUS v4; 
  __int64 v5; 
  UINT8 v8; 
  __int64 v9; 
  int v10; 
  __int64 v11; 
  __int64 v12; 
  __int64 v13; 
  const wchar_t *v14; 
  _UNICODE_STRING DestinationString; 
  UINT64 Lcid; 

  v4 = 0;
  v5 = LangSpec;
  LODWORD(Lcid) = 0;
  v8 = 1;
  DestinationString = 0i64;
  if( !RegInfo )
    return -1073741811;
  v9 = *((_QWORD *)RegInfo + 3);
  if( (_DWORD)LangType == 3 )
  {
    v10 = 0;
    if( *(_WORD *)(v9 + 6) )
    {
      v11 = *(_QWORD *)(v9 + 16);
      while( 1 )
      {
        v12 = 28i64 * v10;
        if( (*(_WORD *)(v12 + v11) & 0x1020) == 32 && *(_WORD *)(v12 + v11 + 6) == (_WORD)v5 && ResultIndexRtrn )
          break;
        if( ++v10 >= *(unsigned __int16 *)(v9 + 6) )
          goto LABEL_10;
      }
      *ResultIndexRtrn = v10;
      return v4;
    }
LABEL_10:
    v13 = *((_QWORD *)RegInfo + 4);
    if( v13 && (v5 & 0x8000u) == 0i64 && (int)v5 < *(unsigned __int16 *)(v13 + 6) )
      v14 = (const wchar_t *)(*(_QWORD *)(v13 + 24) + 2i64 * *(__int16 *)(*(_QWORD *)(v13 + 16) + 2 * v5));
    else
      v14 = 0i64;
    if( !v14 )
      return -1073741772;
    RtlInitUnicodeString(&DestinationString, v14);
    if( !RtlCultureNameToLCID(&DestinationString, &Lcid) )
      return -1073741772;
    LOWORD(v5) = Lcid;
    LODWORD(LangType) = 1;
    v8 = 0;
  }
  if( (_DWORD)LangType == 1 )
    return RtlpMuiRegGetInstalledLanguageIndexByLangId(RegInfo, v5, v8, ResultIndexRtrn);
  if( (_DWORD)LangType != 2 )
    return -1073741772;
  if( (__int16)v5 <= 0 || (__int16)v5 >= (int)*(unsigned __int16 *)(v9 + 6) )
    return -1073741811;
  if( ResultIndexRtrn )
    *ResultIndexRtrn = v5;
  return v4;
}

Referenced by:

RtlpLoadPolicyLanguageSpec
RtlpMuiRegConfigMatchesInstalled
RtlpMuiRegValidateConfigNode