mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
fix(game-env): exclude ARM64EC images and removed component files from x64 guests
ARM64EC images no longer count as x64 importers, component files that are being removed no longer keep their dependencies, and a saved x64 DLL is restored when its component is deselected.
This commit is contained in:
1 parent
f54dba2b96
commit
1e4ad00dcf
4 files changed
+50
-7
No files matched your search
@@ -952,7 +952,7 @@ def restore_x64_guest_dlls(prefix, proton, env=None):
|
||||
for name in names:
|
||||
path = system32 / name
|
||||
if not path.is_symlink():
|
||||
if pe_machine(path) == 0x8664:
|
||||
if pe_machine(path) == 0x8664 and not PE["pe_has_arm64ec_metadata"](path):
|
||||
present.append(name)
|
||||
continue
|
||||
if not os.path.realpath(path).startswith(os.path.realpath(builtins) + os.sep):
|
||||
@@ -994,7 +994,8 @@ def repair_foreign_system_dlls(prefix, proton, env=None):
|
||||
except OSError:
|
||||
continue
|
||||
candidates = [name for name in names if name.lower().endswith(".dll") and not (windows / folder / name).is_symlink()
|
||||
and pe_machine(windows / folder / name) == 0x8664]
|
||||
and pe_machine(windows / folder / name) == 0x8664
|
||||
and not PE["pe_has_arm64ec_metadata"](windows / folder / name)]
|
||||
guests = PE["x64_guests"](builtins, candidates) if candidates and 0xA641 in machines else frozenset()
|
||||
for name in names:
|
||||
path = windows / folder / name
|
||||
|
||||
@@ -492,18 +492,26 @@ def foreign_component(rel, path, machines, guests=frozenset()):
|
||||
return machine is not None and not machine_compatible(path, machines[folder][1], machine, guests, Path(rel).name)
|
||||
|
||||
|
||||
def component_guests(pfx, proton, machines, planned):
|
||||
def plain_x64(path):
|
||||
return pe_machine(path) == 0x8664 and not PE["pe_has_arm64ec_metadata"](path)
|
||||
|
||||
|
||||
def component_guests(compat, proton, machines, planned, owned):
|
||||
if not machines or 0xA641 not in machines["system32"][1]:
|
||||
return frozenset()
|
||||
system32 = pfx / "drive_c/windows/system32"
|
||||
system32 = compat / "pfx/drive_c/windows/system32"
|
||||
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"}
|
||||
names = {Path(rel).name for rel, src in planned
|
||||
if system_folder(rel) == "system32" and rel.lower().endswith(".dll") and pe_machine(src) == 0x8664}
|
||||
if system_folder(rel) == "system32" and rel.lower().endswith(".dll") and plain_x64(src)}
|
||||
try:
|
||||
present = list(os.scandir(system32))
|
||||
except OSError:
|
||||
present = []
|
||||
names.update(entry.name for entry in present if entry.name.lower().endswith(".dll") and not entry.is_symlink()
|
||||
and pe_machine(entry.path) == 0x8664)
|
||||
and ("drive_c/windows/system32/" + entry.name).lower() not in removed and plain_x64(entry.path))
|
||||
names.update(Path(rel).name for rel in removed.values()
|
||||
if rel.lower().endswith(".dll") and (compat / BACKUP / rel).is_file() and plain_x64(compat / BACKUP / rel))
|
||||
if not names:
|
||||
return frozenset()
|
||||
return PE["x64_guests"](Path(proton).parent / "files/lib/wine" / machines["system32"][0], names)
|
||||
@@ -581,7 +589,7 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
|
||||
inferred.add(cid)
|
||||
kept_overrides, kept_requires = {}, {}
|
||||
planned = [entry for cid in expand(store, ids, saved_requires) for entry in (component(store, cid) or ([], [], [], []))[1]]
|
||||
guests = component_guests(pfx, proton, machines, planned)
|
||||
guests = component_guests(compat, proton, machines, planned, state["files"])
|
||||
for cid in expand(store, ids, saved_requires):
|
||||
found = component(store, cid)
|
||||
if found is None:
|
||||
|
||||
@@ -2964,6 +2964,17 @@ class ForeignSystemDllTest(unittest.TestCase):
|
||||
self.assertEqual(["system32/d3dcompiler_43.dll (machine 0x8664)"], self.run_repair(compat, proton))
|
||||
self.assertEqual(0xAA64, MODULE["pe_machine"](windows / "system32/d3dcompiler_43.dll"))
|
||||
|
||||
def test_arm64ec_importer_does_not_let_an_x64_dependency_stay(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
proton, compat, windows = self.prefix(tmp)
|
||||
builtins = proton.parent / "files/lib/wine/aarch64-windows"
|
||||
builtins.joinpath("d3dcompiler_43.dll").write_bytes(pe_image(0xAA64))
|
||||
builtins.joinpath("d3dx9_43.dll").write_bytes(pe_image_importing(0xAA64, ("d3dcompiler_43.dll",)))
|
||||
(windows / "system32/d3dx9_43.dll").write_bytes(arm64ec_pe_image())
|
||||
(windows / "system32/d3dcompiler_43.dll").write_bytes(pe_image(0x8664))
|
||||
self.assertEqual(["system32/d3dcompiler_43.dll (machine 0x8664)"], self.run_repair(compat, proton))
|
||||
self.assertFalse((windows / "system32/d3dx9_43.dll").is_symlink())
|
||||
|
||||
def test_x64_proton_prefix_ignores_builtin_imports(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
proton, compat, windows = self.prefix(tmp, arm=False)
|
||||
|
||||
@@ -124,6 +124,29 @@ class WinComponentsTest(unittest.TestCase):
|
||||
names, _ = self.apply(proton)
|
||||
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dcompiler_43.dll"), 0x8664)
|
||||
|
||||
def test_deselected_x64_d3dx9_no_longer_keeps_its_compiler(self):
|
||||
proton = self.proton()
|
||||
self.component("d3dx9", ["d3dx9_43"], {"system32/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.pick("d3dcompiler")
|
||||
self.apply(proton)
|
||||
self.assertFalse((self.pfx / "system32/d3dx9_43.dll").exists())
|
||||
self.assertNotEqual(MODULE["pe_machine"](self.pfx / "system32/d3dcompiler_43.dll"), 0x8664)
|
||||
|
||||
def test_deselected_component_restores_the_saved_x64_dll(self):
|
||||
proton = self.proton()
|
||||
self.pfx.joinpath("system32").mkdir(parents=True)
|
||||
self.pfx.joinpath("system32/d3dx9_43.dll").write_bytes(self.pe_image(0x8664))
|
||||
self.component("d3dx9", ["d3dx9_43"], {"system32/d3dx9_43.dll": pe_image_importing(0xAA64)})
|
||||
self.pick("d3dx9")
|
||||
self.apply(proton)
|
||||
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dx9_43.dll"), 0xAA64)
|
||||
self.pick()
|
||||
self.apply(proton)
|
||||
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dx9_43.dll"), 0x8664)
|
||||
|
||||
def test_x64_compiler_alone_is_skipped_while_the_builtin_d3dx9_imports_it(self):
|
||||
proton = self.proton()
|
||||
self.component("d3dcompiler", ["d3dcompiler_43"], {
|
||||
|
||||
Reference in new issue
Block a user