Skip to content

gameinput: answer the executable's GameInput.dll ordinal 1 import - #7673

Closed
bobcatchris wants to merge 1 commit into
ProjectLeonida:mainfrom
bobcatchris:ginput-ordinal
Closed

bobcatchris wants to merge 1 commit into
ProjectLeonida:mainfrom
bobcatchris:ginput-ordinal

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

runtime/shims/gameinput.cpp:32 carried an ASSUMPTION that the executable is not available, so the DLL it imports GameInputCreate from is unknown. It is available now, and the answer is not a name.

Measured. dumpbin //imports over game_scarlett_master.exe (120,181,760 bytes, the size and SHA-256 game/xbox-1.0.2.1.json records): one import from GameInput.dll, Ordinal 1, no import-by-name entry. docs/d3d12_vulkan.md:3760 says the same from the sibling layer (GameInput.dll ordinal 1 is GameInputCreate); this is the executable's own import table agreeing with it.

Why that mattered. Loader::resolve builds "#1" for an ordinal import and asks rt::shims::find("gameinput.dll", "#1"). The registry matches export names and #ordinal symbols separately, and the table had only the name, so the import fell through to the host's copy at load time. Measured with a runtime built from this tree (gta6rt --dry-run over the executable, Windows 11, MSVC 14.39 with #7146 applied because main does not compile on 14.39):

before  game_scarlett_master.exe  shim=61 host=432 module=72 unimplemented=22   (no gameinput line at all:
                                                                                 neither shim nor unimplemented,
                                                                                 so the host bound it)
after   game_scarlett_master.exe  shim=62 host=431 module=72 unimplemented=22
            shim          GameInput.dll!#1

The unimplemented count does not move, so this binds an import that was already bound, only to the shim instead of the host.

Change. {"gameinput.dll", "#1", &GameInputCreate} in the table, the measurement in place of the ASSUMPTION, gameinput_test checking the ordinal resolves to the same function as the name, and docs/gameinput.md updated: the paragraph that said the executable is not available now records the measured module and ordinal, and the VERIFY item keeps only the API version, which is still unmeasured (v0 vs v1 vtables).

Checks. runtime/build/gameinput_test.exe (built with SDL3): 342 checks, 0 failures, including the new gameinput.dll!#1 (the executable's ordinal import) is the same function. Both dry-runs exit 0 with nothing on stderr. Without SDL3 the shim table is not compiled and the host copy still serves the import, as before, so nothing changes for a runtime built without it.

Fixes the GameInput line of tools/exe_checklist.py output. Counts, ordinals and binding kinds only, no game data.

AI-assisted.

The retail executable imports GameInput once, from `GameInput.dll` **by ordinal** (`Ordinal 1`, no name,
`dumpbin //imports` on the 120,181,760-byte image the manifest pins). The registry keys shim entries by export name
or by `#ordinal` and no table had the ordinal form, so that import fell through to the host's copy:
`gta6rt --dry-run` over the executable listed neither a shim nor an unimplemented import for it and counted it under
`host` (`shim=61 host=432 unimplemented=22`).

Registering `#1` makes the shim answer the import the title actually has, which is what `docs/gameinput.md` says the
shim is for: the same run now prints `shim GameInput.dll!#1` with `shim=62 host=431` and the unimplemented count
unchanged at 22. Without SDL3 the table does not exist and the host copy still serves it, as before.

`gameinput_test` checks the ordinal resolves to the same function as the export name (342 checks, 0 failures). The
`ASSUMPTION` that the import's module was unknown is replaced by the measurement, and the VERIFY item keeps only the
API version, which is still unmeasured.

AI-assisted.
@brothernog

Copy link
Copy Markdown

Code read of 89b08f0 (Windows 11, no game files; not built here: gameinput_test needs SDL3, which this machine doesn't have, and without it the ctest only echoes "built without SDL3"):

So unless something here is missing from those, this one looks like a duplicate. There is also no coordination item ID in the description.

This review was AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Duplicate confirmed at 89b08f0c. I checked the three PRs brothernog named, at their current heads:

Everything in this branch is covered by those three; it adds no distinct behaviour or test. I also omitted the coordination item ID from the description. Closing in favour of #3410 / #7216 / #7667 rather than leaving a fourth PR for the same change.

AI-assisted.

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.

2 participants