From 2f70849798eaf731bfe8076a942267f2b18b5b28 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sat, 14 Dec 2019 15:48:15 +0100 Subject: [PATCH] [XAM/User] Implemented XamUserGetGamerTag --- src/xenia/kernel/xam/xam_user.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/xenia/kernel/xam/xam_user.cc b/src/xenia/kernel/xam/xam_user.cc index bd018e79e..7b606a7e7 100644 --- a/src/xenia/kernel/xam/xam_user.cc +++ b/src/xenia/kernel/xam/xam_user.cc @@ -187,6 +187,28 @@ dword_result_t XamUserGetName(dword_t user_index, lpstring_t buffer, } DECLARE_XAM_EXPORT1(XamUserGetName, kUserProfiles, kImplemented); +dword_result_t XamUserGetGamerTag(dword_t user_index, lpwstring_t buffer, + dword_t buffer_len) { + if (user_index) { + return X_ERROR_NO_SUCH_USER; + } + + if (!buffer_len) { + return X_ERROR_SUCCESS; + } + + const auto& user_profile = kernel_state()->user_profile(); + const auto& user_name = xe::to_wstring(user_profile->name()); + + size_t copy_length = std::min({size_t(buffer_len * 2), user_name.size(), + static_cast(buffer_len * 2) - 1}); + + kernel_memory()->Fill(buffer, buffer_len * 2, 0x00); + xe::copy_and_swap(buffer, user_name.c_str(), copy_length); + return X_ERROR_SUCCESS; +} +DECLARE_XAM_EXPORT1(XamUserGetGamerTag, kUserProfiles, kImplemented); + typedef struct { xe::be setting_count; xe::be settings_ptr;