mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
Merge pull request #924 from Adin-bima/feat/np-get-np-id
feat(libSceNpManager): implement sceNpGetNpId
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
add_library(libSceNpManager SHARED EXCLUDE_FROM_ALL Export.cpp)
|
||||
target_include_directories(libSceNpManager PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
configure_windows_unwind(libSceNpManager)
|
||||
|
||||
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_np_manager_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpManager.cpp)
|
||||
target_include_directories(guest_np_manager_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(guest_np_manager_tests PRIVATE libSceNpManager)
|
||||
add_test(NAME guest_np_manager COMMAND guest_np_manager_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_np_manager PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceNpManager>")
|
||||
endif()
|
||||
endif()
|
||||
@@ -79,10 +79,9 @@ int APS5_VABI sceNpGetAccountIdA(int user_id, uint64_t* account_id) {
|
||||
}
|
||||
|
||||
int APS5_VABI sceNpGetNpId(int user_id, NpId* np_id) {
|
||||
(void)user_id;
|
||||
(void)np_id;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
(void)user_id;
|
||||
if (!np_id) return SCE_NP_ERROR_INVALID_ARGUMENT;
|
||||
return SCE_NP_ERROR_SIGNED_OUT;
|
||||
}
|
||||
|
||||
int APS5_VABI sceNpGetNpReachabilityState(int user_id, uint32_t* state) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "prx/libc/include/general/VabiMacros.hpp"
|
||||
#include "SceTypes.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
extern "C" {
|
||||
int APS5_VABI sceNpGetNpId(int user_id, NpId* np_id);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int InvalidArgument = static_cast<int>(0x80550003u);
|
||||
constexpr int SignedOut = static_cast<int>(0x80550006u);
|
||||
|
||||
void Require(bool condition, const char* message) {
|
||||
if (!condition) {
|
||||
std::fprintf(stderr, "NpManager: %s\n", message);
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
NpId npId{};
|
||||
std::memset(&npId, 0x5a, sizeof(npId));
|
||||
NpId untouched{};
|
||||
std::memset(&untouched, 0x5a, sizeof(untouched));
|
||||
Require(sceNpGetNpId(0x10000, &npId) == SignedOut, "sceNpGetNpId must report the user as signed out");
|
||||
Require(std::memcmp(&npId, &untouched, sizeof(npId)) == 0, "sceNpGetNpId must leave the NpId untouched");
|
||||
Require(sceNpGetNpId(0x10000, nullptr) == InvalidArgument, "sceNpGetNpId must reject a null NpId");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user