diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp index 411e0478f7..2ed5328bdd 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp @@ -292,22 +292,58 @@ error_code cellSysutilGetSystemParamString(CellSysutilParamId id, vm::ptr return CELL_SYSUTIL_ERROR_VALUE; } - memset(buf.get_ptr(), 0, bufsize); + u32 copy_size; + std::string param_str = "Unknown"; + bool report_use = false; switch (id) { case CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME: - memcpy(buf.get_ptr(), "Unknown", 8); // for example - break; - - case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME: - memcpy(buf.get_ptr(), "Unknown", 8); - break; - - default: - return CELL_SYSUTIL_ERROR_VALUE; + { + copy_size = CELL_SYSUTIL_SYSTEMPARAM_NICKNAME_SIZE; + break; } + case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME: + { + const fs::file username(vfs::get(fmt::format("/dev_hdd0/home/%08u/localusername", Emu.GetUsrId()))); + + if (!username) + { + cellSysutil.error("cellSysutilGetSystemParamString(): Username for user %08u doesn't exist. Did you delete the username file?", Emu.GetUsrId()); + } + else + { + // Read current username + param_str = username.to_string(); + } + + copy_size = CELL_SYSUTIL_SYSTEMPARAM_CURRENT_USERNAME_SIZE; + break; + } + + case CELL_SYSUTIL_SYSTEMPARAM_ID_x1011: // Same as x1012 + case CELL_SYSUTIL_SYSTEMPARAM_ID_x1012: copy_size = 0x400; report_use = true; break; + case CELL_SYSUTIL_SYSTEMPARAM_ID_x1024: copy_size = 0x100; report_use = true; break; + case CELL_SYSUTIL_SYSTEMPARAM_ID_x1008: copy_size = 0x4; report_use = true; break; + default: + { + return CELL_SYSUTIL_ERROR_VALUE; + } + } + + if (bufsize != copy_size) + { + return CELL_SYSUTIL_ERROR_SIZE; + } + + if (report_use) + { + cellSysutil.error("cellSysutilGetSystemParamString: Unknown ParamId 0x%x", id); + } + + std::strncpy(buf.get_ptr(), param_str.c_str(), copy_size - 1); + buf[copy_size - 1] = '\0'; return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.h b/rpcs3/Emu/Cell/Modules/cellSysutil.h index fe5ff892e7..0caba70e78 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.h +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.h @@ -39,6 +39,11 @@ enum CellSysutilParamId: s32 // Strings CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME = 0x0113, CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME = 0x0131, + // Unknown strings + CELL_SYSUTIL_SYSTEMPARAM_ID_x1008 = 0x1008, + CELL_SYSUTIL_SYSTEMPARAM_ID_x1011 = 0x1011, + CELL_SYSUTIL_SYSTEMPARAM_ID_x1012 = 0x1012, // Equal meaning to x1011 + CELL_SYSUTIL_SYSTEMPARAM_ID_x1024 = 0x1024, }; enum CellSysutilLang : s32 @@ -65,6 +70,12 @@ enum CellSysutilLang : s32 CELL_SYSUTIL_LANG_TURKISH = 19, // FW 4.30 }; +enum +{ + CELL_SYSUTIL_SYSTEMPARAM_NICKNAME_SIZE = 0x80, + CELL_SYSUTIL_SYSTEMPARAM_CURRENT_USERNAME_SIZE = 0x40 +}; + enum { CELL_SYSUTIL_REQUEST_EXITGAME = 0x0101, diff --git a/rpcs3/Emu/Cell/Modules/cellUserInfo.cpp b/rpcs3/Emu/Cell/Modules/cellUserInfo.cpp index 0e2e367373..e34c5fe7d1 100644 --- a/rpcs3/Emu/Cell/Modules/cellUserInfo.cpp +++ b/rpcs3/Emu/Cell/Modules/cellUserInfo.cpp @@ -56,7 +56,7 @@ error_code cellUserInfoGetStat(u32 id, vm::ptr stat) if (!f) { - cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_INTERNAL. Username for user %d doesn't exist. Did you delete the username file?", id); + cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_INTERNAL. Username for user %08u doesn't exist. Did you delete the username file?", id); return CELL_USERINFO_ERROR_INTERNAL; }