Commit Graph

7 Commits

Author SHA1 Message Date
369bf541b1 tools/import_call_sites: scan direct call qword [rip+disp32] (FF 15) import call sites
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)
2026-11-26 00:27:21 +03:00
aa7223ecfa Count call sites for delay-loaded imports 2026-11-24 00:49:53 -05:00
caf5f9fd6c Merge PR #9599 2026-11-23 17:08:52 -05:00
f9b6bd3503 import_call_sites: keep the DLL and the name apart when selecting imports
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>
2026-11-23 18:37:47 -03:00
74cc7ccf9c import_call_sites: refuse a selector this image does not import
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.
2026-11-23 22:34:50 +01:00
6f26e9baae import_call_sites: refuse a --import or --dll value that can select no import
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.
2026-11-23 22:19:53 +01:00
a847ee646a RT-5: how the retail executable calls the audio coprocessor, texture layout and DirectStorage imports (22, no shim) (#6899)
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)
2026-11-23 09:37:29 -06:00