libNet: answer sceNpGetAccountLanguage2 as a signed-out user #1186

Manually merged
github merged 2 commits from gh-pr/1186/head into gh-pr/1186/base 2026-11-26 09:47:01 +00:00
Owner

@⁠overlordxrz-source on GitHub · 2026-10-08 02:31 UTC · original
overlordxrz-source:libs/np-account-language2 → main · +22 −0 · 3 files · 2 commits · merged 2026-10-08 12:48 UTC

sceNpGetAccountLanguage2 (3Tcz5bNCfZQ) is not registered, so games that call it get the unresolved-import stub. The stub returns 0. That tells the game the request worked and that its language-code buffer now holds the account's language, but nothing was written there.

Every other NpManager account query in network.cpp answers as a signed-out user: sceNpGetAccountAge, sceNpGetAccountCountryA, sceNpGetAccountIdA, sceNpGetNpId. This registers sceNpGetAccountLanguage2 next to them and does the same:

  • SCE_NP_ERROR_INVALID_ARGUMENT (0x80550003) for a request id <= 0 or a null output pointer, the same check NpGetAccountAge makes
  • SCE_NP_ERROR_REQUEST_NOT_FOUND (0x80550014) when a positive request id does not refer to a live request, including a deleted request
  • SCE_NP_ERROR_SIGNED_OUT (0x80550006) for an existing request
  • the request lookup uses the same mutex as request creation and deletion
  • the output is left untouched

The arguments are (req_id, user_id, language_code*), the same shape as sceNpGetAccountAge and sceNpGetAccountLanguageA. The call sequence in the Saros log fits that too.

Evidence

  • #1053 Saros (PPSA07631): on SIEAnalyticsWorkerThread, the game creates a request, calls sceNpGetAccountAge (which returns SIGNED_OUT) and deletes the request. Then it creates a new request and hits Unresolved import stub called [0]: ... symbol=3Tcz5bNCfZQ[NpManager_v1][NpManager_v1.1][Func], then deletes that request. So right now it's told the user is signed out for the age query and signed in for the language query.
  • #890 Demon's Souls, #1095 Ghost of Yōtei and #1101 NHL 27 import it as well (their logs show it patched to the stub)

This is a consistency fix. I'm not claiming it changes how far any of these games get.

Testing

There's no NpManager test target, and adding a full-emulator one for this felt like too much. What I ran (my machine is aarch64 Linux, no Vulkan):

  • a native harness built from network.cpp and libNet.cpp (zig c++ 0.16, static musl, with unreferenced emulator symbols stubbed). It resolves 3Tcz5bNCfZQ through InitNet_1_NpManager and checks SIGNED_OUT for a valid request, that the output buffer is untouched, INVALID_ARGUMENT for request id 0, a negative request id and a null pointer, and that the codes match NpGetAccountAge. All of them pass.
  • compiled network.cpp and libNet.cpp for x86_64-linux-gnu at -Wall -Wextra. The new lines add no warnings.
  • changed lines are clean under src/.clang-format (clang-format 23.1.3)

Not built on Windows or macOS.

Follow-up verification:

  • 13 focused checks compiled from the production NpManager functions passed: missing/deleted request ids, live synchronous/asynchronous requests, id reuse, invalid arguments, and untouched output.
  • Clang C++20 syntax checks for network.cpp and libNet.cpp at -Wall -Wextra passed; warnings were in existing code.
  • git diff --check and formatting checks for the changed function passed.

AI assistance

An AI assistant helped me find the missing export in the issue logs, write the change and the harness, and run the builds above. I reviewed the code and the results.

**@⁠overlordxrz-source** on GitHub · 2026-10-08 02:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1186) `overlordxrz-source:libs/np-account-language2` → `main` · +22 −0 · 3 files · 2 commits · merged 2026-10-08 12:48 UTC `sceNpGetAccountLanguage2` (`3Tcz5bNCfZQ`) is not registered, so games that call it get the unresolved-import stub. The stub returns 0. That tells the game the request worked and that its language-code buffer now holds the account's language, but nothing was written there. Every other NpManager account query in `network.cpp` answers as a signed-out user: `sceNpGetAccountAge`, `sceNpGetAccountCountryA`, `sceNpGetAccountIdA`, `sceNpGetNpId`. This registers `sceNpGetAccountLanguage2` next to them and does the same: - `SCE_NP_ERROR_INVALID_ARGUMENT` (`0x80550003`) for a request id <= 0 or a null output pointer, the same check `NpGetAccountAge` makes - `SCE_NP_ERROR_REQUEST_NOT_FOUND` (`0x80550014`) when a positive request id does not refer to a live request, including a deleted request - `SCE_NP_ERROR_SIGNED_OUT` (`0x80550006`) for an existing request - the request lookup uses the same mutex as request creation and deletion - the output is left untouched The arguments are `(req_id, user_id, language_code*)`, the same shape as `sceNpGetAccountAge` and `sceNpGetAccountLanguageA`. The call sequence in the Saros log fits that too. ## Evidence - #1053 Saros (PPSA07631): on `SIEAnalyticsWorkerThread`, the game creates a request, calls `sceNpGetAccountAge` (which returns SIGNED_OUT) and deletes the request. Then it creates a new request and hits `Unresolved import stub called [0]: ... symbol=3Tcz5bNCfZQ[NpManager_v1][NpManager_v1.1][Func]`, then deletes that request. So right now it's told the user is signed out for the age query and signed in for the language query. - #890 Demon's Souls, #1095 Ghost of Yōtei and #1101 NHL 27 import it as well (their logs show it patched to the stub) This is a consistency fix. I'm not claiming it changes how far any of these games get. ## Testing There's no NpManager test target, and adding a full-emulator one for this felt like too much. What I ran (my machine is aarch64 Linux, no Vulkan): - a native harness built from `network.cpp` and `libNet.cpp` (zig c++ 0.16, static musl, with unreferenced emulator symbols stubbed). It resolves `3Tcz5bNCfZQ` through `InitNet_1_NpManager` and checks SIGNED_OUT for a valid request, that the output buffer is untouched, INVALID_ARGUMENT for request id 0, a negative request id and a null pointer, and that the codes match `NpGetAccountAge`. All of them pass. - compiled `network.cpp` and `libNet.cpp` for `x86_64-linux-gnu` at `-Wall -Wextra`. The new lines add no warnings. - changed lines are clean under `src/.clang-format` (clang-format 23.1.3) Not built on Windows or macOS. Follow-up verification: - 13 focused checks compiled from the production NpManager functions passed: missing/deleted request ids, live synchronous/asynchronous requests, id reuse, invalid arguments, and untouched output. - Clang C++20 syntax checks for `network.cpp` and `libNet.cpp` at `-Wall -Wextra` passed; warnings were in existing code. - `git diff --check` and formatting checks for the changed function passed. ## AI assistance An AI assistant helped me find the missing export in the issue logs, write the change and the harness, and run the builds above. I reviewed the code and the results.
sceNpGetAccountLanguage2 was not registered, so games that call it hit
the unresolved-import stub. The stub returns 0, which tells the game the
request succeeded and that the language code buffer now holds the
account's language, but nothing was written to it.

Saros (#1053) calls it from its analytics thread right after
sceNpGetAccountAge, each on its own request. sceNpGetAccountAge already
reports SCE_NP_ERROR_SIGNED_OUT there, so the game is told the user is
signed out for one query and signed in for the next. Demon's Souls
(#890), Ghost of Yotei (#1095) and NHL 27 (#1101) import it as well.

Register it next to the other NpManager account queries and answer the
way they do: SCE_NP_ERROR_INVALID_ARGUMENT for a request id <= 0 or a
null output pointer, SCE_NP_ERROR_SIGNED_OUT otherwise. The output is
left untouched because nothing was looked up.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:46:58 +00:00
github manually merged commit 9407ba9876 into gh-pr/1186/base 2026-11-26 09:47:01 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 02:34 UTC · original · edited 2026-10-08 12:46 UTC

Review in Change Stack →

📝 Walkthrough

Walkthrough

The change adds NpGetAccountLanguage2 to the NpManager API and symbol table. The function returns np_error_invalid_argument when the request ID is nonpositive or the language-code pointer is null. If no active request matches the ID, it returns np_error_request_not_found. Otherwise, it returns np_error_signed_out without writing a language code.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: 🟡 Moderate · up to 9407b

Callers can receive an inconsistent error for the new account-language query. Correct the response before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the main change: registering and implementing sceNpGetAccountLanguage2 to return the signed-out response.
Description check ✅ Passed The description directly explains the registration, signed-out behavior, error handling, rationale, and validation for the changeset.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 02:34 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1186#issuecomment-6050996743) · edited 2026-10-08 12:46 UTC <!-- 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/1186?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The change adds `NpGetAccountLanguage2` to the `NpManager` API and symbol table. The function returns `np_error_invalid_argument` when the request ID is nonpositive or the language-code pointer is null. If no active request matches the ID, it returns `np_error_request_not_found`. Otherwise, it returns `np_error_signed_out` without writing a language code. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"9407ba987676051b7fc405007d2e70e4ce5a5571" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **🟡 Moderate** · up to `9407b` <!-- final_review_risk_coverage:{"sourceCommitId":"9407ba987676051b7fc405007d2e70e4ce5a5571","coveredCommitId":"9407ba987676051b7fc405007d2e70e4ce5a5571","kind":"reviewed"} --> Callers can receive an inconsistent error for the new account-language query. Correct the response before merging. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :--------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------ | :------- | :--------------------------------------------------------------------------------------------------------------------------------------- | | 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. | | Title check | ✅ Passed | The title clearly identifies the main change: registering and implementing `sceNpGetAccountLanguage2` to return the signed-out response. | | Description check | ✅ Passed | The description directly explains the registration, signed-out behavior, error handling, rationale, and validation for the changeset. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1186)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [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) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -4109,0 +4120,4 @@
std::lock_guard lock(g_np_request_mutex);
if (np_get_request_locked(req_id) == nullptr) {
return np_error_request_not_found;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 12:44 UTC · original

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Return np_error_signed_out for positive IDs without a request.

NpGetAccountAge returns np_error_signed_out for any positive req_id when its output pointer is valid. If the caller passes that same ID to NpGetAccountLanguage2 without creating a request, this lookup returns np_error_request_not_found instead. Remove the request lookup so the two account queries give the intended signed-out response and leave the language output untouched.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 12:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1186#discussion_r4219068810) **🎯 Functional Correctness** | **🟠 Major** | **⚡ Quick win** **Return `np_error_signed_out` for positive IDs without a request.** `NpGetAccountAge` returns `np_error_signed_out` for any positive `req_id` when its output pointer is valid. If the caller passes that same ID to `NpGetAccountLanguage2` without creating a request, this lookup returns `np_error_request_not_found` instead. Remove the request lookup so the two account queries give the intended signed-out response and leave the language output untouched. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:07f3869fddad00867f7ec343 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 12:44 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f20b0d9-f940-45f7-84d7-183e68e98b89
📥 Commits

Reviewing files that changed from the base of the PR and between 40cee61178 and 9407ba9876.

📒 Files selected for processing (1)
  • src/libs/network.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 12:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1186#pullrequestreview-5456754668) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `2f20b0d9-f940-45f7-84d7-183e68e98b89` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 40cee61178ba21a381230e5cfaab7b84b39f6396 and 9407ba987676051b7fc405007d2e70e4ce5a5571. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/libs/network.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=d0268251-6206-4bae-acf3-5bb95f5f5718 attempt=930fb293-3175-4c50-b370-bc80acaec19a batch=1/1 -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.