Skip to content

feat(libSceNpTrophy): return 0x80551692 from the system debug calls as firmware 13.42 does - #12957

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
zaryabzip:feat/nptrophy-dbg-calls
Oct 30, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
zaryabzip:feat/nptrophy-dbg-calls

Conversation

@zaryabzip

Copy link
Copy Markdown
Contributor

What

sceNpTrophySystemDbgCtl, sceNpTrophySystemGetDbgParam, sceNpTrophySystemGetDbgParamInt, sceNpTrophySystemSetDbgParam and sceNpTrophySystemSetDbgParamInt now return 0x80551692. That is all firmware 13.42's module does: @BunnyFl ran them in an emulator twice, with null, small and all-ones arguments. They made no calls and wrote no memory.

The declarations stay parameterless, because the bodies read no arguments. The five names leave the "unknown function info" list and get a Silent stubs entry citing the measurement. The convention checker requires a constant return to be listed there, as #9173's firmware-measured libSceComposite returns are. libSceNpTrophy goes from 12 to 17 of 97.

GuestNpTrophySystemDebug.cpp calls each one twice and checks the code. They're declared on main, so the test builds there and aborts at the first call. It's a new test file because open PRs #12218 and #11104 edit the existing NpTrophy tests.

Tested

Windows 11 Home 10.0.26200 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) at 161792d, and Ubuntu 24.04.5 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1) with it merged into main bb04a4f:

  • No new warnings. The new test has none, and Export.cpp shows only the two -Wformat-truncation lines main already prints on Linux.
  • ctest -R "^guest_np_trophy": every NpTrophy test passes on both hosts (6 on Windows, 5 on Linux, where guest_np_trophy_host_write isn't built). The new test prints NpTrophy system debug tests passed and passes 3 of 3 on --repeat until-fail:3.
  • Baseline: on main with only the new test file and its CMakeLists.txt block, the test builds and then aborts with sceNpTrophySystemDbgCtl not implemented on both hosts (Windows exit 0xc0000409, Linux SIGABRT).
  • tools/check_conventions.py passes. No open PR touches libSceNpTrophy/ or its debt file.

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 (Claude Code)

…s firmware 13.42 does

Firmware 13.42's sceNpTrophySystemDbgCtl, GetDbgParam, GetDbgParamInt,
SetDbgParam and SetDbgParamInt each return 0x80551692 and do nothing else.
@github-actions

Copy link
Copy Markdown

Progress report (bb04a4f → 161792d)

📈 System libraries: 46.53% (+0.04%, +5 implemented functions)

✅ 5 implemented
Library Name
libSceNpTrophy sceNpTrophySystemDbgCtl
libSceNpTrophy sceNpTrophySystemGetDbgParam
libSceNpTrophy sceNpTrophySystemGetDbgParamInt
libSceNpTrophy sceNpTrophySystemSetDbgParam
libSceNpTrophy sceNpTrophySystemSetDbgParamInt

Changed libraries (implemented exports)

Library Before After Change
libSceNpTrophy 12/97 (12.37%) 17/97 (17.53%) +5.15 pp

@zaryabzip

Copy link
Copy Markdown
Contributor Author

@BunnyFl Your 13.42 run of the five debug calls is what this PR implements, thanks. libSceNpTrophy still throws on 78 more exports, almost all System*, Config* and Int*. Could your harness sort them in firmware 13.42's libSceNpTrophy.sprx?

  1. Fixed returns: which ones are a single return like the debug calls, with no calls and no writes?
  2. Checks, then a fixed result: which ones only check their arguments and then return a fixed code or write a fixed value, with no IPC to the trophy service? For those I'd need the argument list and the checks.

The rest go to the service, so I'd leave them throwing. sceNpTrophyGetGroupInfo and sceNpTrophyGetTrophyInfo are left out on purpose, because they need the encrypted TROPCONF.ESFM.

The 78 exports
  • sceNpTrophyCaptureScreenshot
  • sceNpTrophyConfigGetTrophyDetails
  • sceNpTrophyConfigGetTrophyFlagArray
  • sceNpTrophyConfigGetTrophyGroupArray
  • sceNpTrophyConfigGetTrophyGroupDetails
  • sceNpTrophyConfigGetTrophySetInfo
  • sceNpTrophyConfigGetTrophySetInfoInGroup
  • sceNpTrophyConfigGetTrophySetVersion
  • sceNpTrophyConfigGetTrophyTitleDetails
  • sceNpTrophyConfigHasGroupFeature
  • sceNpTrophyGroupArrayGetNum
  • sceNpTrophyIntAbortHandle
  • sceNpTrophyIntCheckNetSyncTitles
  • sceNpTrophyIntCreateHandle
  • sceNpTrophyIntDestroyHandle
  • sceNpTrophyIntGetLocalTrophySummary
  • sceNpTrophyIntGetProgress
  • sceNpTrophyIntGetRunningTitle
  • sceNpTrophyIntGetRunningTitles
  • sceNpTrophyIntGetTrpIconByUri
  • sceNpTrophyIntNetSyncTitle
  • sceNpTrophyIntNetSyncTitles
  • sceNpTrophyNumInfoGetTotal
  • sceNpTrophySetInfoGetTrophyFlagArray
  • sceNpTrophySetInfoGetTrophyNum
  • sceNpTrophyShowTrophyList
  • sceNpTrophySystemAbortHandle
  • sceNpTrophySystemBuildGroupIconUri
  • sceNpTrophySystemBuildNetTrophyIconUri
  • sceNpTrophySystemBuildTitleIconUri
  • sceNpTrophySystemBuildTrophyIconUri
  • sceNpTrophySystemCheckCallback
  • sceNpTrophySystemCheckNetSyncTitles
  • sceNpTrophySystemCheckRecoveryRequired
  • sceNpTrophySystemCloseStorage
  • sceNpTrophySystemCreateContext
  • sceNpTrophySystemCreateHandle
  • sceNpTrophySystemDebugLockTrophy
  • sceNpTrophySystemDebugUnlockTrophy
  • sceNpTrophySystemDestroyContext
  • sceNpTrophySystemDestroyHandle
  • sceNpTrophySystemDestroyTrophyConfig
  • sceNpTrophySystemGetGroupIcon
  • sceNpTrophySystemGetLocalTrophySummary
  • sceNpTrophySystemGetNextTitleFileEntryStatus
  • sceNpTrophySystemGetProgress
  • sceNpTrophySystemGetTitleFileStatus
  • sceNpTrophySystemGetTitleIcon
  • sceNpTrophySystemGetTitleSyncStatus
  • sceNpTrophySystemGetTrophyConfig
  • sceNpTrophySystemGetTrophyData
  • sceNpTrophySystemGetTrophyGroupData
  • sceNpTrophySystemGetTrophyIcon
  • sceNpTrophySystemGetTrophyTitleData
  • sceNpTrophySystemGetUserFileInfo
  • sceNpTrophySystemGetUserFileStatus
  • sceNpTrophySystemIsServerAvailable
  • sceNpTrophySystemNetSyncTitle
  • sceNpTrophySystemNetSyncTitles
  • sceNpTrophySystemOpenStorage
  • sceNpTrophySystemPerformRecovery
  • sceNpTrophySystemRegisterTitleSyncedCallback
  • sceNpTrophySystemRegisterTitleUpdateCallback
  • sceNpTrophySystemRemoveAll
  • sceNpTrophySystemRemoveTitleData
  • sceNpTrophySystemRemoveUserData
  • sceNpTrophySystemUnregisterTitleSyncedCallback
  • sceNpTrophySystemUnregisterTitleUpdateCallback
  • sceNpTrophySystemWrapDebugLockTrophy
  • sceNpTrophySystemWrapDebugUnlockTrophy
  • sceNpTrophySystemWrapGetGroupDetails
  • sceNpTrophySystemWrapGetPlayedTrophyTitles
  • sceNpTrophySystemWrapGetTitleDetails
  • sceNpTrophySystemWrapGetTrophyDetailsArray
  • sceNpTrophySystemWrapGetTrophyTitleIdsByNpTitleId
  • sceNpTrophySystemWrapRemoveAll
  • sceNpTrophySystemWrapRemoveTitleData
  • sceNpTrophySystemWrapRemoveUserData

@adriadam10 adriadam10 self-assigned this Oct 29, 2026

@rooklz rooklz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 161792d (merged into main bb04a4f for the checks below).

Evidence. The cited source is BunnyFl's comment on #9874: firmware 13.42 libSceNpTrophy.sprx, five exports run in an emulator. That is source 2 in docs/dev/REVERSE_ENGINEERING.md (the library's own code). The behaviour is a constant return with no calls and no writes, and the debt line keeps the parameter lists listed as unknown. Because the bodies read no arguments, the parameterless SysV declarations are ABI-safe for any caller. The debt entry follows the #9173 libSceComposite precedent of firmware-measured constant returns under Silent stubs, and it states the provenance (an emulator run, not a console).

Checks (macOS arm64 host, Apple clang, -arch x86_64)

  • git merge-tree against bb04a4f is clean, git diff --check is clean, and tools/check_conventions.py --base upstream/main passes.
  • tools/pr_overlap.py: 0 of 1467 open PRs share files or exports.
  • -fsyntax-only reports 0 errors for both Export.cpp and GuestNpTrophySystemDebug.cpp.
  • I built Export.cpp standalone with ASan+UBSan and ran the new test against it: NpTrophy system debug tests passed.
  • Negative control: the same test linked against main's Export.cpp aborts at the first call. (My shim has no NotImplemented definition, so here it shows as a SEGV. The author's real-build baseline reports the abort.)
  • Mutant: making sceNpTrophySystemSetDbgParamInt return 0 is killed (sceNpTrophySystemSetDbgParamInt did not return 0x80551692).
  • CI: windows, conventions and intake pass. The relinker and linux lanes are skipped by path filter.

Optional

  • Export.cpp:21-35 already names every other NpTrophy code as a constant. This one has no public name, so the literal is fine. If a later PR learns the name, it can be lifted into that table.

Approving.

AI-assisted: yes

@BunnyFl

BunnyFl commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

@zaryabzip I sorted the 78 in firmware 13.42's libSceNpTrophy.sprx. The sorting is from the disassembly: from each export I followed every branch and internal calls up to three levels deep, and listed the imports it can reach. The four helpers in section 2 were also run natively, 3 runs with identical output.

1. Fixed returns, and checks followed by a fixed result: none. No export among the 78 is a bare constant return like the debug calls, and none only checks its arguments and then returns a fixed code or value.

2. Argument-only helpers: no service, no library state, no imports. Measured.

  • sceNpTrophyNumInfoGetTotal(numInfo) returns the sum of the four uint32 at +0x0, +0x4, +0x8 and +0xC, wrapping at 32 bits. {1, 20, 300, 4000} gives 4321; {0xffffffff, 2, 0, 0} gives 1.
  • sceNpTrophyGroupArrayGetNum(groupArray) returns the number of set bits in the first uint32 only. With words 1–3 all ones, 0x12345678 gives 13 and 0xffffffff gives 32.
  • sceNpTrophySetInfoGetTrophyNum(setInfo) returns the number of set bits in bytes 0x00–0x3F, which is four 16-byte flag arrays. Bytes from 0x40 on are not read (a pattern with bits there still gave 256, not 512).
  • sceNpTrophySetInfoGetTrophyFlagArray(setInfo, flagArray) writes the OR of the four 16-byte arrays at +0x00, +0x10, +0x20 and +0x30 into the first 16 bytes of flagArray. It leaves the rest of the output untouched. Setting only one of the four arrays to all ones gave an all-ones output each time.

None of the four checks for NULL, so a NULL argument faults.

3. Trophy-config accessors: argument checks, then they read the config object. That object is the one sceNpTrophySystemGetTrophyConfig builds from the service, so these need TROPCONF too. Each Config…Get… call first returns 0x80551601 if the library isn't initialized, then 0x80551604 if the config or the output pointer is NULL. The calls are:

  • ConfigGetTrophyFlagArray, ConfigGetTrophyGroupArray, ConfigGetTrophySetInfo, ConfigGetTrophySetVersion and ConfigGetTrophyTitleDetails.
  • ConfigGetTrophyDetails(config, trophyId, out): trophyId 0–127 (unsigned compare), otherwise 0x80551604.
  • ConfigGetTrophyGroupDetails(config, groupId, out) and ConfigGetTrophySetInfoInGroup: groupId -1 takes its own path, otherwise 0–31.
  • ConfigHasGroupFeature(config): NULL gives 0, otherwise bit 0 of the byte at config+0x90.
  • SystemDestroyTrophyConfig(config): NULL returns at once, otherwise it drops one reference.

4. No direct call to the trophy service, but they depend on library state or other modules; I did not sort these further:

  • IntGetProgress, SystemGetProgress, IntGetRunningTitle, IntGetRunningTitles and ShowTrophyList.
  • SystemCreateContext, SystemOpenStorage and SystemCloseStorage.
  • The four System(Un)RegisterTitleSynced/UpdateCallback.
  • SystemWrapDebugLockTrophy and SystemWrapDebugUnlockTrophy.
  • The four SystemBuild*IconUri.
  • SystemIsServerAvailable, which reads sceNpUtilGetEnv and sceRegMgrGetInt.

Several of them make indirect calls through objects, which could reach the service. For example, SystemCloseStorage returns 0x80551601, then 0x80551604 for handle 0, then calls the storage close.

5. Requests to the trophy service (ServiceIpmiClient), 45 exports, so they stay throwing:

  • CaptureScreenshot.
  • IntAbortHandle, IntCheckNetSyncTitles, IntCreateHandle, IntDestroyHandle, IntGetLocalTrophySummary, IntGetTrpIconByUri, IntNetSyncTitle and IntNetSyncTitles.
  • SystemAbortHandle, SystemCheckCallback, SystemCheckNetSyncTitles, SystemCheckRecoveryRequired, SystemCreateHandle, SystemDebugLockTrophy, SystemDebugUnlockTrophy, SystemDestroyContext, SystemDestroyHandle and SystemGetGroupIcon.
  • SystemGetLocalTrophySummary, SystemGetNextTitleFileEntryStatus, SystemGetTitleFileStatus, SystemGetTitleIcon, SystemGetTitleSyncStatus, SystemGetTrophyConfig, SystemGetTrophyData, SystemGetTrophyGroupData, SystemGetTrophyIcon, SystemGetTrophyTitleData, SystemGetUserFileInfo and SystemGetUserFileStatus.
  • SystemNetSyncTitle, SystemNetSyncTitles, SystemPerformRecovery, SystemRemoveAll, SystemRemoveTitleData and SystemRemoveUserData.
  • SystemWrapGetGroupDetails, SystemWrapGetPlayedTrophyTitles, SystemWrapGetTitleDetails, SystemWrapGetTrophyDetailsArray, SystemWrapGetTrophyTitleIdsByNpTitleId, SystemWrapRemoveAll, SystemWrapRemoveTitleData and SystemWrapRemoveUserData.

So the four helpers in section 2 can be implemented exactly now. The section 3 checks could front a throw for the config read, if that's useful.

AI-assisted: yes (Claude Code)

@zaryabzip

Copy link
Copy Markdown
Contributor Author

@BunnyFl Thanks for sorting all 78. The five that read only their arguments, your four section-2 helpers and ConfigHasGroupFeature, are #13005, stacked on this PR, with your measured values as its test. The service and state-bound ones stay throwing.

@adriadam10
adriadam10 merged commit 8c8b998 into boykopovar:main Oct 30, 2026
11 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the return value and the "no calls, no writes" claim against @BunnyFl's 13.42 run on #9874, the parameterless declarations (the bodies read no arguments), the Silent stubs entry and the moved names in the debt file, and that the new test checks all five exports twice and aborts on main; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants