Map the title image natively and bind imports to shims alongside per-function lifting #46
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#46
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Leyukaka on GitHub · 2026-11-21 13:31 UTC · original
Question
Scarlett title code is already x64 in a PE32+ image. Could mapping the image with our own loader and binding its imports to Windows shims sit alongside per-function lifting, so that title code runs natively and static translation is kept for the functions that need patching or checking?
Most of the current CPU translators cover one function shape with a fixed prologue or ABI. The version-query lowerer in
tools/ffx_version_query.pyhandles backward branches and a few xmm/ymm instructions, but it tracks only ZF/CF and works on hand-bound slices, with absolute addresses rebound throughglobals_. To lift a whole executable we would also need full flags, the rest of SSE/AVX, relocations, SEH/unwind and an indirect-call dispatcher.With a custom loader the CPU executes the original instructions. The loader would then own:
.pdataregistration (RtlAddFunctionTable) so that SEH and C++ exceptions unwind through the mapped image;pe_inventory.pyanddependency_paths.py;Static translation stays useful for patching individual functions, for instrumenting guest code, and as a reference when checking a shim against the original behavior.
Evidence so far
None measured. This is a proposal. No existing issue or section of
docs/experiments.mdcovers native mapping. XWine1 is publicly described as a translation layer for Xbox One titles, but its source is private. Its public DLL subset, SlimEra, states that on its own it does not run games, so I have not confirmed how XWine1 loads title images.Relevant inputs already in the repo: the source-built import fixtures in
tests/cpu/(import.def,import_provider.cpp,named_provider.def,ordinal_provider.def) and the intake and dependency reports.Completion condition
A CTest case,
cpu_native_loador similar, that:LoadLibraryfor the image itself), applies relocations at a non-preferred base and registers its.pdata;cpu_aot_import_call/cpu_aot_ordinal_importand gets the same results as the lifted DLLs and the native originals;A negative control should fail clearly when an import is left unresolved.
I can take parts 1 to 3 using synthetic fixtures only. If static translation is a hard requirement for reasons not covered in the README, I'd be glad to hear them before starting.
AI-assisted.
@R0Y00 on GitHub · 2026-11-21 13:42 UTC · original
Thanks for offering to take this on, @Leyukaka. Please go ahead with items 1–3 in a first PR using the import fixtures built from this repository. Static recompilation remains the project's main direction. The native run gives us an independent reference for checking the translated calls and the shim.
For the named and ordinal cases, please run the same inputs through the Windows-loaded original, your fixture path and the recompiled DLL. Compare both the return value and the output written by the callee, and include the unresolved-import case in CTest. Please leave item 4 open for a separate fixture that actually raises and catches an exception. Looking forward to the comparison.
@R0Y00 on GitHub · 2026-11-21 14:38 UTC · original
Implementation update: @Leyukaka’s #49 covers the mapping, import binding and comparison work for items 1–3. CI passed on b102794. The review comment asks for two error-path fixes and tests before merge. Keeping this issue open for the separate exception/unwind fixture; registering .pdata alone does not exercise an exception across a mapped frame.
@R0Y00 on GitHub · 2026-11-21 15:22 UTC · original
Thanks for both contributions. #49 verified manual mapping, named and ordinal imports, relocations and the unresolved-import control. #65 has now merged after passing Windows CI and verifies exception recovery and propagation through a mapped fixture. Together they cover the four completion criteria.