Compare commits

..
Author SHA1 Message Date
The412Banner 66b1b3c017 fix(game-env): give ARM64EC games the hybrid Visual C++ runtime in ARM64 prefixes
A plain x64 Visual C++ runtime DLL in an ARM64 prefix's system32 is now
foreign when one of the game's own ARM64EC images imports it, so the
prefix repair and the component filter keep Proton's ARM64EC-capable
builtin there, as Windows on Arm does. x64 games, other x64 DLLs and
launches without a game folder keep the x64 copies.
2026-11-29 17:36:34 +00:00
6 changed files with 159 additions and 118 deletions

No files matched your search

+33 -108
View File
@@ -148,7 +148,6 @@ struct slot {
uint32_t fmt;
int release_fd;
int busy;
uint64_t generation;
};
struct layer {
@@ -176,7 +175,6 @@ struct layer {
int votes_rate;
float fps_applied;
int recreate_pending;
int pending_callbacks;
int32_t ds_applied;
@@ -224,7 +222,6 @@ struct complete_ctx {
ASurfaceControl *sc;
int layer;
int prev_slot;
uint64_t prev_generation;
void *prev_token;
int retire;
};
@@ -291,16 +288,12 @@ static void on_complete(void *context, ASurfaceTransactionStats *stats) {
pthread_mutex_lock(&g_lock);
if (ctx->layer >= 0 && ctx->layer < SC_LAYER_COUNT && ctx->prev_slot >= 0 && ctx->prev_slot < POOL_MAX) {
struct slot *s = &g_layers[ctx->layer].slots[ctx->prev_slot];
if (s->generation == ctx->prev_generation) {
int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1;
if (s->release_fd >= 0) close(s->release_fd);
s->release_fd = fd;
s->busy = 0;
}
int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1;
if (s->release_fd >= 0) close(s->release_fd);
s->release_fd = fd;
s->busy = 0;
}
if (g_pending_cb > 0) g_pending_cb--;
if (ctx->layer >= 0 && ctx->layer < SC_LAYER_COUNT && g_layers[ctx->layer].pending_callbacks > 0)
g_layers[ctx->layer].pending_callbacks--;
pthread_mutex_unlock(&g_lock);
if (ctx->prev_token) {
int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1;
@@ -315,15 +308,9 @@ static int add_complete_on(ASurfaceTransaction *tx, struct layer *l, ASurfaceCon
struct complete_ctx *ctx = calloc(1, sizeof(*ctx));
if (!ctx) return -1;
ctx->sc = sc; ctx->layer = (int)(l - g_layers); ctx->prev_slot = prev_slot;
if (prev_slot >= 0 && prev_slot < POOL_MAX) {
pthread_mutex_lock(&g_lock);
ctx->prev_generation = l->slots[prev_slot].generation;
pthread_mutex_unlock(&g_lock);
}
ctx->prev_token = prev_token; ctx->retire = retire;
pthread_mutex_lock(&g_lock);
g_pending_cb++;
l->pending_callbacks++;
pthread_mutex_unlock(&g_lock);
api.setOnComplete(tx, ctx, on_complete);
return 0;
@@ -410,16 +397,12 @@ static void retire_sc(struct layer *l) {
ASurfaceTransaction *tx = api.txCreate();
if (tx) {
retire_ops(tx, l->sc);
if (add_complete(tx, l, l->cur_slot, l->cur_token, 1) != 0) {
api.txDelete(tx);
droiddeck_log("layer", "%s: retirement deferred because its release callback could not be allocated", l->name);
return;
}
if (add_complete(tx, l, l->cur_slot, l->cur_token, 1) != 0) api.release(l->sc);
api.txApply(tx);
api.txDelete(tx);
} else {
droiddeck_log("layer", "%s: retirement deferred because a transaction could not be allocated", l->name);
return;
if (l->cur_token) ahb_swapchain_layer_released(l->cur_token, -1);
api.release(l->sc);
}
droiddeck_log("layer", "%s: SurfaceControl retired (window %p)", l->name, (void *)l->win);
l->sc = NULL; l->win = NULL;
@@ -438,28 +421,20 @@ static void drain_and_free_pools(void) {
if (!pending || now_ns() > deadline) break;
usleep(2000);
}
pthread_mutex_lock(&g_lock);
for (int i = 0; i < SC_LAYER_COUNT; i++) {
struct layer *l = &g_layers[i];
pthread_mutex_lock(&g_lock);
const int pending = l->pending_callbacks;
if (pending || l->sc) {
pthread_mutex_unlock(&g_lock);
droiddeck_log("layer", "pool drain deferred for %s (%s)", l->name,
pending ? "SurfaceControl callbacks are pending" : "SurfaceControl retirement is deferred");
continue;
}
for (int j = 0; j < POOL_MAX; j++) {
struct slot *s = &l->slots[j];
struct slot *s = &g_layers[i].slots[j];
if (s->release_fd >= 0) { struct pollfd p = {.fd = s->release_fd, .events = POLLIN}; poll(&p, 1, 100); close(s->release_fd); }
if (s->img) vkp_image_destroy(s->img);
if (s->ahb) AHardwareBuffer_release(s->ahb);
memset(s, 0, sizeof(*s));
s->release_fd = -1;
}
l->first_logged = 0;
l->logged_w = l->logged_h = 0;
pthread_mutex_unlock(&g_lock);
g_layers[i].first_logged = 0;
g_layers[i].logged_w = g_layers[i].logged_h = 0;
}
pthread_mutex_unlock(&g_lock);
}
static int sniff_modifier(const struct droiddeck_native_handle *h, uint64_t *mod) {
@@ -637,10 +612,7 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait
if (pending < 0) pending = i;
}
if (idx < 0) idx = pending;
if (idx >= 0) {
fd = l->slots[idx].release_fd; l->slots[idx].release_fd = -1;
l->slots[idx].generation++;
}
if (idx >= 0) { fd = l->slots[idx].release_fd; l->slots[idx].release_fd = -1; }
pthread_mutex_unlock(&g_lock);
if (idx < 0) return -1;
if (fd >= 0 && fence_signalled(fd)) { close(fd); fd = -1; }
@@ -648,8 +620,7 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait
if (s->ahb && (s->w != w || s->h != h || s->fmt != fmt)) {
if (fd >= 0) { close(fd); fd = -1; }
vkp_image_destroy(s->img); AHardwareBuffer_release(s->ahb);
const uint64_t generation = s->generation;
memset(s, 0, sizeof(*s)); s->release_fd = -1; s->generation = generation;
memset(s, 0, sizeof(*s)); s->release_fd = -1;
}
if (fd >= 0 && !vkp_can_wait_sync_fd()) {
if (fence_wait(fd, 100) == 0) { slot_keep_fence(s, fd); return -1; }
@@ -688,13 +659,7 @@ static int ensure_sc(struct layer *l) {
if (load_api() != 0) return -1;
ANativeWindow *win = vkp_window();
if (!win) return -1;
if (l->sc && l->win != win) {
retire_sc(l);
if (l->sc) {
droiddeck_log("layer", "%s: keeping the old SurfaceControl until retirement completes", l->name);
return -1;
}
}
if (l->sc && l->win != win) retire_sc(l);
if (!l->sc) {
l->sc = api.createFromWindow(win, l->name);
if (!l->sc) { droiddeck_log("error", "layer: ASurfaceControl_createFromWindow(%s) failed", l->name); return -1; }
@@ -853,7 +818,6 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) {
if (!win || win != l->win) return NULL;
ASurfaceControl *fresh = api.createFromWindow(win, l->name);
if (!fresh) {
l->recreate_pending = 1;
droiddeck_log("error", "layer: %s: composition recovery could not create a new SurfaceControl", l->name);
return NULL;
}
@@ -868,45 +832,24 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) {
return old;
}
static void rollback_swap_sc(struct layer *l, ASurfaceControl *old, int was_shown,
int32_t ds_applied, uint32_t md_applied, float hr_applied) {
if (!old) return;
ASurfaceControl *fresh = l->sc;
l->sc = old;
l->shown = was_shown;
l->recreate_pending = 1;
l->geo_valid = 0;
l->fps_applied = -1.0f;
l->ds_applied = ds_applied; l->md_applied = md_applied; l->hr_applied = hr_applied;
if (fresh) api.release(fresh);
}
static int present_slot(struct layer *l, int idx, const int r[8], const struct droiddeck_color *color,
int translucent) {
struct slot *s = &l->slots[idx];
ASurfaceTransaction *tx = api.txCreate();
if (!tx) return -1;
const int was_shown = l->shown;
const int32_t ds_applied = l->ds_applied;
const uint32_t md_applied = l->md_applied;
const float hr_applied = l->hr_applied;
ASurfaceControl *old = swap_sc_begin(l);
if (old) api.setZOrder(tx, l->sc, l->z);
api.setBuffer(tx, l->sc, s->ahb, -1);
if (api.setEnableBackPressure) api.setEnableBackPressure(tx, l->sc, true);
api.setBufferTransparency(tx, l->sc,
translucent ? ASC_TRANSPARENCY_TRANSLUCENT : ASC_TRANSPARENCY_OPAQUE);
if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW);
if (old) retire_ops(tx, old);
if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token, old ? 1 : 0) != 0) {
api.txDelete(tx);
rollback_swap_sc(l, old, was_shown, ds_applied, md_applied, hr_applied);
droiddeck_log("layer", "%s: frame transition skipped because its release callback could not be allocated", l->name);
return -1;
}
apply_geometry(tx, l, r);
apply_frame_rate(tx, l);
apply_colour(tx, l, color);
if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW);
if (old) retire_ops(tx, old);
if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token, old ? 1 : 0) != 0 && old)
api.release(old);
pthread_mutex_lock(&g_lock);
s->busy = 1;
pthread_mutex_unlock(&g_lock);
@@ -961,27 +904,23 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi
}
ASurfaceTransaction *tx = api.txCreate();
if (!tx) goto unavailable;
const int was_shown = l->shown;
const int32_t ds_applied = l->ds_applied;
const uint32_t md_applied = l->md_applied;
const float hr_applied = l->hr_applied;
ASurfaceControl *old = swap_sc_begin(l);
if (old) api.setZOrder(tx, l->sc, l->z);
api.setBuffer(tx, l->sc, ahb, acquire_fd);
if (api.setEnableBackPressure) api.setEnableBackPressure(tx, l->sc, true);
api.setBufferTransparency(tx, l->sc, ASC_TRANSPARENCY_OPAQUE);
apply_geometry(tx, l, r);
apply_frame_rate(tx, l);
apply_colour(tx, l, color);
if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW);
if (old) retire_ops(tx, old);
if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot,
l->cur_token == token ? NULL : l->cur_token, old ? 1 : 0) != 0) {
api.txDelete(tx);
rollback_swap_sc(l, old, was_shown, ds_applied, md_applied, hr_applied);
droiddeck_log("layer", "zero-copy: frame transition skipped because its release callback could not be allocated");
if (old) api.release(old);
l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f;
return -1;
}
apply_geometry(tx, l, r);
apply_frame_rate(tx, l);
apply_colour(tx, l, color);
apply_present_time(tx, 1);
api.txApply(tx);
api.txDelete(tx);
@@ -1228,26 +1167,15 @@ int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int transl
return 0;
}
static int hide_layer(struct layer *l) {
if (!l->sc || !l->shown || api.state != 1) return 0;
static void hide_layer(struct layer *l) {
if (!l->sc || !l->shown || api.state != 1) return;
ASurfaceTransaction *tx = api.txCreate();
if (!tx) return -1;
api.setVisibility(tx, l->sc, ASC_VISIBILITY_HIDE);
if (add_complete(tx, l, l->cur_slot, l->cur_token, 0) != 0) {
/*
* Keep the current buffer attached when its release callback cannot
* be allocated. The hide can still apply without releasing the slot.
*/
api.txApply(tx);
api.txDelete(tx);
l->shown = 0;
droiddeck_log("layer", "%s: hidden; buffer release deferred because its callback could not be allocated", l->name);
return 0;
}
if (!tx) return;
replace_with_blank(tx, l);
api.setVisibility(tx, l->sc, ASC_VISIBILITY_HIDE);
add_complete(tx, l, l->cur_slot, l->cur_token, 0);
api.txApply(tx); api.txDelete(tx);
l->shown = 0; l->cur_slot = -1; l->cur_token = NULL;
return 0;
}
void sc_layer_hide(void) {
@@ -1255,20 +1183,17 @@ void sc_layer_hide(void) {
int said = g_layers[SC_LAYER_GAME].shown || g_layers[SC_LAYER_OVERLAY].sc;
if (g_layers[SC_LAYER_OVERLAY].sc) sc_layer_hide_overlay();
if (g_layers[SC_LAYER_GAME].shown) hide_layer(&g_layers[SC_LAYER_GAME]);
if (said && !g_layers[SC_LAYER_GAME].shown && !g_layers[SC_LAYER_OVERLAY].shown)
droiddeck_log("layer", "layers hidden (scene is not a single fullscreen window)");
if (said) droiddeck_log("layer", "layers hidden (scene is not a single fullscreen window)");
}
void sc_layer_hide_overlay(void) {
layers_init();
struct layer *l = &g_layers[SC_LAYER_OVERLAY];
if (!l->sc) return;
if (l->shown && hide_layer(l) != 0) return;
if (l->shown) hide_layer(l);
retire_sc(l);
if (!l->sc) {
droiddeck_log("layer", "%s: gone (nothing is above the game any more)", l->name);
if (g_layers[SC_LAYER_GAME].sc) g_layers[SC_LAYER_GAME].recreate_pending = 1;
}
droiddeck_log("layer", "%s: gone (nothing is above the game any more)", l->name);
if (g_layers[SC_LAYER_GAME].sc) g_layers[SC_LAYER_GAME].recreate_pending = 1;
}
void sc_layer_window_gone(void) {
@@ -1099,6 +1099,7 @@ def newest_foreign_backup(backups):
def restore_compatible_system_dlls(prefix, proton, env=None):
restored = []
game = (env or {}).get("STEAM_COMPAT_INSTALL_PATH")
for folder, name, path, source, machines, builtins, backups in prefix_system_dlls(prefix, proton, env):
if not path.is_symlink() or not path.is_file():
continue
@@ -1111,7 +1112,7 @@ def restore_compatible_system_dlls(prefix, proton, env=None):
if backup is None or backup.is_symlink() or not backup.is_file():
continue
machine = pe_machine(backup)
if machine is None or not PE["machine_compatible"](backup, machines, machine, builtins, name):
if machine is None or not PE["machine_compatible"](backup, machines, machine, builtins, name, game):
continue
try:
os.replace(backup, path)
@@ -1123,11 +1124,12 @@ def restore_compatible_system_dlls(prefix, proton, env=None):
def repair_foreign_system_dlls(prefix, proton, env=None):
repaired = []
game = (env or {}).get("STEAM_COMPAT_INSTALL_PATH")
for folder, name, path, source, machines, builtins, backups in prefix_system_dlls(prefix, proton, env):
if path.is_symlink() or not path.is_file():
continue
machine = pe_machine(path)
if machine is None or PE["machine_compatible"](path, machines, machine, builtins):
if machine is None or PE["machine_compatible"](path, machines, machine, builtins, game=game):
continue
link = path.parent / (name + ".dd-new")
backup = path.parent / (name + FOREIGN_SUFFIX)
@@ -479,7 +479,7 @@ def save_state(compat, state):
os.replace(temp, compat / STATE)
def foreign_component(rel, path, machines, dist=None):
def foreign_component(rel, path, machines, dist=None, game=None):
parts = Path(rel).parts
folder = parts[2] if len(parts) > 2 and parts[:2] == ("drive_c", "windows") else None
if not machines or folder not in PE_MACHINES or not rel.lower().endswith(".dll"):
@@ -487,7 +487,7 @@ def foreign_component(rel, path, machines, dist=None):
machine = pe_machine(path)
libdir, compatible = machines[folder]
builtins = dist / libdir if dist else None
return machine is not None and not machine_compatible(path, compatible, machine, builtins)
return machine is not None and not machine_compatible(path, compatible, machine, builtins, game=game)
def pending_for(app_id, pending=PENDING):
@@ -549,6 +549,7 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
placed_stems = set()
machines = PE["proton_pe_machines"](proton, env) if proton else None
dist = Path(proton).parent / "files/lib/wine" if proton else None
game = (env or {}).get("STEAM_COMPAT_INSTALL_PATH")
saved_overrides = state.get("overrides") if isinstance(state.get("overrides"), dict) else {}
saved_requires = state.get("requires") if isinstance(state.get("requires"), dict) else {}
recorded = [c for c in state.get("components", []) if isinstance(c, str) and valid_id(c)]
@@ -588,7 +589,7 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
kept_requires[cid] = list(requires)
values += [(cid, value) for value in registry]
for rel, src in files:
foreign = foreign_component(rel, src, machines, dist)
foreign = foreign_component(rel, src, machines, dist, game)
if foreign:
skipped.add(Path(rel).stem.lower())
changed = False
@@ -609,7 +610,7 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
path = existing(pfx / rel)
saved = compat / BACKUP / rel
if saved.is_file():
if foreign_component(rel, saved, machines, dist):
if foreign_component(rel, saved, machines, dist, game):
if path is not None and not path.is_symlink():
path.unlink()
continue
@@ -1,8 +1,12 @@
#!/usr/bin/python3
import mmap
import os
import re
from pathlib import Path
VC_RUNTIME = re.compile(r"(msvc[pr]\d.*|vcruntime\d.*|vcomp\d*|vcamp\d.*|vccorlib\d.*|concrt\d.*|mfcm?\d.*)\.dll",
re.IGNORECASE)
PE_MACHINES = {
"system32": ("aarch64-windows", frozenset((0xAA64, 0xA641))),
"syswow64": ("i386-windows", frozenset((0x14C,))),
@@ -79,8 +83,8 @@ def pe_has_arm64ec_metadata(path):
def pe_imports(path):
try:
with open(path, "rb") as source:
image = source.read()
except OSError:
image = mmap.mmap(source.fileno(), 0, access=mmap.ACCESS_READ)
except (OSError, ValueError):
return None
try:
if image[:2] != b"MZ":
@@ -137,9 +141,13 @@ def pe_imports(path):
return names
except (IndexError, ValueError):
return None
finally:
image.close()
PROGRAM_IMPORTS = {}
GAME_IMPORTS = {}
GAME_DEPTH = 4
def program_imports(builtins):
@@ -166,13 +174,33 @@ def program_imports(builtins):
return PROGRAM_IMPORTS[key]
def machine_compatible(path, machines, machine=None, builtins=None, name=None):
def game_arm64ec_imports(folder):
key = str(folder)
if key not in GAME_IMPORTS:
names = 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:
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)
return GAME_IMPORTS[key]
def machine_compatible(path, machines, machine=None, builtins=None, name=None, game=None):
machine = pe_machine(path) if machine is None else machine
if machine == 0x8664 and 0xA641 in machines:
if pe_has_arm64ec_metadata(path):
return True
imported = program_imports(builtins) if builtins is not None else None
return imported is not None and (name or Path(path).name).lower() not in imported
name = (name or Path(path).name).lower()
if game and VC_RUNTIME.fullmatch(name) and name in game_arm64ec_imports(game):
return False
return imported is not None and name not in imported
if machine == 0x8664 and pe_has_arm64ec_metadata(path):
return False
return machine in machines
+67
View File
@@ -3499,6 +3499,16 @@ def program_image(machine, imports):
return bytes(image)
def arm64ec_program_image(imports):
image = bytearray(program_image(0x8664, imports))
directory = 68 + 20 + 112 + 10 * 8
image[directory:directory + 4] = (0x1100).to_bytes(4, "little")
image[directory + 4:directory + 8] = (0xD0).to_bytes(4, "little")
image[0x300:0x304] = (0xD0).to_bytes(4, "little")
image[0x3C8:0x3D0] = (0x10000000).to_bytes(8, "little")
return bytes(image)
def bytes_path(folder, data):
path = folder / "image.exe"
path.write_bytes(data)
@@ -3573,6 +3583,63 @@ class ForeignSystemDllTest(unittest.TestCase):
self.assertFalse((windows / "system32" / name).is_symlink())
self.assertEqual(0x8664, MODULE["pe_machine"](windows / "system32" / name))
def arm64ec_game(self, tmp, shipping):
game = Path(tmp) / "common/Game"
binaries = game / "Game/Binaries/Win64"
binaries.mkdir(parents=True)
(game / "Game.exe").write_bytes(program_image(0x8664, ["kernel32.dll"]))
(binaries / "Game-Win64-Shipping.exe").write_bytes(shipping)
(binaries / "plugin.dll").write_bytes(program_image(0x8664, ["concrt140.dll"]))
return {"STEAM_COMPAT_INSTALL_PATH": str(game)}
def visual_cpp_prefix(self, tmp):
proton, compat, windows = self.prefix(tmp)
builtins = proton.parent / "files/lib/wine/aarch64-windows"
for name in ("vcruntime140.dll", "msvcp140.dll", "concrt140.dll", "vulkan-1.dll"):
(builtins / name).write_bytes(program_image(0xAA64, []))
(windows / "system32" / name.upper()).write_bytes(pe_image(0x8664))
return proton, compat, windows
def test_x64_runtime_an_arm64ec_game_image_imports_is_replaced_by_the_builtin(self):
with tempfile.TemporaryDirectory() as tmp:
proton, compat, windows = self.visual_cpp_prefix(tmp)
env = self.arm64ec_game(tmp, arm64ec_program_image(["VCRUNTIME140.dll", "MSVCP140.dll", "vulkan-1.dll"]))
fixed = MODULE["repair_foreign_system_dlls"](str(compat), str(proton), env)
self.assertEqual(["system32/MSVCP140.DLL (machine 0x8664)", "system32/VCRUNTIME140.DLL (machine 0x8664)"], fixed)
for name in ("CONCRT140.DLL", "VULKAN-1.DLL"):
self.assertFalse((windows / "system32" / name).is_symlink())
self.assertEqual(0x8664, MODULE["pe_machine"](windows / "system32" / name))
self.assertEqual([], MODULE["restore_compatible_system_dlls"](str(compat), str(proton), env))
self.assertEqual([], MODULE["repair_foreign_system_dlls"](str(compat), str(proton), env))
restored = MODULE["restore_compatible_system_dlls"](str(compat), str(proton))
self.assertEqual(2, len(restored))
self.assertFalse((windows / "system32/VCRUNTIME140.DLL").is_symlink())
def test_x64_runtime_stays_for_x64_games_and_launches_without_a_game_folder(self):
with tempfile.TemporaryDirectory() as tmp:
proton, compat, windows = self.visual_cpp_prefix(tmp)
env = self.arm64ec_game(tmp, program_image(0x8664, ["VCRUNTIME140.dll", "MSVCP140.dll"]))
self.assertEqual([], MODULE["repair_foreign_system_dlls"](str(compat), str(proton), env))
self.assertEqual([], MODULE["repair_foreign_system_dlls"](str(compat), str(proton), {}))
self.assertEqual([], MODULE["repair_foreign_system_dlls"](
str(compat), str(proton), {"STEAM_COMPAT_INSTALL_PATH": str(Path(tmp) / "missing")}))
for name in ("VCRUNTIME140.DLL", "MSVCP140.DLL"):
self.assertFalse((windows / "system32" / name).is_symlink())
def test_arm64ec_images_below_the_scanned_depth_are_ignored(self):
with tempfile.TemporaryDirectory() as tmp:
proton, compat, windows = self.visual_cpp_prefix(tmp)
game = Path(tmp) / "common/Deep"
deep = game.joinpath(*("d%d" % level for level in range(MODULE["PE"]["GAME_DEPTH"] + 2)))
deep.mkdir(parents=True)
(deep / "tool.exe").write_bytes(arm64ec_program_image(["VCRUNTIME140.dll"]))
env = {"STEAM_COMPAT_INSTALL_PATH": str(game)}
self.assertEqual([], MODULE["repair_foreign_system_dlls"](str(compat), str(proton), env))
(deep.parent / "tool.exe").write_bytes(arm64ec_program_image(["VCRUNTIME140.dll"]))
MODULE["PE"]["GAME_IMPORTS"].clear()
self.assertEqual(["system32/VCRUNTIME140.DLL (machine 0x8664)"],
MODULE["repair_foreign_system_dlls"](str(compat), str(proton), env))
def test_repaired_dll_proton_programs_do_not_import_gets_its_native_copy_back(self):
with tempfile.TemporaryDirectory() as tmp:
proton, compat, windows = self.prefix(tmp)
+18
View File
@@ -6,6 +6,8 @@ import unittest
from pathlib import Path
from unittest import mock
from tools.tests.test_game_environment import arm64ec_program_image
BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin"
MODULE = runpy.run_path(str(BIN / "droiddeck-wincomponents"))
GAME_ENV = runpy.run_path(str(BIN / "droiddeck-game-env"))
@@ -169,6 +171,22 @@ class WinComponentsTest(unittest.TestCase):
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/msvcp140.dll"), 0x8664)
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/vcruntime140.dll"), 0x8664)
def test_x64_runtime_an_arm64ec_game_imports_is_not_placed(self):
proton = self.proton()
game = Path(self.tmp.name) / "common/Game/Game/Binaries/Win64"
game.mkdir(parents=True)
(game / "Game-Win64-Shippingarm64ec.exe").write_bytes(arm64ec_program_image(["MSVCP140.dll", "VCRUNTIME140.dll"]))
names = ["concrt140", "msvcp140", "vcruntime140"]
self.component("vc", names, {"system32/%s.dll" % name: self.pe_image(0x8664) for name in names})
self.pick("vc")
env = {"STEAM_COMPAT_INSTALL_PATH": str(game.parents[2])}
for _ in range(2):
placed, _ = self.apply(proton, env)
self.assertEqual(placed, ["concrt140"])
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/concrt140.dll"), 0x8664)
self.assertFalse((self.pfx / "system32/msvcp140.dll").exists())
self.assertFalse((self.pfx / "system32/vcruntime140.dll").exists())
def test_deselected_component_restores_the_saved_x64_dll(self):
proton = self.proton()
self.pfx.joinpath("system32").mkdir(parents=True)