RtlCustomCPToUnicodeN

NTSTATUS __stdcall RtlCustomCPToUnicodeN(
        PCPTABLEINFO CustomCP,
        WCHAR *UnicodeString,
        UINT64 MaxBytesInUnicodeString,
        PULONG BytesInUnicodeString,
        PCH CustomCPString,
        UINT64 BytesInCustomCPString){
  NTSTATUS v6; 
  unsigned int v7; 
  WCHAR *v8; 
  UINT64 *v10; 
  NTSTATUS v11; 
  unsigned int v13; 
  unsigned int v14; 
  unsigned int v15; 
  PUSHORT MultiByteTable; 
  PCH v17; 
  __int64 v18; 
  __int64 v19; 
  PUSHORT DBCSOffsets; 
  int v21; 
  PCH v22; 
  __int64 v23; 
  __int64 v24; 
  UINT64 UTF8StringByteCount; 
  char v26; 

  v6 = 0;
  v7 = MaxBytesInUnicodeString;
  v8 = UnicodeString;
  if( CustomCP->CodePage == 0xFDE9 )
  {
    v10 = (UINT64 *)&v26;
    if( BytesInUnicodeString )
      v10 = (UINT64 *)BytesInUnicodeString;
    if( (_DWORD)BytesInCustomCPString )
    {
      LODWORD(UTF8StringByteCount) = BytesInCustomCPString;
      v11 = RtlUTF8ToUnicodeN(UnicodeString, v7, v10, CustomCPString, UTF8StringByteCount);
    }
    else
    {
      *(_DWORD *)v10 = 0;
      v11 = 0;
    }
    if( v11 == -1073741789 )
      return -2147483643;
    return v6;
  }
  else
  {
    v13 = BytesInCustomCPString;
    v14 = v7 >> 1;
    if( CustomCP->DBCSCodePage )
    {
      DBCSOffsets = CustomCP->DBCSOffsets;
      v21 = (int)v8;
      if( v14 )
      {
        v22 = CustomCPString;
        while( v13 )
        {
          v23 = (unsigned __int8)*v22;
          --v14;
          --v13;
          v24 = DBCSOffsets[v23];
          if( (_WORD)v24 )
          {
            if( !v13 )
            {
              *v8 = 0;
              LODWORD(v8) = (_DWORD)v8 + 2;
              break;
            }
            ++v22;
            --v13;
            *v8 = DBCSOffsets[v24 + (unsigned __int8)*v22];
          }
          else
          {
            *v8 = CustomCP->MultiByteTable[v23];
          }
          ++v8;
          ++v22;
          if( !v14 )
            break;
        }
      }
      if( BytesInUnicodeString )
        *BytesInUnicodeString = (_DWORD)v8 - v21;
    }
    else
    {
      v15 = BytesInCustomCPString;
      if( v14 < (unsigned int)BytesInCustomCPString )
        v15 = v14;
      if( BytesInUnicodeString )
        *BytesInUnicodeString = 2 * v15;
      MultiByteTable = CustomCP->MultiByteTable;
      if( v15 )
      {
        v17 = CustomCPString;
        v18 = v15;
        do
        {
          v19 = (unsigned __int8)*v17++;
          *v8++ = MultiByteTable[v19];
          --v18;
        }
        while( v18 );
      }
    }
    return v14 < v13 ? 0x80000005 : 0;
  }
}

Referenced by:

No references.