From 1925206001d8b3fcdbe7597ed380ba5dbf6e3b4c Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Sat, 14 Nov 2026 21:21:33 -0500 Subject: [PATCH] fix(wincomponents): only accepted top-level system32 files decide x64 guests --- .../usr/local/bin/droiddeck-wincomponents | 10 ++++++---- tools/tests/test_wincomponents.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-wincomponents b/tools/linuxfs/overlay/usr/local/bin/droiddeck-wincomponents index 19c0cd6918..cd2b44d55d 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-wincomponents +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-wincomponents @@ -500,15 +500,17 @@ def component_guests(compat, proton, machines, planned, owned): if not machines or 0xA641 not in machines["system32"][1]: return frozenset() system32 = compat / "pfx/drive_c/windows/system32" + def top_dll(rel): + return len(Path(rel).parts) == 4 and system_folder(rel) == "system32" and rel.lower().endswith(".dll") + final = {} for rel, src in planned: - if system_folder(rel) == "system32" and rel.lower().endswith(".dll"): + if top_dll(rel) and (plain_x64(src) or machine_compatible(src, machines["system32"][1])): final[rel.lower()] = (rel, src) planned_rels = {rel.lower() for rel, src in planned} - removed = {rel.lower(): rel for rel in owned if rel.lower() not in planned_rels and system_folder(rel) == "system32"} + removed = {rel.lower(): rel for rel in owned if rel.lower() not in planned_rels and top_dll(rel)} names = {Path(rel).name for rel, src in final.values() if plain_x64(src)} - replaced = {key for key, (rel, src) in final.items() - if not plain_x64(src) and machine_compatible(src, machines["system32"][1])} + replaced = {key for key, (rel, src) in final.items() if not plain_x64(src)} try: present = list(os.scandir(system32)) except OSError: diff --git a/tools/tests/test_wincomponents.py b/tools/tests/test_wincomponents.py index a8b0703060..d69eef4dc6 100644 --- a/tools/tests/test_wincomponents.py +++ b/tools/tests/test_wincomponents.py @@ -179,6 +179,24 @@ class WinComponentsTest(unittest.TestCase): self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dx9_43.dll"), 0xAA64) self.assertFalse((self.pfx / "system32/d3dcompiler_43.dll").exists()) + def test_rejected_later_entry_does_not_hide_an_accepted_x64_entry(self): + proton = self.proton() + self.component("a-x64", ["d3dx9_43"], {"system32/d3dx9_43.dll": self.pe_image(0x8664)}) + self.component("b-x86", ["d3dx9_43"], {"system32/d3dx9_43.dll": pe_image_importing(0x14C)}) + self.component("c-compiler", ["d3dcompiler_43"], {"system32/d3dcompiler_43.dll": self.pe_image(0x8664)}) + self.pick("a-x64", "b-x86", "c-compiler") + self.apply(proton) + self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dx9_43.dll"), 0x8664) + self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dcompiler_43.dll"), 0x8664) + + def test_nested_system32_file_does_not_count_as_an_importer(self): + proton = self.proton() + self.component("d3dx9", ["d3dx9_43"], {"system32/drivers/d3dx9_43.dll": self.pe_image(0x8664)}) + self.component("d3dcompiler", ["d3dcompiler_43"], {"system32/d3dcompiler_43.dll": self.pe_image(0x8664)}) + self.pick("d3dx9", "d3dcompiler") + self.apply(proton) + self.assertFalse((self.pfx / "system32/d3dcompiler_43.dll").exists()) + def test_held_component_files_still_count_as_x64_importers(self): proton = self.proton() self.component("d3dx9", ["d3dx9_43"], {"system32/d3dx9_43.dll": self.pe_image(0x8664)})