feat: read plaintext PS5 packages directly (relinker input and runtime /app0 mount) #1056

Closed
snowzhangy wants to merge 5 commits from upstream-pr/1056 into main
snowzhangy commented 2026-10-07 06:02:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by snowzhangy on 2026-10-07T06:02:43Z.


What

Read plaintext PS5 packages directly, without extracting them.

  • core/pkg: reader for plaintext debug packages: FIH finalized image, outer PFS (signed 32-bit inodes, PPRPLAIN-NOAUTH! seed), NAPS native-span inner image with indexed sparse pages, inner PFSv2 tree, CNT named entries, and fake-signed SELF to ELF unwrapping. Kraken blocks are rebuilt into Oodle streams (block, quantum and chunk headers from the CblockInfo selectors) and decoded by a user-supplied oo2core library loaded on first use. Reads are positional and thread-safe, with an LRU of decoded 256 KiB blocks.
  • Relinker: accepts a .pkg input and a new --oodle <library> option. eboot.bin and the modules in sce_module/, sce_modules/ and prx/ are read in memory and unwrapped; the Windows icon comes from the CNT. Only the executable, the *.guest.prx modules and anyps5-package.ini (package path, size, content ID, Oodle path) are written. GuestModuleBuilder is split into disk collection and building from in-memory sources; WindowsPePatcher accepts icon bytes.
  • Runtime: libc mounts the package as /app0 from the sidecar, or from ANYPS5_PACKAGE/ANYPS5_OODLE; files missing from the package fall back to the host app0/ (converted modules). Package files get read-only descriptors in 0x08000000-0x0fffffff, dispatched in kernel open, close, read, pread, readv, preadv, lseek, stat, fstat, getdents, getdirentries and reachability, AIO reads, AMPR resolve/read/stat, libc opendir/readdir/access/rename/remove, AvPlayer sources (custom AVIO), sceFontOpenFontFile, param.json/icon0.png metadata and PlayGo chunk definitions. Writes and namespace changes inside the mount report EROFS. Lookups are exact, then case-insensitive.
  • Not supported yet, and throwing: stdio streams over package files (fopen, freopen, fdopen), encrypted packages and other NAPS layouts. Recorded in TechnicalDebt.

Provenance: the format facts (offsets, bit layouts, flag meanings) come from the GPL-3.0 projects LibProsperoPKG and PS5PCEM, and from a decompiled copy of the ProsperoPkgTool engine vendored by PS5PkgTool. That engine is labelled MIT, but its Kraken decoder mirrors ooz, so I treat the label as unverified. No code was copied. The NAPS walk and the Oodle stream rebuild follow that engine's behaviour and were checked against a real package. The project does not ship or download Oodle: packages with Kraken blocks need a user-supplied oo2core library. Maintainers may want to weigh that against the README's "does not require proprietary libraries".

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs UCRT r7), AMD Radeon 8060S.

  • ctest with -DBUILD_TESTING=ON: 380/382 pass. Failing: agc_driver_lds_atomics64 and agc_driver_vopc_compare_table (shader math, not touched here; not checked against main on this GPU).
  • New tests:
    • package_format: Kraken stream headers, SELF unwrap (version trailer, encrypted and compressed segments), entry name validation.
    • package_input: synthetic packages relinked for Linux and Windows; sidecar contents; Kraken without --oodle, unloadable Oodle, missing plaintext marker, unsafe entry names.
    • guest_package_mount: synthetic package mounted through the env override, a sidecar, a stale sidecar and a non-ASCII path. Covers stat, open, read, pread, lseek, getdents, case-insensitive lookup, EROFS, host fallback, and libc opendir/access/rename/remove.
  • PPSA21567, a 39 GB plaintext debug package built by a third-party fPKG tool, decoded with Oodle 2.9.10:
    • Relinked without extraction: eboot.bin plus 2 guest modules.
    • All 736,923 blocks decode.
    • Runtime reads match an independent decoder on 256 sampled files (1.3 GB).
    • The title boots and reads about 70 MB from the package through AMPR and kernel opens. It then stops at AGC graphics: unsupported descriptor role Gds, which is unrelated to package reading.
  • Linux: not compiled or tested (no Linux toolchain available).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none added; Oodle is loaded from a user-supplied path)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4768644971 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1056). Originally posted by [snowzhangy](https://github.com/snowzhangy) on 2026-10-07T06:02:43Z. --- ### What Read plaintext PS5 packages directly, without extracting them. - `core/pkg`: reader for plaintext debug packages: FIH finalized image, outer PFS (signed 32-bit inodes, `PPRPLAIN-NOAUTH!` seed), NAPS native-span inner image with indexed sparse pages, inner PFSv2 tree, CNT named entries, and fake-signed SELF to ELF unwrapping. Kraken blocks are rebuilt into Oodle streams (block, quantum and chunk headers from the CblockInfo selectors) and decoded by a user-supplied `oo2core` library loaded on first use. Reads are positional and thread-safe, with an LRU of decoded 256 KiB blocks. - Relinker: accepts a `.pkg` input and a new `--oodle <library>` option. `eboot.bin` and the modules in `sce_module/`, `sce_modules/` and `prx/` are read in memory and unwrapped; the Windows icon comes from the CNT. Only the executable, the `*.guest.prx` modules and `anyps5-package.ini` (package path, size, content ID, Oodle path) are written. `GuestModuleBuilder` is split into disk collection and building from in-memory sources; `WindowsPePatcher` accepts icon bytes. - Runtime: libc mounts the package as `/app0` from the sidecar, or from `ANYPS5_PACKAGE`/`ANYPS5_OODLE`; files missing from the package fall back to the host `app0/` (converted modules). Package files get read-only descriptors in `0x08000000`-`0x0fffffff`, dispatched in kernel open, close, read, pread, readv, preadv, lseek, stat, fstat, getdents, getdirentries and reachability, AIO reads, AMPR resolve/read/stat, libc `opendir`/`readdir`/`access`/`rename`/`remove`, AvPlayer sources (custom AVIO), `sceFontOpenFontFile`, `param.json`/`icon0.png` metadata and PlayGo chunk definitions. Writes and namespace changes inside the mount report `EROFS`. Lookups are exact, then case-insensitive. - Not supported yet, and throwing: stdio streams over package files (`fopen`, `freopen`, `fdopen`), encrypted packages and other NAPS layouts. Recorded in TechnicalDebt. Provenance: the format facts (offsets, bit layouts, flag meanings) come from the GPL-3.0 projects [LibProsperoPKG](https://github.com/SvenGDK/LibProsperoPKG) and [PS5PCEM](https://github.com/iStark/PS5PCEM), and from a decompiled copy of the ProsperoPkgTool engine vendored by [PS5PkgTool](https://github.com/pearlxcore/PS5PkgTool). That engine is labelled MIT, but its Kraken decoder mirrors ooz, so I treat the label as unverified. No code was copied. The NAPS walk and the Oodle stream rebuild follow that engine's behaviour and were checked against a real package. The project does not ship or download Oodle: packages with Kraken blocks need a user-supplied `oo2core` library. Maintainers may want to weigh that against the README's "does not require proprietary libraries". ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs UCRT r7), AMD Radeon 8060S. - `ctest` with `-DBUILD_TESTING=ON`: 380/382 pass. Failing: `agc_driver_lds_atomics64` and `agc_driver_vopc_compare_table` (shader math, not touched here; not checked against `main` on this GPU). - New tests: - `package_format`: Kraken stream headers, SELF unwrap (version trailer, encrypted and compressed segments), entry name validation. - `package_input`: synthetic packages relinked for Linux and Windows; sidecar contents; Kraken without `--oodle`, unloadable Oodle, missing plaintext marker, unsafe entry names. - `guest_package_mount`: synthetic package mounted through the env override, a sidecar, a stale sidecar and a non-ASCII path. Covers stat, open, read, pread, lseek, getdents, case-insensitive lookup, `EROFS`, host fallback, and libc `opendir`/`access`/`rename`/`remove`. - PPSA21567, a 39 GB plaintext debug package built by a third-party fPKG tool, decoded with Oodle 2.9.10: - Relinked without extraction: `eboot.bin` plus 2 guest modules. - All 736,923 blocks decode. - Runtime reads match an independent decoder on 256 sampled files (1.3 GB). - The title boots and reads about 70 MB from the package through AMPR and kernel opens. It then stops at `AGC graphics: unsupported descriptor role Gds`, which is unrelated to package reading. - Linux: not compiled or tested (no Linux toolchain available). ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source (none added; Oodle is loaded from a user-supplied path) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1056
No description provided.