From 5a321471c20d619d83ba4d3c46935229eafb1c8a Mon Sep 17 00:00:00 2001 From: Chad Date: Mon, 5 Oct 2026 20:16:49 -0500 Subject: [PATCH 1/2] feat(libSceHttp2): implement cookie boxes and requests without a content length sceHttp2CreateCookieBox hands out an id from the library's handle counter, sceHttp2SetCookieBox binds one to a template or request, and sceHttp2CookieFlush succeeds: no request reaches the network, so no cookie is ever stored. sceHttp2SetRequestNoContentLength is accepted like sceHttp2SetRequestContentLength. The library gets its own CMakeLists for the new guest_http2 test. Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libSceHttp2/CMakeLists.txt | 21 ++++++++++++++ core/libs/prx/libSceHttp2/Export.cpp | 23 +++++++-------- core/libs/tests/GuestHttp2.cpp | 36 ++++++++++++++++++++++++ docs/dev/TechnicalDebt.md | 1 + 4 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 core/libs/prx/libSceHttp2/CMakeLists.txt create mode 100644 core/libs/tests/GuestHttp2.cpp diff --git a/core/libs/prx/libSceHttp2/CMakeLists.txt b/core/libs/prx/libSceHttp2/CMakeLists.txt new file mode 100644 index 000000000..08d9a13c8 --- /dev/null +++ b/core/libs/prx/libSceHttp2/CMakeLists.txt @@ -0,0 +1,21 @@ +add_library(libSceHttp2 SHARED EXCLUDE_FROM_ALL Export.cpp) +target_include_directories(libSceHttp2 PRIVATE ${LIBS_INCLUDE_DIR}) +configure_windows_unwind(libSceHttp2) + +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_http2_tests ${LIBS_INCLUDE_DIR}/tests/GuestHttp2.cpp) + target_include_directories(guest_http2_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_http2_tests PRIVATE libSceHttp2 libc) + configure_windows_unwind(guest_http2_tests) + add_test(NAME guest_http2 COMMAND guest_http2_tests) + if(WIN32) + set_tests_properties(guest_http2 PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() +endif() diff --git a/core/libs/prx/libSceHttp2/Export.cpp b/core/libs/prx/libSceHttp2/Export.cpp index adaa00e78..a90ecb83f 100644 --- a/core/libs/prx/libSceHttp2/Export.cpp +++ b/core/libs/prx/libSceHttp2/Export.cpp @@ -214,23 +214,24 @@ int APS5_VABI sceHttp2GetMemoryPoolStats() { return 0; } -int APS5_VABI sceHttp2CookieFlush(void) { - NotImplemented_nid_no_patch(__func__); +int APS5_VABI sceHttp2CookieFlush(int id) { + (void)id; return 0; } -int APS5_VABI sceHttp2CreateCookieBox(void) { - NotImplemented_nid_no_patch(__func__); +int APS5_VABI sceHttp2CreateCookieBox(int lib_http2_ctx_id) { + (void)lib_http2_ctx_id; + return g_nextHandle.fetch_add(1, std::memory_order_relaxed); +} + +int APS5_VABI sceHttp2SetCookieBox(int id, int cookie_box_id) { + (void)id; + (void)cookie_box_id; return 0; } -int APS5_VABI sceHttp2SetCookieBox(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - -int APS5_VABI sceHttp2SetRequestNoContentLength(void) { - NotImplemented_nid_no_patch(__func__); +int APS5_VABI sceHttp2SetRequestNoContentLength(int id) { + (void)id; return 0; } diff --git a/core/libs/tests/GuestHttp2.cpp b/core/libs/tests/GuestHttp2.cpp new file mode 100644 index 000000000..7be4800b5 --- /dev/null +++ b/core/libs/tests/GuestHttp2.cpp @@ -0,0 +1,36 @@ +#include "SceTypes.hpp" +#include +#include + +extern "C" { +int APS5_VABI sceHttp2Init(int, int, std::size_t, int); +int APS5_VABI sceHttp2CreateTemplate(int, const char*, int, int); +int APS5_VABI sceHttp2CreateRequestWithURL(int, const char*, const char*, std::uint64_t); +int APS5_VABI sceHttp2CreateCookieBox(int); +int APS5_VABI sceHttp2SetCookieBox(int, int); +int APS5_VABI sceHttp2CookieFlush(int); +int APS5_VABI sceHttp2SetRequestNoContentLength(int); +int APS5_VABI sceHttp2SendRequest(int, const void*, std::size_t); +int APS5_VABI sceHttp2Term(int); +} + +static void Require(bool value) { if (!value) std::abort(); } + +int main() { + const int context = sceHttp2Init(1, 1, 0x10000, 4); + Require(context > 0); + const int box = sceHttp2CreateCookieBox(context); + const int other = sceHttp2CreateCookieBox(context); + Require(box > 0 && other > 0 && box != other && box != context); + const int tmpl = sceHttp2CreateTemplate(context, "agent", 2, 0); + Require(tmpl > 0 && tmpl != box && tmpl != other); + Require(sceHttp2SetCookieBox(tmpl, box) == 0); + Require(sceHttp2SetCookieBox(tmpl, 0) == 0); + const int request = sceHttp2CreateRequestWithURL(tmpl, "POST", "https://example.com/", 16); + Require(request > 0); + Require(sceHttp2SetCookieBox(request, other) == 0); + Require(sceHttp2SetRequestNoContentLength(request) == 0); + Require(sceHttp2CookieFlush(context) == 0); + Require(sceHttp2SendRequest(request, nullptr, 0) == static_cast(0x80436063)); + Require(sceHttp2Term(context) == 0); +} diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index b57c3f774..74f3cd5a0 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -117,6 +117,7 @@ Throughout the project, every function at every stage either **does exactly what - [libSceUlt queues](../../core/libs/prx/libSceUlt/Export.cpp) - the added `sceUltQueuePop`, `sceUltQueueTryPush`, `sceUltQueueDestroy` and `sceUltQueueDataResourcePoolDestroy` signatures are inferred from the existing push/pop and object APIs. Queue destruction is assumed to reject blocked callers with `ULT_ERROR_BUSY` and otherwise discard queued data; pool exhaustion returns `ULT_ERROR_AGAIN`. These rules, alignment checks and shared slot limits have not been confirmed on PS5 hardware or a title. Non-null queue and data-pool option parameters throw because their layouts are unknown. - [_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 - [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 +- [libSceHttp2 cookie boxes](../../core/libs/prx/libSceHttp2/Export.cpp) (libSceHttp2) - `sceHttp2CreateCookieBox` is taken to take the library context id first, as in the [prosper](https://github.com/mattias800/prosper) reimplementation; further arguments are unknown and ignored. `sceHttp2SetRequestNoContentLength` is assumed to take only the request id. Cookies are never stored, so `sceHttp2CookieFlush` has nothing to discard ### Functional From cf0955f277c79b269e7aa4114101c67ab0367d6e Mon Sep 17 00:00:00 2001 From: Chad Date: Tue, 6 Oct 2026 15:13:58 -0500 Subject: [PATCH 2/2] docs: keep the Http2 cookie box entry beside the other libSceHttp2 entries Co-Authored-By: Claude Opus 5.5 --- docs/dev/TechnicalDebt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index ca22769ce..30f70d765 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -112,6 +112,7 @@ Throughout the project, every function at every stage either **does exactly what - [sceHttpUriUnescape](../../core/libs/prx/libSceHttp/src/Uri.cpp) (libSceHttp) - signature follows [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/main/src/SharpProspero/Interop/Net/Http.cs); percent decoding, invalid sequences and error codes follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/network/http.cpp), not confirmed on a PS5 title or hardware. Size includes the final NUL; malformed escapes and `+` remain unchanged, and decoding runs once. - [sceHttpSetResponseHeaderMaxSize, sceHttpRedirectCacheFlush, sceHttpsUnloadCert](../../core/libs/prx/libSceHttp/Export.cpp) (libSceHttp) - signatures follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/network/http.cpp) (PS4); no PS5 reference has them - [sceHttp2GetMemoryPoolStats](../../core/libs/prx/libSceHttp2/Export.cpp) (libSceHttp2) - unknown signature +- [libSceHttp2 cookie boxes](../../core/libs/prx/libSceHttp2/Export.cpp) (libSceHttp2) - `sceHttp2CreateCookieBox` is taken to take the library context id first, as in the [prosper](https://github.com/mattias800/prosper) reimplementation; further arguments are unknown and ignored. `sceHttp2SetRequestNoContentLength` is assumed to take only the request id. Cookies are never stored, so `sceHttp2CookieFlush` has nothing to discard - [sceNetGetMemoryPoolStats](../../core/libs/prx/libSceNet/Export.cpp) (libSceNet) - unknown signature - [sceHttpSetRequestStatusCallback](../../core/libs/prx/libSceHttp/Export.cpp) (libSceHttp) - no reference implements it (shadPS4 only logs and returns 0); when the callback runs and what status it gets is unknown - [sceNpSessionSignalingGetMemoryInfo](../../core/libs/prx/libSceNpSessionSignaling/Export.cpp) (libSceNpSessionSignaling) - unknown signature @@ -132,7 +133,6 @@ Throughout the project, every function at every stage either **does exactly what - [sceAgcDcbSetZPassPredicationEnableGetSize, sceAgcDcbSetPredicationDisableGetSize, sceAgcDcbSetBoolPredicationEnableGetSize](../../core/libs/prx/libSceAgc/DcbState/src/Predication.cpp) (libSceAgc) - the builders are inline in the SDK and not exported; the size is assumed to be that of the SET_PREDICATION packet `sceAgcDcbSetPredication` writes (16 bytes) - [Resource registration](../../core/libs/prx/libSceAgcDriver/Resource/src/Registration.cpp) (libSceAgcDriver) - registration always fails with `RESOURCE_REGISTRATION_UNAVAILABLE`, so the owner and resource queries, `sceAgcDriverSetResourceUserData`, `sceAgcDriverFindResourcesPublic` and `sceAgcDriverUnregisterAllResourcesForOwner` return the same error without reading their arguments. Their parameter lists follow the libSceGnmDriver counterparts and are unverified - [sceNgs2VoiceControl sampler filter](../../core/libs/prx/libSceNgs2.native/src/Voice.cpp) (libSceNgs2.native) - param `0x1000000a`, its layout and meaning follow KytyPS5 only: location 1 type 1 is an RBJ low-pass biquad at the system sample rate after resampling, scaled by `level`, a set `channel_mask` bit bypasses that channel, type 0 turns the filter off. Other locations and types throw. The voice keeps playing a filter tail after its last block until the history is zero, with outputs below 1e-20 flushed to zero (a KytyPS5 choice); the console's tail length is unknown -- [libSceHttp2 cookie boxes](../../core/libs/prx/libSceHttp2/Export.cpp) (libSceHttp2) - `sceHttp2CreateCookieBox` is taken to take the library context id first, as in the [prosper](https://github.com/mattias800/prosper) reimplementation; further arguments are unknown and ignored. `sceHttp2SetRequestNoContentLength` is assumed to take only the request id. Cookies are never stored, so `sceHttp2CookieFlush` has nothing to discard ### Functional