Skip to content

tombox-launch: stage and start a dumped GDK title (Windows, Wine / Proton), plus a runtime-bundle workflow - #30

Open
fffluffy-dev wants to merge 8 commits into
mainfrom
claude/tombox-launch
Open

fffluffy-dev wants to merge 8 commits into
mainfrom
claude/tombox-launch

Conversation

@fffluffy-dev

Copy link
Copy Markdown
Owner

Refs #14 (a clean clone could not start a title).

Why

The upstream developers start titles with run_xone.ps1 and similar scripts. Those scripts live outside the repository and use paths on their machine (D:\TomBox, D:\xbox-pc-port). This PR makes a title startable from the repository plus a dump, including on a Steam Deck through Proton.

What

crates/tools/tombox-launch (CLI; see its README):

  1. Reads MicrosoftGame.Config: identity, version, the Game executable.
  2. Scans every .exe / .dll of the package for imports, delay imports and DLL names loaded by string.
  3. Sorts each DLL into title / api set / system / runtime / missing:
    • the console OS is EmbeddedXvd/Windows/System32;
    • the host is System32 on Windows, or the Wine prefix's system32.
  4. Builds an overlay of the package, so the dump is never written:
    • symlinks on Unix, hard links or --copy on Windows;
    • the runtime's console libraries are copied beside the executable;
    • a runtime DLL that forwards to <name>_sys.dll gets a copy of the host DLL under that name.
  5. Writes launch_report.md and launch.env:
    • TOMBOX_PACKAGE_ROOT, TOMBOX_XBTHUNK_TITLE_ROOT, TOMBOX_GDK_ROOT, TOMBOX_XCRD_ROOT, TOMBOX_COMPAT_DIR, TOMBOX_LOG;
    • off Windows also WINEPATH, and WINEDLLOVERRIDES for the staged DLLs, appended to any existing value.
  6. With --run, starts the title natively, under --mdbg, or through --wine (Proton's wine64).

.github/workflows/runtime-bundle.yml: the runtime DLLs need the MSVC linker. This workflow builds them on Windows together with mdbg.exe and tombox-launch.exe, and uploads tombox-runtime-windows-x64.

  • It runs on pushes to main and this branch (when crates/ or the lockfile change) and on workflow_dispatch.
  • The build uses --keep-going. MISSING.txt in the bundle lists any of the core DLLs that did not build.

Test plan

  • cargo test -p tombox-launch (9 tests): config parsing, classification and staging rules, ASCII / UTF-16 DLL-name extraction, layout detection, arguments, overlay.
  • End to end on a synthetic dump with a hand-built PE32+. Staged d3d12_x / xmem / audiohalwrapper (loaded by name) / mfplat (with mfplat_sys from the prefix), kept the title's XCurl.dll, flagged GameInput.dll as missing; the env file and Wine command were correct.
  • cargo clippy; cargo check --target x86_64-pc-windows-gnu; PR gate: 0 problems.
  • runtime-bundle run on this branch.
  • Steam Deck: --plan, then --run, on the user's own Trackmania package.

Generated by Claude Code

…oton)

The launch scripts the upstream developers use (run_xone.ps1 and friends)
live outside the repository, so a clean clone could not start a title.
tombox-launch does it from the dump alone:

- reads MicrosoftGame.Config (identity, version, the Game executable);
- scans every .exe / .dll of the package for imports, delay imports and
  DLL names loaded by string, and sorts each DLL into title / api set /
  system / runtime / missing, using EmbeddedXvd/Windows/System32 for the
  console OS and System32 (Windows) or the Wine prefix's system32 for the
  host;
- builds an overlay of the package (symlinks on Unix, hard links or
  copies on Windows; the dump is never written), copies the runtime's
  console libraries beside the executable, and gives runtime DLLs that
  forward to <name>_sys.dll a copy of the host DLL;
- writes launch_report.md and launch.env (TOMBOX_PACKAGE_ROOT,
  TOMBOX_XBTHUNK_TITLE_ROOT, TOMBOX_GDK_ROOT, TOMBOX_XCRD_ROOT,
  TOMBOX_COMPAT_DIR, TOMBOX_LOG; WINEPATH and WINEDLLOVERRIDES off
  Windows) and, with --run, starts the title natively, under mdbg, or
  through Wine / Proton.

runtime-bundle.yml builds the MSVC runtime DLLs, mdbg.exe and
tombox-launch.exe on Windows and uploads them as
tombox-runtime-windows-x64, so a Linux machine such as a Steam Deck can
use them.

Tests: config parsing, the import classification and staging rules,
DLL-name extraction in ASCII and UTF-16, package layout detection,
argument parsing and the overlay; a synthetic dump with a hand-built
PE32+ was staged end to end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vTZArnDeG1xtBcLprpoCq

Copy link
Copy Markdown
Owner Author

rust-workspace-check fails on wldp, the same as on main (#14). Its include_bytes!("../data/*.bin") blobs are not in the repository. The log has no error from tombox-launch. Because the job stops at the first failing crate, the new crate is checked by its own tests instead:

  • cargo test -p tombox-launch passes, 9 tests;
  • cargo clippy is clean;
  • cargo check --target x86_64-pc-windows-gnu passes.

The Windows MSVC build of tombox-launch.exe comes from the runtime-bundle run on this branch.


Generated by Claude Code

…ange check

From the review on the Steam Deck:
- --plan now works when the runtime directory has no DLLs yet: every
  console library then shows as missing. Staging still refuses.
- Without --work, the overlay goes to ~/tombox-run/<identity>
  (%LOCALAPPDATA%\tombox-run on Windows) instead of the current
  directory.
- The overlay links point into the dump, so a title that writes into its
  package would change the original. Before --run the launcher records
  size and mtime of every dump file and compares after the title exits;
  changes go to <work>/dump_changes.txt with a warning (--copy isolates).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vTZArnDeG1xtBcLprpoCq
…prefix

The compat-common GDK runtime emulates the title's interfaces by hooking
GetProcAddress(xgameruntime, "QueryApiImpl"), so it relies on Microsoft's
PC xgameruntime.dll being loadable. Wine has none: the Trackmania plan on
the Steam Deck shows xgameruntime.dll as the one console library nobody
provides (GbxGame.exe, GameChat2.dll and XCurl.dll load it by name).

crates/compat/xgameruntime builds an xgameruntime.dll with the five
dispatcher entry points of the PC DLL (InitializeApiImpl,
InitializeApiImplEx, QueryApiImpl, UninitializeApiImpl, XErrorReport).
QueryApiImpl answers E_NOINTERFACE, which is what the emulated runtime
already returns when there is no real runtime behind it. On Windows the
host's own DLL wins (tombox-launch never stages a DLL the host has).

tombox-launch --into-prefix NAME copies a runtime DLL into the Wine
prefix's system32 for titles that load it from System32 only; it never
overwrites a different file, and the plan suggests it for xgameruntime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vTZArnDeG1xtBcLprpoCq
… ships

First Trackmania run on the Steam Deck (Proton 10): the runtime came up
inside the title (emulated GDK runtime, 36 interfaces, title key
700107ED, game drive G: on the overlay, import hooks in 7 modules), then
the title's own console XCurl.dll faulted on a null handle in ntdll
(XCurl +0x12e9a, called from GbxGame +0x16f133f). The runtime builds its
own XCurl.dll (libcurl API on WinHTTP behind the network guard) for
exactly this, but the launcher kept the title's copy.

Where the runtime has a DLL of the same name as one the package ships,
the runtime's copy is now staged; --prefer-title NAME keeps the title's.
A shipped DLL the runtime lacks stays the title's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vTZArnDeG1xtBcLprpoCq
Second Trackmania run on the Steam Deck: the runtime's XCurl came up on
WinHTTP, the network guard installed, the title read its packs through
G: and opened Packs/GpuCache_XboxOne.zip, then dxcompiler_x found no
dxcompiler.dll ("DxcCreateInstance no DXC available -> E_NOTIMPL") and
the title faulted on a null pointer half a second later. Also,
advapi32legacy.dll forwards to advapi32_sys.dll, which was missing: the
launcher only looked for <name>_sys.dll companions in staged DLLs, but
the runtime loads advapi32legacy itself from its own directory.

- --dxc DIR (default $TOMBOX_DXC_DIR) sets TOMBOX_DXC_DIR, as a Windows
  path under Wine; the plan warns when dxcompiler_x is staged without one.
- Companions are collected from every runtime DLL (any *_sys.dll name in
  it) and copied from the host into the overlay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vTZArnDeG1xtBcLprpoCq
…e fails

Third Trackmania run on the Steam Deck (Proton 10): D3D12 device, queues,
heaps, resources, 8 translated shaders and ~40 compute PSOs were up, then
the title read through a null object about a second after
"[gamepad] GameInputCreate real GameInputCreate failed hr=0x80004001".
Wine's gameinput.dll answers E_NOTIMPL, the hook passed the failure on,
and the title used the IGameInput it never got.

When the real GameInputCreate fails, the hook now wraps a built-in host
object instead and returns S_OK: no host devices or readings
(GAMEINPUT_E_READING_NOT_FOUND, E_NOTFOUND), QPC timestamps, callback
registrations that succeed with fresh tokens, unregister true. The usual
wrapper puts the virtual Xbox gamepad on top of it, so the title sees one
pad (driven through the pad control directory) and no keyboard or mouse.
Hosts with a working GameInput are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vTZArnDeG1xtBcLprpoCq
…imeUninitialize

GTA VI 1.0.2.1 imports these from xgameruntime.dll (upstream
omonkeyz#293, host shim 1). They succeed like InitializeApiImpl;
the compat-common GDK runtime still serves QueryApiImpl through its
GetProcAddress hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vTZArnDeG1xtBcLprpoCq
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