Merge remote-tracking branch 'upstream/master' into canary

This commit is contained in:
illusion98 2019-09-13 03:11:03 -05:00
commit cf6cc7a108
1 changed files with 12 additions and 1 deletions

View File

@ -168,8 +168,19 @@ dword_result_t XamUserGetName(dword_t user_index, lpstring_t buffer,
if (user_index) {
return X_ERROR_NO_SUCH_USER;
}
if (!buffer_len) {
return X_ERROR_SUCCESS;
}
const auto& user_profile = kernel_state()->user_profile();
std::strncpy(buffer, user_profile->name().data(), buffer_len);
const auto& user_name = user_profile->name();
// Real XAM will only copy a maximum of 15 characters out.
size_t copy_length = std::min(
{size_t(15), user_name.size(), static_cast<size_t>(buffer_len) - 1});
std::memcpy(buffer, user_name.data(), copy_length);
buffer[copy_length] = '\0';
return X_ERROR_SUCCESS;
}
DECLARE_XAM_EXPORT1(XamUserGetName, kUserProfiles, kImplemented);