From bf98eaa98284f95c028af1405a47814d1d63b293 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Sat, 27 Jun 2026 17:03:55 +0300 Subject: [PATCH] username changes to onlineid once connected (#4633) --- src/core/libraries/system/userservice.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/libraries/system/userservice.cpp b/src/core/libraries/system/userservice.cpp index cc0053811..d7924797c 100644 --- a/src/core/libraries/system/userservice.cpp +++ b/src/core/libraries/system/userservice.cpp @@ -10,6 +10,7 @@ #include "common/singleton.h" #include "core/emulator_settings.h" #include "core/libraries/libs.h" +#include "core/libraries/np/np_handler.h" #include "core/libraries/np/np_manager.h" #include "core/libraries/system/userservice.h" #include "core/libraries/system/userservice_error.h" @@ -18,6 +19,8 @@ namespace Libraries::UserService { +static bool g_shadnet_enabled = false; + int PS4_SYSV_ABI sceUserServiceInitializeForShellCore() { LOG_ERROR(Lib_UserService, "(STUBBED) called"); return ORBIS_OK; @@ -1102,6 +1105,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetUserName(int user_id, char* user_name, std::si LOG_ERROR(Lib_UserService, "user_name is null"); return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT; } + std::string name = "shadPS4"; auto const* u = UserManagement.GetUserByID(user_id); if (u != nullptr) { @@ -1109,7 +1113,16 @@ s32 PS4_SYSV_ABI sceUserServiceGetUserName(int user_id, char* user_name, std::si } else { LOG_ERROR(Lib_UserService, "No user found"); } - if (size < name.length()) { + // once signed in shadnet onlineid is set as username + if (g_shadnet_enabled && Libraries::Np::NpHandler::GetInstance().IsPsnSignedIn(user_id)) { + const auto np_id = Libraries::Np::NpHandler::GetInstance().GetNpId(user_id); + const std::size_t handle_len = strnlen(np_id.handle.data, sizeof(np_id.handle.data)); + if (handle_len > 0) { + name.assign(np_id.handle.data, handle_len); + } + } + + if (size < name.length() + 1) { LOG_ERROR(Lib_UserService, "buffer is too short"); return ORBIS_USER_SERVICE_ERROR_BUFFER_TOO_SHORT; } @@ -2203,6 +2216,7 @@ int PS4_SYSV_ABI Func_D2B814603E7B4477() { } void RegisterLib(Core::Loader::SymbolsResolver* sym) { + g_shadnet_enabled = EmulatorSettings.IsShadNetEnabled(); LIB_FUNCTION("Psl9mfs3duM", "libSceUserServiceForShellCore", 1, "libSceUserService", sceUserServiceInitializeForShellCore); LIB_FUNCTION("CydP+QtA0KI", "libSceUserServiceForShellCore", 1, "libSceUserService",