feat(libSceUserService): take the user name from ANYPS5_USER_NAME #9345

Open
Techx3 wants to merge 1 commit from upstream-pr/9345 into main
Techx3 commented 2026-10-21 18:59:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Techx3 on 2026-10-21T18:59:29Z.


What

sceUserServiceGetUserName reports ANYPS5_USER_NAME when it is set and not empty, so a launcher can show its own user's name in games. Unset or empty keeps Player. A name longer than 16 bytes throws with the variable's name, like ANYPS5_LANGUAGE. Documented in docs/user/USAGE.md and docs/dev/ENVIRONMENT.md; GuestUserServiceUserName covers set, empty, UTF-8, 16 and 17 bytes, and the short buffer with a name set.

Tested

Linux, g++: built libSceUserService/Export.cpp with core/libs/tests/GuestUserServiceUserName.cpp; the test passes, and fails against main. Not checked in a title that shows the user name. tools/check_conventions.py --base origin/main passes.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4956812581 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9345). Originally posted by [Techx3](https://github.com/Techx3) on 2026-10-21T18:59:29Z. --- ### What `sceUserServiceGetUserName` reports `ANYPS5_USER_NAME` when it is set and not empty, so a launcher can show its own user's name in games. Unset or empty keeps `Player`. A name longer than 16 bytes throws with the variable's name, like `ANYPS5_LANGUAGE`. Documented in `docs/user/USAGE.md` and `docs/dev/ENVIRONMENT.md`; `GuestUserServiceUserName` covers set, empty, UTF-8, 16 and 17 bytes, and the short buffer with a name set. ### Tested Linux, g++: built `libSceUserService/Export.cpp` with `core/libs/tests/GuestUserServiceUserName.cpp`; the test passes, and fails against `main`. Not checked in a title that shows the user name. `tools/check_conventions.py --base origin/main` passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
ycbuzi commented 2026-10-21 22:41:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T22:41:56Z.


Windows run of 753030c31c merged onto main a6dcea9279 (6dd107b324, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceUserService and guest_user_service_user_name_tests with no errors or warnings. guest_user_service_user_name fails on Windows: the new length check throws inside libSceUserService.prx, and the test's catch never receives it:

  what():  sceUserServiceGetUserName: ANYPS5_USER_NAME must be at most 16 bytes, not 17
FATAL: abort() (SIGABRT)

Exit code 0xc0000409. On MinGW the libraries are built with -fno-asynchronous-unwind-tables, so a test that catches an exception from one needs configure_windows_unwind; guest_user_service_tests in the same CMakeLists.txt has it, guest_user_service_user_name_tests does not. With this one line added after its target_link_libraries (merge 0499f95b39), the test passes on both repeats of ctest --repeat until-fail:2:

    configure_windows_unwind(guest_user_service_user_name_tests)

Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328166678 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9345#issuecomment-6328166678). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T22:41:56Z. --- Windows run of 753030c31c merged onto `main` a6dcea9279 (6dd107b324, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceUserService` and `guest_user_service_user_name_tests` with no errors or warnings. `guest_user_service_user_name` fails on Windows: the new length check throws inside `libSceUserService.prx`, and the test's `catch` never receives it: ``` what(): sceUserServiceGetUserName: ANYPS5_USER_NAME must be at most 16 bytes, not 17 FATAL: abort() (SIGABRT) ``` Exit code `0xc0000409`. On MinGW the libraries are built with `-fno-asynchronous-unwind-tables`, so a test that catches an exception from one needs `configure_windows_unwind`; `guest_user_service_tests` in the same `CMakeLists.txt` has it, `guest_user_service_user_name_tests` does not. With this one line added after its `target_link_libraries` (merge 0499f95b39), the test passes on both repeats of `ctest --repeat until-fail:2`: ```cmake configure_windows_unwind(guest_user_service_user_name_tests) ``` Not run: a title.
xXPBSXx commented 2026-10-22 04:41:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-22T04:41:18Z.


Linux data point for 753030c31c (WSL2, Ubuntu 24.04, kernel 6.18 - a virtualised kernel, not bare-metal Linux; GCC 13.3, Release, BUILD_TESTING=ON), this head merged onto main df2569d2c5 (clean merge). I built guest_user_service_user_name_tests and ran the executable directly (exit code, not through ctest):

  • With the PR: exit code 0.
  • Without it (the PR's test sources on top of main, with core/libs/prx/libSceUserService/Export.cpp and UserService.hpp reset to main): it aborts (SIGABRT, exit code 134).
    Not tested: macOS, Windows, the rest of the test suite.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6332875862 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9345#issuecomment-6332875862). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-22T04:41:18Z. --- Linux data point for `753030c31c` (WSL2, Ubuntu 24.04, kernel 6.18 - a virtualised kernel, not bare-metal Linux; GCC 13.3, Release, `BUILD_TESTING=ON`), this head merged onto `main` `df2569d2c5` (clean merge). I built `guest_user_service_user_name_tests` and ran the executable directly (exit code, not through `ctest`): - With the PR: exit code 0. - Without it (the PR's test sources on top of `main`, with `core/libs/prx/libSceUserService/Export.cpp and UserService.hpp` reset to `main`): it aborts (SIGABRT, exit code 134). Not tested: macOS, Windows, the rest of the test suite. AI-assisted (Claude Code).
harisibrar1 commented 2026-10-22 13:42:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T13:42:54Z.

Review: COMMENTED


Checked against main 8b3e39832a (sceUserServiceGetUserName still copies "Player"; ANYPS5_LANGUAGE in SystemService.hpp as the pattern) and a local Windows probe of the UCRT getenv:

  • The PR and its tests treat the variable as UTF-8 (Jos\xc3\xa9), but on Windows std::getenv returns the value in the ANSI code page. On my Windows 11 machine (ACP 1252), with ANYPS5_USER_NAME set from PowerShell, ucrtbase's getenv returned Jos\xe9 for José (not valid UTF-8), ????? for ユーザー名, and 9 bytes for ÉÉÉÉÉÉÉÉÉ, which passes the 16-byte check though the UTF-8 name is 18 bytes.
  • The test sets the value with _putenv_s, which round-trips the same narrow bytes, so it can't see this.
  • Main reads non-ASCII variables with _wgetenv on Windows (ANYPS5_INPUT_CONFIG in InputMapping.cpp, ANYPS5_SHADER_CACHE_DIR in ShaderDiskCache.cpp). Doing the same here and converting to UTF-8 before the length check would make the 16-byte limit and the USAGE.md wording hold on Windows.
  • Optional: rejecting a value that isn't valid UTF-8, with the same error that names the variable, would keep an odd Linux locale from passing invalid bytes to the game.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5615174923 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9345#pullrequestreview-5615174923). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-22T13:42:54Z. **Review:** COMMENTED --- Checked against main 8b3e39832a (`sceUserServiceGetUserName` still copies `"Player"`; `ANYPS5_LANGUAGE` in `SystemService.hpp` as the pattern) and a local Windows probe of the UCRT `getenv`: - The PR and its tests treat the variable as UTF-8 (`Jos\xc3\xa9`), but on Windows `std::getenv` returns the value in the ANSI code page. On my Windows 11 machine (ACP 1252), with `ANYPS5_USER_NAME` set from PowerShell, ucrtbase's `getenv` returned `Jos\xe9` for `José` (not valid UTF-8), `?????` for `ユーザー名`, and 9 bytes for `ÉÉÉÉÉÉÉÉÉ`, which passes the 16-byte check though the UTF-8 name is 18 bytes. - The test sets the value with `_putenv_s`, which round-trips the same narrow bytes, so it can't see this. - Main reads non-ASCII variables with `_wgetenv` on Windows (`ANYPS5_INPUT_CONFIG` in `InputMapping.cpp`, `ANYPS5_SHADER_CACHE_DIR` in `ShaderDiskCache.cpp`). Doing the same here and converting to UTF-8 before the length check would make the 16-byte limit and the USAGE.md wording hold on Windows. - Optional: rejecting a value that isn't valid UTF-8, with the same error that names the variable, would keep an odd Linux locale from passing invalid bytes to the game. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
MarcZX10 commented 2026-11-17 05:28:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T05:28:21Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this; the points below are optional.

What I ran

  • Head 753030c31c4abfe0529dd0ed573ca0af9eb341e3, base main. No build and no test run in this review.
  • Repository searches at the head with the repository reader (repo_read.py) for ANYPS5_USER_NAME, ANYPS5_LANGUAGE and the new function.
  • Files read: UserService.hpp and GuestUserServiceUserName.cpp in full; the changed function in Export.cpp (lines 128–143); the changed sections of docs/dev/ENVIRONMENT.md and docs/user/USAGE.md.
  • Files excluded by rule: none.

Results

Check Result Note
Build and GuestUserServiceUserName test not run Author reports a pass on Linux g++
tools/check_conventions.py not run Author reports a pass
Repository search for the variable and symbols passed Names resolve at the head
No comments added in code passed Checked in the diff
Error style matches ANYPS5_LANGUAGE passed Same throw pattern

Findings

Blocking

None.

Non-blocking

  • docs/user/USAGE.md:239 says a longer name "stops the game at its first user name query". A query with a buffer under 17 bytes returns USER_SERVICE_ERROR_BUFFER_TOO_SHORT before the variable is read (core/libs/prx/libSceUserService/Export.cpp:139), so the error waits for a query with a buffer of 17 bytes or more. Consider saying so in the sentence.

Sources

Not verified

  • The Linux build and the GuestUserServiceUserName test, and the Windows _putenv_s branch. These are the author's reports only.
  • tools/check_conventions.py, the claim that no other open PR implements these functions, and the title that shows the name (the author also says that one was not checked).
  • Only the changed sections of docs/dev/ENVIRONMENT.md and docs/user/USAGE.md were read, not the full files.
  • Behaviour inside a running game.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5933422296 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9345#pullrequestreview-5933422296). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T05:28:21Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this; the points below are optional. ## What I ran - Head `753030c31c4abfe0529dd0ed573ca0af9eb341e3`, base `main`. No build and no test run in this review. - Repository searches at the head with the repository reader (`repo_read.py`) for `ANYPS5_USER_NAME`, `ANYPS5_LANGUAGE` and the new function. - Files read: `UserService.hpp` and `GuestUserServiceUserName.cpp` in full; the changed function in `Export.cpp` (lines 128–143); the changed sections of `docs/dev/ENVIRONMENT.md` and `docs/user/USAGE.md`. - Files excluded by rule: none. ## Results | Check | Result | Note | |-------|--------|------| | Build and `GuestUserServiceUserName` test | not run | Author reports a pass on Linux g++ | | `tools/check_conventions.py` | not run | Author reports a pass | | Repository search for the variable and symbols | passed | Names resolve at the head | | No comments added in code | passed | Checked in the diff | | Error style matches `ANYPS5_LANGUAGE` | passed | Same throw pattern | ## Findings **Blocking** None. **Non-blocking** - `docs/user/USAGE.md:239` says a longer name "stops the game at its first user name query". A query with a buffer under 17 bytes returns `USER_SERVICE_ERROR_BUFFER_TOO_SHORT` before the variable is read (`core/libs/prx/libSceUserService/Export.cpp:139`), so the error waits for a query with a buffer of 17 bytes or more. Consider saying so in the sentence. ## Sources - [`sceUserServiceGetUserName`](https://github.com/boykopovar/AnyPS5/blob/753030c31c4abfe0529dd0ed573ca0af9eb341e3/core/libs/prx/libSceUserService/Export.cpp#L128-L143) - [`UserServiceUserName`](https://github.com/boykopovar/AnyPS5/blob/753030c31c4abfe0529dd0ed573ca0af9eb341e3/core/libs/prx/libSceUserService/UserService.hpp#L26-L35) - [Existing `ANYPS5_LANGUAGE` pattern](https://github.com/boykopovar/AnyPS5/blob/753030c31c4abfe0529dd0ed573ca0af9eb341e3/core/libs/prx/libSceSystemService/SystemService.hpp#L41-L48) ## Not verified - The Linux build and the `GuestUserServiceUserName` test, and the Windows `_putenv_s` branch. These are the author's reports only. - `tools/check_conventions.py`, the claim that no other open PR implements these functions, and the title that shows the name (the author also says that one was not checked). - Only the changed sections of `docs/dev/ENVIRONMENT.md` and `docs/user/USAGE.md` were read, not the full files. - Behaviour inside a running game. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 12:02:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:02:53Z.

Review: COMMENTED


Compiled the changed UserService implementation with GuestUserServiceUserName against the existing Linux PRXs. It passed the default, ASCII and UTF-8 overrides, length boundary, and too-short destination cases.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6169386941 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9345#pullrequestreview-6169386941). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T12:02:53Z. **Review:** COMMENTED --- Compiled the changed UserService implementation with `GuestUserServiceUserName` against the existing Linux PRXs. It passed the default, ASCII and UTF-8 overrides, length boundary, and too-short destination cases. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/9345:upstream-pr/9345'
git switch 'upstream-pr/9345'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/9345'
git switch 'upstream-pr/9345'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/9345'
git switch 'upstream-pr/9345'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/9345'
git switch 'main'
git merge --squash 'upstream-pr/9345'
git switch 'main'
git merge --ff-only 'upstream-pr/9345'
git switch 'main'
git merge 'upstream-pr/9345'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9345
No description provided.