From 928633e93921c10bf65ba03df5ce8479503ca626 Mon Sep 17 00:00:00 2001 From: Anne Kremer Date: Mon, 23 Nov 2026 15:14:34 +0100 Subject: [PATCH] d3d12_guid_sites: scan the last whole slot of every section absolute_refs, the queue-description windows and movabs_pairs stopped one step short: range(0, len - 8, 8), range(0, len - 16, 4) and range(len - 10) never reach the 8-byte slot, 16-byte window or 10-byte instruction that ends exactly at the section end. A GUID pointer, queue description or movabs GUID half there was silently dropped. Use len - 7, len - 15 and len - 9, the same "must fit entirely" bound rip_refs already uses, and test each scan on a hand-built PE32+ whose candidate ends its section. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 --- tests/test_d3d12_guid_sites.py | 24 ++++++++++++++++++++++++ tools/d3d12_guid_sites.py | 6 +++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/test_d3d12_guid_sites.py b/tests/test_d3d12_guid_sites.py index 5e44b5d505..a0ebfac2f7 100644 --- a/tests/test_d3d12_guid_sites.py +++ b/tests/test_d3d12_guid_sites.py @@ -159,6 +159,30 @@ def test_queue_desc_window(self): self.assertEqual(len(r["queue_descs"]), 2) self.assertEqual(r["guid_candidates"][0]["value"], str(UNKNOWN)) + def test_queue_desc_in_the_last_16_bytes_of_a_section(self): + # The window that ends exactly at the end of .rdata is a whole window and is scanned too. + rdata = b"\0" * 16 + struct.pack(" list[tuple[int, bytes]]: continue blob = img.data[s["raw"]:s["raw"] + s["rsize"]] imm: list[tuple[int, bytes]] = [] - for i in range(len(blob) - 10): + for i in range(len(blob) - 9): # a 10-byte movabs must fit entirely if blob[i] == 0x48 and 0xB8 <= blob[i + 1] <= 0xBF: imm.append((s["va"] + i, blob[i + 2:i + 10])) for (rva1, first), (rva2, second) in zip(imm, imm[1:]): @@ -245,7 +245,7 @@ def absolute_refs(img: Image) -> list[tuple[int, int]]: lo = img.image_base for s in img.initialized(): blob = img.data[s["raw"]:s["raw"] + s["rsize"]] - for i in range(0, len(blob) - 8, 8): + for i in range(0, len(blob) - 7, 8): # the last whole 8-byte slot too value = struct.unpack_from(" tuple[bytes, str] | None: if s["chars"] & 0x20000000: # code sections are not queue descriptions continue blob = img.data[s["raw"]:s["raw"] + s["rsize"]] - for i in range(0, len(blob) - 16, 4): + for i in range(0, len(blob) - 15, 4): # the last whole 16-byte window too if s["va"] + i in lea_targets and queue_desc_shaped(blob[i:i + 16]): t, p, flags, node = struct.unpack_from("