From 09c985464c11a96492c99d569759ea031ddc53c0 Mon Sep 17 00:00:00 2001 From: Mouad-Scriptz-0 Date: Mon, 12 Oct 2026 01:30:29 +0000 Subject: [PATCH] feat(libSceNpAuth): return the signed-out error from sceNpAuthGetAuthorizedAppCode There is no PSN sign-in, so the code getter answers SCE_NP_ERROR_SIGNED_OUT instead of throwing; its parameters are unknown and not read. Minecraft (PPSA17221) calls it after its sign-in dialog and treats the result as offline play. The request, token and wait calls are left to #3604. Co-Authored-By: Claude Fable 5.1 --- core/libs/prx/libSceNpAuth/CMakeLists.txt | 14 ++++++++++++++ core/libs/prx/libSceNpAuth/Export.cpp | 3 +-- core/libs/tests/GuestNpAuthAuthorizedAppCode.cpp | 13 +++++++++++++ docs/dev/debt/libSceNpAuth.md | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 core/libs/prx/libSceNpAuth/CMakeLists.txt create mode 100644 core/libs/tests/GuestNpAuthAuthorizedAppCode.cpp diff --git a/core/libs/prx/libSceNpAuth/CMakeLists.txt b/core/libs/prx/libSceNpAuth/CMakeLists.txt new file mode 100644 index 000000000..ce6ce6a2f --- /dev/null +++ b/core/libs/prx/libSceNpAuth/CMakeLists.txt @@ -0,0 +1,14 @@ +add_library(libSceNpAuth SHARED EXCLUDE_FROM_ALL Export.cpp) +target_include_directories(libSceNpAuth PRIVATE ${LIBS_INCLUDE_DIR}) +configure_windows_unwind(libSceNpAuth) + +if(BUILD_TESTING) + add_test_executable(guest_np_auth_authorized_app_code_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpAuthAuthorizedAppCode.cpp) + target_include_directories(guest_np_auth_authorized_app_code_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_np_auth_authorized_app_code_tests PRIVATE libSceNpAuth) + add_test(NAME guest_np_auth_authorized_app_code COMMAND guest_np_auth_authorized_app_code_tests) + if(WIN32) + set_tests_properties(guest_np_auth_authorized_app_code PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() +endif() diff --git a/core/libs/prx/libSceNpAuth/Export.cpp b/core/libs/prx/libSceNpAuth/Export.cpp index 0cc41fcd2..21e28519a 100644 --- a/core/libs/prx/libSceNpAuth/Export.cpp +++ b/core/libs/prx/libSceNpAuth/Export.cpp @@ -61,8 +61,7 @@ int APS5_VABI sceNpAuthDeleteRequest(int req_id) { } int APS5_VABI sceNpAuthGetAuthorizedAppCode() { - NotImplemented_nid_no_patch(__func__); - return 0; + return SCE_NP_ERROR_SIGNED_OUT; } int APS5_VABI sceNpAuthGetAuthorizationCodeV3(int req_id, const void* param, void* auth_code, int* issuer_id) { diff --git a/core/libs/tests/GuestNpAuthAuthorizedAppCode.cpp b/core/libs/tests/GuestNpAuthAuthorizedAppCode.cpp new file mode 100644 index 000000000..f6dfce0de --- /dev/null +++ b/core/libs/tests/GuestNpAuthAuthorizedAppCode.cpp @@ -0,0 +1,13 @@ +#include "prx/libc/include/general/VabiMacros.hpp" +#include + +extern "C" { +int APS5_VABI sceNpAuthGetAuthorizedAppCode(); +} + +int main() { + constexpr int kSignedOut = static_cast(0x80550006); + if (sceNpAuthGetAuthorizedAppCode() != kSignedOut) std::abort(); + if (sceNpAuthGetAuthorizedAppCode() != kSignedOut) std::abort(); + return 0; +} diff --git a/docs/dev/debt/libSceNpAuth.md b/docs/dev/debt/libSceNpAuth.md index a7d0e43b7..a4964a44d 100644 --- a/docs/dev/debt/libSceNpAuth.md +++ b/docs/dev/debt/libSceNpAuth.md @@ -2,5 +2,5 @@ ### Unknown function info -- [sceNpAuthGetAuthorizedAppCode](../../../core/libs/prx/libSceNpAuth/Export.cpp) (libSceNpAuth) - declared without parameters as a throwing stub; Minecraft (PPSA17221) imports it and fails to load without it. The request parameter and code output are not known, and there is no PSN sign-in for it to succeed against. +- [sceNpAuthGetAuthorizedAppCode](../../../core/libs/prx/libSceNpAuth/Export.cpp) (libSceNpAuth) - declared without parameters and returns `SCE_NP_ERROR_SIGNED_OUT` without reading them, as there is no PSN sign-in; the request parameter and code output are not known. Minecraft (PPSA17221) imports it, fails to load without it, and after its sign-in dialog treats the signed-out code as offline play. - [sceNpAuthAbortRequest, sceNpAuthGetAuthorizationCodeV3, sceNpAuthGetIdTokenV3, sceNpAuthPollAsync, sceNpAuthWaitAsync](../../../core/libs/prx/libSceNpAuth/Export.cpp) (libSceNpAuth) - request tracking, `ORBIS_NP_AUTH_ERROR_REQUEST_NOT_FOUND` (0x80550306) on unknown request IDs, `ORBIS_NP_AUTH_ERROR_INVALID_ID` (0x80550307) on non-async or unprocessed requests in Poll/Wait, `ORBIS_NP_AUTH_ERROR_INVALID_ARGUMENT` (0x80550301) on null arguments and repeated calls on completed requests, and `ORBIS_NP_AUTH_ERROR_ABORTED` (0x80550304) after an abort follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/np/np_auth.cpp) (PS4); async requests return OK and defer `SCE_NP_ERROR_SIGNED_OUT` to `sceNpAuthPollAsync`/`sceNpAuthWaitAsync` while sync requests fail immediately; PlayStation Network is not contacted. The parameter `size` fields are not checked (`ORBIS_NP_AUTH_ERROR_INVALID_SIZE`, structure layouts unknown), the request table has no limit (`ORBIS_NP_AUTH_ERROR_REQUEST_MAX`), and console behavior on PS5 is unverified