[PR #126] xgameruntime: XUserFindForDevice answers E_GAMEUSER_USER_NOT_FOUND until XUserAddAsync (RT-382) #178

Open
opened 2026-11-26 20:17:02 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/126
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9860


📝 Commits (1)

  • b18da3d xgameruntime: XUserFindForDevice answers E_GAMEUSER_USER_NOT_FOUND until XUserAddAsync (RT-382)

📊 Changes

4 files changed (+40 additions, -7 deletions)

View changed files

📝 docs/runtime_imports.md (+5 -2)
📝 runtime/shims/xgameruntime_offline.cpp (+9 -1)
📝 runtime/shims/xgameruntime_user.cpp (+8 -0)
📝 runtime/test/xgameruntime_offline_test.cpp (+18 -4)

📄 Description

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).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/126 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9860` --- ### 📝 Commits (1) - [`b18da3d`](https://github.com/ubiquitarianism/leonida/commit/b18da3d13c01f2db49ec69ba1f55844e2024ea67) xgameruntime: XUserFindForDevice answers E_GAMEUSER_USER_NOT_FOUND until XUserAddAsync (RT-382) ### 📊 Changes **4 files changed** (+40 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `docs/runtime_imports.md` (+5 -2) 📝 `runtime/shims/xgameruntime_offline.cpp` (+9 -1) 📝 `runtime/shims/xgameruntime_user.cpp` (+8 -0) 📝 `runtime/test/xgameruntime_offline_test.cpp` (+18 -4) </details> ### 📄 Description > 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#178
No description provided.