runtime: replay the console list's inline records as their vtable calls (BL-3) #1050

Open
github-bot wants to merge 1 commit from github-bot/gh-1050 into main AGit
Owner

@⁠baldyb4242 on GitHub · 2026-11-24 17:20 UTC · original
baldyb4242:bl3/console-slot-drop-check → main · +490 −0 · 4 files · 1 commits · open

Claimed in the coordination issue as: BL-3 (#14)

What and why

A console DLL writes a command into the list object itself while the list has room, instead of calling the vtable (docs/d3d12_command_objects.md §3.5a). The list proxy avoids this today by keeping the cursor at its limit, so every command goes through the vtable. An inline write the title makes without checking the cursor first would be lost.

This adds the decoder half of BL-3:

  • runtime/src/console_list_records.h decodes the measured inline records into the vtable calls they replace:

    Record Fallback slot
    0x4002C400 dispatch 14
    0x4003CC00 dispatch with an extra word 80
    one root constant 37
    several root constants 39
    descriptor table 35
    root CBV / SRV / UAV 41 / 43 / 45
    pipeline record 25
  • The root-argument header is the list's table entry at +0x344, which the runtime fills. The header defines an encoding for it that keeps bits 30–31 clear (the DLL writes inline only then) and leaves room for the DLL's measured + 4*offset and + ((n-1) << 16) adjustments.

  • An unknown or truncated record stops decoding and reports its offset. It is never skipped.

  • docs/boot_leads.md: a status line for BL-3.

Not in this PR (draft for that reason):

  • Wiring the decoder into runtime/shims/d3d12_xs_device.cpp: replay pending records before each vtable call and at Close.
  • The bytes our PSOs expose as the 28-byte pipeline record. The decoder takes a resolver for now.
  • Widening the 32-bit descriptor-table address (BL-4).

Slot 80 → Dispatch on the vtable path is #687's change and is not duplicated here.

Tested

  • console_list_records_test (new) models the DLL independently from §3.5a. It runs 1,200 seeded sequences at six cursor limits (0 to 4,096 bytes), and the inline path and the all-vtable path give the same call stream (13,190 commands written inline and replayed). It also has one case per measured form and 11 refusal cases.
  • Eight planted decoder bugs (slot swap, dropped VA high half, offset and count arithmetic, field masks, skipping unknown records, the combined-adjustment check) each make the test fail.
  • Portable ctest on macOS (AppleClang 21, Apple Silicon): 75/75 passed, 2 skipped (shader_library_corpus and vk_sync_validation need game files). Before the change: 72/72.
  • Builds clean with -Wall -Wextra -Wpedantic -Werror.
  • check_no_game_data.py passes on the changed files.
  • Not built with MSVC or run under Wine: this change touches no Windows-only code.

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

AI-assisted: yes (Claude Code)

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

**@⁠baldyb4242** on GitHub · 2026-11-24 17:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1050) `baldyb4242:bl3/console-slot-drop-check` → `main` · +490 −0 · 4 files · 1 commits · open Claimed in the coordination issue as: BL-3 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why A console DLL writes a command into the list object itself while the list has room, instead of calling the vtable (`docs/d3d12_command_objects.md` §3.5a). The list proxy avoids this today by keeping the cursor at its limit, so every command goes through the vtable. An inline write the title makes without checking the cursor first would be lost. This adds the decoder half of BL-3: - `runtime/src/console_list_records.h` decodes the measured inline records into the vtable calls they replace: | Record | Fallback slot | |---|---| | `0x4002C400` dispatch | 14 | | `0x4003CC00` dispatch with an extra word | 80 | | one root constant | 37 | | several root constants | 39 | | descriptor table | 35 | | root CBV / SRV / UAV | 41 / 43 / 45 | | pipeline record | 25 | - The root-argument header is the list's table entry at `+0x344`, which the runtime fills. The header defines an encoding for it that keeps bits 30–31 clear (the DLL writes inline only then) and leaves room for the DLL's measured `+ 4*offset` and `+ ((n-1) << 16)` adjustments. - An unknown or truncated record stops decoding and reports its offset. It is never skipped. - `docs/boot_leads.md`: a status line for BL-3. Not in this PR (draft for that reason): - Wiring the decoder into `runtime/shims/d3d12_xs_device.cpp`: replay pending records before each vtable call and at Close. - The bytes our PSOs expose as the 28-byte pipeline record. The decoder takes a resolver for now. - Widening the 32-bit descriptor-table address (BL-4). Slot 80 → `Dispatch` on the vtable path is #687's change and is not duplicated here. ### Tested - `console_list_records_test` (new) models the DLL independently from §3.5a. It runs 1,200 seeded sequences at six cursor limits (0 to 4,096 bytes), and the inline path and the all-vtable path give the same call stream (13,190 commands written inline and replayed). It also has one case per measured form and 11 refusal cases. - Eight planted decoder bugs (slot swap, dropped VA high half, offset and count arithmetic, field masks, skipping unknown records, the combined-adjustment check) each make the test fail. - Portable `ctest` on macOS (AppleClang 21, Apple Silicon): 75/75 passed, 2 skipped (`shader_library_corpus` and `vk_sync_validation` need game files). Before the change: 72/72. - Builds clean with `-Wall -Wextra -Wpedantic -Werror`. - `check_no_game_data.py` passes on the changed files. - Not built with MSVC or run under Wine: this change touches no Windows-only code. GPUs tested: n/a (CPU-only test) AI-assisted: yes (Claude Code) ### 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)
A console DLL writes a command into the list object while it has room instead
of calling the vtable (docs/d3d12_command_objects.md §3.5a). The list proxy
avoids this today by pinning the cursor at its limit; an inline write the
title makes without checking first would be lost.

console_list_records.h decodes the measured records (the two dispatch headers,
root constants, descriptor table, root CBV/SRV/UAV, pipeline record) into the
fallback calls (slots 14, 80, 37, 39, 35, 41/43/45, 25), using a root-argument
header table this runtime defines. An unknown or truncated record stops
decoding with its offset instead of being skipped.

console_list_records_test models the DLL independently from the doc and runs
1,200 seeded sequences at six cursor limits: the inline path (replayed before
each vtable call and at Close) and the all-vtable path give the same calls.
Eight planted decoder bugs each fail it.

Not yet wired into runtime/shims/d3d12_xs_device.cpp (Windows-only, not
buildable here). No game files, no GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:35:19 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 18:49 UTC · original · approved these changes

Clean-Room Audit & Architectural Review — PR #1050 (BL-3 Console Command List Record Decoder)

Strong, clean-room implementation for BL-3!

Technical Verification

  1. Inline Record Decoding (runtime/src/console_list_records.h):
    • Decodes the measured inline forms from docs/d3d12_command_objects.md §3.5a (0x4002C400 -> slot 14 Dispatch, 0x4003CC00 -> slot 80, root constants slots 37/39, root table slot 35, root CBV/SRV/UAV slots 41/43/45, and 28-byte pipeline record -> slot 25 SetPipelineState).
    • Stops cleanly at the exact byte offset on unknown/truncated/misaligned records rather than skipping bytes.
    • Accurately updates docs/boot_leads.md §BL-3 noting the remaining proxy wiring and BL-4 widening items.
  2. Synthetic Verification (runtime/test/console_list_records_test.cpp):
    • Verifies header bitfields don't collide with dispatch headers or overflow across max parameters/constants, tests all 9 record forms and refusal paths, and validates inline-vs-vtable stream equivalence across 1,200 seeded sequences.
  3. Clean-Room Compliance:
    • 0 retail files or keys; C++20 stdlib + synthetic tests only.

Verdict: APPROVED

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 18:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1050#pullrequestreview-6045339914) · **approved these changes** ### Clean-Room Audit & Architectural Review — PR #1050 (`BL-3` Console Command List Record Decoder) Strong, clean-room implementation for BL-3! #### Technical Verification 1. **Inline Record Decoding (`runtime/src/console_list_records.h`)**: - Decodes the measured inline forms from `docs/d3d12_command_objects.md §3.5a` (`0x4002C400` -> slot 14 `Dispatch`, `0x4003CC00` -> slot 80, root constants slots 37/39, root table slot 35, root CBV/SRV/UAV slots 41/43/45, and 28-byte pipeline record -> slot 25 `SetPipelineState`). - Stops cleanly at the exact byte offset on unknown/truncated/misaligned records rather than skipping bytes. - Accurately updates `docs/boot_leads.md §BL-3` noting the remaining proxy wiring and BL-4 widening items. 2. **Synthetic Verification (`runtime/test/console_list_records_test.cpp`)**: - Verifies header bitfields don't collide with dispatch headers or overflow across max parameters/constants, tests all 9 record forms and refusal paths, and validates inline-vs-vtable stream equivalence across 1,200 seeded sequences. 3. **Clean-Room Compliance**: - 0 retail files or keys; C++20 stdlib + synthetic tests only. **Verdict: APPROVED**
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1050/head:github-bot/gh-1050'
git switch 'github-bot/gh-1050'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1050'
git switch 'github-bot/gh-1050'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1050'
git switch 'github-bot/gh-1050'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1050'
git switch 'main'
git merge --squash 'github-bot/gh-1050'
git switch 'main'
git merge --ff-only 'github-bot/gh-1050'
git switch 'main'
git merge 'github-bot/gh-1050'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.