Repository navigation
Conversation
…oc sites pass an attribute word the shim refuses tools/import_call_sites.py finds an import's thunk and the call/jmp rel32 instructions that reach it, from the file alone. On game_scarlett_master.exe: XMemVirtualAlloc 23 sites (every attributes value nonzero, protections carrying PAGE_GRAPHICS bits), the physical-page family 21 sites with an AWE-shaped signature and 64 KiB pages, and the constants the other xmem imports are called with. docs/xmem_exe_calls.md records them and what is still unmeasured.
…elf on an import's result From the file alone, per import: the call sites that test the returned value and branch to int3, ud2, int 29h or a call that does not return, with the value that takes that side. Call sites come from import_call_sites.py's thunk calls plus `call [rip+slot]` for the api-ms-win-* imports; the result is tracked through mov/movzx/movsx copies and cdqe, and each side is followed through up to two jumps. On the retail 1.0.2.1 executable: 515 imports called, 27 with a fatal result check, 78 sites. docs/exe_fail_fast.md groups them by how main binds each import: XMemVirtualAlloc stops on NULL at 14 of its 23 sites, and the unbound xmem physical-page imports stop on the default return of 0 at 8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/README.md
…sNotRexed#6792) XMemVirtualAlloc now takes the attribute word and drops the PAGE_GRAPHICS_* bits (ItsNotRexed#6908). It still refuses the 2 MiB page mode (0x20003000), which 4 of the 14 fatal sites pass; the other 10 reach VirtualAlloc. The 6 calls refused for 0x4000/0x40000 are not fatal sites. D3D12ConfigureVirtualMemoryX has a shim returning S_OK (ItsNotRexed#6792), so it moves from "No binding" to the shims table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged main and refreshed |
|
Code read + CPU tests, b721585: pass ( I also ran the tool against the retail image, and the PR's numbers reproduce exactly: It holds up under the JSON too (587 import entries, 515 with One usability note: |
|
Tested 4440b6f on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass (CPU only, no GPU)
AI-assisted (Claude Code). |
|
Tested 4440b6f merged with main 8575d36 on Linux/Python 3.12.16: pass Merge was clean (new tools/import_fail_fast.py, tests/test_import_fail_fast.py, docs/exe_fail_fast.md, one line in docs/README.md). All four files are new, so restoring files from main would only remove the tool; I used two mutations of the tool as the negative control instead.
Diff read: the test image has 24 hand-written call sites (test/cmp forms, register copies, overwritten result, extra call or branch before the test, window limits, tail jump, |
Reported on ItsNotRexed#7010: on the retail image the JSON has 587 entries while the table line says 515 imports called. Both are right; the docstring now says the JSON keeps calls == 0 entries and the line counts only calls > 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@dcastell1 thanks for running it on the retail image. Done in 0e15828 (see the commit below): the docstring now says that |
|
Ran 0e15828 against the retail Xbox Series 1.0.2.1 executable (185 MB image) on Windows 11, Python 3.14. The tool completes in a few minutes single-threaded and the table is directly usable for the boot work: Rows that matter most for the current boot chain (#7132 gets to D3D12ConfigureVirtualMemoryX, then stops):
Also confirmed the JSON/table count split you documented: the table says 515 imports called while --json lists more entries including calls == 0. AI-assisted. Import names, counts and conditions only, no game data. |
|
AI-assisted. Measured on my own 1.0.2.1 executable (120,181,760 bytes; SHA-256 matches Tested
One related cross-check from #7207's |
|
Tested 0e15828 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass. Ran the test files this PR adds or changes, from a clean checkout of the PR head: AI-assisted (Claude Code). |
|
Tested
One thing worth a line in the PR description or AI-assisted (Claude Code). |
…ot only how many are called On the 1.0.2.1 image it now reads "515 of 587 import(s) called directly, ...": the 72 imports with no direct call site were the first question a tester asked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@TheAirborneCoder good point, done in AI-assisted. |
|
Tested 14dc0b8 on Linux, Python 3.14.4: pass
|
Claimed in the coordination issue as: #6910 (comment) (RT-5 tooling)
Depends on: #6843 (this branch is stacked on it and reuses its
tools/import_call_sites.py; only the last commit is new)@ItsNotRexed exe PR, as asked.
What and why
Every stop on the retail boot path so far has been the title's own
int3: it tests what an import returned and breaks when the value is the failing one (#6824 stops this way atXMemAllocatePhysicalPages). This adds a tool that finds those checks ahead of a run, from the executable file alone. A shim author can then see which results the title will not accept before a run reaches them.tools/import_fail_fast.py <exe> [--import DLL!NAME] [--dll DLL] [--all] [--json]. Per import, it lists the call sites that test the returned value and branch toint3,ud2,int 29hor a call that does not return, with the value that takes that side (eax == 0,rax == -1,eax < 0,eax != 1,(al & 0x1) == 0).call [rip+slot], the form theapi-ms-win-*imports use. The result is tracked throughmov/movzx/movsxcopies andcdqe.tools/gdk_runtime_calls.pyand runs in about 1.3 s on the 120 MB executable.docs/exe_fail_fast.md(+ index row) gives the retail result: 515 of 587 imports called directly, 27 with a fatal result check, 78 sites (the other 72 imports have no direct call site; the summary line now prints both numbers). They are grouped by howmainbinds each import. Highlights:XMemVirtualAllocstops onNULLat 14 of its 23 sites. RT-5: how the retail executable calls xmem.dll: all 23 XMemVirtualAlloc sites pass an attribute word the shim refuses #6843 shows thatmain's shim refuses all 23, so the first of those 14 that is reached ends the boot.XMemMapPhysicalPages,XMemAllocatePhysicalPages,XMemMapPhysicalPagesScatterandXMemIsToolsMemAvailablestop on the default unimplemented return of 0 at 8 sites. xmem: serve the seven missing imports (physical pages, default allocators, XMemIsToolsMemAvailable); XMemVirtualAlloc takes 2 MiB pages and placeholders #6919 serves them.VirtualFreesites stop onFALSE, so whateverXMemVirtualAllochands out must be releasable by the hostVirtualFree.GameInput.dllis imported by ordinal 1 only, and its one call has theGameInputCreate(IGameInput**)shape, which gameinput: answer GameInputCreate imported by ordinal 1 #3410 binds._Mtx_lock,IsProcessorFeaturePresent(PF_FASTFAIL_AVAILABLE), theGetLogicalProcessorInformationsize-query pair) are marked as not shim failures.The doc quotes only import names, counts and conditions: no addresses, offsets or bytes from the executable. The tool prints RVAs only for whoever runs it on their own copy.
Tested
python -I tests/test_import_fail_fast.pypasses: 8 tests on a PE built byte by byte, with 24 call-site cases. These cover each test form, copies, the jump-follow, a noreturn call,int 29h/ud2, a direct slot call, an ordinal import, a tail jump and a strayFF 15(both ignored), the cases the tool must not judge, and the CLI's table,--json,--import,--alland exit 2.cdqeorint 29heach makes the test fail.tests/test_import_call_sites.py,tests/test_gdk_runtime_calls.py, everytests/test_docs_*.py,tests/test_ci_registration.py,python -m compileall -q make_game.py tools testsandscripts/check_no_game_data.py.tests/test_text_write_line_endings.pyfails on the base too (tools/f64_omod_probe.py:268), so that failure is not from this change.e95020b2…08993, my own copy), read statically on Linux with Python 3.13.5: the result is above. An independent Capstone-based pass found the same sites per import, except 2XMemVirtualAllocsites that it missed. I checked both by hand: one tests a copy of the result, and one reachesint3through ajmp.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code