From 97958bdd07d0d65dcf3e1670390e62a4d36a074f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Thu, 1 Oct 2026 19:49:12 +0200 Subject: [PATCH 1/2] fix(libScePlayGo): use the library's error codes for bad pointer, handle and size BAD_POINTER, BAD_HANDLE and BAD_SIZE were 0x80B20004, 0x80B20005 and 0x80B2000D, which are INVALID_ARGUMENT, NOT_INITIALIZED and BAD_SPEED. They are 0x80B2000A, 0x80B20009 and 0x80B2000B. Co-Authored-By: Claude --- core/libs/prx/libScePlayGo/Export.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/libs/prx/libScePlayGo/Export.cpp b/core/libs/prx/libScePlayGo/Export.cpp index f9b308cba..de1ca05a6 100644 --- a/core/libs/prx/libScePlayGo/Export.cpp +++ b/core/libs/prx/libScePlayGo/Export.cpp @@ -9,8 +9,8 @@ #include // The game is fully installed on the host, so every chunk is local and nothing is pending. -static constexpr int SCE_PLAYGO_ERROR_BAD_POINTER = static_cast(0x80B20004); -static constexpr int SCE_PLAYGO_ERROR_BAD_HANDLE = static_cast(0x80B20005); +static constexpr int SCE_PLAYGO_ERROR_BAD_POINTER = static_cast(0x80B2000A); +static constexpr int SCE_PLAYGO_ERROR_BAD_HANDLE = static_cast(0x80B20009); static constexpr int PLAYGO_HANDLE = 1; static constexpr int8_t PLAYGO_LOCUS_LOCAL_FAST = 3; static constexpr int32_t PLAYGO_INSTALL_SPEED_FULL = 2; @@ -18,7 +18,7 @@ static constexpr int32_t PLAYGO_INSTALL_SPEED_FULL = 2; static int32_t g_installSpeed = PLAYGO_INSTALL_SPEED_FULL; static constexpr int SCE_PLAYGO_ERROR_BAD_CHUNK_ID = static_cast(0x80B2000C); -static constexpr int SCE_PLAYGO_ERROR_BAD_SIZE = static_cast(0x80B2000D); +static constexpr int SCE_PLAYGO_ERROR_BAD_SIZE = static_cast(0x80B2000B); // The package's chunk table is not part of the dump, so the chunk set comes from the title's // playgo-chunkdefs.xml: every listed chunk plus chunks 0 through the default chunk. Games probe From 2b36dc2408e955799233c243a95e35475b1f39dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Thu, 1 Oct 2026 19:50:33 +0200 Subject: [PATCH 2/2] feat(libScePlayGo): implement the language mask and to-do list The title is fully installed, so scePlayGoGetLanguageMask reports every language. scePlayGoSetToDoList validates the handle, entries, chunk IDs and loci; nothing is pending, so the list is not kept. Co-Authored-By: Claude --- core/libs/prx/libScePlayGo/CMakeLists.txt | 21 +++++++++ core/libs/prx/libScePlayGo/Export.cpp | 27 +++++++---- core/libs/tests/GuestPlayGo.cpp | 55 +++++++++++++++++++++++ 3 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 core/libs/prx/libScePlayGo/CMakeLists.txt create mode 100644 core/libs/tests/GuestPlayGo.cpp diff --git a/core/libs/prx/libScePlayGo/CMakeLists.txt b/core/libs/prx/libScePlayGo/CMakeLists.txt new file mode 100644 index 000000000..9c34dab0b --- /dev/null +++ b/core/libs/prx/libScePlayGo/CMakeLists.txt @@ -0,0 +1,21 @@ +add_library(libScePlayGo SHARED EXCLUDE_FROM_ALL Export.cpp) +target_include_directories(libScePlayGo PRIVATE ${LIBS_INCLUDE_DIR}) +configure_windows_unwind(libScePlayGo) + +if(MINGW) + foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static) + string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + endforeach() +endif() + +if(BUILD_TESTING) + add_test_executable(guest_playgo_tests ${LIBS_INCLUDE_DIR}/tests/GuestPlayGo.cpp) + target_include_directories(guest_playgo_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_playgo_tests PRIVATE libScePlayGo libc) + configure_windows_unwind(guest_playgo_tests) + add_test(NAME guest_playgo COMMAND guest_playgo_tests) + if(WIN32) + set_tests_properties(guest_playgo PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() +endif() diff --git a/core/libs/prx/libScePlayGo/Export.cpp b/core/libs/prx/libScePlayGo/Export.cpp index de1ca05a6..58d081c3d 100644 --- a/core/libs/prx/libScePlayGo/Export.cpp +++ b/core/libs/prx/libScePlayGo/Export.cpp @@ -12,13 +12,17 @@ static constexpr int SCE_PLAYGO_ERROR_BAD_POINTER = static_cast(0x80B2000A); static constexpr int SCE_PLAYGO_ERROR_BAD_HANDLE = static_cast(0x80B20009); static constexpr int PLAYGO_HANDLE = 1; +static constexpr int8_t PLAYGO_LOCUS_NOT_DOWNLOADED = 0; +static constexpr int8_t PLAYGO_LOCUS_LOCAL_SLOW = 2; static constexpr int8_t PLAYGO_LOCUS_LOCAL_FAST = 3; +static constexpr uint64_t PLAYGO_LANGUAGE_MASK_ALL = ~0ull; static constexpr int32_t PLAYGO_INSTALL_SPEED_FULL = 2; static int32_t g_installSpeed = PLAYGO_INSTALL_SPEED_FULL; static constexpr int SCE_PLAYGO_ERROR_BAD_CHUNK_ID = static_cast(0x80B2000C); static constexpr int SCE_PLAYGO_ERROR_BAD_SIZE = static_cast(0x80B2000B); +static constexpr int SCE_PLAYGO_ERROR_BAD_LOCUS = static_cast(0x80B20010); // The package's chunk table is not part of the dump, so the chunk set comes from the title's // playgo-chunkdefs.xml: every listed chunk plus chunks 0 through the default chunk. Games probe @@ -96,10 +100,10 @@ int APS5_VABI scePlayGoGetInstallSpeed(int handle, int32_t* out_speed) { } int APS5_VABI scePlayGoGetLanguageMask(int handle, uint64_t* out_language_mask) { - (void)handle; - (void)out_language_mask; - NotImplemented_nid_no_patch(__func__); - return 0; + if (handle != PLAYGO_HANDLE) return SCE_PLAYGO_ERROR_BAD_HANDLE; + if (!out_language_mask) return SCE_PLAYGO_ERROR_BAD_POINTER; + *out_language_mask = PLAYGO_LANGUAGE_MASK_ALL; + return 0; } int APS5_VABI scePlayGoGetLocus(int handle, const uint16_t* chunk_ids, uint32_t number_of_entries, int8_t* out_loci) { @@ -176,11 +180,16 @@ int APS5_VABI scePlayGoSetInstallSpeed(int handle, int32_t speed) { } int APS5_VABI scePlayGoSetToDoList(int handle, const PlayGoToDo* todo_list, uint32_t number_of_entries) { - (void)handle; - (void)todo_list; - (void)number_of_entries; - NotImplemented_nid_no_patch(__func__); - return 0; + if (handle != PLAYGO_HANDLE) return SCE_PLAYGO_ERROR_BAD_HANDLE; + if (!todo_list) return SCE_PLAYGO_ERROR_BAD_POINTER; + if (number_of_entries == 0) return SCE_PLAYGO_ERROR_BAD_SIZE; + const auto& valid = ValidChunks(); + for (uint32_t index = 0; index < number_of_entries; ++index) { + if (!valid.contains(todo_list[index].chunk_id)) return SCE_PLAYGO_ERROR_BAD_CHUNK_ID; + const int8_t locus = todo_list[index].locus; + if (locus != PLAYGO_LOCUS_NOT_DOWNLOADED && locus != PLAYGO_LOCUS_LOCAL_SLOW && locus != PLAYGO_LOCUS_LOCAL_FAST) return SCE_PLAYGO_ERROR_BAD_LOCUS; + } + return 0; } int APS5_VABI scePlayGoTerminate(void) { diff --git a/core/libs/tests/GuestPlayGo.cpp b/core/libs/tests/GuestPlayGo.cpp new file mode 100644 index 000000000..84ee10f08 --- /dev/null +++ b/core/libs/tests/GuestPlayGo.cpp @@ -0,0 +1,55 @@ +#include "SceTypes.hpp" +#include "prx/libc/include/general/VabiMacros.hpp" +#include +#include + +extern "C" { +int APS5_VABI scePlayGoInitialize(const PlayGoInitParams*); +int APS5_VABI scePlayGoOpen(int*, const void*); +int APS5_VABI scePlayGoClose(int); +int APS5_VABI scePlayGoGetLanguageMask(int, std::uint64_t*); +int APS5_VABI scePlayGoSetToDoList(int, const PlayGoToDo*, std::uint32_t); +int APS5_VABI scePlayGoGetToDoList(int, PlayGoToDo*, std::uint32_t, std::uint32_t*); +int APS5_VABI scePlayGoGetLocus(int, const std::uint16_t*, std::uint32_t, std::int8_t*); +} + +static void Require(bool value) { if (!value) std::abort(); } + +int main() { + constexpr int badHandle = static_cast(0x80B20009); + constexpr int badPointer = static_cast(0x80B2000A); + constexpr int badSize = static_cast(0x80B2000B); + constexpr int badChunkId = static_cast(0x80B2000C); + constexpr int badLocus = static_cast(0x80B20010); + + PlayGoInitParams init{}; + int handle = 0; + Require(scePlayGoInitialize(nullptr) == badPointer); + Require(scePlayGoInitialize(&init) == 0); + Require(scePlayGoOpen(nullptr, nullptr) == badPointer); + Require(scePlayGoOpen(&handle, nullptr) == 0); + + std::uint64_t mask = 0; + Require(scePlayGoGetLanguageMask(handle + 1, &mask) == badHandle); + Require(scePlayGoGetLanguageMask(handle, nullptr) == badPointer); + Require(scePlayGoGetLanguageMask(handle, &mask) == 0 && mask == ~0ull); + + PlayGoToDo todo[2] = {{0, 3, 0}, {0, 0, 0}}; + Require(scePlayGoSetToDoList(handle + 1, todo, 2) == badHandle); + Require(scePlayGoSetToDoList(handle, nullptr, 2) == badPointer); + Require(scePlayGoSetToDoList(handle, todo, 0) == badSize); + Require(scePlayGoSetToDoList(handle, todo, 2) == 0); + todo[1].locus = 1; + Require(scePlayGoSetToDoList(handle, todo, 2) == badLocus); + todo[1] = {0xFFFF, 3, 0}; + Require(scePlayGoSetToDoList(handle, todo, 2) == badChunkId); + + std::uint32_t entries = 1; + Require(scePlayGoGetToDoList(handle, todo, 2, &entries) == 0 && entries == 0); + const std::uint16_t chunk = 0; + std::int8_t locus = 0; + Require(scePlayGoGetLocus(handle, &chunk, 0, &locus) == badSize); + Require(scePlayGoGetLocus(handle, &chunk, 1, &locus) == 0 && locus == 3); + Require(scePlayGoClose(handle + 1) == badHandle); + Require(scePlayGoClose(handle) == 0); +}