diff --git a/core/libs/prx/libSceRegMgr/CMakeLists.txt b/core/libs/prx/libSceRegMgr/CMakeLists.txt new file mode 100644 index 0000000000..e10c382e33 --- /dev/null +++ b/core/libs/prx/libSceRegMgr/CMakeLists.txt @@ -0,0 +1,15 @@ +add_library(libSceRegMgr SHARED EXCLUDE_FROM_ALL Export.cpp) +target_include_directories(libSceRegMgr PRIVATE ${LIBS_INCLUDE_DIR}) +configure_windows_unwind(libSceRegMgr) + +if(BUILD_TESTING) + add_test_executable(guest_regmgr_tests ${LIBS_INCLUDE_DIR}/tests/GuestRegMgr.cpp) + target_include_directories(guest_regmgr_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_regmgr_tests PRIVATE libSceRegMgr libc) + configure_windows_unwind(guest_regmgr_tests) + add_test(NAME guest_regmgr COMMAND guest_regmgr_tests) + if(WIN32) + set_tests_properties(guest_regmgr PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() +endif() diff --git a/core/libs/prx/libSceRegMgr/Export.cpp b/core/libs/prx/libSceRegMgr/Export.cpp new file mode 100644 index 0000000000..d71daed4b0 --- /dev/null +++ b/core/libs/prx/libSceRegMgr/Export.cpp @@ -0,0 +1,14 @@ +#include +#include "prx/libc/include/General.hpp" + +extern "C" { + +std::int32_t APS5_VABI sceRegMgrNonSysGetInt(std::int64_t key, std::int32_t unk, std::int32_t* data) { + (void)key; + (void)unk; + (void)data; + NotImplemented_nid_no_patch(__func__); + return 0; +} + +} diff --git a/core/libs/tests/GuestRegMgr.cpp b/core/libs/tests/GuestRegMgr.cpp new file mode 100644 index 0000000000..dfdf074535 --- /dev/null +++ b/core/libs/tests/GuestRegMgr.cpp @@ -0,0 +1,27 @@ +#include "prx/libc/include/general/VabiMacros.hpp" +#include +#include +#include +#include + +extern "C" { +std::int32_t APS5_VABI sceRegMgrNonSysGetInt(std::int64_t key, std::int32_t unk, std::int32_t* data); +} + +static void Require(bool value) { if (!value) std::abort(); } + +template +static bool ReportsNotImplemented(const char* name, TCall call) { + try { + call(); + } catch (const std::runtime_error& error) { + return std::string(error.what()) == std::string(name) + " not implemented"; + } + return false; +} + +int main() { + std::int32_t value = 0; + Require(ReportsNotImplemented("sceRegMgrNonSysGetInt", [&] { sceRegMgrNonSysGetInt(0, 0, &value); })); + Require(ReportsNotImplemented("sceRegMgrNonSysGetInt", [&] { sceRegMgrNonSysGetInt(-1, 1, nullptr); })); +} diff --git a/docs/dev/debt/libSceRegMgr.md b/docs/dev/debt/libSceRegMgr.md new file mode 100644 index 0000000000..467ad2850e --- /dev/null +++ b/docs/dev/debt/libSceRegMgr.md @@ -0,0 +1,5 @@ +# libSceRegMgr technical debt + +### Unknown function info + +- [sceRegMgrNonSysGetInt](../../../core/libs/prx/libSceRegMgr/Export.cpp) (libSceRegMgr, NID `dKeshzt29G4`) - imported by Astro Bot (PPSA21564), which fails to load without libSceRegMgr.prx (issue 4720); the `(int64_t key, int32_t unk, int32_t* data)` signature follows [ChonkyStation4](https://github.com/liuk7071/ChonkyStation4/blob/c101a23ecbc15e56c6e30d5dd24d3ed8880a957a/ChonkyStation4/OS/Libraries/SceRegMgr/SceRegMgr.cpp#L38-L47), not measured on a console, so every call throws