user_service: bind sceUserServiceTerminate to its own NID and implement sceUserServiceGetForegroundUser #2498

Manually merged
github merged 3 commits from gh-pr/2498/head into gh-pr/2498/base 2026-11-26 10:21:24 +00:00
Owner

@⁠DIMPM32145 on GitHub · 2026-11-21 16:40 UTC · original
DIMPM32145:user-service-foreground-terminate → main · +139 −9 · 3 files · 3 commits · merged 2026-11-22 12:14 UTC

Summary

  • Fixes an incorrect NID mapping where bwFjS+bX9mA (sceUserServiceTerminate) was mistakenly registered to UserServiceGetUserNumber. When titles clean up or reset user services, calling sceUserServiceTerminate() invoked a 2-argument getter with uninitialized register state. It is now bound to UserServiceTerminate().
  • Implements sceUserServiceGetForegroundUser (eNb53LQJmIM), querying the active foreground controller/user (Config::GetUserId()), with nullptr validation returning USER_SERVICE_ERROR_INVALID_ARGUMENT.
  • Implements sceUserServiceGetRegisteredUserIdList (5EiQCnL2G1Y).
  • Adds tests/UserServiceTests.cpp unit test suite covering initialization, foreground user lookup, registered/logged-in user list retrieval, user number queries, and clean termination.

Affected Games

Titles querying foreground user state during controller session setup and calling user service termination on shutdown/mode transitions (e.g. Astro's Playroom, Neptunia ReVerse, and UE4/UE5 games).

Testing

Built with clang-cl and Ninja; all tests in user_service_tests pass:

[==========] Running 4 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 4 tests from UserService
[ RUN      ] UserService.InitializeAndTerminateSucceed
[       OK ] UserService.InitializeAndTerminateSucceed (0 ms)
[ RUN      ] UserService.ForegroundUserMatchesInitialUser
[       OK ] UserService.ForegroundUserMatchesInitialUser (0 ms)
[ RUN      ] UserService.RegisteredAndLoginUserIdListsIncludePrimaryUser
[       OK ] UserService.RegisteredAndLoginUserIdListsIncludePrimaryUser (0 ms)
[ RUN      ] UserService.UserNumberAndNameReturnValidDataForPrimaryUser
[       OK ] UserService.UserNumberAndNameReturnValidDataForPrimaryUser (0 ms)
[----------] 4 tests from UserService (0 ms total)
[  PASSED  ] 4 tests.
1/1 Test #43: user_service .....................   Passed    0.23 sec
**@⁠DIMPM32145** on GitHub · 2026-11-21 16:40 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2498) `DIMPM32145:user-service-foreground-terminate` → `main` · +139 −9 · 3 files · 3 commits · merged 2026-11-22 12:14 UTC ### Summary - Fixes an incorrect NID mapping where `bwFjS+bX9mA` (`sceUserServiceTerminate`) was mistakenly registered to `UserServiceGetUserNumber`. When titles clean up or reset user services, calling `sceUserServiceTerminate()` invoked a 2-argument getter with uninitialized register state. It is now bound to `UserServiceTerminate()`. - Implements `sceUserServiceGetForegroundUser` (`eNb53LQJmIM`), querying the active foreground controller/user (`Config::GetUserId()`), with `nullptr` validation returning `USER_SERVICE_ERROR_INVALID_ARGUMENT`. - Implements `sceUserServiceGetRegisteredUserIdList` (`5EiQCnL2G1Y`). - Adds `tests/UserServiceTests.cpp` unit test suite covering initialization, foreground user lookup, registered/logged-in user list retrieval, user number queries, and clean termination. ### Affected Games Titles querying foreground user state during controller session setup and calling user service termination on shutdown/mode transitions (e.g. *Astro's Playroom*, *Neptunia ReVerse*, and UE4/UE5 games). ### Testing Built with `clang-cl` and Ninja; all tests in `user_service_tests` pass: ```text [==========] Running 4 tests from 1 test suite. [----------] Global test environment set-up. [----------] 4 tests from UserService [ RUN ] UserService.InitializeAndTerminateSucceed [ OK ] UserService.InitializeAndTerminateSucceed (0 ms) [ RUN ] UserService.ForegroundUserMatchesInitialUser [ OK ] UserService.ForegroundUserMatchesInitialUser (0 ms) [ RUN ] UserService.RegisteredAndLoginUserIdListsIncludePrimaryUser [ OK ] UserService.RegisteredAndLoginUserIdListsIncludePrimaryUser (0 ms) [ RUN ] UserService.UserNumberAndNameReturnValidDataForPrimaryUser [ OK ] UserService.UserNumberAndNameReturnValidDataForPrimaryUser (0 ms) [----------] 4 tests from UserService (0 ms total) [ PASSED ] 4 tests. 1/1 Test #43: user_service ..................... Passed 0.23 sec ```
Bind NID bwFjS+bX9mA to UserService::UserServiceTerminate instead of UserServiceGetUserNumber, preventing titles invoking termination from calling a two-argument getter with uninitialized register state.

Implement sceUserServiceGetForegroundUser (eNb53LQJmIM) and sceUserServiceGetRegisteredUserIdList (5EiQCnL2G1Y) to support titles initializing foreground player state.

Add unit tests in tests/UserServiceTests.cpp verifying initialization, foreground user lookup, registered user lists, and termination.
Define UserServiceRegisteredUserIdList with 16 slots and initialize entries 4 through 15 with -1 as expected by the public SDK layout.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:21:22 +00:00
github manually merged commit 76262f9291 into gh-pr/2498/base 2026-11-26 10:21:24 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-21 16:44 UTC · original · edited 2026-11-21 18:38 UTC

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds UserService termination, foreground-user lookup, and registered-user-list functions. It updates symbol registration for these functions and the user-number function. It also adds a Google Test executable with coverage for UserService initialization, lookups, and error cases, and registers that executable with CMake and CTest.

Suggested reviewers: nmzik

Change: Bug fix

Merge Risk: Minimal · up to a73d6

This change fixes the termination mapping and adds foreground-user and registered-user-list lookups. The registered list is now fully initialized, so games no longer read stale values. The tests cover the new behavior and are wired into the build. Remaining uncertainty is limited to whether guest slots should appear in the registered list, which is minor and not established as a defect.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two main changes: the sceUserServiceTerminate NID rebinding to UserServiceTerminate, and the new sceUserServiceGetForegroundUser implementation. The summary and objectives both des…
Description check Passed The description states the NID mapping fix, the foreground-user implementation with nullptr validation, the registered user ID list implementation, the new unit test suite, affected titles, and the te…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main changes: the sceUserServiceTerminate NID rebinding to UserServiceTerminate, and the new sceUserServiceGetForegroundUser implementation. The summary and objectives both describe these changes. The title is slightly long at 103 characters, but it is specific and accurate.

Full details: Description check

Explanation

The description states the NID mapping fix, the foreground-user implementation with nullptr validation, the registered user ID list implementation, the new unit test suite, affected titles, and the test run output. It matches the changeset and objectives.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c53ed85166 and a73d62b4fd.

Files selected for processing: 2

  • src/libs/libUserService.cpp
  • tests/UserServiceTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-21 16:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2498#issuecomment-7065879577) · edited 2026-11-21 18:38 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/2498?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_status_start --> No actionable comments were generated in the recent review. <!-- recent_review_status_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> The change adds UserService termination, foreground-user lookup, and registered-user-list functions. It updates symbol registration for these functions and the user-number function. It also adds a Google Test executable with coverage for UserService initialization, lookups, and error cases, and registers that executable with CMake and CTest. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"a73d62b4fd001d70079f1450bad6490d9e214c3f" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>a73d6</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `a73d6` --> <!-- final_review_risk_coverage:{"sourceCommitId":"a73d62b4fd001d70079f1450bad6490d9e214c3f","coveredCommitId":"a73d62b4fd001d70079f1450bad6490d9e214c3f","kind":"reviewed"} --> This change fixes the termination mapping and adds foreground-user and registered-user-list lookups. The registered list is now fully initialized, so games no longer read stale values. The tests cover the new behavior and are wired into the build. Remaining uncertainty is limited to whether guest slots should appear in the registered list, which is minor and not established as a defect. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title names the two main changes: the sceUserServiceTerminate NID rebinding to UserServiceTerminate, and the new sceUserServiceGetForegroundUser implementation. The summary and objectives both des… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description states the NID mapping fix, the foreground-user implementation with nullptr validation, the registered user ID list implementation, the new unit test suite, affected titles, and the te… | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title names the two main changes: the sceUserServiceTerminate NID rebinding to UserServiceTerminate, and the new sceUserServiceGetForegroundUser implementation. The summary and objectives both describe these changes. The title is slightly long at 103 characters, but it is specific and accurate. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description states the NID mapping fix, the foreground-user implementation with nullptr validation, the registered user ID list implementation, the new unit test suite, affected titles, and the test run output. It matches the changeset and objectives. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2498)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> <br> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end --> <!-- recent_review_start --> <h6> <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <br> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/39936ffa39237997080f8d169370667ca63d12fa/.coderabbit.yaml>) - **Commit**: [39936ff](<https://github.com/KytyPS5/KytyPS5/commit/39936ffa39237997080f8d169370667ca63d12fa>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `a2b53d1d-4fac-4ff3-adf9-ed10272164bb` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between c53ed851662bebfa57de6ce0d60917715cf798d0 and a73d62b4fd001d70079f1450bad6490d9e214c3f. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 2</strong></summary> <dl> <dd> <br> * `src/libs/libUserService.cpp` * `tests/UserServiceTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-21 16:44 UTC · original
On src/libs/libUserService.cpp line 131 (outdated):

@@ -110,6 +128,24 @@ static KYTY_SYSV_ABI int UserServiceGetLoginUserIdList(UserServiceLoginUserIdLis
 	return OK;
 }
 
+static KYTY_SYSV_ABI int UserServiceGetRegisteredUserIdList(UserServiceLoginUserIdList* user_id_list) {

Major · Data Integrity & Integration · Quick win

Use the registered-user list layout and initialize every slot.

sceUserServiceGetRegisteredUserIdList takes a registered-user list with 16 entries, not the four-entry login-user list used here. The public headers declare these as separate types. (raw.githubusercontent.com)

With MAX_PLAYERS == 4, the first loop writes four IDs. The trailing loop never runs. A guest that scans all 16 entries therefore reads unchanged values as additional user IDs.

Define a separate registered-user list type. Keep the four configured IDs and fill entries 4 through 15 with -1. Update the registered-list test to check the complete output.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-21 16:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2498#discussion_r4653722636) On `src/libs/libUserService.cpp` line 131 (outdated): ```diff @@ -110,6 +128,24 @@ static KYTY_SYSV_ABI int UserServiceGetLoginUserIdList(UserServiceLoginUserIdLis return OK; } +static KYTY_SYSV_ABI int UserServiceGetRegisteredUserIdList(UserServiceLoginUserIdList* user_id_list) { ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Quick win** **Use the registered-user list layout and initialize every slot.** `sceUserServiceGetRegisteredUserIdList` takes a registered-user list with 16 entries, not the four-entry login-user list used here. The public headers declare these as separate types. ([raw.githubusercontent.com](https://raw.githubusercontent.com/OpenOrbis/OpenOrbis-PS4-Toolchain/master/include/orbis/UserService.h)) With `MAX_PLAYERS == 4`, the first loop writes four IDs. The trailing loop never runs. A guest that scans all 16 entries therefore reads unchanged values as additional user IDs. Define a separate registered-user list type. Keep the four configured IDs and fill entries 4 through 15 with `-1`. Update the registered-list test to check the complete output. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:2732d6247b411c66a1625bcd --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-21 16:44 UTC · original · reviewed

Actionable comments posted: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 39936ffa39 and c53ed85166.

Files selected for processing: 3

  • CMakeLists.txt
  • src/libs/libUserService.cpp
  • tests/UserServiceTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-21 16:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2498#pullrequestreview-6006644964) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/39936ffa39237997080f8d169370667ca63d12fa/.coderabbit.yaml>) - **Commit**: [39936ff](<https://github.com/KytyPS5/KytyPS5/commit/39936ffa39237997080f8d169370667ca63d12fa>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `806ba646-27bd-4b01-9ee5-a14858632e47` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 39936ffa39237997080f8d169370667ca63d12fa and c53ed851662bebfa57de6ce0d60917715cf798d0. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 3</summary> <dl> <dd> <br> * `CMakeLists.txt` * `src/libs/libUserService.cpp` * `tests/UserServiceTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=9d8699dd-fcac-42a4-8639-d61fc3bb4494 attempt=deff5489-7579-4ffc-93d1-f57cc132c079 batch=1/1 -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.