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, |
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 imports called, 27 with a fatal result check, 78 sites. 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