Merge pull request #3718 from MarcZX100/codex/libsce-np-ea-access-3339

feat(libSceNpPartner001): implement EA access init and terminate
This commit is contained in:
Adrià 2026-10-12 22:03:30 +02:00 committed by GitHub
commit 70da6f41c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 63 additions and 4 deletions

View File

@ -0,0 +1,15 @@
add_library(libSceNpPartner001 SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceNpPartner001 PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceNpPartner001)
if(BUILD_TESTING)
add_test_executable(guest_np_partner_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpPartner.cpp)
target_include_directories(guest_np_partner_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_np_partner_tests PRIVATE libSceNpPartner001 libc)
configure_windows_unwind(guest_np_partner_tests)
add_test(NAME guest_np_partner COMMAND guest_np_partner_tests)
if(WIN32)
set_tests_properties(guest_np_partner PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceNpPartner001>")
endif()
endif()

View File

@ -1,14 +1,23 @@
#include "prx/libc/include/General.hpp"
#include <atomic>
#include <stdexcept>
#include <string>
namespace {
std::atomic<bool> g_initialized{false};
}
extern "C" {
int APS5_VABI sceNpEAAccessInitialize(void) {
NotImplemented_nid_no_patch(__func__);
bool expected = false;
if (!g_initialized.compare_exchange_strong(expected, true)) throw std::logic_error(std::string(__func__) + ": already initialized");
return 0;
}
int APS5_VABI sceNpEAAccessTerminate(void) {
NotImplemented_nid_no_patch(__func__);
bool expected = true;
if (!g_initialized.compare_exchange_strong(expected, false)) throw std::logic_error(std::string(__func__) + ": not initialized");
return 0;
}

View File

@ -0,0 +1,34 @@
#include "prx/libc/include/general/VabiMacros.hpp"
#include <cstdlib>
#include <stdexcept>
extern "C" {
int APS5_VABI sceNpEAAccessInitialize(void);
int APS5_VABI sceNpEAAccessTerminate(void);
}
namespace {
void Require(bool value) { if (!value) std::abort(); }
template <typename TAction>
bool Throws(TAction action) {
try {
action();
} catch (const std::logic_error&) {
return true;
}
return false;
}
}
int main() {
Require(Throws([] { sceNpEAAccessTerminate(); }));
Require(sceNpEAAccessInitialize() == 0);
Require(Throws([] { sceNpEAAccessInitialize(); }));
Require(sceNpEAAccessTerminate() == 0);
Require(Throws([] { sceNpEAAccessTerminate(); }));
Require(sceNpEAAccessInitialize() == 0);
Require(sceNpEAAccessTerminate() == 0);
}

View File

@ -1,5 +1,6 @@
# libSceNpPartner001 technical debt
### Unknown function info
### Functional
- [sceNpEAAccessInitialize, sceNpEAAccessTerminate](../../../core/libs/prx/libSceNpPartner001/Export.cpp) (libSceNpPartner001) - names and the no-argument signatures follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/np/np_partner.cpp); imported by PPSA23566, not confirmed on a PS5 title
- [sceNpEAAccessInitialize, sceNpEAAccessTerminate](../../../core/libs/prx/libSceNpPartner001/Export.cpp) (libSceNpPartner001) - initialization marks the library initialized without contacting the server and termination clears it, as in [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/np/np_partner.cpp); whether the console fails initialization while signed out is unknown. Termination without initialization throws where shadPS4 returns the PS4 error `0x819D0001`, whose PS5 value is unverified, and a second initialization throws where shadPS4 returns 0 without checking. PPSA23566 imports both, not confirmed on its start-up path
- [sceNpEAAccessInitialize, sceNpEAAccessTerminate](../../../core/libs/prx/libSceNpPartner001/Export.cpp) (libSceNpPartner001) - initialization marks the library initialized without contacting the server and termination clears it, as in [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/np/np_partner.cpp); whether the console fails initialization while signed out is unknown. Termination without initialization throws where shadPS4 returns the PS4 error `0x819D0001`, whose PS5 value is unverified, and a second initialization throws where shadPS4 returns 0 without checking. PPSA23566 imports both, not confirmed on its start-up path