mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
cellSysutilGetSystemParamString improvements
- Check bufsize, must match to max string length - Add missing cases for ParamId 0x1008, 0x1011, 0x1012, 0x1024 - Set actual current username in buffer on id == ID_CURRENT_USERNAME
This commit is contained in:
parent
2290c389d6
commit
b5f6b27f86
@ -292,22 +292,58 @@ error_code cellSysutilGetSystemParamString(CellSysutilParamId id, vm::ptr<char>
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -56,7 +56,7 @@ error_code cellUserInfoGetStat(u32 id, vm::ptr<CellUserInfoUserStat> 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user