feat(libSceContentExport): local checks for GetProgress, ValidateContents and two exports #27221

Merged
zaryabzip merged 1 commit from upstream-pr/27221 into main 2026-11-26 04:44:07 +00:00
zaryabzip commented 2026-11-25 14:22:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-11-25T14:22:41Z.


What

Four libSceContentExport exports now run the local checks that come before the content-management service, following firmware 9.20. On main all four throw for any call: sceContentExportValidateContents always, and the other three after the session lookup. A title that polls sceContentExportGetProgress on an idle session now gets 0 (SDK 6.00 and up) or 0x809D3002 instead of an abort.

Source. @noisyweather's reading of firmware 9.20's libSceContentExport.sprx on #25863 (comment). It is disassembly only, not measured on a console. Addresses below are from that reading.

Export Checks, in order Then
ValidateContents(ids, count) not initialized → 0x809D3004, with no SDK exception; count > 0x100 → 0x809D3016; null ids with count != 0 → 0x809D3016; count == 0 → 0 throws (the service decides)
GetProgress(id) init gate; id above 9 unsigned → 0x809D3016; empty slot → 0x809D3016 idle: 0, or 0x809D3002 below SDK 6.00; ended: 100, or 0x809D3002 below SDK 6.00
FromFileWithTitleIdList init gate; id above 9; null param, source or thumbnail → 0x809D3016; thumbnail length outside 1–0x400 → 0x809D3016; non-null list with length outside 1–15000 → 0x809D3016; param+0x101 not all zero → 0x809D3016; empty slot → 0x809D3016 content type not one of the five → 0x809D3012, and the session is ended; otherwise throws
FromDataWithThumbnail init gate; id above 9; null param or either callback param → 0x809D3016; param+0x101 not all zero → 0x809D3016; empty slot → 0x809D3016; either callback length 0 or provider null → 0x809D3016, state unchanged content type → 0x809D3012; at SDK 4.00 and up, thumbnail type null or not exactly image/jpeg → 0x809D3019. Both end the session; otherwise throws

"Init gate" is 0x809D3004 while not initialized, skipped when the caller's SDK is below 4.00. This is the same gate sceContentExportFromData already has.

Change (Export.cpp):

  • Sessions keep a state: idle after Start, or ended after one of the failures above. The reading's state 2 ("last export ended, success or failure") is what GetProgress reports as 100. Its probe list has the same step (T5: a text/plain export, then GetProgress → 100).
  • The five content types are exact matches: video/mp4, image/jpeg, image/png, image/gif, and video/webm in a PS5 process. sceContentExportFromData keeps its own check, which this reading doesn't cover.
  • The 0x101-byte block at param+0x101 is the comment field of ContentExportParam.
  • sceContentExportFromData marks its session as run. GetProgress throws for such a session, because this reading doesn't cover FromData's state changes.

Not done. Each of these needs the service or files, so these paths still throw:

  • the title-id list export's file opens, file-identity, sce_ name and JSON checks;
  • the data export's TRC notification, callback writes and temporary files;
  • the progress of an export that is still running.

The data export's subtype check isn't needed: every accepted content type already passes it.

Debt. Following the fragment rule, this adds docs/dev/debt/changes/feat-content-export-progress-checks.md. It drops the GetProgress and FromDataWithThumbnail sentences from the "Content export sessions" entry, and adds a Functional entry for the four exports. That entry covers what is still missing, the comment mapping, and the 0x809D3016/0x809D3019 host-safety fallbacks for unreadable params and strings. The fragment folds cleanly with main's pending fragments and in isolation.

Test (GuestContentExport.cpp, ctest guest_content_export). New rows:

  • Before Init: GetProgress and ValidateContents give 0x809D3004. At SDK 3.00 the gate is skipped, so GetProgress, the title-id export and the data export give 0x809D3016, while ValidateContents still gives 0x809D3004.
  • After Init, before Start: GetProgress(0) → 0x809D3016. ValidateContents gives 0 for (NULL, 0), 0x809D3016 for (NULL, 1) and for 257 ids.
  • Started sessions:
    • Idle GetProgress → 0, and 0x809D3002 at SDK 5.00.
    • Ids 10 and -1 → 0x809D3016.
    • Each entry check in turn → 0x809D3016, after which the session still reports 0.
    • A image/png thumbnail type → 0x809D3019, then GetProgress → 100, and 0x809D3002 at SDK 5.00.
    • A null or image/jpegs thumbnail type → 0x809D3019.
    • text/plain and an unterminated content type → 0x809D3012, then GetProgress → 100.
    • A 0x400-character thumbnail path and a 15000-character list pass their length checks.
  • Changed rows: four existing rows that expected a throw now expect 0x809D3004 or 0x809D3016. Rows that would need the service are left out.

Tested

  • Windows, by my test session at 2edb799778. Windows 11 Home 25H2 (26200.9974), i7-11800H, WinLibs GCC 15.2.0 r7 UCRT, CMake 4.3.1, Ninja 1.13.2, Release, BUILD_TESTING=ON, on main 098c73473f.
    • guest_content_export passes. The build has no warnings.
    • Control: main's Export.cpp with the branch's test. It aborts (0xc0000409) at GuestContentExport.cpp:207, the first new row, with sceContentExportGetProgress: not initialized.
  • macOS host (arm64): Export.cpp and GuestContentExport.cpp built with Apple clang (C++20) against stub guest-copy and process-parameter functions. The head passes. Control: main's Export.cpp aborts at the first new row (GetProgress before Init, which throws on main).

git merge-tree finds no conflict with main (098c73473f) or with any open PR that merges with main. That includes #26967, which also edits this Export.cpp.

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 under Silent stubs in their library's technical debt file
  • 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none (from the #25863 reading)
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5493186201 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27221). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-11-25T14:22:41Z. --- ### What Four `libSceContentExport` exports now run the local checks that come before the content-management service, following firmware 9.20. On `main` all four throw for any call: `sceContentExportValidateContents` always, and the other three after the session lookup. A title that polls `sceContentExportGetProgress` on an idle session now gets 0 (SDK 6.00 and up) or `0x809D3002` instead of an abort. **Source.** @noisyweather's reading of firmware 9.20's `libSceContentExport.sprx` on #25863 ([comment](https://github.com/boykopovar/AnyPS5/issues/25863#issuecomment-7136157911)). It is disassembly only, not measured on a console. Addresses below are from that reading. | Export | Checks, in order | Then | |---|---|---| | `ValidateContents(ids, count)` | not initialized → `0x809D3004`, with no SDK exception; `count > 0x100` → `0x809D3016`; null `ids` with `count != 0` → `0x809D3016`; `count == 0` → 0 | throws (the service decides) | | `GetProgress(id)` | init gate; `id` above 9 unsigned → `0x809D3016`; empty slot → `0x809D3016` | idle: 0, or `0x809D3002` below SDK 6.00; ended: 100, or `0x809D3002` below SDK 6.00 | | `FromFileWithTitleIdList` | init gate; `id` above 9; null `param`, source or thumbnail → `0x809D3016`; thumbnail length outside 1–0x400 → `0x809D3016`; non-null list with length outside 1–15000 → `0x809D3016`; `param+0x101` not all zero → `0x809D3016`; empty slot → `0x809D3016` | content type not one of the five → `0x809D3012`, and the session is ended; otherwise throws | | `FromDataWithThumbnail` | init gate; `id` above 9; null `param` or either callback param → `0x809D3016`; `param+0x101` not all zero → `0x809D3016`; empty slot → `0x809D3016`; either callback length 0 or provider null → `0x809D3016`, state unchanged | content type → `0x809D3012`; at SDK 4.00 and up, thumbnail type null or not exactly `image/jpeg` → `0x809D3019`. Both end the session; otherwise throws | "Init gate" is `0x809D3004` while not initialized, skipped when the caller's SDK is below 4.00. This is the same gate `sceContentExportFromData` already has. **Change** (`Export.cpp`): - Sessions keep a state: idle after `Start`, or ended after one of the failures above. The reading's state 2 ("last export ended, success or failure") is what `GetProgress` reports as 100. Its probe list has the same step (T5: a `text/plain` export, then `GetProgress` → 100). - The five content types are exact matches: `video/mp4`, `image/jpeg`, `image/png`, `image/gif`, and `video/webm` in a PS5 process. `sceContentExportFromData` keeps its own check, which this reading doesn't cover. - The 0x101-byte block at `param+0x101` is the `comment` field of `ContentExportParam`. - `sceContentExportFromData` marks its session as run. `GetProgress` throws for such a session, because this reading doesn't cover FromData's state changes. **Not done.** Each of these needs the service or files, so these paths still throw: - the title-id list export's file opens, file-identity, `sce_` name and JSON checks; - the data export's TRC notification, callback writes and temporary files; - the progress of an export that is still running. The data export's subtype check isn't needed: every accepted content type already passes it. **Debt.** Following the fragment rule, this adds `docs/dev/debt/changes/feat-content-export-progress-checks.md`. It drops the `GetProgress` and `FromDataWithThumbnail` sentences from the "Content export sessions" entry, and adds a Functional entry for the four exports. That entry covers what is still missing, the `comment` mapping, and the `0x809D3016`/`0x809D3019` host-safety fallbacks for unreadable params and strings. The fragment folds cleanly with `main`'s pending fragments and in isolation. **Test** (`GuestContentExport.cpp`, ctest `guest_content_export`). New rows: - **Before `Init`:** `GetProgress` and `ValidateContents` give `0x809D3004`. At SDK 3.00 the gate is skipped, so `GetProgress`, the title-id export and the data export give `0x809D3016`, while `ValidateContents` still gives `0x809D3004`. - **After `Init`, before `Start`:** `GetProgress(0)` → `0x809D3016`. `ValidateContents` gives 0 for `(NULL, 0)`, `0x809D3016` for `(NULL, 1)` and for 257 ids. - **Started sessions:** - Idle `GetProgress` → 0, and `0x809D3002` at SDK 5.00. - Ids 10 and -1 → `0x809D3016`. - Each entry check in turn → `0x809D3016`, after which the session still reports 0. - A `image/png` thumbnail type → `0x809D3019`, then `GetProgress` → 100, and `0x809D3002` at SDK 5.00. - A null or `image/jpegs` thumbnail type → `0x809D3019`. - `text/plain` and an unterminated content type → `0x809D3012`, then `GetProgress` → 100. - A 0x400-character thumbnail path and a 15000-character list pass their length checks. - **Changed rows:** four existing rows that expected a throw now expect `0x809D3004` or `0x809D3016`. Rows that would need the service are left out. ### Tested - **Windows, by my test session** at `2edb799778`. Windows 11 Home 25H2 (26200.9974), i7-11800H, WinLibs GCC 15.2.0 r7 UCRT, CMake 4.3.1, Ninja 1.13.2, Release, `BUILD_TESTING=ON`, on `main` `098c73473f`. - `guest_content_export` passes. The build has no warnings. - Control: `main`'s `Export.cpp` with the branch's test. It aborts (`0xc0000409`) at `GuestContentExport.cpp:207`, the first new row, with `sceContentExportGetProgress: not initialized`. - **macOS host (arm64)**: `Export.cpp` and `GuestContentExport.cpp` built with Apple clang (C++20) against stub guest-copy and process-parameter functions. The head passes. Control: `main`'s `Export.cpp` aborts at the first new row (`GetProgress` before `Init`, which throws on `main`). `git merge-tree` finds no conflict with `main` (`098c73473f`) or with any open PR that merges with `main`. That includes #26967, which also edits this `Export.cpp`. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none (from the #25863 reading) - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-25 14:49:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T14:49:09Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the reviewed code and focused test coverage support the added local checks.

What I ran

Reviewed head 2edb7997789d5aa3a34e2904b3b0a2cf47443e82 using repo_read.py to inspect the prepared description, commit summary, manifest, diff, and changed source and test files. I did not run commands or tests. The description reports a macOS arm64 stub build and says Windows was not run; those are author-reported results.

Results

Check Result Note
Diff and changed code review passed Three changed files reviewed
Automated tests not run No local test execution
Windows build not run Description reports it remains untested

Findings

Blocking

None.

Non-blocking

None.

Not verified

The PR description, commits, manifest, diff, core/libs/prx/libSceContentExport/Export.cpp, core/libs/tests/GuestContentExport.cpp, and the new debt fragment were read. No files were excluded in manifest.json. The external firmware disassembly source and physical-console behavior were not independently verified. No tests or builds were run in this review.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6059857169 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27221#pullrequestreview-6059857169). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T14:49:09Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the reviewed code and focused test coverage support the added local checks. ## What I ran Reviewed head `2edb7997789d5aa3a34e2904b3b0a2cf47443e82` using `repo_read.py` to inspect the prepared description, commit summary, manifest, diff, and changed source and test files. I did not run commands or tests. The description reports a macOS arm64 stub build and says Windows was not run; those are author-reported results. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code review | passed | Three changed files reviewed | | Automated tests | not run | No local test execution | | Windows build | not run | Description reports it remains untested | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The PR description, commits, manifest, diff, `core/libs/prx/libSceContentExport/Export.cpp`, `core/libs/tests/GuestContentExport.cpp`, and the new debt fragment were read. No files were excluded in `manifest.json`. The external firmware disassembly source and physical-console behavior were not independently verified. No tests or builds were run in this review. ## To get this to a good state Nothing is required.
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!27221
No description provided.