xgameruntime: XUserFindForDevice answers E_GAMEUSER_USER_NOT_FOUND until XUserAddAsync (RT-382) #126

Open
github-bot wants to merge 1 commit from github-bot/gh-126 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:23 UTC · original
ubiquitarianism:old-pr/9860 → main · +40 −7 · 4 files · 1 commits · draft

Carried over from old PR 9860 by milas6669 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9860, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
milas6669: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Resubmission of #5166 (closed during repo transfer/purge at 22:47 UTC). Mergeable with current main with zero conflicts.

Claimed in the coordination issue as: RT-382, https://github.com/ItsNotRexed/Leonida/issues/5156#issuecomment-7095909064 (found by @Roberto0953)

What and why

XUserFindForDevice (XUserDeviceImpl slot 3, device_find_user in runtime/shims/xgameruntime_offline.cpp) handed out an XUserHandle before the title had called XUserAddAsync. The GDK reference says it "cannot return a user handle to a user that hasn't been signed in with a call to XUserAddAsync". A title that probes its devices before signing in saw a user it never added, which can change its first-boot sign-in flow.

  • xgameruntime_user.cpp: an atomic flag, set when XUserAddAsync completes (and when the local user is added by id), exposed to the other shim as xgameruntime_user_was_added().
  • device_find_user: before the flag is set it writes no handle and answers E_GAMEUSER_USER_NOT_FOUND (0x89245104, the code the user shim already uses); after it, the handle as before.
  • docs/runtime_imports.md: the "Devices" paragraph states the rule.

Tested

Windows 11, MSVC 19.44 + Ninja, RelWithDebInfo.

  • xgameruntime_offline_test: passes 32/32 checks (fails 4 of 32 on merge base).
  • ctest -R xgameruntime: 8/8 passed.
  • Independently verified by @shdann, @gertify, @Atomic258, @searyecheesepeaceful on #5166.

Synthetic probes only; no game data.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md).
**@⁠Andretuta** on GitHub · 2026-11-24 02:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/126) `ubiquitarianism:old-pr/9860` → `main` · +40 −7 · 4 files · 1 commits · draft > Carried over from **old PR 9860** by `milas6669` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9860`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `milas6669`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Resubmission of `#5166` (closed during repo transfer/purge at 22:47 UTC). Mergeable with current main with zero conflicts. Claimed in the coordination issue as: RT-382, https://github.com/ItsNotRexed/Leonida/issues/5156#issuecomment-7095909064 (found by `@Roberto0953`) ### What and why `XUserFindForDevice` (XUserDeviceImpl slot 3, `device_find_user` in `runtime/shims/xgameruntime_offline.cpp`) handed out an `XUserHandle` before the title had called `XUserAddAsync`. The GDK reference says it "cannot return a user handle to a user that hasn't been signed in with a call to XUserAddAsync". A title that probes its devices before signing in saw a user it never added, which can change its first-boot sign-in flow. - `xgameruntime_user.cpp`: an atomic flag, set when `XUserAddAsync` completes (and when the local user is added by id), exposed to the other shim as `xgameruntime_user_was_added()`. - `device_find_user`: before the flag is set it writes no handle and answers `E_GAMEUSER_USER_NOT_FOUND` (`0x89245104`, the code the user shim already uses); after it, the handle as before. - `docs/runtime_imports.md`: the "Devices" paragraph states the rule. ### Tested Windows 11, MSVC 19.44 + Ninja, RelWithDebInfo. - `xgameruntime_offline_test`: passes 32/32 checks (fails 4 of 32 on merge base). - `ctest -R xgameruntime`: 8/8 passed. - Independently verified by `@shdann`, `@gertify`, `@Atomic258`, `@searyecheesepeaceful` on `#5166`. Synthetic probes only; no game data. AI-assisted: yes ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md).
The GDK reference says XUserFindForDevice cannot return a user handle to a user that
was not signed in with a call to XUserAddAsync. Track whether the offline user was
added (XUserAddAsync, or the local user by id) and answer E_GAMEUSER_USER_NOT_FOUND
with no handle before that. The HRESULT is an assumption: the reference names no code.
docs/runtime_imports.md updated; the offline test asks before and after the add.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

# Conflicts:
#	docs/runtime_imports.md
#	runtime/test/xgameruntime_offline_test.cpp
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:45:21 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/126/head:github-bot/gh-126'
git switch 'github-bot/gh-126'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-126'
git switch 'github-bot/gh-126'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-126'
git switch 'github-bot/gh-126'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-126'
git switch 'main'
git merge --squash 'github-bot/gh-126'
git switch 'main'
git merge --ff-only 'github-bot/gh-126'
git switch 'main'
git merge 'github-bot/gh-126'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.