RtlpMuiRegAddAlternateCodePage

VOID __stdcall RtlpMuiRegAddAlternateCodePage(_MUILANGINFO *LangInfo, VOID *LangKeyHandle){
  __int64 v4; 
  NTSTATUS v5; 
  int v6; 
  unsigned int v7; 
  size_t v8; 
  VOID **PoolWithTag; 
  VOID **v10; 
  unsigned int v11; 
  unsigned int v12; 
  const wchar_t *v13; 
  __int16 *AlternateCodePage; 
  __int64 v15; 
  UINT64 Value; 
  _UNICODE_STRING DestinationString; 
  UINT64 KeyValueLength; 
  UINT64 KeyValueType; 

  LODWORD(KeyValueType) = 7;
  v4 = 0i64;
  LODWORD(KeyValueLength) = 0;
  LODWORD(Value) = 0;
  DestinationString = 0i64;
  RtlInitUnicodeString(&DestinationString, L"AlternateCodePage");
  v5 = LdrpQueryValueKey(LangKeyHandle, &DestinationString, &KeyValueType, 0i64, &KeyValueLength);
  if( v5 != -1073741772 )
  {
    v6 = KeyValueLength;
    if( (_DWORD)KeyValueLength )
    {
      if( v5 == -2147483643 )
      {
        LODWORD(KeyValueLength) = KeyValueLength + 2;
        v7 = (v6 + 5) & 0xFFFFFFFC;
        if( v7 )
        {
          v8 = v7;
          PoolWithTag = ExAllocatePoolWithTag(1ui64, v7, 1920232557i64);
          v10 = PoolWithTag;
          if( PoolWithTag )
            memset(PoolWithTag, 0i64, v8);
        }
        else
        {
          v10 = 0i64;
        }
        if( v10 )
        {
          if( !LdrpQueryValueKey(LangKeyHandle, &DestinationString, &KeyValueType, v10, &KeyValueLength)
            && ((_DWORD)KeyValueType == 1 || (_DWORD)KeyValueType == 7) )
          {
            v11 = 0;
            v12 = (unsigned int)KeyValueLength >> 1;
            v13 = (const wchar_t *)v10;
            if( (unsigned int)KeyValueLength >> 1 )
            {
              AlternateCodePage = LangInfo->AlternateCodePage;
              while( v13 && *v13 )
              {
                if( !wcsicmp(v13, L"*") )
                {
                  LangInfo->AlternateCodePage[0] = -1;
                  break;
                }
                RtlInitUnicodeString(&DestinationString, v13);
                if( RtlUnicodeStringToInteger(&DestinationString, 0xAui64, &Value)
                  || (++v4, *AlternateCodePage = Value, ++AlternateCodePage, v4 < 4) )
                {
                  v15 = -1i64;
                  do
                    ++v15;
                  while( v13[v15] );
                  v11 += v15 + 1;
                  v13 += (unsigned int)(v15 + 1);
                  if( v11 < v12 )
                    continue;
                }
                break;
              }
            }
          }
          ExFreeHeapPool(v10);
        }
      }
    }
  }
}

Referenced by:

RtlpMuiRegAddLanguageByName