[PR #2006] tools/import_call_sites: scan direct call qword [rip+disp32] (FF 15) import call sites (IMPORT-CALL-SITES-DIRECT-FF15-CALLS) #2011

Open
opened 2026-11-26 21:19:44 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2006
Author: @abnalstlll-byte
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: feat/import-call-sites-direct-ff15


📝 Commits (1)

  • 369bf54 tools/import_call_sites: scan direct call qword [rip+disp32] (FF 15) import call sites

📊 Changes

3 files changed (+84 additions, -6 deletions)

View changed files

📝 tests/test_import_call_sites.py (+62 -0)
📝 tools/import_call_sites.py (+15 -5)
📝 tools/import_fail_fast.py (+7 -1)

📄 Description

Claimed in the coordination issue as: IMPORT-CALL-SITES-DIRECT-FF15-CALLS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7170156749)

What and why

  • tools/import_call_sites.py searches for thunks (jmp qword [rip+disp32] / \xff\x25) and relative branches (E8/E9 rel32) to those thunks. However, MSVC and compilers also emit direct call qword [rip+disp32] (\xff\x15) targeting the import's IAT slot directly without an intermediate jmp thunk (as noted in BubsMcgee's finding and docs/xdxr.md §6 for XboxBvhBuilder.dll call sites).
  • Add CALL_INDIRECT = re.compile(b"\xff\x15") and scan executable sections for direct calls targeting import slots, recording them in entry["call"].
  • Update tools/import_fail_fast.py to identify instruction boundary sizes (rva + 6 for 0xFF 0x15 vs rva + 5 for 0xE8) and deduplicate call sites when classifying results.
  • Add unit tests in tests/test_import_call_sites.py covering:
    • direct slot call counted without a thunk
    • combined thunk and direct calls sorted by RVA
    • direct call targeting non-slot ignored
    • direct call truncated near section boundary
    • CLI JSON and table outputs

Tested

  • python -I tests/test_import_call_sites.py -> Ran 26 tests in 0.091s, OK
  • python -I tests/test_import_fail_fast.py -> Ran 10 tests in 0.066s, OK
  • python -I tests/test_int3_cause.py -> Ran 15 tests in 0.022s, OK
  • python -I tests/test_x86_high_byte_writes.py -> Ran 4 tests in 0.001s, OK
  • python -I tests/test_text_write_line_endings.py -> Ran 3 tests in 12.225s, OK
  • python -I scripts/check_no_game_data.py tools/import_call_sites.py tools/import_fail_fast.py tests/test_import_call_sites.py -> exit 0
  • python -m compileall -q make_game.py tools tests -> exit 0
  • git diff --check -> clean

Tested on Windows 11 x64 (Python 3.12, stdlib tests, no game data needed).
AI-assisted (Claude Code)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2006 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/import-call-sites-direct-ff15` --- ### 📝 Commits (1) - [`369bf54`](https://github.com/ubiquitarianism/leonida/commit/369bf541b14abeff8c67a5e4b631b1996e41910e) tools/import_call_sites: scan direct call qword [rip+disp32] (FF 15) import call sites ### 📊 Changes **3 files changed** (+84 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_import_call_sites.py` (+62 -0) 📝 `tools/import_call_sites.py` (+15 -5) 📝 `tools/import_fail_fast.py` (+7 -1) </details> ### 📄 Description Claimed in the coordination issue as: IMPORT-CALL-SITES-DIRECT-FF15-CALLS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7170156749) ### What and why - `tools/import_call_sites.py` searches for thunks (`jmp qword [rip+disp32]` / `\xff\x25`) and relative branches (`E8`/`E9 rel32`) to those thunks. However, MSVC and compilers also emit direct `call qword [rip+disp32]` (`\xff\x15`) targeting the import's IAT slot directly without an intermediate jmp thunk (as noted in BubsMcgee's finding and `docs/xdxr.md` §6 for `XboxBvhBuilder.dll` call sites). - Add `CALL_INDIRECT = re.compile(b"\xff\x15")` and scan executable sections for direct calls targeting import slots, recording them in `entry["call"]`. - Update `tools/import_fail_fast.py` to identify instruction boundary sizes (`rva + 6` for `0xFF 0x15` vs `rva + 5` for `0xE8`) and deduplicate call sites when classifying results. - Add unit tests in `tests/test_import_call_sites.py` covering: - direct slot call counted without a thunk - combined thunk and direct calls sorted by RVA - direct call targeting non-slot ignored - direct call truncated near section boundary - CLI JSON and table outputs ### Tested - `python -I tests/test_import_call_sites.py` -> `Ran 26 tests in 0.091s`, `OK` - `python -I tests/test_import_fail_fast.py` -> `Ran 10 tests in 0.066s`, `OK` - `python -I tests/test_int3_cause.py` -> `Ran 15 tests in 0.022s`, `OK` - `python -I tests/test_x86_high_byte_writes.py` -> `Ran 4 tests in 0.001s`, `OK` - `python -I tests/test_text_write_line_endings.py` -> `Ran 3 tests in 12.225s`, `OK` - `python -I scripts/check_no_game_data.py tools/import_call_sites.py tools/import_fail_fast.py tests/test_import_call_sites.py` -> `exit 0` - `python -m compileall -q make_game.py tools tests` -> `exit 0` - `git diff --check` -> `clean` Tested on Windows 11 x64 (Python 3.12, stdlib tests, no game data needed). AI-assisted (Claude Code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2011
No description provided.