diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index 81627077c0..235268dd48 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -36,7 +36,7 @@ struct trophy_context_t std::string trp_name; std::unique_ptr 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 is_initialized = false; // Get context + check handle given - static std::pair get_context_ex(u32 context, u32 handle) + static std::pair 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(handle); if (error)