[XAM] XamUserGetName: Prevent false-positive in MS defender
This commit is contained in:
parent
ceb94e019a
commit
3f0a7f171f
|
@ -145,19 +145,23 @@ dword_result_t XamUserGetName_entry(dword_t user_index, dword_t buffer,
|
||||||
return X_ERROR_INVALID_PARAMETER;
|
return X_ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* str_buffer = kernel_memory()->TranslateVirtual<char*>(buffer);
|
kernel_memory()->Zero(buffer, buffer_len);
|
||||||
|
|
||||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||||
*str_buffer = 0;
|
|
||||||
return X_ERROR_NO_SUCH_USER;
|
return X_ERROR_NO_SUCH_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& user_profile =
|
const auto& user_profile =
|
||||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||||
|
|
||||||
|
// Because name is always limited to 16 characters we can assume length will
|
||||||
|
// never exceed that limit.
|
||||||
const auto& user_name = user_profile->name();
|
const auto& user_name = user_profile->name();
|
||||||
xe::string_util::copy_truncating(str_buffer, user_name,
|
|
||||||
std::min(buffer_len.value(), uint32_t(16)));
|
char* str_buffer = kernel_memory()->TranslateVirtual<char*>(buffer);
|
||||||
|
xe::string_util::copy_truncating(
|
||||||
|
str_buffer, user_name,
|
||||||
|
std::min(buffer_len.value(), static_cast<uint32_t>(user_name.length())));
|
||||||
return X_ERROR_SUCCESS;
|
return X_ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
DECLARE_XAM_EXPORT1(XamUserGetName, kUserProfiles, kImplemented);
|
DECLARE_XAM_EXPORT1(XamUserGetName, kUserProfiles, kImplemented);
|
||||||
|
|
Loading…
Reference in New Issue