### C code: Install package and monitor status with sceAppInstUtilInstallByPackage and sceAppInstUtilGetInstallStatus Source: https://github.com/aydencharles/onionhen/blob/main/docs/pkg-writeup.md Initializes the App Install Utility, prepares PlayGoInfo and MetaInfo structures, calls sceAppInstUtilInstallByPackage to start installation, then loops on sceAppInstUtilGetInstallStatus until the status becomes 'playable', printing progress and error information. ```cpp int ret = sceAppInstUtilInitialize(); if(ret){ printf("sceAppInstUtilInitialize failed: 0x%08X\n", ret); return -1; } PlayGoInfo arg3; SceAppInstallPkgInfo pkg_info; (void)memset(&arg3, 0, sizeof(arg3)); for (size_t i = 0; i < NUM_LANGUAGES; i++) { strncpy(arg3.languages[i], "", sizeof(arg3.languages[i]) - 1); } for (size_t i = 0; i < NUM_IDS; i++) { strncpy(arg3.playgo_scenario_ids[i], "", sizeof(playgo_scenario_id_t) - 1); strncpy(*arg3.content_ids, "", sizeof(content_id_t) - 1); } MetaInfo in = { .uri = "/path/to/pkg.pkg", .ex_uri = "", .playgo_scenario_id = "", .content_id = "", .content_name = "PKG TITLE", .icon_url = "" }; int num = sceAppInstUtilInstallByPackage(&in, &pkg_info, &arg3); if (num == 0) { puts("Download and Install console Task initiated"); } else { printf("DPI: Install failed with error code %d\n", num); } float prog = 0; SceAppInstallStatusInstalled status; while (strcmp(status.status, "playable") != 0) { sceAppInstUtilGetInstallStatus(pkg_info.content_id, &status); if (status.total_size != 0) { prog = ((float)status.downloaded_size / status.total_size) * 100.0f; } printf("DPI: Status: %s | error: %d | progress %.2f%% (%llu/%llu)\n", status.status, status.error_info.error_code, prog, status.downloaded_size, status.total_size); } ``` -------------------------------- ### ExecuteInstall and OnUpdate methods for PKG installation Source: https://github.com/aydencharles/onionhen/blob/main/docs/pkg-writeup.md C# implementation of the ExecuteInstall and OnUpdate methods from the PS5 ShellUI component. ExecuteInstall initiates the package installation via AppInstUtilInstallByPackage and starts a timer to poll status. OnUpdate checks installation status, updates the progress bar, and handles success or error conditions. These functions are part of the reverse-engineered PKG installer and cannot be called directly via conventional mono method calls. ```csharp private Task ExecuteInstall() { return Task.Run(delegate() { this.Lock(); AppInstUtilWrapper.SceAppInstallPkgInfo sceAppInstallPkgInfo = default(AppInstUtilWrapper.SceAppInstallPkgInfo); string[] array = new string[30]; string[] array2 = new string[64]; string[] array3 = new string[64]; for (int i = 0; i < array.Length; i++) { array[i] = ""; } for (int j = 0; j < array2.Length; j++) { array2[j] = ""; } for (int k = 0; k < array3.Length; k++) { array3[k] = ""; } int num = AppInstUtilWrapper.AppInstUtilInstallByPackage(this.mTargetList[this.mInstallIndex], "", "", "", "", "", 0U, false, ref sceAppInstallPkgInfo, array, array2, array3); if (num == 0) { this.mTimer = new UITimer(0.1f, true); UITimer uitimer = this.mTimer; uitimer.Executed = (UITimer.ExecutedHandler)Delegate.Combine(uitimer.Executed, new UITimer.ExecutedHandler(this.OnUpdate)); this.mTimer.Start(); } else { this.Unlock(); } return num; }); } private bool OnUpdate() { ShellCoreUtilWrapper.sceShellCoreUtilResetAutoPowerDownTimer(); AppInstUtilWrapper.SceAppInstallStatusInstalled sceAppInstallStatusInstalled = default(AppInstUtilWrapper.SceAppInstallStatusInstalled); int num = AppInstUtilWrapper.AppInstUtilGetInstallStatus(this.mContentId, ref sceAppInstallStatusInstalled); if (num == 0) { if (sceAppInstallStatusInstalled.total_size != 0UL) { this.mProgressBar.Progress = sceAppInstallStatusInstalled.downloaded_size / sceAppInstallStatusInstalled.total_size; } if (sceAppInstallStatusInstalled.status == "playable" || sceAppInstallStatusInstalled.status == "error" || sceAppInstallStatusInstalled.status == "none") { this.Unlock(); this.mTimer.Stop(); if (sceAppInstallStatusInstalled.status == "error" || sceAppInstallStatusInstalled.status == "none") { int error_code = sceAppInstallStatusInstalled.error_info.error_code; this.ShowError(error_code); return false; } this.Next(); } return false; } this.Unlock(); this.mTimer.Stop(); this.ShowErrorDialog(num); return false; } ``` -------------------------------- ### Initialize AppInstUtil and install package with sceAppInstUtilInstallByPackage Source: https://github.com/aydencharles/onionhen/blob/main/docs/pkg-writeup.md Initializes the AppInstUtil module by loading libSceAppInstUtil.sprx and calling sceAppInstUtilInitialize. Then installs a package using sceAppInstUtilInstallByPackage, checking for success and returning errors on failure. The initialization is mandatory and improper initialization can cause crashes. ```cpp int(*sceAppInstUtilInstallByPackage)(MetaInfo* arg1, SceAppInstallPkgInfo* pkg_info, PlayGoInfo* arg2) = nullptr; extern bool sceAppInst_done; int app_inst_module_id = -1; bool app_inst_util_init(int &m_id) { int ret; if (sceAppInst_done) { m_id = app_inst_module_id; return true; } int lib_appinstutil = sceKernelLoadStartModule("/system/common/lib/libSceAppInstUtil.sprx", 0, NULL, 0, NULL, NULL); if (lib_appinstutil < 0) { return PKG_ERROR("AppInstUtil System Module failed to load.", lib_appinstutil); } m_id = app_inst_module_id = lib_appinstutil; ret = sceAppInstUtilInitialize(); if (ret) { log_debug("sceAppInstUtilInitialize failed: 0x%08X", ret); goto err; } sceAppInst_done = true; return true; err: log_error("error inilizing appinstlutil"); sceAppInst_done = false; m_id = -1; return false; } int pkginstall(const char* fullpath, const char* filename) { int lib_appinstutil = -1; if (!if_exists(fullpath)) { return PKG_ERROR("PKG Doesnt exist", -1); } log_info("Initializing AppInstUtil..."); if (!app_inst_util_init(lib_appinstutil)) return PKG_ERROR("AppInstUtil", 1337); log_info("AppInstUtil Initialized..."); sceAppInstUtilInstallByPackage = (int(*)(MetaInfo*, SceAppInstallPkgInfo*, PlayGoInfo*)) LOAD_FUNCTION_AND_CHECK(lib_appinstutil, "sceAppInstUtilInstallByPackage"); PlayGoInfo arg3; SceAppInstallPkgInfo pkg_info; memset(&arg3, 0, sizeof(arg3)); for (size_t i = 0; i < NUM_LANGUAGES; i++) { strncpy(arg3.languages[i], "", sizeof(language_t) - 1); } for (size_t i = 0; i < NUM_IDS; i++) { strncpy(arg3.playgo_scenario_ids[i], "", sizeof(playgo_scenario_id_t) - 1); strncpy(*arg3.content_ids, "", sizeof(content_id_t) - 1); } MetaInfo arg1 = (MetaInfo){ .uri = fullpath, .ex_uri = "", .playgo_scenario_id = "", .content_id = "", .content_name = filename, .icon_url = "" }; int num = sceAppInstUtilInstallByPackage(&arg1, &pkg_info, &arg3); if (num == 0) { log_info("install successful"); } else { log_info("install failed"); return PKG_ERROR("install_pkg", num); } log_info("%s(%s) done.", __FUNCTION__, fullpath); return 0; } ``` -------------------------------- ### sceAppInstUtilGetInstallStatus Source: https://github.com/aydencharles/onionhen/blob/main/docs/pkg-writeup.md Retrieves the installation status for a given content ID and populates the provided status structure with installation metrics such as remaining time, downloaded size, and progress. ```APIDOC ## sceAppInstUtilGetInstallStatus ### Description Retrieves the installation status for a given content ID and populates the provided status structure with installation metrics such as remaining time, downloaded size, and progress. ### Method C/C++ Function ### Signature int sceAppInstUtilGetInstallStatus(const char* content_id, SceAppInstallStatusInstalled* status); ### Parameters - **content_id** (const char*) - Required - The content ID of the installation to query. - **status** (SceAppInstallStatusInstalled*) - Required - Pointer to a structure that will receive the installation status. ### Return Value - **int** - Returns an error code (0 on success, non-zero on failure). ### Data Structures #### SceAppInstallStatusInstalled - **status** (char[16]) - Installation status string. - **src_type** (char[8]) - Source type string. - **remain_time** (uint32_t) - Remaining time in seconds. - **downloaded_size** (uint64_t) - Downloaded size in bytes. - **initial_chunk_size** (uint64_t) - Initial chunk size in bytes. - **total_size** (uint64_t) - Total size in bytes. - **promote_progress** (uint32_t) - Promotion progress percentage. - **error_info** (SceAppInstallErrorInfo) - Error information structure. - **local_copy_percent** (int32_t) - Local copy percentage. - **is_copy_only** (bool) - Indicates if the installation is copy-only. #### SceAppInstallErrorInfo - **error_code** (int32_t) - Error code. - **version** (int32_t) - Version. - **description** (char[512]) - Error description. - **type** (char[9]) - Error type. ### Example ```cpp SceAppInstallStatusInstalled status; int result = sceAppInstUtilGetInstallStatus("content_id_here", &status); if (result == 0) { // Use status fields } ``` ``` -------------------------------- ### Runtime startup chain: OnionHEN.elf to SceShellUI Source: https://github.com/aydencharles/onionhen/blob/main/CONTRIBUTING.md Shows the serial startup order of the runtime. The first hop still needs an external elfldr on 9021; after that, user payloads and internal ELFs go through the private loader on 9020. Startup is serial on purpose: util, then kstuff, then daemon — do not start those three in parallel. ```text OnionHEN.elf (unpacker) → bootstrapper.elf → onion_elfldr.elf :9020 → util.elf → kstuff.elf → daemon.elf → inject shellui.elf into SceShellUI ``` -------------------------------- ### SprxCatalog INI manifest example Source: https://github.com/aydencharles/onionhen/blob/main/docs/sprx-catalog.md Example manifest for the SprxCatalog INI format. Each plugin is defined in a [plugin.] section with an absolute path, optional exact_title_ids or title_id_prefixes allowlists, optional auto_start, priority, and dependencies. The example shows a base-runtime plugin, an overlay plugin that depends on it, and a native plugin using a title ID prefix. ```ini [plugin.base-runtime] path=/data/OnionHEN/sprx/base-runtime.sprx exact_title_ids=CUSA12345,CUSA67890 priority=10 [plugin.overlay] path=/data/OnionHEN/sprx/overlay.sprx exact_title_ids=CUSA12345 auto_start=true priority=100 dependencies=base-runtime [plugin.native] path=/data/OnionHEN/sprx/native.prx title_id_prefixes=PPSA auto_start=true ``` -------------------------------- ### C/C++ structures and function signature for sceAppInstUtilGetInstallStatus Source: https://github.com/aydencharles/onionhen/blob/main/docs/pkg-writeup.md Defines SceAppInstallErrorInfo and SceAppInstallStatusInstalled structures, and the sceAppInstUtilGetInstallStatus function signature. The function accepts a content ID and populates the status structure with installation metrics. Content ID can be extracted from PKG metadata or obtained programmatically. ```cpp typedef struct { int32_t error_code; int32_t version; char description[512]; char type[9]; } SceAppInstallErrorInfo; typedef struct { char status[16]; char src_type[8]; uint32_t remain_time; uint64_t downloaded_size; uint64_t initial_chunk_size; uint64_t total_size; uint32_t promote_progress; SceAppInstallErrorInfo error_info; int32_t local_copy_percent; bool is_copy_only; } SceAppInstallStatusInstalled; int sceAppInstUtilGetInstallStatus(const char* content_id, SceAppInstallStatusInstalled* status); ``` -------------------------------- ### sceAppInstUtilInstallByPackage Source: https://github.com/aydencharles/onionhen/blob/main/docs/pkg-writeup.md Installs a package using the sceAppInstUtilInstallByPackage function. The function returns an AppInstErrorCodes value indicating success or failure. ```APIDOC ## sceAppInstUtilInstallByPackage ### Description Installs a package using the sceAppInstUtilInstallByPackage function. The function returns an AppInstErrorCodes value indicating success or failure. ### Method C/C++ Function ### Endpoint sceAppInstUtilInstallByPackage ### Parameters None documented. ### Request Example No request example provided. ### Response #### Success Response - **SCE_APP_INSTALLER_ERROR_UNKNOWN** (enum) - Unknown error. - **SCE_APP_INSTALLER_ERROR_NOSPACE** (enum) - No space available. - **SCE_APP_INSTALLER_ERROR_PARAM** (enum) - Invalid parameter. - **SCE_APP_INSTALLER_ERROR_APP_NOT_FOUND** (enum) - Application not found. - **SCE_APP_INSTALLER_ERROR_DISC_NOT_INSERTED** (enum) - Disc not inserted. - **SCE_APP_INSTALLER_ERROR_PKG_INVALID_DRM_TYPE** (enum) - Invalid DRM type. - **SCE_APP_INSTALLER_ERROR_OUT_OF_MEMORY** (enum) - Out of memory. - **SCE_APP_INSTALLER_ERROR_APP_BROKEN** (enum) - Application broken. - **SCE_APP_INSTALLER_ERROR_PKG_INVALID_CONTENT_TYPE** (enum) - Invalid content type. - **SCE_APP_INSTALLER_ERROR_USED_APP_NOT_FOUND** (enum) - Used application not found. - **SCE_APP_INSTALLER_ERROR_ADDCONT_BROKEN** (enum) - Add-on content broken. - **SCE_APP_INSTALLER_ERROR_APP_IS_RUNNING** (enum) - Application is running. - **SCE_APP_INSTALLER_ERROR_SYSTEM_VERSION** (enum) - System version error. - **SCE_APP_INSTALLER_ERROR_NOT_INSTALL** (enum) - Not installed. - **SCE_APP_INSTALLER_ERROR_CONTENT_ID_DISAGREE** (enum) - Content ID disagreement. - **SCE_APP_INSTALLER_ERROR_NOSPACE_KERNEL** (enum) - No space in kernel. - **SCE_APP_INSTALLER_ERROR_APP_VER** (enum) - Application version error. - **SCE_APP_INSTALLER_ERROR_DB_DISABLE** (enum) - Database disabled. - **SCE_APP_INSTALLER_ERROR_CANCELED** (enum) - Operation canceled. - **SCE_APP_INSTALLER_ERROR_ENTRYDIGEST** (enum) - Entry digest error. - **SCE_APP_INSTALLER_ERROR_BUSY** (enum) - Busy. - **SCE_APP_INSTALLER_ERROR_DLAPP_ALREADY_INSTALLED** (enum) - Downloadable application already installed. - **SCE_APP_INSTALLER_ERROR_NEED_ADDCONT_INSTALL** (enum) - Need add-on content installation. - **SCE_APP_INSTALLER_ERROR_APP_MOUNTED_BY_HOST_TOOL** (enum) - Application mounted by host tool. - **SCE_APP_INSTALLER_ERROR_INVALID_PATCH_PKG** (enum) - Invalid patch package. - **SCE_APP_INSTALLER_ERROR_NEED_ADDCONT_INSTALL_NO_CHANGE_TYPE** (enum) - Need add-on content installation with no change type. - **SCE_APP_INSTALLER_ERROR_ADDCONT_IS_INSTALLING** (enum) - Add-on content is installing. - **SCE_APP_INSTALLER_ERROR_ADDCONT_ALREADY_INSTALLED** (enum) - Add-on content already installed. - **SCE_APP_INSTALLER_ERROR_CANNOT_READ_DISC** (enum) - Cannot read disc. - **SCE_APP_INSTALLER_ERROR_DATA_DISC_NOT_INSTALLED** (enum) - Data disc not installed. - **SCE_APP_INSTALLER_ERROR_NOT_TRANSFER_DISC_VERSION** (enum) - Not transfer disc version. - **SCE_APP_INSTALLER_ERROR_NO_SLOT_SPACE** (enum) - No slot space. - **SCE_APP_INSTALLER_ERROR_NO_SLOT_INFORMATION** (enum) - No slot information. - **SCE_APP_INSTALLER_ERROR_INSTALL_MAIN_MISSING** (enum) - Install main missing. - **SCE_APP_INSTALLER_ERROR_INSTALL_TIME_VALID_IN_FUTURE** (enum) - Install time valid in future. - **SCE_APP_INSTALLER_ERROR_SYSTEM_FILE_DISAGREE** (enum) - System file disagreement. - **SCE_APP_INSTALLER_ERROR_INSTALL_BLANK_SLOT** (enum) - Install blank slot. - **SCE_APP_INSTALLER_ERROR_INSTALL_LINK_SLOT** (enum) - Install link slot. - **SCE_APP_INSTALLER_ERROR_INSTALL_PKG_NOT_COMPLETED** (enum) - Install package not completed. - **SCE_APP_INSTALLER_ERROR_NOSPACE_IN_EXTERNAL_HDD** (enum) - No space in external HDD. - **SCE_APP_INSTALLER_ERROR_NOSPACE_KERNEL_IN_EXTERNAL_HDD** (enum) - No space in kernel in external HDD. - **SCE_APP_INSTALLER_ERROR_COMPILATION_DISC_INSERTED** (enum) - Compilation disc inserted. - **SCE_APP_INSTALLER_ERROR_COMPILATION_DISC_INSERTED_NOT_VISIBLE_DISC_ICON** (enum) - Compilation disc inserted not visible disc icon. - **SCE_APP_INSTALLER_ERROR_ACCESS_FAILED_IN_EXTERNAL_HDD** (enum) - Access failed in external HDD. - **SCE_APP_INSTALLER_ERROR_MOVE_FAILED_SOME_APPLICATIONS** (enum) - Move failed some applications. - **SCE_APP_INSTALLER_ERROR_DUPLICATION** (enum) - Duplication error. - **SCE_APP_INSTALLER_ERROR_INVALID_STATE** (enum) - Invalid state. - **SCE_APP_INSTALLER_ERROR_NOSPACE_DISC** (enum) - No space on disc. - **SCE_APP_INSTALLER_ERROR_NOSPACE_DISC_IN_EXTERNAL_HDD** (enum) - No space on disc in external HDD. - **SCE_APP_INST_UTIL_ERROR_NOT_INITIALIZED** (enum) - Utility not initialized. - **SCE_APP_INST_UTIL_ERROR_OUT_OF_MEMORY** (enum) - Utility out of memory. #### Response Example No response example provided. ``` -------------------------------- ### Initialize submodules and sync dependencies Source: https://github.com/aydencharles/onionhen/blob/main/third_party/README.md Commands to set up the project's dependencies: first, initialize and update all git submodules recursively, then run the dependency sync script to stage required bootstrapper input from the cache. ```bash git submodule update --init --recursive ./scripts/sync_dependencies.sh ``` -------------------------------- ### Load SPRX module with SprxLoader Source: https://github.com/aydencharles/onionhen/blob/main/docs/sprx-loader.md Shows how to construct a SprxLoader with a PtraceSprxRuntime, a NoopTargetAccessPolicy, and a TitleIdAllowlist, then load a module by PID and path. The target must resolve the required NIDs and access the path; for sandboxed games, apply jailbreak/privilege policy beforehand. ```cpp #include onion::sprx::PtraceSprxRuntime runtime; onion::sprx::NoopTargetAccessPolicy access; onion::sprx::TitleIdAllowlist allowlist; allowlist.add_exact("CUSA12345"); onion::sprx::SprxLoader loader(runtime, access, allowlist); const auto result = loader.load({ .pid = game_pid, .path = "/data/plugins/example.sprx", .options = {.timeout_ms = 5000, .poll_ms = 10}, }); if (!result.succeeded()) { // load_status_name(result.status), result.remote_result } ``` -------------------------------- ### Manual CMake build with ps5_cmake.sh Source: https://github.com/aydencharles/onionhen/blob/main/source/README.md Alternative manual CMake build: configure with the PS5 cmake helper and then build with CMake. Build products go under build/bin and build/lib at the repo root. ```bash ./scripts/ps5_cmake.sh -S source -B build -G Ninja cmake --build build ``` -------------------------------- ### Initialize submodules and run full build with PS5 Payload SDK Source: https://github.com/aydencharles/onionhen/blob/main/README.md Initializes Git submodules, sets the PS5_PAYLOAD_SDK environment variable, and runs the build script with 8 jobs. The script configures the project, fetches external dependencies, and builds the embed chain in the required order. ```shell git submodule update --init --recursive export PS5_PAYLOAD_SDK=/path/to/ps5-payload-sdk ./scripts/build.sh --jobs 8 ``` -------------------------------- ### Run host tests with make test Source: https://github.com/aydencharles/onionhen/blob/main/source/util/tests/README.md Run the host unit tests from the source/util/tests directory. Requires host clang/c++ (or set HOST_CC/HOST_CXX) and Keystone (default /opt/homebrew, override with KEYSTONE_PREFIX). ```bash cd source/util/tests make test ``` -------------------------------- ### Full build pipeline with ./scripts/build.sh Source: https://github.com/aydencharles/onionhen/blob/main/source/README.md Use this to run the full build pipeline from the repo root. It stages external embeds and then builds shellui, daemon/util, bootstrapper, and unpacker. The SDK path must point to a Prospero / PS5 payload SDK. ```bash export PS5_PAYLOAD_SDK=/path/to/ps5-payload-sdk ./scripts/build.sh ``` -------------------------------- ### Add sources, dependencies, include dirs, and link libraries Source: https://github.com/aydencharles/onionhen/blob/main/source/shellui/CMakeLists.txt Adds the globbed sources to the shellui target, declares dependencies on OnionHEN modules, sets include directories for internal and third-party headers, links against OnionHEN libraries and PS5 system libraries, and adds a post-build strip step. ```cmake target_sources(${PROJECT_NAME} PRIVATE ${SrcFiles}) add_dependencies(${PROJECT_NAME} shellui_i18n_catalog onion_version onion_ipc onion_settings onion_detour onion_proc onion_platform onion_ready onion_plugin_ui onion_plugin_bridge) onion_target_debug_define(${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE "${D_CWD}/include" "${I18N_GENERATED_DIR}" "${ONIONHEN_THIRD_PARTY_DIR}/cjson" "${ONIONHEN_THIRD_PARTY_DIR}/sha1" "${PROJECT_ROOT}/libonion_ipc/include" "${PROJECT_ROOT}/libonion_settings/include" "${PROJECT_ROOT}/libonion_detour/include" "${PROJECT_ROOT}/libonion_proc/include" "${PROJECT_ROOT}/libonion_platform/include" "${PROJECT_ROOT}/libonion_fps/include" "${PROJECT_ROOT}/libonion_plugin_ui/include" "${PROJECT_ROOT}/libonion_plugin_bridge/include" "${PROJECT_ROOT}/include" ) target_link_directories (${PROJECT_NAME} PUBLIC "${ONIONHEN_PS5_STUB_DIR}") target_link_libraries (${PROJECT_NAME} PUBLIC onion_payload onion_detour onion_proc onion_platform onion_ipc onion_settings onion_ready onion_plugin_ui onion_plugin_bridge SceRegMgr SceSystemService SceUserService SceNetCtl) # Add post-build command onion_strip_debug(${PROJECT_NAME}) ``` -------------------------------- ### Reconstructed struct definitions and function signature for sceAppInstUtilInstallByPackage Source: https://github.com/aydencharles/onionhen/blob/main/docs/pkg-writeup.md Header definitions derived from the decompiled implementation, showing the three struct parameters: MetaInfo, SceAppInstallPkgInfo, and PlayGoInfo. The function signature is declared with these structs. Note the comment about Sony's memory usage. ```cpp #define PLAYGOSCENARIOID_SIZE 3 #define CONTENTID_SIZE 0x30 #define LANGUAGE_SIZE 8 #define NUM_LANGUAGES 30 #define NUM_IDS 64 typedef char playgo_scenario_id_t[PLAYGOSCENARIOID_SIZE]; typedef char language_t[LANGUAGE_SIZE]; typedef char content_id_t[CONTENTID_SIZE]; typedef struct { content_id_t content_id; int content_type; int content_platform; } SceAppInstallPkgInfo; typedef struct { const char* uri; const char* ex_uri; const char* playgo_scenario_id; const char* content_id; const char* content_name; const char* icon_url; } MetaInfo; typedef struct { language_t languages[NUM_LANGUAGES]; playgo_scenario_id_t playgo_scenario_ids[NUM_IDS]; content_id_t content_ids[NUM_IDS]; unsigned char unknown[6480]; // standard sony practice of wasting memory? } PlayGoInfo; sceAppInstUtilInstallByPackage(MetaInfo* arg1, SceAppInstallPkgInfo* pkg_info, PlayGoInfo* arg2); ``` -------------------------------- ### Reproducible Docker build with docker compose Source: https://github.com/aydencharles/onionhen/blob/main/README.md Builds the onionhen image and runs the build inside a disposable container. Requires Docker and the compose file in the repository root. ```shell docker compose build onionhen-build docker compose run --rm onionhen-build ``` -------------------------------- ### Run host tests with verbose output Source: https://github.com/aydencharles/onionhen/blob/main/source/util/tests/README.md Optional: enable extra klog-style noise on stderr with ONION_TEST_VERBOSE=1. Also shows how to clean and rebuild. ```bash ONION_TEST_VERBOSE=1 make test # extra klog-style noise on stderr make clean && make test ``` -------------------------------- ### Set compiler flags and source files Source: https://github.com/aydencharles/onionhen/blob/main/source/shellui/CMakeLists.txt Globs source files from src and include directories plus third-party cjson files, then sets C and C++ flags including warnings, PIC/PIE, and release optimizations. Uses ONION_PS5_TARGET_FLAGS and ONIONHEN_THIRD_PARTY_DIR. ```cmake file(GLOB SrcFiles CONFIGURE_DEPENDS ${D_SRC}/*.c ${D_SRC}/*.cpp ${D_SRC}/../include/*.h ${D_SRC}/../include/*.hpp ${D_SRC}/*.s ${ONIONHEN_THIRD_PARTY_DIR}/cjson/*.cpp ${ONIONHEN_THIRD_PARTY_DIR}/cjson/*.hpp) set(CMAKE_C_FLAGS "${ONION_PS5_TARGET_FLAGS} ") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-nested-anon-types -Wno-gnu-anonymous-struct -Wno-zero-length-array -Wno-keyword-macro -fPIC -fPIE -march=znver2 -Wall -Werror -fstack-protector-all -ffunction-sections -fdata-sections") set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -gfull -gdwarf-2 -pedantic -pedantic-errors") set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") ``` -------------------------------- ### CMake configuration for shellui executable Source: https://github.com/aydencharles/onionhen/blob/main/source/shellui/CMakeLists.txt Sets up the shellui executable with C11/C++20 standards, output name, compile and link options, and an option to disable the HomeUI top-nav patch. Requires CMake 3.20 and uses OnionHEN helper functions. ```cmake cmake_minimum_required (VERSION 3.20) set(basename "shellui") project(${basename} C CXX ASM) onion_module_prologue(C_STANDARD 11 CXX_STANDARD 20) set(D_CWD "${CMAKE_CURRENT_SOURCE_DIR}") onion_output_dirs() set(D_SRC ${D_CWD}/src) add_executable(${PROJECT_NAME}) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}.elf") # Finalize main target sources target_compile_options(${PROJECT_NAME} PUBLIC $<$:${C_DEFS} ${C_FLAGS}> $<$:${CXX_DEFS} ${CXX_FLAGS}> $<$:${ASM_FLAGS}> ) target_link_options(${PROJECT_NAME} PRIVATE "-Wl,--gc-sections" "-Wl,--icf=safe") # A/B: disable HomeUI top-nav Hermes patch without editing sources. # cmake -DONIONHEN_SHELLUI_HOMEUI_TOP_NAV_PATCH=OFF ... option(ONIONHEN_SHELLUI_HOMEUI_TOP_NAV_PATCH "Patch HomeUI top-nav Fps slot into OnionHEN entry" ON) if(NOT ONIONHEN_SHELLUI_HOMEUI_TOP_NAV_PATCH) target_compile_definitions(${PROJECT_NAME} PRIVATE SHELLUI_HOMEUI_TOP_NAV_PATCH=0) message(STATUS "shellui: HomeUI top-nav patch DISABLED") endif() ``` -------------------------------- ### Decompiled BGFT download function returning SCE_BGFT_ERROR_NOT_SUPPORTED Source: https://github.com/aydencharles/onionhen/blob/main/docs/pkg-writeup.md Shows the decompiled PS5 shellcore function that handles package download registration. It checks the session and auth ID, then calls DownloadRegisterTaskByStorageEx, which always prints an error and returns 0x80990006, confirming BGFT is unsupported on PS5. ```cpp uint FUN_0100ee70(Session *session,int user_id,int entitlement_type,char *id,char *package_type, char *package_sub_type,char *content_url,char *content_name,char *icon_path, char *sku_id,char *playgo_scenario_id,char *release_date,size_t package_size, bgft_task_option_t options,uint slot,void *result) { undefined auVar1 [32]; long lVar2; pid_t pid; uint uVar3; uint uVar4; bgft_download_param args; lVar2 = __stack_chk_guard; if (session == NULL) { uVar4 = 0x80990050; } else { pid = (*session->_vptr->getClientPid)(session); uVar3 = check_authid(pid); uVar4 = 0x80990007; if (uVar3 == 1) { args._60_4_ = 0; args.content_url = content_url; auVar1._8_8_ = icon_path; auVar1._0_8_ = content_name; auVar1._16_8_ = sku_id; auVar1._24_8_ = 0; args._24_32_ = auVar1 << 0x40; args.options = options; args.playgo_scenario_id = playgo_scenario_id; args.release_date = release_date; args.package_size = package_size; args.user_id = user_id; args.entitlement_type = entitlement_type; args.id = id; args.package_type = package_type; args.package_sub_type = package_sub_type; uVar4 = DownloadRegisterTaskByStorageEx(&args,result); } } if (__stack_chk_guard == lVar2) { return uVar4; } __stack_chk_fail(); } uint DownloadRegisterTaskByStorageEx(bgft_download_param *param_1,void *param_2) { printf("[BGFT] ERROR: [%d] ",0x18); puts("NOT SUPPORTED API"); return 0x80990006; } ``` -------------------------------- ### Declare compressed payload outputs and add custom command Source: https://github.com/aydencharles/onionhen/blob/main/source/bootstrapper/CMakeLists.txt Sets variables for the LZMA, size, and SHA1 files, then adds a custom command that runs pack_bootstrapper.sh with the target ELF path. The command depends on the project target and produces the three output files. A custom target _packed depends on these outputs to ensure they are built. ```cmake set(_bootstrapper_lzma "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bootstrapper.elf.lzma") set(_bootstrapper_lzma_size "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bootstrapper.elf.lzma.size") set(_bootstrapper_sha1 "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bootstrapper.elf.sha1") add_custom_command( OUTPUT "${_bootstrapper_lzma}" "${_bootstrapper_lzma_size}" "${_bootstrapper_sha1}" COMMAND ${CMAKE_COMMAND} -E env "TARGET_ELF=$" ${PROJECT_ROOT}/../scripts/pack_bootstrapper.sh DEPENDS ${PROJECT_NAME} COMMENT "Packing bootstrapper (lzma + size + sha1 of uncompressed ELF)" VERBATIM ) add_custom_target(${PROJECT_NAME}_packed DEPENDS "${_bootstrapper_lzma}" "${_bootstrapper_lzma_size}" "${_bootstrapper_sha1}") add_dependencies(${PROJECT_NAME}_packed ${PROJECT_NAME}) ``` -------------------------------- ### Host tests command Source: https://github.com/aydencharles/onionhen/blob/main/source/util/source/cheats/README.md Runs the host tests for cheat parsers and utilities, requiring no PS5 SDK. ```bash cd source/util/tests && make test ``` -------------------------------- ### Generate i18n catalog from JSON locales Source: https://github.com/aydencharles/onionhen/blob/main/source/shellui/CMakeLists.txt Adds a custom command that runs generate_catalog.py to produce toolbox_i18n_catalog.inc from JSON locale files in the i18n directory. Requires Python3 and creates a custom target shellui_i18n_catalog. ```cmake find_package(Python3 REQUIRED COMPONENTS Interpreter) set(I18N_DIR "${D_CWD}/../i18n") set(I18N_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") set(I18N_CATALOG "${I18N_GENERATED_DIR}/toolbox_i18n_catalog.inc") file(GLOB I18N_LOCALE_JSON CONFIGURE_DEPENDS "${I18N_DIR}/*.json") add_custom_command( OUTPUT "${I18N_CATALOG}" COMMAND "${Python3_EXECUTABLE}" "${I18N_DIR}/generate_catalog.py" --locales-dir "${I18N_DIR}" --catalog toolbox --output "${I18N_CATALOG}" DEPENDS "${I18N_DIR}/generate_catalog.py" ${I18N_LOCALE_JSON} COMMENT "Generating toolbox i18n catalog" VERBATIM ) add_custom_target(shellui_i18n_catalog DEPENDS "${I18N_CATALOG}") ``` -------------------------------- ### Formats / paths pattern Source: https://github.com/aydencharles/onionhen/blob/main/source/util/source/cheats/README.md Shows the file path pattern for cheat files, with optional process and source ID components. ```text /data/OnionHEN/cheats/_[_][_].{json,shn,mc4,ShnExt} ``` -------------------------------- ### IPC 通信拓扑图 Source: https://github.com/aydencharles/onionhen/blob/main/docs/arch.md 展示 shellui 与 homebrew 通过 Unix domain socket 连接 daemon 和 util 服务,以及 homebrew 通过沙盒文件触发 SceSysCore 事件。 ```text shellui / homebrew │ Unix domain socket ├─► /system_tmp/onionhen/ipc/crit_service (daemon, 0x9xxxxxxx) └─► /system_tmp/onionhen/ipc/util_service (util, 0x8xxxxxxx) homebrew (app jailbreak) └─► sandbox file …/download0/etahen_jailbreak|onionhen_jailbreak (SceSysCore 进程事件触发 Running Big App 补扫 + 沙盒 vnode + 白名单 TID) ``` -------------------------------- ### Architecture diagram (IPC / main) Source: https://github.com/aydencharles/onionhen/blob/main/source/util/source/cheats/README.md Shows the component hierarchy for the main cheat service, including CheatService, CheatRepository, CheatParserFactory, CheatApplier, and memory backends. ```text IPC / main └─ onion::cheats::CheatService # Facade + mutex + hot-reload state ├─ CheatRepository # path resolve, load, flatten │ └─ CheatParserFactory # Strategy by extension │ ├─ JsonCheatParser │ ├─ XmlCheatParser (.shn) │ ├─ Mc4CheatParser │ └─ ShnExtCheatParser → C ├─ CheatApplier # apply patches │ └─ IMemoryBackend (Strategy) │ ├─ MdbgMemoryBackend │ └─ KdirectMemoryBackend # MemoryBackendFactory └─ C helpers # utils / ShnExt crypto / flatten IPC DOWNLOAD_CHEATS └─ onion::cheats::sync::CheatSyncService ├─ CheatCatalogRegistry / ICheatCatalog ├─ CheatMirrorFactory / ICheatMirror ├─ IHttpTransport + miniz archive extractor └─ CheatRepository::flattenInstallTree # reuse ``` -------------------------------- ### Cheat IPC sequence diagram (ShellUI to game) Source: https://github.com/aydencharles/onionhen/blob/main/docs/util_arch/README.md ASCII sequence diagram showing the flow of cheat-related IPC commands from ShellUI to the util daemon and then to the target game process. Includes GET_GAME_VER, GET_GAME_CHEAT, and TOGGLE_CHEAT steps. ```text ShellUI │ GET_GAME_VER(tid) ▼ util handleIPC ──► param.json / sfo ──► version 字符串 │ │ GET_GAME_CHEAT(mode, tid, version, [pid, appid, process, generation]) ▼ cheat_service_export_list │ Browse: title/version; Runtime: title/version/process + source identity │ load + parse → 写带请求 ID 的 /user/data/OnionHEN/_cheats_* 文件 ▼ ShellUI 读列表 JSON;只有 Runtime 响应可切换 │ │ TOGGLE_CHEAT(session_id, cheat_key, enabled) ▼ cheat_service_toggle │ 校验 session_id、稳定 CheatKey 和文件签名 → onion_toggle_cheat ▼ cheat_engine_runtime │ util_find_module → base │ remote_ops(fw):mdbg | kdirect ▼ 目标游戏进程内存 ``` -------------------------------- ### Send notifications with catalog keys (onion_notify, onion_notify_rich) Source: https://github.com/aydencharles/onionhen/blob/main/source/i18n/README.md Use when triggering notifications from C code. Pass a stable catalog key rather than raw English text; unknown keys display unchanged or as a debug %s passthrough. The first argument controls notification suppression, and variable arguments appear after the key. Placeholders must match exactly across languages. ```c onion_notify(true, "notify.fan.open_failed"); onion_notify(true, "notify.payload.loading", name); onion_notify_rich("notify.brand", "notify.boot.starting", ...); ``` -------------------------------- ### Add post-build command: onion_strip_debug Source: https://github.com/aydencharles/onionhen/blob/main/source/bootstrapper/CMakeLists.txt Invokes the onion_strip_debug function on the current project to strip debug information from the built ELF. This is a post-build step that modifies the target output. ```cmake onion_strip_debug(${PROJECT_NAME}) ``` -------------------------------- ### Decompiled native function UndefinedFunction_001b8aa0 Source: https://github.com/aydencharles/onionhen/blob/main/docs/pkg-writeup.md Decompiled C/C++ implementation of the native function that mono wrappers invoke. It reveals the true parameter structure and count, including three struct parameters. The function performs memory operations and calls InstallByPackage with the prepared data. ```cpp void UndefinedFunction_001b8aa0 (long param_1,long param_2,long param_3,long param_4,long param_5,long param_6, undefined4 param_7,byte param_8,long param_9,long param_10,long param_11, long param_12) { undefined auVar1 [16]; long lVar2; undefined *puVar3; undefined *puVar4; undefined in_YMM0 [32]; long lStack10144; long lStack10136; long lStack10128; long lStack10120; long lStack10112; long lStack10104; undefined4 uStack10096; uint uStack10092; undefined auStack10080 [240]; undefined auStack9840 [192]; undefined auStack9648 [9552]; long lStack96; lStack96 = f7uOxY9mM1U#1#u; if ((((((param_1 != 0) && (param_2 != 0)) && (param_3 != 0)) && ((param_4 != 0 && (param_5 != 0)) ) ) && ((param_6 != 0 && ((param_9 != 0 && (param_10 != 0)))))) && ((param_11 != 0 && (param_12 != 0)))) { auVar1 = vxorps_avx(SUB3216(in_YMM0,0),SUB3216(in_YMM0,0)); uStack10096 = param_7; uStack10092 = (uint)param_8; lVar2 = 0; lStack10144 = param_1; lStack10136 = param_2; lStack10128 = param_3; lStack10120 = param_4; lStack10112 = param_5; lStack10104 = param_6; memset(SUB168(auVar1,0),auStack10080,0,0x2700); do { strncpy(auStack10080 + lVar2,*(undefined8 *)(param_10 + lVar2),7); lVar2 = lVar2 + 8; } while (lVar2 != 0xf0); puVar4 = auStack9840; puVar3 = auStack9648; lVar2 = 0; do { strncpy(puVar4,*(undefined8 *)(param_11 + lVar2 * 8),2); strncpy(puVar3,*(undefined8 *)(param_12 + lVar2 * 8),0x2f); lVar2 = lVar2 + 1; puVar4 = puVar4 + 3; puVar3 = puVar3 + 0x30; } while (lVar2 != 0x40); InstallByPackage(&lStack10144,param_9,auStack10080); } if (f7uOxY9mM1U#1#u == lStack96) { return; } __stack_chk_fail(); do { invalidInstructionException(); } while( true ); } ``` -------------------------------- ### set_ucred_to_ptrace() call for authid elevation Source: https://github.com/aydencharles/onionhen/blob/main/source/libonion_elfldr/README.md Elevates the ucred authid to Sony's SceTracer-style id (PTRACE_AUTHID 0x4800000000010003) once for the inject/attach window. DEBUG_AUTHID (…0006) is not accepted for PT_* and causes attach/waitpid failures (e.g. errno ECHILD). Restore the previous authid after the inject window. ```c set_ucred_to_ptrace(); // → PTRACE_AUTHID 0x4800000000010003 ``` -------------------------------- ### IPCMessage 结构体定义 Source: https://github.com/aydencharles/onionhen/blob/main/docs/arch.md 定义 IPC 消息结构,包含魔数、命令枚举、错误码和消息缓冲区。 ```cpp struct IPCMessage { int magic = 0xDEADBABE; enum DaemonCommands cmd; int error = 0; char msg[0x1000]; }; ``` -------------------------------- ### IPCMessage struct definition Source: https://github.com/aydencharles/onionhen/blob/main/docs/util_arch/README.md Defines the IPC message structure used between ShellUI and the util daemon. Contains a magic number 0xDEADBABE, a command enum, an error field, and a 0x1000-byte buffer for JSON input or text output. ```text struct IPCMessage { int magic = 0xDEADBABE; DaemonCommands cmd; int error; char msg[0x1000]; // JSON 入参 / 文本出参 }; ```