windows-boot: recover private stacks for manually mapped images #1772

Merged
sodove merged 1 commit from upstream-pr/1772 into main 2026-11-28 13:26:09 +00:00
sodove commented 2026-11-25 11:48:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-25T11:48:06Z.


Claimed in the coordination issue as WIN-BOOT-MAPPED-IMAGE-STACK.

Depends on: #1693 (produces the private exception dump).

What and why

The initial stack can stop inside a PE that the runtime mapped outside the Windows module list. A new offline command takes the private dump and the exact mapped PE. It matches captured instructions to a unique location in an executable section, derives the actual base, and checks for a file-backed x64 unwind entry at the exception RIP. Available header and unwind bytes must agree with the local image.

The tool gives x64 CDB a fixed staging name, disables network symbols and shell commands, selects the saved exception context, and writes the recovered frames to a new private file. Console output contains the outcome and frame count. The Windows boot README documents the command and its limits, including exit-only snapshots and dumps with insufficient instruction bytes.

Tested

  • All eight mapped-stack tests passed on Windows 11 Pro x64. The native CDB test used a hand-built, relocated PE absent from the minidump module list and recovered its caller through the disk unwind table. The synthetic PE was never executed.
  • The tests also cover both minidump memory-list formats, code and header mismatches, duplicate code windows, missing unwind metadata, registered module conflicts, incomplete debugger output, a filename containing debugger command separators, and preservation of an existing report.
  • All three text-writer checks and all 22 report-path tests passed. Python compilation, the no-game-data check on all three changed files, and the whitespace check passed.
  • Verified clean merge trees with main at ed94fbef9 and the current #1693 head.

GPUs tested: n/a (CPU-only synthetic Windows debugging).

AI-assisted: yes

Checklist

  • Based on upstream main and checked for merge conflicts.
  • One topic.
  • No game data, keys or decryption in the change, tests or report.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5490730860 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1772). Originally posted by [sodove](https://github.com/sodove) on 2026-11-25T11:48:06Z. --- Claimed in the coordination issue as [WIN-BOOT-MAPPED-IMAGE-STACK](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161231063). Depends on: #1693 (produces the private exception dump). ### What and why The initial stack can stop inside a PE that the runtime mapped outside the Windows module list. A new offline command takes the private dump and the exact mapped PE. It matches captured instructions to a unique location in an executable section, derives the actual base, and checks for a file-backed x64 unwind entry at the exception RIP. Available header and unwind bytes must agree with the local image. The tool gives x64 CDB a fixed staging name, disables network symbols and shell commands, selects the saved exception context, and writes the recovered frames to a new private file. Console output contains the outcome and frame count. The Windows boot README documents the command and its limits, including exit-only snapshots and dumps with insufficient instruction bytes. ### Tested - All eight mapped-stack tests passed on Windows 11 Pro x64. The native CDB test used a hand-built, relocated PE absent from the minidump module list and recovered its caller through the disk unwind table. The synthetic PE was never executed. - The tests also cover both minidump memory-list formats, code and header mismatches, duplicate code windows, missing unwind metadata, registered module conflicts, incomplete debugger output, a filename containing debugger command separators, and preservation of an existing report. - All three text-writer checks and all 22 report-path tests passed. Python compilation, the no-game-data check on all three changed files, and the whitespace check passed. - Verified clean merge trees with main at ed94fbef9 and the current #1693 head. GPUs tested: n/a (CPU-only synthetic Windows debugging). AI-assisted: yes ### Checklist - [x] Based on upstream main and checked for merge conflicts. - [x] One topic. - [x] No game data, keys or decryption in the change, tests or report.
zmasi commented 2026-11-28 11:53:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:53:18Z.


#1772 | head 056e682321 (merged cleanly with main 24549bdb1) | python -I tests/test_mapped_stack.py | red on main: ModuleNotFoundError: No module named 'mapped_stack' (rc=1) | green on PR+main: 8 tests OK (skipped=1) | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited scripts/windows-boot/mapped_stack.py, scripts/windows-boot/README.md, and tests/test_mapped_stack.py (validating local-only drive/path checks via GetDriveTypeW, checkout-outside enforcement, minidump stream/bounds parsing, relocated mapping-base inference, .pdata/.xdata corroboration, sanitized CDB environment/command construction, and exclusive rename publication; cdb.exe is not installed on this host so the 7 synthetic PE32+/minidump tests ran and the optional LEONIDA_TEST_CDB test skipped cleanly). Also verified tests/test_docs_encoding.py (1 OK), tests/test_ci_registration.py (18 OK), tests/test_runner_calls_all_tests.py (3 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238848533 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1772#issuecomment-7238848533). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T11:53:18Z. --- #1772 | head 056e6823217b5f2a1fd9b2556ba71fd41a757877 (merged cleanly with main 24549bdb1) | `python -I tests/test_mapped_stack.py` | red on main: `ModuleNotFoundError: No module named 'mapped_stack'` (`rc=1`) | green on PR+main: `8 tests OK (skipped=1)` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `scripts/windows-boot/mapped_stack.py`, `scripts/windows-boot/README.md`, and `tests/test_mapped_stack.py` (validating local-only drive/path checks via `GetDriveTypeW`, checkout-outside enforcement, minidump stream/bounds parsing, relocated mapping-base inference, `.pdata`/`.xdata` corroboration, sanitized CDB environment/command construction, and exclusive `rename` publication; `cdb.exe` is not installed on this host so the 7 synthetic PE32+/minidump tests ran and the optional `LEONIDA_TEST_CDB` test skipped cleanly). Also verified `tests/test_docs_encoding.py` (`1 OK`), `tests/test_ci_registration.py` (`18 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-28 13:26:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T13:26:13Z.


Merged after local re-verification: this PR merged onto main 1a0e77ecb without conflict, and its test file(s) (tests/test_mapped_stack.py) pass there. Earlier today the same tests failed on main without the PR (red/green) and a bundle with other open PRs showed no new failures. check_no_game_data.py is clean. Windows 11, Python 3.14; no GPU needed for these tests.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239934044 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1772#issuecomment-7239934044). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T13:26:13Z. --- Merged after local re-verification: this PR merged onto `main` 1a0e77ecb without conflict, and its test file(s) (`tests/test_mapped_stack.py`) pass there. Earlier today the same tests failed on `main` without the PR (red/green) and a bundle with other open PRs showed no new failures. `check_no_game_data.py` is clean. Windows 11, Python 3.14; no GPU needed for these tests. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1772
No description provided.