feat(libSceAppContent): implement sceAppContentGetEntitlementKey #9638

Merged
Noxy-HNR merged 1 commit from upstream-pr/9638 into main 2026-10-25 21:30:08 +00:00
Noxy-HNR commented 2026-10-22 05:43:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Noxy-HNR on 2026-10-22T05:43:56Z.


What

Converts sceAppContentGetEntitlementKey from NotImplemented_nid_no_patch. The library installs no additional content, so it answers the way sceAppContentGetAddcontInfo already does:

  • before sceAppContentInitialize it answers NOT_INITIALIZED;
  • a null entitlement label or key answers PARAMETER, as does a label with nonzero padding for SDK 0x01500000 and later, using the threshold of sceAppContentGetAddcontInfo;
  • every other label answers DRM_NO_ENTITLEMENT and the 16-byte key is left unchanged.

The (service label, label, 16-byte key) signature follows shadPS4's app_content.h. shadPS4 also answers PARAMETER for service labels above 7; like the other add-content exports here, this one ignores the service label on purpose. None of it is measured on a console, which its own entry in docs/dev/debt/libSceAppContent.md records; the pending-exports count there drops from 16 to 15. libSceAppContent goes from 16/32 to 17/32 in tools/progress.py.

Tested

Windows 11 26H2 (build 10.0.26300, WinLibs GCC 15.2.0 r7, full Release build), head 0be7638 on main 01f9930, after #9114 merged: guest_appcontent passes, 1/1, including #9114's sceAppContentTemporaryDataMount checks. It checks sceAppContentGetEntitlementKey before initialization, with null arguments, with service labels 0 and 7, with nonzero label padding across SDK 0x014fffff to 0x03500000, and that DRM_NO_ENTITLEMENT leaves a sentinel-filled key unchanged. tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass. tools/pr_overlap.py reports no overlap with other open pull requests; #6044, which conflicts with main, shares GuestAppContent.cpp but could not be compared. No title tested.

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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4962716912 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9638). Originally posted by [Noxy-HNR](https://github.com/Noxy-HNR) on 2026-10-22T05:43:56Z. --- ### What Converts `sceAppContentGetEntitlementKey` from `NotImplemented_nid_no_patch`. The library installs no additional content, so it answers the way `sceAppContentGetAddcontInfo` already does: - before `sceAppContentInitialize` it answers `NOT_INITIALIZED`; - a null entitlement label or key answers `PARAMETER`, as does a label with nonzero padding for SDK 0x01500000 and later, using the threshold of `sceAppContentGetAddcontInfo`; - every other label answers `DRM_NO_ENTITLEMENT` and the 16-byte key is left unchanged. The `(service label, label, 16-byte key)` signature follows [shadPS4's app_content.h](https://github.com/shadps4-emu/shadPS4/blob/0918faa0255e9816b795b62c9b09eaea51a1bc5e/src/core/libraries/app_content/app_content.h#L97-L99). shadPS4 also answers `PARAMETER` for service labels above 7; like the other add-content exports here, this one ignores the service label on purpose. None of it is measured on a console, which its own entry in `docs/dev/debt/libSceAppContent.md` records; the pending-exports count there drops from 16 to 15. libSceAppContent goes from 16/32 to 17/32 in `tools/progress.py`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 26H2 (build 10.0.26300, WinLibs GCC 15.2.0 r7, full Release build), head 0be7638 on main 01f9930, after #9114 merged: `guest_appcontent` passes, 1/1, including #9114's `sceAppContentTemporaryDataMount` checks. It checks `sceAppContentGetEntitlementKey` before initialization, with null arguments, with service labels 0 and 7, with nonzero label padding across SDK 0x014fffff to 0x03500000, and that `DRM_NO_ENTITLEMENT` leaves a sentinel-filled key unchanged. `tools/check_conventions.py --base origin/main` and `tools/check_test_registration.py` pass. `tools/pr_overlap.py` reports no overlap with other open pull requests; #6044, which conflicts with `main`, shares `GuestAppContent.cpp` but could not be compared. No title tested. ### 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: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
harisibrar1 commented 2026-10-22 06:01:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T06:01:42Z.

Review: COMMENTED


Checked against main 4a17c7175 and shadPS4 0918faa (src/core/libraries/app_content/app_content.cpp L329-L357):

  • The code matches shadPS4's flow when no add-content is installed: NOT_INITIALIZED, then PARAMETER for a null label or key, then DRM_NO_ENTITLEMENT. The key is never written. Ignoring service_label > 7 is the only difference, and the debt file records it. The pending-exports count of 16 matches the remaining NotImplemented_nid_no_patch calls in Export.cpp.
  • One small wording issue in docs/dev/debt/libSceAppContent.md line 14. The new sceAppContentGetEntitlementKey sentence lands right before "Its 16-byte layout (DataSize, then DownloadedSize, both 64-bit)…". That sentence describes the download-progress structure, but it now reads as if it described the entitlement key, which is also 16 bytes. Could the new sentence move after the SharpProspero layout sentence, or could "Its" become "The progress structure's"?

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609875498 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9638#pullrequestreview-5609875498). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-22T06:01:42Z. **Review:** COMMENTED --- Checked against main 4a17c7175 and shadPS4 0918faa (src/core/libraries/app_content/app_content.cpp L329-L357): - The code matches shadPS4's flow when no add-content is installed: NOT_INITIALIZED, then PARAMETER for a null label or key, then DRM_NO_ENTITLEMENT. The key is never written. Ignoring `service_label > 7` is the only difference, and the debt file records it. The pending-exports count of 16 matches the remaining `NotImplemented_nid_no_patch` calls in Export.cpp. - One small wording issue in docs/dev/debt/libSceAppContent.md line 14. The new `sceAppContentGetEntitlementKey` sentence lands right before "Its 16-byte layout (`DataSize`, then `DownloadedSize`, both 64-bit)…". That sentence describes the download-progress structure, but it now reads as if it described the entitlement key, which is also 16 bytes. Could the new sentence move after the SharpProspero layout sentence, or could "Its" become "The progress structure's"? Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
fogydes commented 2026-10-22 08:13:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-22T08:13:17Z.


One inconsistency between the code and its debt entry to resolve before merge; the rest verifies clean.

The debt bullet says shadPS4 "also rejects service labels above 7", but the implementation discards service_label ((void)service_label;) and the test only exercises 7 — no value above 7 is rejected. So the entry names behavior the code does not have. Either align with the reference (reject out-of-range service labels like shadPS4) or state in the debt entry's gap sentence that the rejection is deliberately not carried over. As written the code and the doc contradict each other.

Verified clean: NOT_INITIALIZED first, PARAMETER for null label/engine-key, DRM_NO_ENTITLEMENT for a well-formed label, the output buffer untouched on every error path (the test asserts byte-level equality against a 0x5a sentinel), the label validity threshold matching sceAppContentGetAddcontInfo's 0x01500000 rule, and the pending-export count going 17 → 16 in docs/dev/debt/libSceAppContent.md honestly.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336040345 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9638#issuecomment-6336040345). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-22T08:13:17Z. --- One inconsistency between the code and its debt entry to resolve before merge; the rest verifies clean. The debt bullet says shadPS4 "also rejects service labels above 7", but the implementation discards `service_label` (`(void)service_label;`) and the test only exercises 7 — no value above 7 is rejected. So the entry names behavior the code does not have. Either align with the reference (reject out-of-range service labels like shadPS4) or state in the debt entry's gap sentence that the rejection is deliberately not carried over. As written the code and the doc contradict each other. Verified clean: NOT_INITIALIZED first, PARAMETER for null label/engine-key, `DRM_NO_ENTITLEMENT` for a well-formed label, the output buffer untouched on every error path (the test asserts byte-level equality against a 0x5a sentinel), the label validity threshold matching `sceAppContentGetAddcontInfo`'s 0x01500000 rule, and the pending-export count going 17 → 16 in `docs/dev/debt/libSceAppContent.md` honestly.
MarcZX10 commented 2026-10-22 09:20:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T09:20:55Z.

Review: DISMISSED


The flow and focused test are otherwise consistent with the modeled no-additional-content case, and the test checks the key remains byte-for-byte unchanged. Current-head issues to resolve: - The debt entry says shadPS4 rejects service_label > 7, but this wrapper casts service_label to void and the test has no >7 case. Either match the reference and add boundary tests or explicitly document this deliberate difference. - The debt entry says the entitlement key’s 16-byte layout is (DataSize, DownloadedSize), which is the download-progress structure, not the key. The prior reviewer’s wording note is still present; disambiguate or remove this layout claim. - Exact-head conventions and whitespace checks pass. Hosted eligibility/conventions/intake/labels/report pass, with product jobs skipped. I attempted a local CMake configure for guest_appcontent, but it stops before build because SDL2 is uninitialized and XRandR support is unavailable; I did not run the test. The Windows guest_appcontent pass is author-reported.

I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5611959461 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9638#pullrequestreview-5611959461). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T09:20:55Z. **Review:** DISMISSED --- The flow and focused test are otherwise consistent with the modeled no-additional-content case, and the test checks the key remains byte-for-byte unchanged. Current-head issues to resolve: - The debt entry says shadPS4 rejects `service_label > 7`, but this wrapper casts `service_label` to void and the test has no >7 case. Either match the reference and add boundary tests or explicitly document this deliberate difference. - The debt entry says the entitlement key’s 16-byte layout is `(DataSize, DownloadedSize)`, which is the download-progress structure, not the key. The prior reviewer’s wording note is still present; disambiguate or remove this layout claim. - Exact-head conventions and whitespace checks pass. Hosted eligibility/conventions/intake/labels/report pass, with product jobs skipped. I attempted a local CMake configure for `guest_appcontent`, but it stops before build because SDL2 is uninitialized and XRandR support is unavailable; I did not run the test. The Windows `guest_appcontent` pass is author-reported. I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
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!9638
No description provided.