Support direct import calls through call qword [rip+disp32] (\xff\x15)
in tools/import_call_sites.py alongside thunks (jmp qword [rip+disp32] / \xff\x25).
This enables discovering call sites in images where imports are called
directly without an intermediate jmp thunk (e.g. XboxBvhBuilder.dll calls).
Harden tools/import_fail_fast.py to identify instruction boundary sizes
(5 bytes for E8 vs 6 bytes for FF 15) when classifying call sites.
Add unit tests in tests/test_import_call_sites.py for direct slot call
detection, combined thunk/direct calls, non-slot skips, and CLI reports.
AI-assisted (Claude Code)
Twelve test files failed on main at 2d53a8055 (CI's check and semantic-tests steps, run locally): most are a test
and the code it checks changed by different pull requests in the same merge round. Each fix below is either taken
from a closed pull request that already had it, or restores what an earlier merged change intended.
From closed pull requests:
- test_make_game_resume: FakeProc gets poll(), which translate() now calls (#7018)
- test_make_game_empty_translation: the Exited stub gets poll() and the failed-shard path is checked (#7214)
- test_shader_checks: stub table_fetch_test in the Wave64Checks harness and count it (#7433)
- test_runtime_paths: runtime.yml's path filter lists tools/replace_retry.py, which rdna2spirv.py imports (#7029)
- test_psin_names: patch the same_report_path helpers that report_paths now calls (#8719)
- test_report_source_collision: the fixture is a real Bink 2 header; bink_index refuses other files (#7408)
- test_missing_input_exit_codes: tile_probe checks its inputs before it asks for numpy (#4771)
Restored:
- merge_check: a failed `git show` is an error again (5b88d58); 21016cf brought back the lenient read that
treated it as a new file, while new files are already left out when the diff is read
- rpf_probe: a symlinked --out updates its target again (44d3595); 55d21cc's staged write replaced the link
Updated to the code:
- test_shader_stage_resume: TRANSLATION_SOURCES lists fssm_unpack.py and shader_stage_manifest.py, which the
translator imports; existing work folders translate once more after this
- test_tool_stdout_encoding: the 15 programs merged without the stdout guard get the same block as the others
- test_rdna2spirv_decode: drop the test of decode_any_format, which SHADER-849 replaced with the table decode
that tests/semantic/test_format_decode_table.py checks
Co-authored-by: jewmaster1337 <102986566+jewmaster1337@users.noreply.github.com>
Co-authored-by: TanmaySatyam <248538550+TanmaySatyam@users.noreply.github.com>
Co-authored-by: evilclanker9000 <45567075+evilclanker9000@users.noreply.github.com>
Co-authored-by: slint6614-dev <359954236+slint6614-dev@users.noreply.github.com>
Co-authored-by: BlackNife <108077267+Poussistar@users.noreply.github.com>
Co-authored-by: fiestorra <65175643+fiestorra@users.noreply.github.com>
Co-authored-by: fearkov <289226582+fearkov@users.noreply.github.com>
Co-authored-by: DoubleD17 <48109637+DoubleD17@users.noreply.github.com>
import_slots goes back to {rva: 'dll!name'} for any other caller (#9514's
unmatched_selectors reads it), and import_entries gives the (dll, name)
pairs the selection uses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
selected() re-split each "dll!name" key at its first '!', so an import of a
DLL whose own name contains '!' (x!em.dll) was filed under DLL "x": --dll
x!em.dll selected nothing and --dll x selected all of its imports.
import_slots now returns (dll, name) and the key is formed after selection.
Finding: https://github.com/ItsNotRexed/Leonida/issues/9522#issuecomment-7114646261
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first change refused a value that could select nothing by its shape (a bare DLL, a bare name, an empty half). A misspelling inside a well-formed value still answered '0 import(s), 0 call site(s)' with exit 0, which docs/xmem_exe_calls.md and audio_hal_exe_calls.md read as 'the image never calls it'. --import DLL!NAME and --dll DLL now also have to name an import of the image, else one line on stderr and exit 2; call_sites() keeps its {} answer for a library caller that selects nothing on purpose.
Regression: tests/test_import_call_sites.py builds the image byte by byte; the new case fails on the previous head (0 != 2) and passes here.
A --import value that is a bare DLL name, a bare function name, or half of
DLL!NAME selected no import, and the run answered "0 import(s), 0 call site(s)"
and exit 0: a typo in either half read as proof that the image never calls the
import (docs/xmem_exe_calls.md reads the counts that way, and the retail
executable's imports are triaged from them). A --dll value in the --import form
selected no DLL for the same reason.
Both forms are now refused with the usage and exit 2, before the image is opened.
The library-level call_sites() still accepts whatever sets it is handed.
Observed on the hand-built PE from tests/test_import_call_sites.py
(Windows 11, CPython 3.12, no game files, no GPU):
before: python -I tools/import_call_sites.py image.exe --import xmem.dll
-> "0 import(s), 0 call site(s)", exit 0
after: -> usage, "argument --import: expected DLL!NAME, got 'xmem.dll'", exit 2
Regression: tests/test_import_call_sites.py,
test_cli_refuses_a_selector_that_selects_nothing (six malformed values, plus the
two well-formed ones as a positive control). It fails on the base commit
(SystemExit not raised) and passes with the change; the file is 9/9 green.
Squash-merged after diff review of PR #6899 - RT-5: how the retail executable calls the audio coprocessor, texture layout and DirectStorage imports (22, no shim)