mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
sceNpTrophyRegisterContext: add read_only check
This commit is contained in:
parent
6c7f49d563
commit
1f745c4588
@ -36,7 +36,7 @@ struct trophy_context_t
|
||||
|
||||
std::string trp_name;
|
||||
std::unique_ptr<TROPUSRLoader> tropusr;
|
||||
bool read_only = false; // TODO
|
||||
bool read_only = false;
|
||||
};
|
||||
|
||||
struct trophy_handle_t
|
||||
@ -54,7 +54,7 @@ struct sce_np_trophy_manager
|
||||
atomic_t<bool> is_initialized = false;
|
||||
|
||||
// Get context + check handle given
|
||||
static std::pair<trophy_context_t*, SceNpTrophyError> get_context_ex(u32 context, u32 handle)
|
||||
static std::pair<trophy_context_t*, SceNpTrophyError> get_context_ex(u32 context, u32 handle, bool test_writeable = false)
|
||||
{
|
||||
decltype(get_context_ex(0, 0)) res{};
|
||||
auto& [ctxt, error] = res;
|
||||
@ -75,6 +75,12 @@ struct sce_np_trophy_manager
|
||||
return res;
|
||||
}
|
||||
|
||||
if (test_writeable && ctxt->read_only)
|
||||
{
|
||||
error = SCE_NP_TROPHY_ERROR_INVALID_CONTEXT;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (handle < trophy_handle_t::id_base ||
|
||||
handle >= trophy_handle_t::id_base + trophy_handle_t::id_count)
|
||||
{
|
||||
@ -440,7 +446,7 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle,
|
||||
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle);
|
||||
const auto [ctxt, error] = trophy_manager.get_context_ex(context, handle, true);
|
||||
const auto handle_ptr = idm::get<trophy_handle_t>(handle);
|
||||
|
||||
if (error)
|
||||
|
Loading…
x
Reference in New Issue
Block a user