[PR #648] [MERGED] OLD-7481: restore old upstream PR 7481 - rtti_scan: scan the last aligned qword of a section for a COL pointer #688

Closed
opened 2026-11-26 20:18:43 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/648
Author: @aslan2142
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: rtti-scan-last-slot


📝 Commits (1)

  • 558b1b4 rtti_scan: scan the last aligned qword of a section for a COL pointer

📊 Changes

2 files changed (+18 additions, -1 deletions)

View changed files

📝 tests/test_rtti_scan.py (+17 -0)
📝 tools/rtti_scan.py (+1 -1)

📄 Description

Claimed in the coordination issue as: OLD-7481 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129329833

Restoration of my original pull request, old upstream PR 7481 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c; no changes beyond the rebase.

What and why

  • scan_pe64_rtti looks for vtables by scanning each section's aligned qwords for a CompleteObjectLocator pointer.
  • The loop ran range(start, hi - 8, 8), so the qword at hi - 8 was never read, even though it is the last one that fits in the section.
  • A COL pointer stored in that last qword was missed, along with its vtable.
  • The fix sets the bound to hi - 7, so every qword that fits whole inside the section is read, and none past its end.
  • A new test in tests/test_rtti_scan.py puts the COL pointer in the last aligned qword of a synthetic .rdata. The vtable is found at VirtualSize 0x200, and nothing is found at 0x1FF, where the qword no longer fits.

Tested

Linux, Python 3.14.10, CPU only, synthetic PE images built by the tests (no game files).

  • python -I tests/test_rtti_scan.py:
    • on main, 30/30 pass;
    • on main with only the new test added, 31 run and 1 fails (the new test);
    • with the fix, 31/31 pass.
  • python -m compileall -q tools tests and git diff --check: clean.
  • python -I scripts/check_no_game_data.py tools/rtti_scan.py tests/test_rtti_scan.py: clean.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).


🔄 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/648 **Author:** [@aslan2142](https://github.com/aslan2142) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `rtti-scan-last-slot` --- ### 📝 Commits (1) - [`558b1b4`](https://github.com/ubiquitarianism/leonida/commit/558b1b4e896a8b301668e1632479bd02ee1e77da) rtti_scan: scan the last aligned qword of a section for a COL pointer ### 📊 Changes **2 files changed** (+18 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_rtti_scan.py` (+17 -0) 📝 `tools/rtti_scan.py` (+1 -1) </details> ### 📄 Description Claimed in the coordination issue as: OLD-7481 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129329833 Restoration of my original pull request, old upstream PR 7481 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c675c62f9dbffc318ce6a59d57faf31; no changes beyond the rebase. ### What and why - `scan_pe64_rtti` looks for vtables by scanning each section's aligned qwords for a CompleteObjectLocator pointer. - The loop ran `range(start, hi - 8, 8)`, so the qword at `hi - 8` was never read, even though it is the last one that fits in the section. - A COL pointer stored in that last qword was missed, along with its vtable. - The fix sets the bound to `hi - 7`, so every qword that fits whole inside the section is read, and none past its end. - A new test in `tests/test_rtti_scan.py` puts the COL pointer in the last aligned qword of a synthetic `.rdata`. The vtable is found at `VirtualSize` 0x200, and nothing is found at 0x1FF, where the qword no longer fits. ### Tested Linux, Python 3.14.10, CPU only, synthetic PE images built by the tests (no game files). - `python -I tests/test_rtti_scan.py`: - on `main`, 30/30 pass; - on `main` with only the new test added, 31 run and 1 fails (the new test); - with the fix, 31/31 pass. - `python -m compileall -q tools tests` and `git diff --check`: clean. - `python -I scripts/check_no_game_data.py tools/rtti_scan.py tests/test_rtti_scan.py`: clean. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:43 +01:00
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#688
No description provided.