Skip to content

feat(npentitlementaccess): implement sceNpEntitlementAccessGetEntitlementKey - #1530

Closed
merwie wants to merge 1 commit into
boykopovar:mainfrom
merwie:feat/npentitlement-get-entitlement-key
Closed

merwie wants to merge 1 commit into
boykopovar:mainfrom
merwie:feat/npentitlement-get-entitlement-key

Conversation

@merwie

@merwie merwie commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What

Adds sceNpEntitlementAccessGetEntitlementKey (NID 5LiMEPuW0DQ) to libSceNpEntitlementAccess. It is the only import of God of War Sons of Sparta (PPSA28997) that no AnyPS5 library exports: Unity's Media/Plugins/PSN.prx imports it, so the relinked title stops at load with unresolved ELF import 5LiMEPuW0DQ from libSceNpEntitlementAccess.prx.

Signature, from the call site in PSN.prx (0x4400): int sceNpEntitlementAccessGetEntitlementKey(SceNpServiceLabel, const SceNpUnifiedEntitlementLabel*, SceNpEntitlementAccessEntitlementKey*). The caller copies the label into a 17-byte buffer, zeroes a 16-byte key and treats a negative result as failure. The name was matched by hashing it to the NID.

Behaviour:

  • null label or key: SCE_NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER;
  • a label not listed in the entitlements file (anyps5-entitlements.ini / ANYPS5_ENTITLEMENTS): SCE_NP_ENTITLEMENT_ACCESS_ERROR_NOT_FOUND, the answer sceNpEntitlementAccessGetAddcontEntitlementInfo gives for the same label. The console's error for an unowned label is unverified and recorded in TechnicalDebt;
  • a listed label throws NotImplemented, as AnyPS5 has no key for an add-on.

NpEntitlementAccessEntitlementKey (16 bytes) is added to SceTypes.hpp. The library gets its own CMakeLists.txt (same shape as libSceGameUpdate) so the test can link libc and catch the throw.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0, Release.

  • New test guest_np_entitlement_access: null arguments, an unlisted label (NOT_FOUND, key left untouched) and a listed label (throws, key left untouched), using a temporary entitlements file.
  • Without the change: the test does not link (undefined reference to sceNpEntitlementAccessGetEntitlementKey). With an unlisted label returning 0 it fails at line 59; with a listed label returning 0 instead of throwing it fails at line 68. Restored: passes.
  • ctest -j8 -E "agc_driver|graphics": 262/262 passed.
  • PPSA28997, relinked with feat(relinker): add --module-dir for modules loaded at run time #846 (--module-dir Media/Plugins --module-dir Media/Modules) and feat(libkernel): implement _umtx_op wait and wake operations #1482 (_umtx_op): all imports now resolve; the title starts, renders, mounts and writes its save data, and keeps running.

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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

…mentKey

A label missing from the entitlements file answers NOT_FOUND, as
sceNpEntitlementAccessGetAddcontEntitlementInfo does. A listed label
throws, since no add-on key is available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Progress report (b1c5f10 → 041703b)

📉 System libraries: 85.38% (-0.03%, +1 declared functions)

🆕 1 declared as stubs
Library Name
libSceNpEntitlementAccess sceNpEntitlementAccessGetEntitlementKey

@merwie

merwie commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

The progress report counts sceNpEntitlementAccessGetEntitlementKey as a stub because its body still calls NotImplemented_nid_no_patch. That call is only on the path for a label listed in the entitlements file, where AnyPS5 has no add-on key to return (recorded in TechnicalDebt). Null arguments and unlisted labels are implemented and covered by guest_np_entitlement_access. No change made for this report.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1299 core/libs/prx/libSceNpEntitlementAccess/CMakeLists.txt
#1436 core/libs/SceTypes.hpp L1278 sceNpEntitlementAccessGetEntitlementKey
#1531 docs/dev/TechnicalDebt.md L236

@merwie

merwie commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Correction: #1436 (opened earlier today) already adds sceNpEntitlementAccessGetEntitlementKey with the same signature, so this PR duplicates it. I missed it because my search only matched PR titles. I'll close this one in favour of #1436 unless a maintainer prefers this version.

One difference for whoever reviews #1436: it answers an unlisted label with 0x817D0007 and null arguments with 0x817D0002, while the rest of libSceNpEntitlementAccess on main uses 0x80558007 (NOT_FOUND) and 0x80558003 (PARAMETER), for example sceNpEntitlementAccessGetAddcontEntitlementInfo. It also doesn't look at the entitlements file, so a label listed there is reported as not owned by this function but as owned by GetAddcontEntitlementInfo.

🤖 Generated with Claude Code

@merwie

merwie commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of #1436.

@merwie merwie closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant