From 30a6e03636d1c996a5bc7728823ed5ee0907ef12 Mon Sep 17 00:00:00 2001 From: Pacuka <69674426+Pacuka@users.noreply.github.com> Date: Tue, 6 Oct 2026 17:58:35 +0200 Subject: [PATCH] fix(trophy2): accept a null data or details in sceNpTrophy2GetGameInfo The Smurfs Dreams (Unreal Engine) asks only for the game details and passes a null data pointer; on success it reads the trophy count from the details, on a negative result it takes its error path. The function already fills each output only when it is given, but rejected the call unless both were. Only a call without either output is rejected now. Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libSceNpTrophy2/src/GameInfo.cpp | 2 +- core/libs/tests/GuestNpTrophy2.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libSceNpTrophy2/src/GameInfo.cpp b/core/libs/prx/libSceNpTrophy2/src/GameInfo.cpp index 6a41aa647..0c5b320f6 100644 --- a/core/libs/prx/libSceNpTrophy2/src/GameInfo.cpp +++ b/core/libs/prx/libSceNpTrophy2/src/GameInfo.cpp @@ -9,7 +9,7 @@ extern "C" { int APS5_VABI sceNpTrophy2GetGameInfo(int context, int handle, NpTrophy2GameDetails* details, NpTrophy2GameData* data) { - if (details == nullptr || data == nullptr) { + if (details == nullptr && data == nullptr) { APS5_INVALID_ARG_EX; } (void)context; diff --git a/core/libs/tests/GuestNpTrophy2.cpp b/core/libs/tests/GuestNpTrophy2.cpp index 5a286ab35..d52cc50ba 100644 --- a/core/libs/tests/GuestNpTrophy2.cpp +++ b/core/libs/tests/GuestNpTrophy2.cpp @@ -1,9 +1,12 @@ #include "prx/libc/include/general/VabiMacros.hpp" +#include "prx/libSceNpTrophy2/include/NpTrophy2Types.hpp" #include +#include extern "C" { int APS5_VABI sceNpTrophy2RegisterUnlockCallback(void*, void*); int APS5_VABI sceNpTrophy2UnregisterUnlockCallback(); +int APS5_VABI sceNpTrophy2GetGameInfo(int, int, NpTrophy2GameDetails*, NpTrophy2GameData*); } static void Require(bool value) { if (!value) std::abort(); } @@ -17,4 +20,17 @@ int main() { Require(sceNpTrophy2UnregisterUnlockCallback() == 0); Require(sceNpTrophy2RegisterUnlockCallback(reinterpret_cast(&OnUnlock), &userdata) == 0); Require(sceNpTrophy2UnregisterUnlockCallback() == 0); + + NpTrophy2GameDetails details{}; + NpTrophy2GameData data{}; + Require(sceNpTrophy2GetGameInfo(1, 1, &details, nullptr) == 0); + Require(details.num_trophies != 0); + Require(sceNpTrophy2GetGameInfo(1, 1, nullptr, &data) == 0); + bool threw = false; + try { + sceNpTrophy2GetGameInfo(1, 1, nullptr, nullptr); + } catch (const std::invalid_argument&) { + threw = true; + } + Require(threw); }