From 4f50e0e6c7fa9443291bf08a23f127a688edce01 Mon Sep 17 00:00:00 2001 From: gibbed Date: Mon, 19 Nov 2018 20:43:04 -0600 Subject: [PATCH] [Kernel] Implement RtlCopyString, RtlCopyUnicodeString. --- src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc index 7ac9cd05c..86852889b 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_rtl.cc @@ -186,6 +186,40 @@ void RtlFreeUnicodeString(pointer_t string) { } DECLARE_XBOXKRNL_EXPORT(RtlFreeUnicodeString, ExportTag::kImplemented); +void RtlCopyString(pointer_t destination, + pointer_t source) { + if (!source) { + destination->length = 0; + return; + } + + auto length = std::min(destination->maximum_length, source->length); + if (length > 0) { + auto dst_buf = kernel_memory()->TranslateVirtual(destination->pointer); + auto src_buf = kernel_memory()->TranslateVirtual(source->pointer); + std::memcpy(dst_buf, src_buf, length); + } + destination->length = length; +} +DECLARE_XBOXKRNL_EXPORT(RtlCopyString, ExportTag::kImplemented); + +void RtlCopyUnicodeString(pointer_t destination, + pointer_t source) { + if (!source) { + destination->length = 0; + return; + } + + auto length = std::min(destination->maximum_length, source->length); + if (length > 0) { + auto dst_buf = kernel_memory()->TranslateVirtual(destination->pointer); + auto src_buf = kernel_memory()->TranslateVirtual(source->pointer); + std::memcpy(dst_buf, src_buf, length * 2); + } + destination->length = length; +} +DECLARE_XBOXKRNL_EXPORT(RtlCopyUnicodeString, ExportTag::kImplemented); + // http://msdn.microsoft.com/en-us/library/ff562969 dword_result_t RtlUnicodeStringToAnsiString( pointer_t destination_ptr,