Skip to content

fix(libSceUserService): reject a null account id output before the user check - #14862

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
kallmek3nny:fix/libSceUserService-npaccountid-null-output
Nov 3, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
kallmek3nny:fix/libSceUserService-npaccountid-null-output

Conversation

@kallmek3nny

Copy link
Copy Markdown
Contributor

What

sceUserServiceGetNpAccountId now returns USER_SERVICE_ERROR_INVALID_ARGUMENT (0x80960005) for a null output before it checks whether the user is logged in. Before, a user who is not logged in got USER_SERVICE_ERROR_UNKNOWN_USER (0x80960105) even with a null output. With a non-null output nothing changes: a user who is not logged in still gets 0x80960105 with the output untouched, and a logged-in user still gets account id 0.

Behaviour source: firmware 13.42's libSceUserService.sprx, read from its disassembly and run natively on x86-64 with its imports stubbed, not measured on a console: #12165 (comment). Its handler returns 0x80960002 while the module is not initialized, then 0x80960005 for a null output, and only after that looks at the user; once initialized, null-output calls returned 0x80960005 for users 0x10000000, 0x10000001, 1, 123, 255, -1 and 0. The non-null result for a user who is not logged in stays as measured on a PS4 Pro (firmware 10.71). The not-initialized check that comes first is not modelled; the sceUserServiceGetNpAccountId entry in docs/dev/debt/libSceUserService.md now names this source and that gap.

The four null-output calls in core/libs/tests/GuestUserService.cpp for users that are not logged in now expect USER_SERVICE_ERROR_INVALID_ARGUMENT instead of USER_SERVICE_ERROR_UNKNOWN_USER.

Tested

Microsoft Windows [Version 10.0.26300.9711], gcc 16.1.0 (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r4), cmake 4.0.3. Commit ed71528 on main at 5bae1a4. Not tested with a title.

  • git submodule update --init --recursive --jobs 8 && cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_TESTING=ON -DPython3_EXECUTABLE=C:/Python314/python.exe && cmake --build build --parallel 4 on main at 5bae1a4: exit 0. After the changes, cmake --build build --parallel 4: exit 0, with no error: or FAILED: lines.
  • ctest --test-dir build -R '[Uu]ser_?[Ss]ervice' --no-tests=error --output-on-failure --timeout 60: guest_user_service, guest_user_service_user_name and guest_user_service_lifecycle passed, 3/3.
  • python tools/check_conventions.py --base origin/main: "All conventions checks passed."
  • python tools/pr_overlap.py --branch fix/libSceUserService-npaccountid-null-output: exit 2. It reported 15 open PRs that share files or exports with this branch and merged 15/15 into the base, but couldn't compare feat(libSceUserService): take the user name from ANYPS5_USER_NAME #9345 on core/libs/prx/libSceUserService/Export.cpp or docs(debt): separate entries with blank lines and drop derived export totals #14212 on docs/dev/debt/libSceUserService.md, because both conflict with main. I compared them by hand: in Export.cpp, feat(libSceUserService): take the user name from ANYPS5_USER_NAME #9345's only hunk is in sceUserServiceGetUserName, and none of its changed lines mention the account id. In the debt file, docs(debt): separate entries with blank lines and drop derived export totals #14212 separates entries with blank lines and drops the derived export totals; none of its changed lines name sceUserServiceGetNpAccountId.

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

🤖 Generated with Claude Code

…er check

Firmware 13.42 libSceUserService.sprx returns INVALID_ARGUMENT (0x80960005) from sceUserServiceGetNpAccountId for a null output before it looks at the user, as BunnyFl showed with its disassembly and a native run with stubbed imports on boykopovar#12165. The UserService tests now expect INVALID_ARGUMENT for a null output with an unknown or logged-out user, and the debt entry names that source and the unmodelled not-initialized order.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 9345 core/libs/prx/libSceUserService/Export.cpp
PR 12860 core/libs/prx/libSceUserService/Export.cpp
core/libs/tests/GuestUserService.cpp
docs/dev/debt/libSceUserService.md
PR 12900 core/libs/prx/libSceUserService/Export.cpp
core/libs/tests/GuestUserService.cpp
docs/dev/debt/libSceUserService.md
PR 14212 docs/dev/debt/libSceUserService.md

@BunnyFl BunnyFl 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 ed71528da4, merged locally into main 7fad683776 (clean merge; GitHub also reports it mergeable). Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, Ninja.

Firmware check (disassembly only, not run on a console). libSceUserService.sprx from firmware 13.42:

  • sceUserServiceGetNpAccountId (6dfDreosXGY, 0x4940) is a tail call through a handler table at 0x1c230, slot +0x10, with setting 0x100 in esi and the output in rdx.
  • That table is filled at 0x47d6 from the static table at 0x18000; its +0x10 entry relocates to 0x3e10:
    3e17: mov  0x1c220(%rip),%rdi   ; service object
    3e1e: test %rdi,%rdi ; je -> mov $0x80960002,%eax ; ret
    3e23: test %rcx,%rcx ; jne 0x410            ; the per-user query
    3e2c: mov  $0x80960005,%eax ; ret
    
    So once initialized, a null output returns 0x80960005 before 0x410 looks at the user, as this PR does.
  • The only other writer of 0x1c230 (0x1ad8, in the shared initialize body at 0x1930) copies a caller-supplied table, and only when its fourth argument is non-null. sceUserServiceInitialize (0x2850) and sceUserServiceInitialize2 (0x2880) both pass rcx = 0; only sceUserServiceInitializeForShellCore (0x28a0) passes one. So the 0x3e10 handler is the one titles get.

What I ran

  • ctest -R '^guest_user_service' --repeat until-fail:3: guest_user_service, guest_user_service_user_name, guest_user_service_lifecycle pass, 3 of 3 runs.
  • Negative control: main's libSceUserService/Export.cpp with this PR's test: guest_user_service aborts (0xc0000409).
  • python tools/check_conventions.py --base upstream/main: passes.

The debt entry keeps the PS4 10.71 measurement for a non-null output, adds this source and records the unmodelled 0x80960002 gap. Looks good.

AI-assisted: yes (Claude Code)

@oneandonlydean oneandonlydean self-assigned this Nov 3, 2026
@oneandonlydean
oneandonlydean merged commit 6e67ec7 into boykopovar:main Nov 3, 2026
12 checks passed
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.

3 participants