Skip to content

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

Draft
Andretuta wants to merge 1 commit into
mainfrom
old-pr/9860
Draft

Andretuta wants to merge 1 commit into
mainfrom
old-pr/9860

Conversation

@Andretuta

Copy link
Copy Markdown
Collaborator

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

…til XUserAddAsync (RT-382)

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 <noreply@anthropic.com>

# Conflicts:
#	docs/runtime_imports.md
#	runtime/test/xgameruntime_offline_test.cpp
@fiestorra

Copy link
Copy Markdown
Contributor

Independent verification on this machine (Windows 11, MSVC 19.44.35226), with a negative control that bites on both tests.

1. It applies. merge-tree clean; the commits cherry-pick onto main 4014af7fe without a conflict. Four files, two of them shims: runtime/shims/xgameruntime_offline.cpp and runtime/shims/xgameruntime_user.cpp.

2. With the branch, both tests pass:

ctest -R '^xgameruntime_offline'
100% tests passed, 0 tests failed out of 2

3. The control - revert both shims, keep the test:

git checkout origin/main -- runtime/shims/xgameruntime_user.cpp runtime/shims/xgameruntime_offline.cpp
cmake --build … --target xgameruntime_offline_test
ctest -R '^xgameruntime_offline' --output-on-failure
0% tests passed, 2 tests failed out of 2
FAIL XUserFindForDevice before XUserAddAsync: E_GAMEUSER_USER_NOT_FOUND and no handle

That assertion is the change: before this branch, the offline shim answered a per-client query for a user that had not signed in yet, instead of failing with E_GAMEUSER_USER_NOT_FOUND and writing no handle. The test names the exact behaviour the diff adds, which is the cleanest kind of control - the failure message is a sentence about the change, not a generic mismatch.

What the change is, from the diff and the doc it updates: XUserFindForDevice (and the by-id path) now answer E_GAMEUSER_USER_NOT_FOUND and write no handle until XUserAddAsync has completed, quoting the SDK's own rule that a user handle cannot be returned for a user not signed in with XUserAddAsync.

What I did not test: the rest of the offline surface, and the docs/runtime_imports.md half of the change (documentation, no executable path).

Why I am commenting: I verify open pull requests that replay onto current main by applying them in a scratch worktree, building the targets their tests name in ctest --show-only=json-v1, running them, and then reverting only the source change to see whether the tests still pass. This is the fifth control on the shortlist of 122: #156 and #537 bite, #126 bites on both tests, #183's control is compile-level only, and #138's did not bite on half of its change.

Written with an AI assistant.

@MoonEyes

Copy link
Copy Markdown
Collaborator

The change is still relevant: current main unconditionally hands out an offline user in device_find_user, and its test still expects that before XUserAddAsync. The independent Windows recheck reports both targeted tests pass and its negative control fails as expected. I am leaving this open, not merge-ready: the branch commit records conflicts in docs/runtime_imports.md and runtime/test/xgameruntime_offline_test.cpp, it is still a draft, and the available CI checks were cancelled. Please rebase onto current main and rerun the required CI/Windows runtime checks; keep the HRESULT assumption explicit as documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants