RtlUTF8StringToUnicodeString
NTSTATUS __fastcall RtlUTF8StringToUnicodeString(INT16 *a1, UINT16 *a2, CHAR a3){
UINT64 v6;
CHAR *v7;
NTSTATUS result;
UINT64 v9;
unsigned __int16 v10;
VOID *StringRoutine;
unsigned __int64 v12;
ULONG v13;
NTSTATUS v14;
UINT64 UTF8StringByteCount;
SIZE_T NumberOfBytes;
UINT64 UnicodeStringActualByteCount;
v6 = (unsigned int)*a2 + 1;
LODWORD(NumberOfBytes) = 0;
v7 = (CHAR *)*((_QWORD *)a2 + 1);
LODWORD(UnicodeStringActualByteCount) = 0;
result = CountUTF8ToUnicode(v7, v6, &NumberOfBytes);
if( result >= 0 )
{
v9 = (unsigned int)NumberOfBytes;
if( (unsigned int)NumberOfBytes > 0xFFFE )
return -1073741584;
v10 = NumberOfBytes - 2;
*a1 = NumberOfBytes - 2;
if( a3 )
{
a1[1] = v9;
StringRoutine = ExpAllocateStringRoutine(v9);
*((_QWORD *)a1 + 1) = StringRoutine;
if( !StringRoutine )
return -1073741801;
v10 = *a1;
}
else
{
v12 = v10 + 2i64;
if( v12 > (unsigned __int16)a1[1] || v12 < 2 )
return -2147483643;
}
LODWORD(UTF8StringByteCount) = *a2;
v14 = RtlUTF8ToUnicodeN(
*((WCHAR **)a1 + 1),
v10,
&UnicodeStringActualByteCount,
*((const CHAR **)a2 + 1),
UTF8StringByteCount);
if( v14 < 0 )
{
if( a3 )
{
ExFreePoolWithTag(*((PVOID *)a1 + 1), v13);
*((_QWORD *)a1 + 1) = 0i64;
}
}
else
{
v14 = 0;
*(_WORD *)(*((_QWORD *)a1 + 1) + 2 * ((unsigned __int64)(unsigned int)UnicodeStringActualByteCount >> 1)) = 0;
}
return v14;
}
return result;
}Referenced by:
PiGetDefaultMessageString