fix(game-env): replace x64 DLLs a game's ARM64 images import in ARM64 prefixes

A pure ARM64 process cannot load x64 code, so a plain x64 DLL in an
ARM64 prefix's system32 is now foreign for any name a 0xAA64 (including
ARM64X) image in the game folder imports. ARM64EC importers keep the
Visual C++ runtime-only rule. The same cached walk of the game folder
collects both sets.

The component filter now keeps tracking a saved original whose
restoration is deferred, so it is put back on a later launch.
This commit is contained in:
The412Banner committed 2026-12-03 22:55:05 +00:00
1 parent 66b1b3c017
commit fb4c99ccf0
4 files changed
+105 -10

No files matched your search

@@ -613,6 +613,7 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
if foreign_component(rel, saved, machines, dist, game):
if path is not None and not path.is_symlink():
path.unlink()
keep[rel] = cid
continue
target = path or (pfx / rel)
os.replace(saved, target)
@@ -174,20 +174,27 @@ def program_imports(builtins):
return PROGRAM_IMPORTS[key]
def game_arm64ec_imports(folder):
def game_imports(folder):
key = str(folder)
if key not in GAME_IMPORTS:
names = set()
arm64, arm64ec = set(), set()
root = os.path.realpath(folder)
for top, dirs, files in os.walk(root):
if os.path.relpath(top, root).count(os.sep) >= GAME_DEPTH:
dirs[:] = []
for entry in files:
if not entry.lower().endswith((".exe", ".dll")):
continue
path = os.path.join(top, entry)
if (entry.lower().endswith((".exe", ".dll")) and pe_machine(path) == 0x8664
and pe_has_arm64ec_metadata(path)):
names |= pe_imports(path) or set()
GAME_IMPORTS[key] = frozenset(names)
machine = pe_machine(path)
if machine == 0xAA64:
found = arm64
elif machine == 0x8664 and pe_has_arm64ec_metadata(path):
found = arm64ec
else:
continue
found |= pe_imports(path) or set()
GAME_IMPORTS[key] = (frozenset(arm64), frozenset(arm64ec))
return GAME_IMPORTS[key]
@@ -198,8 +205,10 @@ def machine_compatible(path, machines, machine=None, builtins=None, name=None, g
return True
imported = program_imports(builtins) if builtins is not None else None
name = (name or Path(path).name).lower()
if game and VC_RUNTIME.fullmatch(name) and name in game_arm64ec_imports(game):
return False
if game:
arm64, arm64ec = game_imports(game)
if name in arm64 or (name in arm64ec and VC_RUNTIME.fullmatch(name)):
return False
return imported is not None and name not in imported
if machine == 0x8664 and pe_has_arm64ec_metadata(path):
return False