feat(libSceNpPartner001): implement sceNpEAAccessInitialize and sceNpEAAccessTerminate
UFC 6 (PPSA23566) imports both. Initialization marks the library initialized and termination clears it, as in shadPS4. Termination without initialization and a second initialization throw, since no PS5 source settles their results. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit d2866a886a7702cdaad56d161460a3ce86ede629)
This commit is contained in:
parent
1acfa7f788
commit
e2954aa188
|
|
@ -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()
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -3,3 +3,7 @@
|
|||
### Unknown function info
|
||||
|
||||
- [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
|
||||
|
||||
### Functional
|
||||
|
||||
- [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
|
||||
|
|
|
|||
Loading…
Reference in New Issue