Index: lib/sdk/crt/string/mbstowcs_nt.c =================================================================== --- lib/sdk/crt/string/mbstowcs_nt.c (revision 51002) +++ lib/sdk/crt/string/mbstowcs_nt.c (working copy) @@ -4,26 +4,29 @@ #include #include +WCHAR NTAPI RtlAnsiCharToUnicodeChar(IN OUT PUCHAR *AnsiChar); +#undef MB_CUR_MAX +#define MB_CUR_MAX 2 + /* * @implemented */ int mbtowc (wchar_t *wchar, const char *mbchar, size_t count) { - NTSTATUS Status; - ULONG Size; + UCHAR mbarr[MB_CUR_MAX] = { 0 }; + PUCHAR mbs = mbarr; + if (mbchar == NULL) + return 0; + if (wchar == NULL) return 0; - Status = RtlMultiByteToUnicodeN (wchar, - sizeof(WCHAR), - &Size, - mbchar, - count); - if (!NT_SUCCESS(Status)) - return -1; + memcpy(mbarr, mbchar, min(count, sizeof mbarr)); - return (int)Size; + *wchar = RtlAnsiCharToUnicodeChar(&mbs); + + return mbs - mbarr; } /*