diff --git a/core/libs/CMakeLists.txt b/core/libs/CMakeLists.txt index 23a160828644..8fa7641f8a24 100644 --- a/core/libs/CMakeLists.txt +++ b/core/libs/CMakeLists.txt @@ -209,6 +209,16 @@ if(BUILD_TESTING) "PATH=path_list_prepend:$") endif() + add_test_executable(guest_react_native_vsh_tests tests/GuestReactNativeVsh.cpp) + target_include_directories(guest_react_native_vsh_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + target_link_libraries(guest_react_native_vsh_tests PRIVATE libReactNative.Modules.Vsh libc) + configure_windows_unwind(guest_react_native_vsh_tests) + add_test(NAME guest_react_native_vsh COMMAND guest_react_native_vsh_tests) + if(WIN32) + set_tests_properties(guest_react_native_vsh PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() + add_test_executable(guest_rudp_context_queries_tests tests/GuestRudpContextQueries.cpp) target_include_directories(guest_rudp_context_queries_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(guest_rudp_context_queries_tests PRIVATE libSceRudp libc) diff --git a/core/libs/prx/libReactNative.Modules.Vsh/Export.cpp b/core/libs/prx/libReactNative.Modules.Vsh/Export.cpp index b488eb139bbb..d6a3bae6af82 100644 --- a/core/libs/prx/libReactNative.Modules.Vsh/Export.cpp +++ b/core/libs/prx/libReactNative.Modules.Vsh/Export.cpp @@ -1,21 +1,28 @@ #include #include +#include #include "SceTypes.hpp" #include "prx/libc/include/General.hpp" +namespace { + +constexpr int REMOTEPLAY_CONNECTION_STATUS_DISCONNECT = 0; +constexpr int SHARE_ERROR_INVALID_PARAM = static_cast(0x81960002); + +} + extern "C" { int APS5_VABI RemotePlayGetConnectionStatus(int user_id, int* status) { (void)user_id; - (void)status; - NotImplemented_nid_no_patch(__func__); + if (!status) APS5_INVALID_ARG_EX; + *status = REMOTEPLAY_CONNECTION_STATUS_DISCONNECT; return 0; } int APS5_VABI ShareGetCurrentStatus(uint32_t feature_flag, ShareCurrentStatus* status) { - (void)feature_flag; - (void)status; - NotImplemented_nid_no_patch(__func__); + if (feature_flag == 0 || status == nullptr) return SHARE_ERROR_INVALID_PARAM; + std::memset(status, 0, sizeof(*status)); return 0; } diff --git a/core/libs/tests/GuestReactNativeVsh.cpp b/core/libs/tests/GuestReactNativeVsh.cpp new file mode 100644 index 000000000000..150335da3307 --- /dev/null +++ b/core/libs/tests/GuestReactNativeVsh.cpp @@ -0,0 +1,36 @@ +#include "prx/libc/include/general/VabiMacros.hpp" + +#include +#include +#include +#include +#include + +extern "C" { +int APS5_VABI RemotePlayGetConnectionStatus(int user_id, int* status); +int APS5_VABI ShareGetCurrentStatus(std::uint32_t feature_flag, void* status); +} + +static void Require(bool value) { if (!value) std::abort(); } + +int main() { + int connection = -1; + Require(RemotePlayGetConnectionStatus(1, &connection) == 0 && connection == 0); + bool threw = false; + try { + RemotePlayGetConnectionStatus(1, nullptr); + } catch (const std::invalid_argument&) { + threw = true; + } + Require(threw); + + constexpr int invalidParam = static_cast(0x81960002); + std::uint8_t status[18]; + std::memset(status, 0x5a, sizeof(status)); + Require(ShareGetCurrentStatus(1, status) == 0); + for (std::size_t index = 0; index < sizeof(status); ++index) Require(status[index] == (index < 16 ? 0 : 0x5a)); + std::memset(status, 0x5a, sizeof(status)); + Require(ShareGetCurrentStatus(0, status) == invalidParam && status[0] == 0x5a); + Require(ShareGetCurrentStatus(1, nullptr) == invalidParam); + return 0; +} diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index c1247e46bc80..f7756226bdb8 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -338,6 +338,7 @@ Throughout the project, every function at every stage either **does exactly what - [uDGXwUKqi8s](../../core/libs/prx/libkernel/Unimplemented.cpp) (libkernel) - unknown name, signature - [LinuxProtFromSce](../../core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp) (libkernel) - protection bits 0x100 and 0x200 are accepted and assumed not to affect host CPU access; host protection is derived only from the read, write and execute bits - [_sceUlobjmgrRegisterObject](../../core/libs/prx/ulobjmgr/Export.cpp) (ulobjmgr) - parameters taken from shadPS4 (PS4): a nonzero 64-bit object, a nonzero 32-bit kind and a 32-bit id output; the meaning of the first two and the PS5 signature are unverified. The id bound of `_sceUlobjmgrUnregisterObject` (below 0x4000) and the raw `EINVAL` (22) return also come from shadPS4 +- [RemotePlayGetConnectionStatus, ShareGetCurrentStatus](../../core/libs/prx/libReactNative.Modules.Vsh/Export.cpp) (libReactNative.Modules.Vsh) - these shell module wrappers are assumed to take the arguments of `sceRemoteplayGetConnectionStatus` and `sceShareGetCurrentStatus` and to answer as those do here: no Remote Play session (status 0, disconnected, and a null status throws), and the libSceShare validation with an all-zero 16-byte share status. `ShareInitialize` and `ShareTerminate` still throw - [sceShareGetCurrentStatus](../../core/libs/prx/libSceShare/Export.cpp) (libSceShare) - validation (feature flag non-zero, status non-null) and the all-zero 16-byte status taken from the [KytyPS5](https://github.com/KytyPS5/KytyPS5) reimplementation, not confirmed on a PS5 title; the meaning of the recording status values is unknown - [sceShareGetRunningStatus](../../core/libs/prx/libSceShare/Export.cpp) (libSceShare) - only the first 32-bit word of the status is known: PPSA01317 treats bits 0x3c of it as a running share feature and gives the call a 40-byte buffer. The host never records or broadcasts, so it stores 0 in that word and leaves the rest untouched; a null status returns `INVALID_PARAM` by analogy with `sceShareGetCurrentStatus` - [sceShareSetContentParamForApplicationTitle](../../core/libs/prx/libSceShare/Export.cpp) (libSceShare) - imported by PPSA12544's Unity plugins; the signature follows [KytyPS5](https://github.com/KytyPS5/KytyPS5/blob/main/src/libs/libShare.cpp), not confirmed on a PS5 title. The application title is only checked for null, as KytyPS5 does, since nothing is captured