RtlpMuiRegAddAlternateCodePage

void __fastcall RtlpMuiRegAddAlternateCodePage(__int64 a1, void *a2, WCHAR a3){
  __int64 v5; 
  int v6; 
  int v7; 
  unsigned int v8; 
  wchar_t *PoolWithTag; 
  wchar_t *v10; 
  unsigned int v11; 
  unsigned int v12; 
  const wchar_t *v13; 
  _WORD *v14; 
  WCHAR v15; 
  __int64 v16; 
  _LARGE_INTEGER *v17; 
  _LARGE_INTEGER *v18; 
  UINT64 Value; 
  struct _UNICODE_STRING DestinationString; 
  UINT64 KeyValueLength; 
  UINT64 KeyValueType; 
  LODWORD(KeyValueType) = 7;
  v5 = 0i64;
  LODWORD(KeyValueLength) = 0;
  LODWORD(Value) = 0;
  DestinationString = 0i64;
  RtlInitUnicodeString(&DestinationString, L"AlternateCodePage", a3);
  v6 = LdrpQueryValueKey(a2, &DestinationString, &KeyValueType, 0i64, &KeyValueLength, v17);
  if( v6 != -1073741772 )
  {
    v7 = KeyValueLength;
    if( (_DWORD)KeyValueLength )
    {
      if( v6 == -2147483643 )
      {
        LODWORD(KeyValueLength) = KeyValueLength + 2;
        v8 = (v7 + 5) & 0xFFFFFFFC;
        if( v8 )
        {
          PoolWithTag = (wchar_t *)ExAllocatePoolWithTag(PagedPool, v8, 0x72746C6Dui64);
          v10 = PoolWithTag;
          if( PoolWithTag )
            memset((INT64)PoolWithTag, 0i64);
        }
        else
        {
          v10 = 0i64;
        }
        if( v10 )
        {
          if( !(unsigned int)LdrpQueryValueKey(a2, &DestinationString, &KeyValueType, v10, &KeyValueLength, v18)
            && ((_DWORD)KeyValueType == 1 || (_DWORD)KeyValueType == 7) )
          {
            v11 = 0;
            v12 = (unsigned int)KeyValueLength >> 1;
            v13 = v10;
            if( (unsigned int)KeyValueLength >> 1 )
            {
              v14 = (_WORD *)(a1 + 20);
              while( v13 && *v13 )
              {
                if( !wcsicmp(v13, L"*") )
                {
                  *(_WORD *)(a1 + 20) = -1;
                  break;
                }
                RtlInitUnicodeString(&DestinationString, v13, v15);
                if( RtlUnicodeStringToInteger(&DestinationString, 0xAui64, &Value)
                  || (++v5, *v14 = Value, ++v14, v5 < 4) )
                {
                  v16 = -1i64;
                  do
                    ++v16;
                  while( v13[v16] );
                  v11 += v16 + 1;
                  v13 += (unsigned int)(v16 + 1);
                  if( v11 < v12 )
                    continue;
                }
                break;
              }
            }
          }
          ExFreeHeapPool(v10);
        }
      }
    }
  }
}

Referenced by:

RtlpMuiRegAddLanguageByName