mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
fix(components): a native-only override falls back to builtin when the prefix has no native DLL (#2142)
* fix(components): a native-only override falls back to builtin when the prefix has no native DLL A component that asks for a DLL native-only (for example .NET 4.8's mscoree=n) left the DLL unloadable when its native copy never reached the prefix. On ARM64 prefixes the .NET installer leaves Wine's builtin mscoree in system32, so every program that needs .NET exited at launch with 'mscoree.dll not found'. At launch, an override of n for a DLL whose system32 or syswow64 copy is missing or is Wine's own (a link into the Proton build, or a builtin or placeholder stub) becomes n,b, and the session log says so. A real native copy is still loaded first, and the saved component state is unchanged, so the override returns to n once the native DLL is there. * Treat any prefix symlink as builtin when checking native overrides * Treat an unreadable prefix DLL as missing for native overrides
This commit is contained in:
1 parent
5624b483fb
commit
8ac5652131
2 files changed
+75
-1
No files matched your search
@@ -600,6 +600,8 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
|
||||
written, registry_notes = apply_registry(pfx, values, new_state, held)
|
||||
notes += registry_notes
|
||||
save_state(compat, new_state)
|
||||
overrides, fallback = reachable_overrides(pfx, overrides)
|
||||
notes += fallback
|
||||
if copied or removed or restored or written:
|
||||
note = "components %s: %d file(s) placed, %d removed" % (",".join(ids) or "none", copied, removed)
|
||||
note += ", %d put back as they were" % restored if restored else ""
|
||||
@@ -607,6 +609,26 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
|
||||
return overrides, notes
|
||||
|
||||
|
||||
def native_dll(pfx, name):
|
||||
for arch in ARCH_DIRS:
|
||||
path = existing(pfx / "drive_c/windows" / arch / (name + ".dll"))
|
||||
if path is None or builtin(path) or not os.access(path, os.R_OK):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def reachable_overrides(pfx, names):
|
||||
kept, notes = [], []
|
||||
for entry in names:
|
||||
name, sep, mode = entry.partition("=")
|
||||
name = name.strip().lower()
|
||||
if sep and mode.strip().lower() == "n" and not native_dll(pfx, name):
|
||||
entry = name + "=n,b"
|
||||
notes.append("%s=n has no native DLL in the prefix; using n,b" % name)
|
||||
kept.append(entry)
|
||||
return kept, notes
|
||||
|
||||
|
||||
def overrides_value(names):
|
||||
modes = {}
|
||||
for entry in names:
|
||||
|
||||
@@ -25,6 +25,7 @@ class WinComponentsTest(unittest.TestCase):
|
||||
|
||||
def component(self, cid, overrides, files):
|
||||
folder = self.store / cid
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
for rel, data in files.items():
|
||||
path = folder / rel
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
@@ -248,7 +249,7 @@ class WinComponentsTest(unittest.TestCase):
|
||||
self.component("xaudio2.7", ["xaudio2_7"], {"system32/xaudio2_7.dll": b"xa"})
|
||||
self.pick("directmusic", "xaudio2.7")
|
||||
names, _ = self.apply()
|
||||
self.assertEqual(MODULE["overrides_value"](names), "dmband=n,b;dsound=n;xaudio2_7=n,b")
|
||||
self.assertEqual(MODULE["overrides_value"](names), "dmband=n,b;dsound=n,b;xaudio2_7=n,b")
|
||||
self.assertEqual((self.pfx / "syswow64/dmband.dll").read_bytes(), b"band")
|
||||
self.assertEqual(json.loads((self.compat / ".droiddeck-wincomponents.json").read_text())["components"],
|
||||
["dmband", "dsound", "directmusic", "xaudio2.7"])
|
||||
@@ -263,6 +264,57 @@ class WinComponentsTest(unittest.TestCase):
|
||||
self.assertEqual(MODULE["overrides_value"](["a", "b=n", "a=b", "bad;name", "c=x"]), "b=n;a=b")
|
||||
|
||||
|
||||
def prefix_dll(self, arch, name, data=None, link=None):
|
||||
path = self.pfx / arch / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
if link is not None:
|
||||
link.parent.mkdir(parents=True, exist_ok=True)
|
||||
link.write_bytes(b"MZ" + b"\0" * 126)
|
||||
path.symlink_to(link)
|
||||
else:
|
||||
path.write_bytes(data)
|
||||
|
||||
def test_a_native_only_override_without_a_native_dll_falls_back_to_builtin(self):
|
||||
self.component("dotnet48", ["mscoree=n"], {"drive_c/windows/Microsoft.NET/Framework64/clr.dll": b"clr"})
|
||||
dist = Path(self.tmp.name) / "proton/lib/wine"
|
||||
self.prefix_dll("system32", "mscoree.dll", link=dist / "aarch64-windows/mscoree.dll")
|
||||
self.prefix_dll("syswow64", "mscoree.dll", link=dist / "i386-windows/mscoree.dll")
|
||||
self.pick("dotnet48")
|
||||
names, notes = self.apply()
|
||||
self.assertEqual(MODULE["overrides_value"](names), "mscoree=n,b")
|
||||
self.assertIn("mscoree=n has no native DLL in the prefix; using n,b", notes)
|
||||
|
||||
def test_a_wine_placeholder_file_is_not_a_native_dll(self):
|
||||
self.component("dotnet48", ["mscoree=n"], {})
|
||||
for arch in ("system32", "syswow64"):
|
||||
self.prefix_dll(arch, "MSCOREE.DLL", b"MZ" + b"\0" * 62 + b"Wine placeholder DLL")
|
||||
self.pick("dotnet48")
|
||||
names, _ = self.apply()
|
||||
self.assertEqual(MODULE["overrides_value"](names), "mscoree=n,b")
|
||||
|
||||
def test_a_native_only_override_stays_native_when_the_native_dll_is_there(self):
|
||||
self.component("dotnet48", ["mscoree=n"], {})
|
||||
for arch in ("system32", "syswow64"):
|
||||
self.prefix_dll(arch, "mscoree.dll", b"MZ" + b"\0" * 62 + b"Microsoft .NET runtime")
|
||||
self.pick("dotnet48")
|
||||
names, notes = self.apply()
|
||||
self.assertEqual(MODULE["overrides_value"](names), "mscoree=n")
|
||||
self.assertFalse([n for n in notes if "has no native DLL" in n])
|
||||
|
||||
def test_a_native_only_override_with_one_architecture_missing_keeps_the_other_native(self):
|
||||
self.component("physx", ["physxloader=n"], {"system32/PhysXLoader.dll": b"MZ native64"})
|
||||
self.pick("physx")
|
||||
names, _ = self.apply()
|
||||
self.assertEqual(MODULE["overrides_value"](names), "physxloader=n,b")
|
||||
|
||||
def test_other_override_modes_are_left_alone(self):
|
||||
self.component("mix", ["openal32", "xinput1_3=b", "d3dx9_43=n,b"], {})
|
||||
self.pick("mix")
|
||||
names, notes = self.apply()
|
||||
self.assertEqual(MODULE["overrides_value"](names), "openal32=n,b;xinput1_3=b;d3dx9_43=n,b")
|
||||
self.assertFalse([n for n in notes if "has no native DLL" in n])
|
||||
|
||||
|
||||
class PendingWaitTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
|
||||
Reference in new issue
Block a user