runtime: GameInput v0 call contract of the main executable (static caller evidence, fixture first) #1049

Closed
opened 2026-11-23 23:37:26 +00:00 by lukaslw-lab · 6 comments
lukaslw-lab commented 2026-11-23 23:37:26 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T23:37:26Z.


AI-assisted (Claude Code).

The main executable imports one GameInput entry, by ordinal, and treats a failed call as fatal. Today pe_map --system binds GameInput.dll to the desktop System32 DLL with no check, which is why it doesn't appear among the 22 missing externals in the #870 checkpoint. This issue records the caller-side contract and tracks a fixture-only check.

Evidence. Static reading of a local copy of the main executable; nothing executed. ABI shapes and counts only. "Observed" is read from the caller's code. The right column maps it onto the public v0 header (Windows SDK 10.0.26100 um/GameInput.h, Microsoft Learn); it is an interpretation, not confirmed for the console runtime.

Observed in the caller v0 header interpretation
GameInput.dll ordinal 1, called with one pointer argument; negative result → breakpoint GameInputCreate(IGameInput**); the GDK header gives v0 (build stamps in the executable show an April 2026 GDK)
One lazily created process-wide instance, released by an atexit handler Singleton, as Learn recommends
Object slots 4, 5, 6, 9, 13, 16 (no others) GetCurrentReading, GetNextReading, GetPreviousReading, RegisterDeviceCallback, UnregisterCallback, FindDeviceFromId
Slots 14/15 on keyboard readings (12-byte entries), 22 on gamepad readings (28 bytes zeroed first, all fields read) GetKeyCount, GetKeyState, GetGamepadState
Device slot 3 (32 bytes read at +0x20 of the result), slot 10 (16-byte block, last 8 bytes zero, first two floats clamped to [0, 1]) GetDeviceInfo (deviceId), SetRumbleState (motors only, no trigger rumble)
Kind constants 0x40000 and 0x10; status filter 1; enumeration 2; unregister timeouts 5000 and UINT64_MAX Gamepad, Keyboard; Connected; Blocking
All 14 bits 0x1–0x2000 of the gamepad's first word tested, none above All v0 gamepad buttons, no paddles

What a provider has to satisfy (from the caller's code):

  • Export ordinal 1; no name is imported. No direct field access on any returned object: vtables only.
  • The keyboard registration call is made while the caller holds a recursive lock that its device callback also takes. With blocking enumeration, a provider that runs the callback on the registering thread works; one that runs it on another thread and waits before returning would deadlock.
  • The previous reading is requested relative to the reading just obtained, so at least one earlier reading per device must be kept.
  • The caller identifies extended keys by scanCode & 0xE000 == 0xE000 and accepts right Shift as virtual key 0 with scan code 0xE036.
  • Registration and unregistration results are ignored; reading failures skip the device; only a failed create is fatal. The window procedure is DefWindowProc, so keyboard input arrives only through GameInput.

Not established: the console runtime's actual behavior (callback thread, scan-code encoding, history depth); which thread polls and how often (the polls run from the title's own virtual update methods and task callbacks; static analysis stops there); anything about the desktop runtime.

Plan (fixture-only, following #1047): a source-built caller with the call shapes above and a test-only recording gameinput.dll exporting ordinal 1 only, under the Windows loader and pe_map, dev and release. Controls: failed create reaches the fatal path; withheld export stops pe_map before entry; a two-argument or wrong-ordinal provider, a callback delivered on another thread with a wait, a non-zero rumble tail or a wrong 28-byte layout are each caught. No production export. A comparison against the desktop in-box runtime follows separately, labelled as desktop evidence.

Question: is a test-only provider the right first step here, and should the by-ordinal System32 binding be pinned by a test? Whether production later forwards to the desktop runtime or implements the subset is a separate decision.

Related: #870, #908 (import inventory lists the ordinal-1 import), #1047.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6571122731 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1056). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T23:37:26Z. --- _AI-assisted (Claude Code)._ The main executable imports one GameInput entry, by ordinal, and treats a failed call as fatal. Today `pe_map --system` binds `GameInput.dll` to the desktop System32 DLL with no check, which is why it doesn't appear among the 22 missing externals in the #870 checkpoint. This issue records the caller-side contract and tracks a fixture-only check. **Evidence.** Static reading of a local copy of the main executable; nothing executed. ABI shapes and counts only. "Observed" is read from the caller's code. The right column maps it onto the public v0 header (Windows SDK 10.0.26100 `um/GameInput.h`, [Microsoft Learn](https://learn.microsoft.com/gaming/gdk/docs/features/common/input/overviews/input-overview)); it is an interpretation, not confirmed for the console runtime. | Observed in the caller | v0 header interpretation | |---|---| | `GameInput.dll` ordinal 1, called with one pointer argument; negative result → breakpoint | `GameInputCreate(IGameInput**)`; the GDK header gives v0 (build stamps in the executable show an April 2026 GDK) | | One lazily created process-wide instance, released by an `atexit` handler | Singleton, as Learn recommends | | Object slots 4, 5, 6, 9, 13, 16 (no others) | `GetCurrentReading`, `GetNextReading`, `GetPreviousReading`, `RegisterDeviceCallback`, `UnregisterCallback`, `FindDeviceFromId` | | Slots 14/15 on keyboard readings (12-byte entries), 22 on gamepad readings (28 bytes zeroed first, all fields read) | `GetKeyCount`, `GetKeyState`, `GetGamepadState` | | Device slot 3 (32 bytes read at +0x20 of the result), slot 10 (16-byte block, last 8 bytes zero, first two floats clamped to [0, 1]) | `GetDeviceInfo` (`deviceId`), `SetRumbleState` (motors only, no trigger rumble) | | Kind constants `0x40000` and `0x10`; status filter `1`; enumeration `2`; unregister timeouts `5000` and `UINT64_MAX` | Gamepad, Keyboard; Connected; Blocking | | All 14 bits `0x1`–`0x2000` of the gamepad's first word tested, none above | All v0 gamepad buttons, no paddles | **What a provider has to satisfy** (from the caller's code): - Export ordinal 1; no name is imported. No direct field access on any returned object: vtables only. - The keyboard registration call is made **while the caller holds a recursive lock that its device callback also takes**. With blocking enumeration, a provider that runs the callback on the registering thread works; one that runs it on another thread and waits before returning would deadlock. - The previous reading is requested relative to the reading just obtained, so at least one earlier reading per device must be kept. - The caller identifies extended keys by `scanCode & 0xE000 == 0xE000` and accepts right Shift as virtual key 0 with scan code `0xE036`. - Registration and unregistration results are ignored; reading failures skip the device; only a failed create is fatal. The window procedure is `DefWindowProc`, so keyboard input arrives only through GameInput. **Not established:** the console runtime's actual behavior (callback thread, scan-code encoding, history depth); which thread polls and how often (the polls run from the title's own virtual update methods and task callbacks; static analysis stops there); anything about the desktop runtime. **Plan** (fixture-only, following #1047): a source-built caller with the call shapes above and a test-only recording `gameinput.dll` exporting ordinal 1 only, under the Windows loader and `pe_map`, `dev` and `release`. Controls: failed create reaches the fatal path; withheld export stops `pe_map` before entry; a two-argument or wrong-ordinal provider, a callback delivered on another thread with a wait, a non-zero rumble tail or a wrong 28-byte layout are each caught. No production export. A comparison against the desktop in-box runtime follows separately, labelled as desktop evidence. Question: is a test-only provider the right first step here, and should the by-ordinal System32 binding be pinned by a test? Whether production later forwards to the desktop runtime or implements the subset is a separate decision. Related: #870, #908 (import inventory lists the ordinal-1 import), #1047.
Holastor commented 2026-11-24 06:49:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T23:44:50Z.


I'll take this slice: source-built caller fixture and test recording provider for gameinput.dll!#1 (GameInputCreate).

  • Stage: gameinput.dll ordinal 1 export, GameInputCreate(IGameInput**), singleton lifecycle, and the observed v0 vtable slots (slots 4 GetCurrentReading, 5 GetNextReading, 6 GetPreviousReading, 9 RegisterDeviceCallback, 13 UnregisterCallback, 16 FindDeviceFromId).
  • Environment: Windows 11 x64, MSVC 19.51, CMake/Ninja, Python 3.11 (out/pe-env), dev and release presets.
  • Interface & Provenance (Public evidence only):
    • Public Windows SDK um/GameInput.h (10.0.26100.0) defines GameInputCreate(_COM_Outptr_ IGameInput**) and interface IGameInput (IID_IGameInput = 11BE2A7E-4254-445A-9C09-FFC40F006918).
    • Observed vtable slots 4, 5, 6, 9, 13, 16 match standard IGameInput COM layout.
    • The provider is a test-only recording fixture; no production export is added.
  • Plan:
    • Source-built caller (tests/cpu/gameinput_caller.asm) and test-only recording provider (tests/cpu/gameinput_provider.cpp + gameinput_provider.def exporting ordinal 1 only), following the #1000 / #1047 pattern.
    • Verification under both Windows loader and pe_map, comparing native and mapped execution in dev and release.
    • Negative controls:
      • Null output pointer returns E_POINTER.
      • Failed create reaches fatal refusal path.
      • Synchronous device callback delivery while holding registration lock.
      • Withheld export stops pe_map at import resolution before entry.
      • Faulty provider mutant stops caller at designated diagnostic step.
  • Related: #870, #908, #1056.
    AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7117318346 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1056#issuecomment-7117318346). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T23:44:50Z. --- I'll take this slice: source-built caller fixture and test recording provider for `gameinput.dll!#1` (`GameInputCreate`). - **Stage:** `gameinput.dll` ordinal 1 export, `GameInputCreate(IGameInput**)`, singleton lifecycle, and the observed v0 vtable slots (slots 4 `GetCurrentReading`, 5 `GetNextReading`, 6 `GetPreviousReading`, 9 `RegisterDeviceCallback`, 13 `UnregisterCallback`, 16 `FindDeviceFromId`). - **Environment:** Windows 11 x64, MSVC 19.51, CMake/Ninja, Python 3.11 (`out/pe-env`), dev and release presets. - **Interface & Provenance (Public evidence only):** - Public Windows SDK `um/GameInput.h` (10.0.26100.0) defines `GameInputCreate(_COM_Outptr_ IGameInput**)` and interface `IGameInput` (`IID_IGameInput = 11BE2A7E-4254-445A-9C09-FFC40F006918`). - Observed vtable slots 4, 5, 6, 9, 13, 16 match standard `IGameInput` COM layout. - The provider is a test-only recording fixture; no production export is added. - **Plan:** - Source-built caller (`tests/cpu/gameinput_caller.asm`) and test-only recording provider (`tests/cpu/gameinput_provider.cpp` + `gameinput_provider.def` exporting ordinal 1 only), following the #1000 / #1047 pattern. - Verification under both Windows loader and `pe_map`, comparing native and mapped execution in `dev` and `release`. - Negative controls: - Null output pointer returns `E_POINTER`. - Failed create reaches fatal refusal path. - Synchronous device callback delivery while holding registration lock. - Withheld export stops `pe_map` at import resolution before entry. - Faulty provider mutant stops caller at designated diagnostic step. - Related: #870, #908, #1056. AI-assisted.
lukaslw-lab commented 2026-11-24 06:49:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T23:50:06Z.


AI-assisted (Claude Code).

@Holastor, thanks for the interest. I claimed this fixture on #870 at 23:37 UTC, before opening this tracking issue, and I'm implementing the caller and recording provider described above. To avoid two providers, could you take the independent side instead?

  • an independent Windows 11 run and review of the fixture PR once it's up;
  • or a Windows 11 desktop data point for the runtime-dependent rows: callbacks during blocking enumeration (thread), previous-reading history while keys are typed, and extended-key scan codes.

I'll link the PR here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7117414146 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1056#issuecomment-7117414146). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T23:50:06Z. --- _AI-assisted (Claude Code)._ @Holastor, thanks for the interest. I claimed this fixture on #870 at 23:37 UTC, before opening this tracking issue, and I'm implementing the caller and recording provider described above. To avoid two providers, could you take the independent side instead? - an independent Windows 11 run and review of the fixture PR once it's up; - or a Windows 11 desktop data point for the runtime-dependent rows: callbacks during blocking enumeration (thread), previous-reading history while keys are typed, and extended-key scan codes. I'll link the PR here.
Holastor commented 2026-11-24 06:49:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T23:53:17Z.


Thanks for coordinating, @lukaslw-lab! Absolutely, I'll take the independent side: I will run and review your fixture PR on Windows 11 as soon as you open it.

In the meantime, here is the measured Windows 11 desktop data point from in-box GameInput.dll (version 0.2309.26100.10068, OS build 26100.3037):

  1. Ordinal 1 export:
    GetProcAddress(hMod, (LPCSTR)1) successfully resolves GameInputCreate.

  2. Blocking enumeration callback delivery thread:
    Tested gameInput->RegisterDeviceCallback(nullptr, GameInputKindGamepad | GameInputKindKeyboard, GameInputDeviceConnected, GameInputBlockingEnumeration, nullptr, Callback, &token):

    • Callbacks during registration: total=6, same_thread=6, other_thread=0.
    • All 6 initial device enumeration callbacks fired synchronously on the caller thread (GetCurrentThreadId() in callback matched the caller thread ID).
    • This directly confirms the title's recursive lock requirement: in-box Windows 11 GameInput dispatches blocking enumeration callbacks synchronously on the registering thread, so no thread handoff or deadlock occurs.
  3. Previous-reading behavior without history:

    • GetCurrentReading(GameInputKindKeyboard, ...) returned S_OK (0x00000000).
    • Calling GetPreviousReading on this reading returned 0x838A0004 (GAMEINPUT_E_READING_NOT_FOUND), leaving output null.
  4. Unregister timeout:

    • UnregisterCallback(token, 5000) returned true.

Looking forward to reviewing your PR branch!

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7117470331 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1056#issuecomment-7117470331). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T23:53:17Z. --- Thanks for coordinating, @lukaslw-lab! Absolutely, I'll take the independent side: I will run and review your fixture PR on Windows 11 as soon as you open it. In the meantime, here is the measured Windows 11 desktop data point from in-box `GameInput.dll` (version `0.2309.26100.10068`, OS build 26100.3037): 1. **Ordinal 1 export:** `GetProcAddress(hMod, (LPCSTR)1)` successfully resolves `GameInputCreate`. 2. **Blocking enumeration callback delivery thread:** Tested `gameInput->RegisterDeviceCallback(nullptr, GameInputKindGamepad | GameInputKindKeyboard, GameInputDeviceConnected, GameInputBlockingEnumeration, nullptr, Callback, &token)`: - Callbacks during registration: **`total=6, same_thread=6, other_thread=0`**. - All 6 initial device enumeration callbacks fired **synchronously on the caller thread** (`GetCurrentThreadId()` in callback matched the caller thread ID). - This directly confirms the title's recursive lock requirement: in-box Windows 11 GameInput dispatches blocking enumeration callbacks synchronously on the registering thread, so no thread handoff or deadlock occurs. 3. **Previous-reading behavior without history:** - `GetCurrentReading(GameInputKindKeyboard, ...)` returned `S_OK` (`0x00000000`). - Calling `GetPreviousReading` on this reading returned `0x838A0004` (`GAMEINPUT_E_READING_NOT_FOUND`), leaving output null. 4. **Unregister timeout:** - `UnregisterCallback(token, 5000)` returned `true`. Looking forward to reviewing your PR branch!
lukaslw-lab commented 2026-11-24 06:49:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-24T00:26:23Z.


AI-assisted (Claude Code).

PR #1076 is up. @Holastor, the fixture is ready for your Windows 11 run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118069399 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1056#issuecomment-7118069399). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-24T00:26:23Z. --- _AI-assisted (Claude Code)._ PR #1076 is up. @Holastor, the fixture is ready for your Windows 11 run.
Holastor commented 2026-11-24 06:49:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T00:33:05Z.


Independent Windows 11 run and review posted on #1076 (both dev and release presets passed 4/4, all negative controls and provider counters confirmed on build 26100).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118185262 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1056#issuecomment-7118185262). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-24T00:33:05Z. --- Independent Windows 11 run and review posted on #1076 (both `dev` and `release` presets passed 4/4, all negative controls and provider counters confirmed on build 26100).
R0Y00 commented 2026-11-24 06:50:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T01:05:14Z.


#1076 landed in ded2ce7f. The source-built ordinal-1 fixture passed independently under the Windows loader and pe_map, with the wrong-ordinal, callback-thread, state-layout and creation-failure controls detected. The earlier System32 ordinal and desktop callback observations stay separate. This completes the recording-fixture scope. Production GameInput routing and behavior can be evaluated separately.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118740519 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1056#issuecomment-7118740519). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T01:05:14Z. --- #1076 landed in ded2ce7f. The source-built ordinal-1 fixture passed independently under the Windows loader and pe_map, with the wrong-ordinal, callback-thread, state-layout and creation-failure controls detected. The earlier System32 ordinal and desktop callback observations stay separate. This completes the recording-fixture scope. Production GameInput routing and behavior can be evaluated separately.
Sign in to join this conversation.
No labels
No milestone
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.

Reference
R0Y00/Xbox2Windows#1049
No description provided.