mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:50:53 +01:00
[PR #943] d3d12_guid_sites, d3d12_iid_scan: report an unreadable header or import table (D3D12-TOOLS-ERROR-REPORTING) #981
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#981
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/943
Author: @TuroYT
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/d3d12-tools-error-reporting📝 Commits (1)
255156cd3d12_guid_sites, d3d12_iid_scan: report an unreadable header or import table (D3D12-TOOLS-ERROR-REPORTING)📊 Changes
4 files changed (+143 additions, -10 deletions)
View changed files
📝
tests/test_d3d12_guid_sites.py(+1 -1)➕
tests/test_d3d12_guid_tools_errors.py(+106 -0)📝
tools/d3d12_guid_sites.py(+11 -1)📝
tools/d3d12_iid_scan.py(+25 -8)📄 Description
Claimed in the coordination issue as: D3D12-TOOLS-ERROR-REPORTING (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135584906)
What was wrong
--headerthat does not exist (if header and os.path.isfile(header)).Reproduction on main with a 2-byte image and a missing header:
0 known GUIDs from .../no_such_d3d12.h,skipped (unpack_from requires a buffer of at least 64 bytes ...), exit 0. tools/d3d12_iid_scan.py exits 2 on thesame input with
ERROR: d3d12.h not found; pass --header.read_iids: the MIDL regex accepts any 36-character run of hex digits and dashes, anduuid.UUIDthen raises ValueError, which the OSError-only handler in main() did not catch. Reproduction with the header line
MIDL_INTERFACE("000000000000000000000000000000000000"): traceback ending inValueError: badly formed hexadecimal UUID string, in both tools.except (struct.error, ValueError): return Nonemade a parse error look like "does notimport d3d12_xs.dll", so the "imports may be IID data" warning was lost. Reproduction with two hand-built PE32+
stubs (a few hundred bytes, written by the test): the good stub prints
imports from d3d12_xs.dll: #50and thewarning, exit 0; the stub with an unterminated second import name prints neither. All three defects reproduced.
What changed
--headerthat is not a file exits 2 withERROR: d3d12.h not found: <path>.A malformed GUID exits 2 with
ERROR: cannot read <header>: a MIDL_INTERFACE GUID is malformed (...). The samemalformed-GUID error is in d3d12_iid_scan.py. The default SDK header lookup is unchanged.
d3d12_xs_importskeeps its return value. A newread_d3d12_xs_importsalso returns the reason thetable could not be read to its end. Names read before the error stay in the list, a one-line WARNING goes to stderr
naming the image, and the exit code stays 0 as on main. The JSON report gets a new key,
d3d12_xs_import_error(null when the table reads to its end).cstrnow raises a named ValueError instead of abare
indexfailure.test_clipassed a missing--headerand expected exit 0. It now writes a headerfile that lists no interfaces.
(both tools), malformed GUID (both tools), unreadable import table (warning, names kept, no traceback), and a good
header with a good stub (unchanged output).
The stub layout for defect 3 differs from the one in the report. A descriptor at file offset 0x214 overlaps the name
string at 0x220, so the name is at 0x230 (RVA 0x1030) here, and the unterminated name is at RVA 0x10F8 (file 0x2F8),
inside the section. With RVA 0x1300 the name is outside the section, and the parser skips that descriptor without an
error (see below).
Tested
the malformed GUID; iid_scan on the bad stub prints no imports line and no warning).
python3 -I tests/test_d3d12_guid_tools_errors.py: Ran 4 tests, OK.4 failures, one per new defect test (missing header in guid_sites, malformed GUID in both tools, the bad-stub warning).
python3 -I tests/test_d3d12_guid_sites.py: Ran 10 tests, OK.python3 -I tests/test_d3d12_iid_scan.py: Ran 15tests, OK.
python3 -I tests/test_missing_input_exit_codes.py: Ran 2 tests, OK.python3 -m compileall -q tools tests: exit 0.python3 -I tests/test_text_write_line_endings.py: OK.python3 -I scripts/check_no_game_data.pyon the four changed files: exit 0.git diff --check: clean.Not tested:
__main__block, sopython3 -Iexits 0 without running a test.pytest is not installed here, so the file was not run under pytest.
knownblock and does not touchthe lines this PR changes. A rebase may be needed if #487 lands first.
Not changed, on purpose:
cannot tell whether that import is d3d12_xs.dll, and reporting it would change the result for every image.
--headerisrefused. Making the default an error is a behaviour change for hosts without an SDK.
AI-assisted (Claude Code).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.