From b09d3ca69a7a9c8e31ec8626c42cdb4f150bcc7d Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sun, 17 Dec 2023 11:41:12 -0600 Subject: [PATCH] kernel: update RtlAnsiStringToUnicodeString to include error log returns --- src/core/kernel/exports/EmuKrnlRtl.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/kernel/exports/EmuKrnlRtl.cpp b/src/core/kernel/exports/EmuKrnlRtl.cpp index 671cca6d5..eced8f70a 100644 --- a/src/core/kernel/exports/EmuKrnlRtl.cpp +++ b/src/core/kernel/exports/EmuKrnlRtl.cpp @@ -108,23 +108,28 @@ XBSYSAPI EXPORTNUM(260) xbox::ntstatus_xt NTAPI xbox::RtlAnsiStringToUnicodeStri dword_xt total = RtlAnsiStringToUnicodeSize(SourceString); if (total > 0xffff) { - return X_STATUS_INVALID_PARAMETER_2; + RETURN(X_STATUS_INVALID_PARAMETER_2); } DestinationString->Length = (USHORT)(total - sizeof(WCHAR)); if (AllocateDestinationString) { DestinationString->MaximumLength = (USHORT)total; if (!(DestinationString->Buffer = (USHORT*)ExAllocatePoolWithTag(total, 'grtS'))) { - return X_STATUS_NO_MEMORY; + RETURN(X_STATUS_NO_MEMORY); } } else { if (total > DestinationString->MaximumLength) { - return X_STATUS_BUFFER_OVERFLOW; + RETURN(X_STATUS_BUFFER_OVERFLOW); } } - RtlMultiByteToUnicodeN((PWSTR)DestinationString->Buffer, (ULONG)DestinationString->Length, NULL, SourceString->Buffer, SourceString->Length); + RtlMultiByteToUnicodeN((PWSTR)DestinationString->Buffer, + (ULONG)DestinationString->Length, + NULL, + SourceString->Buffer, + SourceString->Length); + DestinationString->Buffer[DestinationString->Length / sizeof(WCHAR)] = 0; RETURN(X_STATUS_SUCCESS);