Play your Steam library's Windows games on a jailbroken PS5.
C++
Start a game even when its media upgrade fails
Leonardo Lobato1b8b125d7c6e
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cppindex 2ac4259..cf9dc6c 100644--- a/src/homebrew/runtime_host.cpp+++ b/src/homebrew/runtime_host.cpp@@ -403,10 +403,12 @@ std::string RuntimeHost::KitReplaced(const Composition& c) const {std::string RuntimeHost::ApplySteamworks(Composition& c, const rt::RuntimeInstall& record) {if (c.kit) {std::string reason;+ // Media support is an upgrade for older bottles, not a condition to play: a game that doesn't use it+ // still starts, and the next Play tries again.if (!rt::ApplyMediaRegistry((c.kit->view.root / c.kit->view.runtime.path).string(),(HostPath(record.data_root) / "library/prefixes/game").string(),config_.unix_time(), &reason))- return "The bottle's media registrations could not be updated: " + reason + ".";+ Log("media upgrade app=" + std::to_string(record.app_id) + " skipped: " + reason);}const rt::GameRecipe* recipe = nullptr;for (const auto& candidate : c.recipes)diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cppindex f0e168f..da70dfa 100644--- a/src/runtime/game_settings.cpp+++ b/src/runtime/game_settings.cpp@@ -2213,10 +2213,9 @@ bool ApplyMediaRegistry(const std::string& runtime_dir, const std::string& prefivalues.push_back({key->text(), name->text(), data->text(), name->text().empty()});}if (!native || !wow) return fail("media metadata lacks both registry views");- if (!ApplyBottleRegistryValues(values, prefix_dir, unix_time, "system.reg", reason)) return false;- // Once a prefix exists, Wine loads a builtin DLL only through its file in system32 or syswow64 (kit bottles never- // run wineboot), so a bottle made from an earlier template also needs winegstreamer.dll itself. An existing copy- // is kept: Wine loads the runtime's builtin through it.+ // The DLLs go in first, so a failure leaves the registry as it was. Once a prefix exists, Wine loads a builtin DLL+ // only through its file in system32 or syswow64 (kit bottles never run wineboot), so a bottle made from an earlier+ // template also needs winegstreamer.dll itself. An existing copy is kept: Wine loads the runtime's builtin through it.constexpr std::size_t kMaxMediaDllBytes = 64u * 1024u * 1024u;for (const auto& [arch, folder] : {std::pair{"x86_64-windows", "system32"}, std::pair{"i386-windows", "syswow64"}}) {auto bottle = ManagedDirectory::Open(std::filesystem::path(prefix_dir) / "drive_c/windows" / folder,@@ -2233,6 +2232,7 @@ bool ApplyMediaRegistry(const std::string& runtime_dir, const std::string& prefiif (!WriteAtomicAt(*bottle, "winegstreamer.dll", dll, 0644, false, false, false))return fail("cannot copy winegstreamer.dll into the bottle");}+ if (!ApplyBottleRegistryValues(values, prefix_dir, unix_time, "system.reg", reason)) return false;return true;}diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cppindex e4023e2..5c7d2e3 100644--- a/tests/game_settings_test.cpp+++ b/tests/game_settings_test.cpp@@ -861,6 +861,19 @@ int main(int argc, char** argv) {if (std::string(kind) == "old") CHECK(ReadText(bottle / "system.reg.playden-backup") == original);else CHECK(!std::filesystem::exists(bottle / "system.reg.playden-backup"));}+ // A missing kit DLL fails before the registry is touched.+ {+ const auto bare = root / "bare";+ std::filesystem::create_directory(bare);+ std::filesystem::permissions(bare, std::filesystem::perms::owner_all);+ const std::string hive = "WINE REGISTRY Version 2\n";+ std::ofstream(bare / "system.reg") << hive;+ for (const auto* folder : {"system32", "syswow64"}) std::filesystem::create_directories(bare / "drive_c/windows" / folder);+ std::filesystem::rename(media_runtime / "lib/wine/i386-windows/winegstreamer.dll", root / "held.dll");+ CHECK(!ApplyMediaRegistry(media_runtime.string(), bare.string(), 123, &reason));+ CHECK(ReadText(bare / "system.reg") == hive && !std::filesystem::exists(bare / "system.reg.playden-backup"));+ std::filesystem::rename(root / "held.dll", media_runtime / "lib/wine/i386-windows/winegstreamer.dll");+ }std::ofstream(media_manifest) << R"({"schema":"playden-media-registry/1","values":[]})";CHECK(!ApplyMediaRegistry(media_runtime.string(), (root / "old").string(), 123, &reason));CHECK(ReadText(root / "old/system.reg") == upgraded);