Skip to content

gameinput: serve GameInput.dll's ordinal 1, the retail executable's GameInputCreate import - #7216

Open
gkissel wants to merge 1 commit into
ItsNotRexed:mainfrom
gkissel:fix/gameinput-ordinal-1
Open

gkissel wants to merge 1 commit into
ItsNotRexed:mainfrom
gkissel:fix/gameinput-ordinal-1

Conversation

@gkissel

@gkissel gkissel commented Nov 23, 2026

Copy link
Copy Markdown

What and why

The retail 1.0.2.1 executable imports GameInputCreate from GameInput.dll by ordinal 1, not by name. Loader::resolve looks an ordinal import up in the shim table as gameinput.dll!#1, which wasn't registered, so the import fell through to the host's GameInput.dll:

  • On Windows, the installed GameInput answers, so this went unnoticed.
  • Under Wine (11.21 here), the host DLL is Wine's builtin stub (fixme:ginput:GameInputCreate ... stub!). The call fails and the title stops on the result with its own int3, before D3D12XboxCreateDevice.

The change adds {"gameinput.dll", "#1", &GameInputCreate} to the existing SHIM_TABLE (built only with SDL3, as before), plus one check in gameinput_test that #1 is the same function.

Why ordinal 1 is GameInputCreate: Wine's gameinput.spec has it as the first and only export, the executable's call passes a single out-pointer and checks the HRESULT (the GameInputCreate(IGameInput**) shape), and with the alias the title goes on past this point.

Tested

Linux, Wine 11.21, clang-cl + xwin cross build, -DLEONIDA_SDL3_FETCH=ON, GTX 1650 Mobile, own copy of the retail executable (outcomes only):

Related, not changed here

make_game.py's Linux cross build doesn't pass -DLEONIDA_SDL3_FETCH=ON, and xwin has no SDL3. So the GameInput shim is never built for Wine users, and they hit this stop even with the alias. Passing the option from make_game.py would download the pinned, hash-checked SDL3 at configure time. The README says nothing is downloaded unless asked, so I left that choice to you; I can add it (or a flag for it) in a follow-up.

AI-assisted (Claude Code). No game files, bytes or addresses in this PR.

…ameInputCreate import

The retail executable imports GameInputCreate from GameInput.dll by ordinal 1. The loader looks ordinal imports up
as "ItsNotRexed#1", which the shim table did not have, so the import bound to the host's GameInput.dll. On Windows the
installed GameInput answers; under Wine it is the builtin stub, the call fails and the title stops on its result.
The alias maps ItsNotRexed#1 to the same GameInputCreate, and gameinput_test checks it.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 16:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@tikD1337

Copy link
Copy Markdown
Contributor

Review: gameinput: serve GameInput.dll's ordinal 1 (#7216)

Verdict: approve. This is a two-line fix that is correct and matches how the loader already names ordinal imports. One optional follow-up on the test is below.

What changed

  • runtime/shims/gameinput.cpp: SHIM_TABLE(gameinput, …) gets a third entry, {"gameinput.dll", "#1", &GameInputCreate}. It sits beside the existing by-name entries for gameinput.dll and xgameruntime.dll. A comment explains why the alias is there.
  • runtime/test/gameinput_test.cpp: one more registry check. It asserts that rt::shims::find("gameinput.dll", "#1") returns the same function pointer as the by-name GameInputCreate.

Why it is sound

The loader's key matches. In Loader::resolve, runtime/src/pe_loader.cpp:1478-1485 lowercases the DLL name and turns an ordinal import into the key "#" + std::to_string(ordinal). It then tries shims::find(key, sym) before anything else. The import descriptor walk at pe_loader.cpp:1526-1527 takes the ordinal with IMAGE_ORDINAL64, so an import of GameInput.dll ordinal 1 is looked up exactly as ("gameinput.dll", "#1"). That is the key this PR registers. Exports of loaded modules use the same #N form (pe_loader.cpp:1416, and pe_loader.h:25/:46 document it), so this is the loader's existing convention and not a new one.

Forwarders also work. resolve_forwarder (pe_loader.cpp:1436-1437) checks shims::find(shim_key, symbol) with the raw #N string before it parses the ordinal. A forwarder string like GameInput.#1 would reach the shim too.

The ordinal-to-function mapping is already documented. The D3D12 → Vulkan notes say "GameInput.dll ordinal 1 is GameInputCreate" (docs/d3d12_vulkan.md, the export-inventory row on line 3752). The PR's claim is therefore a measured one, not a hypothesis.

The failure it describes is real. Without the alias, the lookup misses the shim. Nothing named GameInput.dll ships in the game folder, so the loader falls through to the host: LoadLibraryExA(..., LOAD_LIBRARY_SEARCH_SYSTEM32) followed by GetProcAddress(h, MAKEINTRESOURCEA(1)) (pe_loader.cpp:1503-1509). On a host with a real or Wine-builtin GameInput, that binds the title to the host implementation and not to rt::gameinput. If it binds anywhere, the import is recorded as Binding::Host, so the miss would not even appear as an unimplemented import. Registering the alias fixes the problem at the lookup and adds no special case in the loader.

Same function, so no ABI or state concerns. The alias points at &GameInputCreate itself, not a wrapper. Calling convention, the IGameInput singleton and refcounting are the same whether the title imports by name or by ordinal.

Notes (none blocking)

  1. The test covers the registry but not the loader's key. The new check confirms the table entry. It would not catch a future change to the key Loader::resolve builds, for example zero-padding or a different prefix. If loader_test can already build a small PE with an ordinal import, which it does for other cases under %TEMP%\leonida_loader_test, one case importing gameinput.dll ordinal 1 and asserting Binding::Shim would cover the whole path. A follow-up is fine for this.
  2. The matching XAudio2 import may have the same gap. The same doc row says XAudio2_9.dll ordinal 1 is XAudio2Create, and runtime/shims has no xaudio2_9.dll entries at all. If the retail executable imports XAudio2 by ordinal too, it would also bind to the host today. I haven't looked into it further; it may be worth posting as a finding: in the coordination issue rather than adding it to this PR.
  3. A GetProcAddress call at run time is a separate path. This PR fixes the static import. If the title also calls GetProcAddress(hGameInput, MAKEINTRESOURCEA(1)) itself, that goes through the GetProcAddress shim, not Loader::resolve. It is out of scope here; I'm noting it only so nobody assumes this alias covers that case.

Test results (Windows 11, CPython 3.13, no game files)

Check Result
git diff --check PASS
python -m compileall -q make_game.py tools tests PASS
python -I scripts/check_no_game_data.py on the changed files PASS
python -I make_game.py --help PASS
Targeted tests None run. The harness found no matching Python test file. The changed test is the C++ gameinput_test, which runs under ctest, and it was not built or run in this verification. The new assertion is therefore checked by reading the code, not by a test run.

For reference, the command that runs it: cmake --build runtime/build --config RelWithDebInfo; ctest --test-dir runtime/build -C RelWithDebInfo -R gameinput --output-on-failure.

Project rules

  • No game data: the change is two table and test lines plus a comment. No executable bytes, import-table dumps, shaders or logs from the game. The ordinal is a public export number of a system DLL, and the project docs already record it.
  • No keys, decryption or protection workarounds: none involved.
  • Nothing online: none involved. GameInput is local input.
  • Fix, don't disable: the import is routed to the existing implementation. Nothing is stubbed, skipped or made to fail quietly.
  • Conventions: this is C++ runtime code, so the Python tool rules don't apply. The comment says why the alias exists, which future readers of the shim table will need.

AI-assisted.

@umnitus

umnitus commented Nov 23, 2026

Copy link
Copy Markdown

Independent native Windows check at 5e45c7da942d7ac08fc57561e9ed924bcfc76476, built with clang-cl/xwin and the PR's pinned SDL 3.4.20. ctest -R '^gameinput$' passed, with 342 checks and 0 failures, including ordinal #1 resolving to GameInputCreate. Synthetic virtual-controller test. AI-assisted testing.

@jtrudeau1530

Copy link
Copy Markdown

Linux/Wine confirmation from our local test setup, with raw logs kept private. Arch Linux, Wine 11.18, clang-cl 23.1.6 + xwin SDK 10.0.26100, RelWithDebInfo, SDL3 enabled; RX 7900 XT / RADV Mesa 26.2.3.

Pinned base: main 8575d36 + #6919 36936f3 + #4313 28ea6b971 + #6582 4224c53b1 + #4348 45c39cf6f.

The negative arm was run by me and the positive arms by a cooperating local tester, with two dedicated Wine prefixes using the same installed Wine. I reviewed the positive run records and matching executable/PDB hashes. Both runners disable networking, keep the original package read-only, and bound startup to 30 seconds. No extra local implementation patches are present in the positive checkpoint.

The cooperating tester's gameinput_test passes 342 checks, including the ordinal alias equality check. Its broader selected set is 27/31, not fully green: native-abort exit-code expectation, missing-TMP refusal, DirectStorage held-copy guard-page checks, and gameinput_host fail. The host test calls Wine's builtin GameInput stub and returns E_NOTIMPL; the DirectStorage failure's cause is undiagnosed. These failures are not being presented as successful validation of those paths.

Observed next failure: access violation in the device slot-26 forwarder, symbolized with the matching host PDB. Its correspondence to the struct-return ABI issue at boot-chain stop 7 is an inference; the existing device fixes are the next separate integration test. No game bytes, raw traces, addresses or dumps attached. AI-assisted.

@cdomergue

Copy link
Copy Markdown

Tested 5e45c7da942d7ac08fc57561e9ed924bcfc76476 against its parent 8575d36 with the retail Xbox 1.0.2.1 executable on native Windows 11 x64. Both builds used MSVC 19.44, Release, and SDL 3.4.20. The ordinal import switches from the Windows host to Leonida's GameInput shim.

Main executable, loader dry-run Parent PR
Bound to shims 54 55
Bound to host 432 431
Bound to packaged modules 72 72
Unimplemented 29 29

The PR's binding report identifies GameInput ordinal 1 as the additional shim binding. Both runs mapped five modules, exited 0 and had empty stderr. The native virtual-controller test also passed on each revision (341 checks on the parent, 342 on the PR).

This verifies import selection with the actual executable. The dry-run does not invoke the game's entry point or exercise physical controller input. GPU/driver not exercised. AI-assisted verification.

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.

6 participants