From fae2c8e6beda0d81cd4a6c7fc2aa46262dfff361 Mon Sep 17 00:00:00 2001 From: Phi1ow <331962174+Phi1ow@users.noreply.github.com> Date: Sun, 4 Oct 2026 22:41:38 +0200 Subject: [PATCH 1/2] feat(logindialog): implement the libSceLoginDialog state machine The seven libSceLoginDialog exports were throwing stubs. They now implement the common-dialog state machine (NONE -> INITIALIZED -> RUNNING -> FINISHED), mirroring the existing libSceSigninDialog: the local user is always signed in, so the dialog finishes as soon as it opens and a title waiting on it never blocks. - sceLoginDialogInitialize -> INITIALIZED, or 0x80B80004 if already initialized - sceLoginDialogOpen -> validates the state and the parameter, then FINISHED - sceLoginDialogUpdateStatus / sceLoginDialogGetStatus -> the status - sceLoginDialogGetResult -> zeroes the result (signed in) once FINISHED - sceLoginDialogClose -> ok, or 0x80B80003 when not initialized - sceLoginDialogTerminate -> NONE, or 0x80B80003 when not initialized The status values and the shared common-dialog error codes match libSceSigninDialog and libSceWebBrowserDialog. Adds a CMakeLists.txt so the library can carry its guest test. New test core/libs/tests/GuestLoginDialog.cpp drives the whole machine (the not-initialized and already-initialized errors, the argument and not-finished errors, open/get-result/close and terminate). It fails on main (the stubs throw) and passes with the change. --- .../libs/prx/libSceLoginDialog/CMakeLists.txt | 20 +++++ core/libs/prx/libSceLoginDialog/Export.cpp | 75 ++++++++++++------- core/libs/tests/GuestLoginDialog.cpp | 52 +++++++++++++ 3 files changed, 122 insertions(+), 25 deletions(-) create mode 100644 core/libs/prx/libSceLoginDialog/CMakeLists.txt create mode 100644 core/libs/tests/GuestLoginDialog.cpp diff --git a/core/libs/prx/libSceLoginDialog/CMakeLists.txt b/core/libs/prx/libSceLoginDialog/CMakeLists.txt new file mode 100644 index 000000000..0271b47ba --- /dev/null +++ b/core/libs/prx/libSceLoginDialog/CMakeLists.txt @@ -0,0 +1,20 @@ +add_library(libSceLoginDialog SHARED EXCLUDE_FROM_ALL Export.cpp) +target_include_directories(libSceLoginDialog PRIVATE ${LIBS_INCLUDE_DIR}) +configure_windows_unwind(libSceLoginDialog) + +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_login_dialog_tests ${LIBS_INCLUDE_DIR}/tests/GuestLoginDialog.cpp) + target_include_directories(guest_login_dialog_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_login_dialog_tests PRIVATE libSceLoginDialog) + add_test(NAME guest_login_dialog COMMAND guest_login_dialog_tests) + if(WIN32) + set_tests_properties(guest_login_dialog PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() +endif() diff --git a/core/libs/prx/libSceLoginDialog/Export.cpp b/core/libs/prx/libSceLoginDialog/Export.cpp index 66c3b8374..f43475385 100644 --- a/core/libs/prx/libSceLoginDialog/Export.cpp +++ b/core/libs/prx/libSceLoginDialog/Export.cpp @@ -1,44 +1,69 @@ +#include #include #include +#include #include "SceTypes.hpp" #include "prx/libc/include/General.hpp" +namespace { + +constexpr int COMMON_DIALOG_STATUS_NONE = 0; +constexpr int COMMON_DIALOG_STATUS_INITIALIZED = 1; +constexpr int COMMON_DIALOG_STATUS_RUNNING = 2; +constexpr int COMMON_DIALOG_STATUS_FINISHED = 3; +constexpr int COMMON_DIALOG_ERROR_NOT_INITIALIZED = static_cast(0x80B80003u); +constexpr int COMMON_DIALOG_ERROR_ALREADY_INITIALIZED = static_cast(0x80B80004u); +constexpr int COMMON_DIALOG_ERROR_NOT_FINISHED = static_cast(0x80B80005u); +constexpr int COMMON_DIALOG_ERROR_BUSY = static_cast(0x80B80007u); +constexpr int COMMON_DIALOG_ERROR_ARG_NULL = static_cast(0x80B8000Du); + +constexpr std::size_t LOGIN_DIALOG_RESULT_SIZE = 8; + +std::atomic g_status{COMMON_DIALOG_STATUS_NONE}; + +} + extern "C" { -int APS5_VABI sceLoginDialogClose(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - -int APS5_VABI sceLoginDialogGetResult(void* result) { - (void)result; - NotImplemented_nid_no_patch(__func__); - return 0; -} - -int APS5_VABI sceLoginDialogGetStatus(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - int APS5_VABI sceLoginDialogInitialize(void) { - NotImplemented_nid_no_patch(__func__); + int expected = COMMON_DIALOG_STATUS_NONE; + if (!g_status.compare_exchange_strong(expected, COMMON_DIALOG_STATUS_INITIALIZED)) return COMMON_DIALOG_ERROR_ALREADY_INITIALIZED; return 0; } int APS5_VABI sceLoginDialogOpen(const void* param) { - (void)param; - NotImplemented_nid_no_patch(__func__); - return 0; -} - -int APS5_VABI sceLoginDialogTerminate(void) { - NotImplemented_nid_no_patch(__func__); + const int status = g_status.load(); + if (status == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED; + if (status == COMMON_DIALOG_STATUS_RUNNING) return COMMON_DIALOG_ERROR_BUSY; + if (param == nullptr) return COMMON_DIALOG_ERROR_ARG_NULL; + g_status = COMMON_DIALOG_STATUS_FINISHED; return 0; } int APS5_VABI sceLoginDialogUpdateStatus(void) { - NotImplemented_nid_no_patch(__func__); + return g_status.load(); +} + +int APS5_VABI sceLoginDialogGetStatus(void) { + return g_status.load(); +} + +int APS5_VABI sceLoginDialogGetResult(void* result) { + const int status = g_status.load(); + if (status == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED; + if (result == nullptr) return COMMON_DIALOG_ERROR_ARG_NULL; + if (status != COMMON_DIALOG_STATUS_FINISHED) return COMMON_DIALOG_ERROR_NOT_FINISHED; + std::memset(result, 0, LOGIN_DIALOG_RESULT_SIZE); + return 0; +} + +int APS5_VABI sceLoginDialogClose(void) { + if (g_status.load() == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED; + return 0; +} + +int APS5_VABI sceLoginDialogTerminate(void) { + if (g_status.exchange(COMMON_DIALOG_STATUS_NONE) == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED; return 0; } diff --git a/core/libs/tests/GuestLoginDialog.cpp b/core/libs/tests/GuestLoginDialog.cpp new file mode 100644 index 000000000..01983f026 --- /dev/null +++ b/core/libs/tests/GuestLoginDialog.cpp @@ -0,0 +1,52 @@ +#include "prx/libc/include/general/VabiMacros.hpp" +#include +#include + +extern "C" { +int APS5_VABI sceLoginDialogInitialize(void); +int APS5_VABI sceLoginDialogOpen(const void* param); +int APS5_VABI sceLoginDialogUpdateStatus(void); +int APS5_VABI sceLoginDialogGetStatus(void); +int APS5_VABI sceLoginDialogGetResult(void* result); +int APS5_VABI sceLoginDialogClose(void); +int APS5_VABI sceLoginDialogTerminate(void); +} + +namespace { + +void Require(bool value) { if (!value) std::abort(); } + +constexpr int kStatusFinished = 3; +constexpr int kErrNotInitialized = static_cast(0x80B80003); +constexpr int kErrAlreadyInitialized = static_cast(0x80B80004); +constexpr int kErrNotFinished = static_cast(0x80B80005); +constexpr int kErrArgNull = static_cast(0x80B8000D); + +} + +int main() { + std::int64_t param = 0; + std::int64_t result = -1; + + Require(sceLoginDialogTerminate() == kErrNotInitialized); + Require(sceLoginDialogOpen(¶m) == kErrNotInitialized); + Require(sceLoginDialogGetResult(&result) == kErrNotInitialized); + + Require(sceLoginDialogInitialize() == 0); + Require(sceLoginDialogInitialize() == kErrAlreadyInitialized); + + Require(sceLoginDialogOpen(nullptr) == kErrArgNull); + Require(sceLoginDialogGetResult(&result) == kErrNotFinished); + + Require(sceLoginDialogOpen(¶m) == 0); + Require(sceLoginDialogGetStatus() == kStatusFinished); + Require(sceLoginDialogUpdateStatus() == kStatusFinished); + + Require(sceLoginDialogGetResult(nullptr) == kErrArgNull); + Require(sceLoginDialogGetResult(&result) == 0); + Require(result == 0); + + Require(sceLoginDialogClose() == 0); + Require(sceLoginDialogTerminate() == 0); + Require(sceLoginDialogTerminate() == kErrNotInitialized); +} From 0178b6530e9db79078d530742b779d57ef2b2a03 Mon Sep 17 00:00:00 2001 From: Phi1ow <331962174+Phi1ow@users.noreply.github.com> Date: Mon, 5 Oct 2026 00:31:15 +0200 Subject: [PATCH 2/2] fix(logindialog): report user-cancelled and write only the leading result int32 sceLoginDialogGetResult zeroed 8 bytes of a result struct of unknown size and reported result 0 with user id 0. It now writes only the leading int32 (USER_CANCELED), like sceWebBrowserDialogGetResult and like the sign-in dialog, so a title takes its "no user chosen" path instead of reading an invalid user id. Records the dialog in the silent-stubs list in docs/dev/TechnicalDebt.md. --- core/libs/prx/libSceLoginDialog/Export.cpp | 6 +++--- core/libs/tests/GuestLoginDialog.cpp | 12 +++++++----- docs/dev/TechnicalDebt.md | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/core/libs/prx/libSceLoginDialog/Export.cpp b/core/libs/prx/libSceLoginDialog/Export.cpp index f43475385..a986655ab 100644 --- a/core/libs/prx/libSceLoginDialog/Export.cpp +++ b/core/libs/prx/libSceLoginDialog/Export.cpp @@ -16,8 +16,7 @@ constexpr int COMMON_DIALOG_ERROR_ALREADY_INITIALIZED = static_cast(0x80B80 constexpr int COMMON_DIALOG_ERROR_NOT_FINISHED = static_cast(0x80B80005u); constexpr int COMMON_DIALOG_ERROR_BUSY = static_cast(0x80B80007u); constexpr int COMMON_DIALOG_ERROR_ARG_NULL = static_cast(0x80B8000Du); - -constexpr std::size_t LOGIN_DIALOG_RESULT_SIZE = 8; +constexpr int COMMON_DIALOG_RESULT_USER_CANCELED = 1; std::atomic g_status{COMMON_DIALOG_STATUS_NONE}; @@ -53,7 +52,8 @@ int APS5_VABI sceLoginDialogGetResult(void* result) { if (status == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED; if (result == nullptr) return COMMON_DIALOG_ERROR_ARG_NULL; if (status != COMMON_DIALOG_STATUS_FINISHED) return COMMON_DIALOG_ERROR_NOT_FINISHED; - std::memset(result, 0, LOGIN_DIALOG_RESULT_SIZE); + const std::int32_t canceled = COMMON_DIALOG_RESULT_USER_CANCELED; + std::memcpy(result, &canceled, sizeof(canceled)); return 0; } diff --git a/core/libs/tests/GuestLoginDialog.cpp b/core/libs/tests/GuestLoginDialog.cpp index 01983f026..7eaeb5619 100644 --- a/core/libs/tests/GuestLoginDialog.cpp +++ b/core/libs/tests/GuestLoginDialog.cpp @@ -21,30 +21,32 @@ constexpr int kErrNotInitialized = static_cast(0x80B80003); constexpr int kErrAlreadyInitialized = static_cast(0x80B80004); constexpr int kErrNotFinished = static_cast(0x80B80005); constexpr int kErrArgNull = static_cast(0x80B8000D); +constexpr int kResultUserCanceled = 1; } int main() { std::int64_t param = 0; - std::int64_t result = -1; + std::int32_t result[2] = {-1, -1}; Require(sceLoginDialogTerminate() == kErrNotInitialized); Require(sceLoginDialogOpen(¶m) == kErrNotInitialized); - Require(sceLoginDialogGetResult(&result) == kErrNotInitialized); + Require(sceLoginDialogGetResult(result) == kErrNotInitialized); Require(sceLoginDialogInitialize() == 0); Require(sceLoginDialogInitialize() == kErrAlreadyInitialized); Require(sceLoginDialogOpen(nullptr) == kErrArgNull); - Require(sceLoginDialogGetResult(&result) == kErrNotFinished); + Require(sceLoginDialogGetResult(result) == kErrNotFinished); Require(sceLoginDialogOpen(¶m) == 0); Require(sceLoginDialogGetStatus() == kStatusFinished); Require(sceLoginDialogUpdateStatus() == kStatusFinished); Require(sceLoginDialogGetResult(nullptr) == kErrArgNull); - Require(sceLoginDialogGetResult(&result) == 0); - Require(result == 0); + Require(sceLoginDialogGetResult(result) == 0); + Require(result[0] == kResultUserCanceled); + Require(result[1] == -1); Require(sceLoginDialogClose() == 0); Require(sceLoginDialogTerminate() == 0); diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index 5e4153ff5..4a8510769 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -15,6 +15,7 @@ Throughout the project, every function at every stage either **does exactly what - [libSceMsgDialog.native](../../core/libs/prx/libSceMsgDialog.native/Export.cpp) - dialogs finish at `sceMsgDialogOpen` without UI and answer with button 1, so `sceMsgDialogClose` returns `NOT_RUNNING`; its result before `sceMsgDialogInitialize` follows libSceMsgDialog - [libSceCommonDialog](../../core/libs/prx/libSceCommonDialog/Export.cpp) - [libSceErrorDialog](../../core/libs/prx/libSceErrorDialog/Export.cpp) - the error dialog runs the state machine but shows nothing; the error code passed to `sceErrorDialogOpen` is only logged +- [libSceLoginDialog](../../core/libs/prx/libSceLoginDialog/Export.cpp) - the login dialog runs the common-dialog state machine but shows nothing and reports the user as having cancelled - [libSceHmd](../../core/libs/prx/libSceHmd/Export.cpp) implements only the disconnected-headset path: initialization succeeds, device queries report `NotDetected`, and opening a device returns `DeviceDisconnected`. Headset support, tracking, rendering and additional HMD exports are not implemented; SDK-level ABI compatibility and in-game behaviour remain unverified. - [libSceAudioPropagation](../../core/libs/prx/libSceAudioPropagation/Export.cpp) implements only the no-acoustic-propagation path: the system keeps a 16-byte header in the title's CPU memory (no GPU memory), rooms, portals, sources and materials are tracked handles, attributes are validated and have no effect, no rays are requested and sources report no audio paths. Ray results, path calculation and audio paths are accepted only when empty and throw otherwise; `sceAudioPropagationSourceRender` writes silence (zeroes) to each source's output buffer for the given size, without a dry signal. Objects still alive when their system is destroyed become unusable, and their later destroy or unregister is a no-op: PPSA21567 releases its reference-counted room, portal and source owners just before `sceAudioPropagationSystemDestroy`, so the order for every object is not proven. Occlusion, reflections and reverb from level geometry are absent; in-game behaviour remains unverified. - [libSceNpCommerce](../../core/libs/prx/libSceNpCommerce/Export.cpp) - the PS Store icon show/hide calls and `sceNpCommerceSetPsStoreIconLayout` do nothing