runtime: add main(argv) CLI and chunk size validation to startup capture reader #2107
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2115"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T00:45:33Z.
Change
Harden
tools/startup/capture.pywith an explicit CLI entry point and chunk-size validation, and add a pure-Python CLI/validation unit suite (tests/startup_capture_cli_check.py, registered inCMakeLists.txtasstartup_capture_cli):main(argv=None) -> intusingargparse, invokingdescribe(Capture(args.capture), out=sys.stdout)and reporting(OSError, ValueError)viaparser.exit(1, ...)without raw Python tracebacks.VIEWchunk headers inCapture.on_VIEW: raiseValueErrorwhenlen(h) < 48 + desc_bytesinstead of silently truncating the descriptor slice.TABLchunk bodies inCapture.on_TABL: raiseValueErrorwhenlen(b) % 4 != 0orentries > len(ids)instead of dropping trailing bytes or silently truncating the shadow table.TABLrecords, exactVIEWboundary (len(h) == 48 + desc_bytes), subprocess CLI smoke tests, truncatedVIEWdescriptors, malformedTABLbodies, damaged chunk headers/payloads, missing CLI argument (exit 2), and missing/directory pathOSErrorhandling (exit 1, zero tracebacks).Verification
Commit:
aaa7d370(rebased ontoupstream/main3ebc3523).out/pe-env/Scripts/python.exe -B tests/startup_capture_cli_check.py -v-> exit0(6 tests OK)out/pe-env/Scripts/python.exe -B tests/startup_capture_check.py-> exit0(7/7 checks ok)out/pe-env/Scripts/python.exe -B tests/startup_tools_lint_check.py-> exit0(PASS: 7 files under tools/startup parse)out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py-> exit0(form coverage checks passed)out/pe-env/Scripts/python.exe -B tests/docs_links_check.py-> exit0out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py-> exit0len(h) < 48 + desc_bytesinon_VIEW,len(b) % 4 != 0inon_TABL,entries > len(ids)inon_TABL, andexcept (OSError, ValueError)inmain()each causedtests/startup_capture_cli_check.pyto fail (exit1).No capability skips (exit 77).
Evidence and follow-up
All
capture.binstreams intests/startup_capture_cli_check.pyare synthetically constructed in Python matching thesrc/startup_stubs/d3d12_capture.inlchunk framing (ViewRecordandTABLlayouts) under the repository MIT license.Checklist
AI-assisted.