[PR #2318] inline_scan: follow a list copied before the cursor load (INLINE-SCAN-COPY-BEFORE-LOAD) #2323

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2318
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/inline-scan-copy-before-load


📝 Commits (1)

  • 1efc629 inline_scan: follow a list copied before the cursor load (INLINE-SCAN-COPY-BEFORE-LOAD)

📊 Changes

2 files changed (+45 additions, -3 deletions)

View changed files

📝 tests/test_inline_scan.py (+38 -0)
📝 tools/inline_scan.py (+7 -3)

📄 Description

Claimed in the coordination issue as: INLINE-SCAN-COPY-BEFORE-LOAD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193762634)

What and why

tools/inline_scan.py exists to say whether every inline command-list write checks the cursor limit; "UNCHECKED 0" is the answer the day-one check in docs/design.md reads as "a cursor-at-limit layer sees every command". classify() walks backwards from a store-back mov [rbx+18h],rax and accepted the cursor load mov rax,[rcx+18h] only if rcx was already known to hold the list at that point of the walk. When this is copied first:

mov rbx,rcx
mov rax,qword ptr [rcx+18h]
mov dword ptr [rax],4002C400h
...
add rax,10h
mov qword ptr [rbx+18h],rax
mov byte ptr [rbx+0000000000000140h],0

the walk meets the load before the copy, so the load was taken for another structure's +18h, load_traced was False and the write was reported as unrelated. The summary said UNCHECKED 0 and counted it among the "cursor-like stores with no list field nearby". The same write with the list in rbx throughout, or with the copy after the load, is UNCHECKED, and the checked form of this exact shape is already a test (test_list_copied_to_another_register_is_followed), found only because the compare pass runs forwards over the final register set.

The load's base is now recorded and checked after the walk, against every register the list was copied through. A load from a register that never held the list still marks the site as another structure. Checked sites do not depend on the load, so the change can only move a site from unrelated to UNCHECKED; the counts in docs/d3d12_command_objects.md (every DLL site checked) cannot change, but I could not re-run them here (no game files).

Tested

Windows 11, Python 3.14.7, synthetic dumpbin-style listings only:

  • python -I tests/test_inline_scan.py: 16 tests OK. New test_list_copied_before_the_cursor_load_is_still_unchecked runs the unchecked write with the copy before and after the load; on main the copy-before-load case fails (list is False), with the fix both are UNCHECKED with the cursor traced and size 0x10. New test_cursor_loaded_from_another_structure_is_not_a_list keeps a load through a register that is never a copy of the list (rsi) out of the list sites.
  • python -I tests/test_cpu_feature_scan.py (imports inline_scan) OK; the test of open #536 (test_inline_scan_extra.py) also passes on this branch.
  • python -m compileall; scripts/check_no_game_data.py on both files.
  • Merges cleanly with open #2273, which changes read_lines and main in the same file (different topic).

GPUs tested: n/a (CPU-only tool)

AI-assisted: yes (Claude Code, Claude Opus 5.5)

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)

🤖 Generated with 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/2318 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/inline-scan-copy-before-load` --- ### 📝 Commits (1) - [`1efc629`](https://github.com/ubiquitarianism/leonida/commit/1efc6290960ffc6dd1dd3c499aec1f47cfe12ad5) inline_scan: follow a list copied before the cursor load (INLINE-SCAN-COPY-BEFORE-LOAD) ### 📊 Changes **2 files changed** (+45 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_inline_scan.py` (+38 -0) 📝 `tools/inline_scan.py` (+7 -3) </details> ### 📄 Description Claimed in the coordination issue as: INLINE-SCAN-COPY-BEFORE-LOAD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193762634) ### What and why `tools/inline_scan.py` exists to say whether every inline command-list write checks the cursor limit; "UNCHECKED 0" is the answer the day-one check in `docs/design.md` reads as "a cursor-at-limit layer sees every command". `classify()` walks backwards from a store-back `mov [rbx+18h],rax` and accepted the cursor load `mov rax,[rcx+18h]` only if rcx was already known to hold the list at that point of the walk. When `this` is copied first: mov rbx,rcx mov rax,qword ptr [rcx+18h] mov dword ptr [rax],4002C400h ... add rax,10h mov qword ptr [rbx+18h],rax mov byte ptr [rbx+0000000000000140h],0 the walk meets the load before the copy, so the load was taken for another structure's `+18h`, `load_traced` was False and the write was reported as `unrelated`. The summary said `UNCHECKED 0` and counted it among the "cursor-like stores with no list field nearby". The same write with the list in rbx throughout, or with the copy after the load, is UNCHECKED, and the checked form of this exact shape is already a test (`test_list_copied_to_another_register_is_followed`), found only because the compare pass runs forwards over the final register set. The load's base is now recorded and checked after the walk, against every register the list was copied through. A load from a register that never held the list still marks the site as another structure. Checked sites do not depend on the load, so the change can only move a site from `unrelated` to `UNCHECKED`; the counts in `docs/d3d12_command_objects.md` (every DLL site checked) cannot change, but I could not re-run them here (no game files). ### Tested Windows 11, Python 3.14.7, synthetic dumpbin-style listings only: - `python -I tests/test_inline_scan.py`: 16 tests OK. New `test_list_copied_before_the_cursor_load_is_still_unchecked` runs the unchecked write with the copy before and after the load; on `main` the copy-before-load case fails (`list` is False), with the fix both are UNCHECKED with the cursor traced and size 0x10. New `test_cursor_loaded_from_another_structure_is_not_a_list` keeps a load through a register that is never a copy of the list (rsi) out of the list sites. - `python -I tests/test_cpu_feature_scan.py` (imports `inline_scan`) OK; the test of open #536 (`test_inline_scan_extra.py`) also passes on this branch. - `python -m compileall`; `scripts/check_no_game_data.py` on both files. - Merges cleanly with open #2273, which changes `read_lines` and `main` in the same file (different topic). GPUs tested: n/a (CPU-only tool) AI-assisted: yes (Claude Code, Claude Opus 5.5) ### 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) 🤖 Generated with [Claude Code](https://claude.com/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#2323
No description provided.