Play your Steam library's Windows games on a jailbroken PS5.
C++
Ship a Clair Obscur recipe with its Steam library copy (#614)
Leonardo Lobato16a5f4011e06
diff --git a/COMPATIBILITY.md b/COMPATIBILITY.mdindex 8514a1c..636685c 100644--- a/COMPATIBILITY.md+++ b/COMPATIBILITY.md@@ -1,6 +1,6 @@# Compatibility-Games tested on a PS5 on firmware 13.60, plus community test reports (linked in the notes) on other firmware. Last updated 2026-11-02.+Games tested on a PS5 on firmware 13.60, plus community test reports (linked in the notes) on other firmware. Last updated 2026-11-04.> [!NOTE]> Games were checked on runtime kit **0.10**, the first stable kit, unless the Kit column names a newer one.@@ -69,6 +69,7 @@ uses: Direct3D 8–11 goes through DXVK to Vulkan, and Direct3D 12 through vkd3d| [ChainStaff Demo](https://store.steampowered.com/app/3463500) | ✅ Works | 0.13 | — | Default settings. || [CHAOS;HEAD NOAH](https://store.steampowered.com/app/1961950) | ✅ Works | 0.13 | — | Needs its free [Costume DLC](https://store.steampowered.com/app/2103330). Playden downloads it from 0.9.0-beta.1 ([#251](https://github.com/leolobato/playden-ps5/issues/251)); the tester copied its file by hand, so the download itself is not tested with this game. Default settings, DualSense. ([#212](https://github.com/leolobato/playden-ps5/issues/212), firmware 11.60) || [CHRONO TRIGGER](https://store.steampowered.com/app/613830) | ✅ Works | 0.17 | Cocos2d · OpenGL · 32-bit | Title, menu, and Resume loads the bookmark; Crono walks. Through Zink. Also works on kit 0.13 ([#183](https://github.com/leolobato/playden-ps5/pull/183), firmware 13.00). Default settings on kit 0.17. ([#383](https://github.com/leolobato/playden-ps5/pull/383)) |+| [Clair Obscur: Expedition 33](https://store.steampowered.com/app/1903340) | ✅ Works | 0.18 | Unreal Engine 5 · D3D12 · vkd3d-proton | Default settings, DualSense. ([#311](https://github.com/leolobato/playden-ps5/issues/311), firmware 13.42) || [Clive Barker's Hellraiser: Revival Demo](https://store.steampowered.com/app/5184670) | ✅ Works | 0.14 | Unreal Engine 5 · D3D12 · vkd3d-proton | Default settings, DualSense, from Playden 0.9.0, which starts Unreal Engine 5 games with Direct3D 12. ([#173](https://github.com/leolobato/playden-ps5/issues/173)) || [Clone Drone in the Danger Zone](https://store.steampowered.com/app/597170) | ✅ Works | 0.17 | — | Default settings. ([#431](https://github.com/leolobato/playden-ps5/pull/431)) || [Core Keeper](https://store.steampowered.com/app/1621690) | ✅ Works | 0.13 | — | Default settings, DualSense. Cloud saves load. ([#236](https://github.com/leolobato/playden-ps5/issues/236), firmware 13.42) |diff --git a/docs/community-recipes.md b/docs/community-recipes.mdindex 73fe8c7..0531786 100644--- a/docs/community-recipes.md+++ b/docs/community-recipes.md@@ -69,6 +69,7 @@ Recipe fields:| `requirements` | What the runtime kit's template bottle must provide: `{"audio": "ps5"}` (Wine's PS5 audio driver) is the only one so far. On a kit without it, Playden refuses to prepare or start the game and names what is missing. || `registry` | Values the bottle gets under `HKEY_CURRENT_USER` when the game's files are prepared, as a Steam install script's would be: `{"Software\\Wine\\AppDefaults\\game.exe\\Direct3D": {"VideoMemorySize": "4096"}}`. Only some keys are allowed; see [Registry values](#registry-values). || `ini` | Values the game's own INI files get when the game's files are prepared, written only when the key is missing or empty: `{"BmGame/Config/UserEngine.ini": {"Engine.Engine": {"Language": "int"}}}`. See [INI values](#ini-values). |+| `steam_api_copies` | Shipped recipes only. Paths in the game folder that get a copy of the game's own Steam library while the emulator answers the game: `["Sandfall/Binaries/Win64/steam_api64.dll"]`. See [Steam library copies](#steam-library-copies). |Community fields:@@ -161,6 +162,27 @@ in a section, no `=`, `[` or `]` in a key, and a key does not start with `;` or`#`. A value is not empty. Each value once (letter case does not make twovalues different).+## Steam library copies++Use `steam_api_copies` only for a game that hashes its Steam library on disk and quits when the file is the emulator,+and only when the game loads the library from a different path than the one it hashes. Clair Obscur: Expedition 33+hashes `Sandfall/Binaries/Win64/steam_api64.dll` first if it exists, while Unreal loads the copy under+`Engine/Binaries/ThirdParty/Steamworks` by its full path.++Playden keeps the emulator where the game loads it. When Steam features = Offline emulation, it copies the `.orig` it+kept to each path when it prepares the game or applies its settings:++- The source is the `.orig` of the one emulated library with the same file name. If there isn't exactly one, or the+ path's folder is missing or is a link, Playden skips the copy and logs `copies_skipped=`.+- The copy is a real file, not a link, because exFAT has no links.+- With Steam features = Game's own files, Playden removes the copy.+- A game that Playden prepared with the recipe it made itself also gets the copies of a recipe that Playden ships for+ the game later.++Rules: the path is a `steam_api.dll` or `steam_api64.dll` in a folder of the game, with `/` between folders and no `.`+or `..` part. At most 4 paths, each once. A community recipe with this field is refused: it places a file that Game+settings doesn't show, and a community recipe is only offered, so the game wouldn't start until the player chose it.+## Shipped recipesA recipe Playden ships lives in `runtime/recipes/` and is used for that gamediff --git a/runtime/recipes/recipes.lst b/runtime/recipes/recipes.lstindex 33eb90f..272f92f 100644--- a/runtime/recipes/recipes.lst+++ b/runtime/recipes/recipes.lst@@ -6,3 +6,4 @@ steam-200260-arkhamcity-v1.jsonsteam-2640950-scottpilgrimex-v1.jsonsteam-4241920-braziliandrugdealer4-v1.jsonsteam-108600-projectzomboid-v1.json+steam-1903340-expedition33-v1.jsondiff --git a/runtime/recipes/steam-1903340-expedition33-v1.json b/runtime/recipes/steam-1903340-expedition33-v1.jsonnew file mode 100644index 0000000..192a9e9--- /dev/null+++ b/runtime/recipes/steam-1903340-expedition33-v1.json@@ -0,0 +1,21 @@+{+ "recipe_id": "steam-1903340-expedition33-v1",+ "recipe_version": 1,+ "app_id": 1903340,+ "name": "Clair Obscur: Expedition 33",+ "launch_entries": [+ {"id": "game", "label": "Clair Obscur: Expedition 33", "executable": "Sandfall/Binaries/Win64/SandFall-Win64-Shipping.exe"}+ ],+ "arguments": "-dx12",+ "dll_overrides": "d3d8,d3d9,d3d10core,d3d11,dxgi=n",+ "architecture": "pe64",+ "runtime": "wine-wow64",+ "prefix": "game",+ "graphics": "dxvk",+ "defaults": {+ "d3d12": "vkd3d-proton",+ "steam_features": "emulate"+ },+ "steam_api_copies": ["Sandfall/Binaries/Win64/steam_api64.dll"],+ "locked": ["steam_features"]+}diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cppindex 89f8b56..3c39647 100644--- a/src/homebrew/runtime_host.cpp+++ b/src/homebrew/runtime_host.cpp@@ -713,6 +713,8 @@ struct RuntimeHost::GameFiles {// The INI values to apply: the recipe's, or for a game still on the recipe Playden generated, those of the recipe// Playden now ships for it (they touch only the game's own files, which the generated recipe doesn't name).const std::vector<rt::IniValue>* ini = nullptr;+ // Likewise, the steam_api DLL copies to keep.+ const std::vector<std::string>* steam_api_copies = nullptr;};namespace {@@ -862,16 +864,19 @@ std::string RuntimeHost::SteamworksStep(const GameFiles& files, bool steam_accou// A game from another store keeps its folder as it shipped: no steam_appid.txt of Playden's would hide// the game's lack of one, so a later app ID in Game settings still reaches the emulator.identity.write_game_appid_file = !other_store;+ identity.steam_api_copies = *files.steam_api_copies;result = rt::EmulateSteamworks(root.string(), emulator, identity);} else {- result = rt::RestoreSteamworks(root.string());+ result = rt::RestoreSteamworks(root.string(), rt::RetiredSteamApiSha256(), *files.steam_api_copies);}if (!emulator_waits) {std::string changed;for (const auto& path : result.changed) changed += (changed.empty() ? "" : ",") + path;+ std::string skipped;+ for (const auto& path : result.skipped) skipped += (skipped.empty() ? "" : ",") + path;Log("steamworks app=" + std::to_string(record.runtime_number) + " mode=" + (emulate ? "emulate" : "game") +" found=" + std::to_string(result.found.size()) + " changed=" + (changed.empty() ? "-" : changed) +- (result.ok ? std::string() : " failed=" + result.message));+ (skipped.empty() ? std::string() : " copies_skipped=" + skipped) + (result.ok ? std::string() : " failed=" + result.message));if (!result.ok) return result.message;}// A game from before Steamworks (no steam_api DLL) checks for Steam through steam.dll instead@@ -1194,11 +1199,14 @@ std::string RuntimeHost::ApplyPreparationSteps(Composition& c, const rt::Runtimeif (RecipeFits(candidate, record) && candidate.id == record.recipe_id) files.recipe = &candidate;if (!files.recipe) return {}; // publication reports the missing recipefiles.ini = &files.recipe->ini;+ files.steam_api_copies = &files.recipe->steam_api_copies;if (rt::IsGeneratedRecipeId(files.recipe->id))for (const auto& candidate : c.recipes)if (rt::RecipeGame(candidate) == GameOf(record) && candidate.app_id == record.runtime_number &&- !rt::IsGeneratedRecipeId(candidate.id))+ !rt::IsGeneratedRecipeId(candidate.id)) {files.ini = &candidate.ini;+ files.steam_api_copies = &candidate.steam_api_copies;+ }files.saved = config_.settings_record ? config_.settings_record(GameOf(record)) : std::nullopt;const rt::SettingsPreset* preset = nullptr;if (files.saved)diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cppindex 33fb4f2..4a53cc9 100644--- a/src/runtime/game_settings.cpp+++ b/src/runtime/game_settings.cpp@@ -1443,6 +1443,24 @@ bool RecipeRegistryValueAllowed(const std::string& key, const std::string& name,}constexpr std::size_t kMaxRecipeIniValues = 16;+constexpr std::size_t kMaxRecipeSteamApiCopies = 4;++// A path in steam_api_copies (docs/community-recipes.md): a steam_api DLL inside the game folder, named with '/' and+// no "." or ".." part.+bool RecipeSteamApiCopyAllowed(const std::string& path) {+ if (path.empty() || path.size() > 200 || path.find_first_of("\\:*?\"<>|") != std::string::npos) return false;+ for (const unsigned char c : path)+ if (c < 0x20 || c > 0x7e) return false;+ std::string part;+ for (std::size_t start = 0; start <= path.size();) {+ const auto end = std::min(path.find('/', start), path.size());+ part = path.substr(start, end - start);+ if (part.empty() || part == "." || part == "..") return false;+ start = end + 1;+ }+ const auto name = LowerAscii(part);+ return path.find('/') != std::string::npos && (name == "steam_api.dll" || name == "steam_api64.dll");+}// An INI value a recipe may carry (docs/community-recipes.md): a .ini file inside the game folder,// named with '/' and no "." or ".." part, and printable ASCII that keeps each value on its own line@@ -1620,6 +1638,19 @@ bool ParseGameRecipe(std::string_view text, GameRecipe* recipe, std::string* rea}}}+ if (const auto* copies = root->get("steam_api_copies")) {+ if (!copies->array()) return fail("steam_api_copies must be a list");+ // It places a file in the game folder that the player can't see in Game settings, so only Playden's own recipes do.+ if (IsCommunityRecipeId(out.id)) return fail("a community recipe can't carry steam_api_copies");+ std::set<std::string> identities;+ for (const auto& item : *copies->array()) {+ if (!item.string() || !RecipeSteamApiCopyAllowed(*item.string()))+ return fail("steam_api_copies needs steam_api DLL paths inside the game folder");+ if (out.steam_api_copies.size() >= kMaxRecipeSteamApiCopies) return fail("steam_api_copies has too many paths");+ if (!identities.insert(LowerAscii(*item.string())).second) return fail("steam_api_copies names a path twice");+ out.steam_api_copies.push_back(*item.string());+ }+ }if (out.dll_overrides.size() && !IsProsperoDllOverrides(out.dll_overrides)) return fail("recipe dll_overrides are invalid");if (out.architecture != "pe32" && out.architecture != "pe64") return fail("architecture must be pe32 or pe64");for (const auto& [id, value] : out.defaults) {@@ -1800,6 +1831,12 @@ std::string SerializeGameRecipe(const GameRecipe& recipe) {text += "}";}if (!recipe.ini.empty()) text += ",\"ini\":" + SerializeIniValues(recipe.ini, "", "");+ if (!recipe.steam_api_copies.empty()) {+ text += ",\"steam_api_copies\":[";+ for (std::size_t index = 0; index < recipe.steam_api_copies.size(); ++index)+ text += (index ? "," : "") + quoted(recipe.steam_api_copies[index]);+ text += "]";+ }return text + "}\n";}@@ -3493,6 +3530,7 @@ bool ParseCommunityRecipe(std::string_view text, CommunityRecipe* community, std};CommunityRecipe out;if (!ParseGameRecipe(text, &out.recipe, reason)) return false;+ if (!out.recipe.steam_api_copies.empty()) return fail("a community recipe can't carry steam_api_copies");const auto root = json::parse(text);std::uint64_t appid = 0;if (!ExactUnsigned(root->get("steam_appid"), std::numeric_limits<std::uint32_t>::max(), &appid, false) ||diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.hindex 6933ed9..eef5318 100644--- a/src/runtime/game_settings.h+++ b/src/runtime/game_settings.h@@ -187,6 +187,9 @@ struct GameRecipe {// Values the game's own INI files get when its files are prepared, for a setting the game's// launcher would write before starting the game, which the console can't do (Batman: Arkham Asylum).std::vector<IniValue> ini;+ // Where the game's own steam_api DLL must also be on disk while the emulator answers it, for a game that hashes the+ // file it finds there (docs/community-recipes.md). Shipped recipes only.+ std::vector<std::string> steam_api_copies;// What the kit's template bottle must provide ("audio": "ps5"); see UnmetRecipeRequirements.std::map<std::string, std::string> requirements;};diff --git a/src/runtime/steamworks.cpp b/src/runtime/steamworks.cppindex 5f8feb3..74a7cfc 100644--- a/src/runtime/steamworks.cpp+++ b/src/runtime/steamworks.cpp@@ -190,6 +190,37 @@ std::optional<Emulator> LoadEmulator(const std::string& emulator_dir, bool pe64)return Emulator{*bytes, *digest};}+// Moves the steam_api_copies out of found, comparing as the file system may: exFAT ignores case.+void DropSteamApiCopies(const std::vector<std::string>& copies, std::vector<std::string>* found) {+ found->erase(std::remove_if(found->begin(), found->end(), [&](const std::string& relative) {+ return std::any_of(copies.begin(), copies.end(), [&](const std::string& copy) { return Lower(copy) == Lower(relative); });+ }), found->end());+}++// Whether every folder from root down to relative's parent is a real folder, not a link.+bool RealFoldersTo(const fs::path& root, const std::string& relative) {+ auto folder = root;+ const auto parent = fs::path(relative).parent_path();+ for (const auto& part : parent) {+ folder /= part;+ struct stat info {};+ if (::lstat(folder.c_str(), &info) != 0 || !S_ISDIR(info.st_mode)) return false;+ }+ return true;+}++// The .orig of the one found DLL named like relative; empty when there is not exactly one.+fs::path OriginalFor(const fs::path& root, const std::vector<std::string>& found, const std::string& relative) {+ const auto name = Lower(fs::path(relative).filename().string());+ fs::path original;+ for (const auto& candidate : found) {+ if (Lower(fs::path(candidate).filename().string()) != name) continue;+ if (!original.empty()) return {};+ original = root / (candidate + ".orig");+ }+ return original;+}+} // namespacestd::vector<std::string> RetiredSteamApiSha256() {@@ -251,6 +282,7 @@ SteamworksResult EmulateSteamworks(const std::string& install_root, const std::sSteamworksResult result;const fs::path root(install_root);result.found = FindSteamApi(install_root);+ DropSteamApiCopies(identity.steam_api_copies, &result.found);const auto fail = [&](std::string why) {result.message = std::move(why);return result;@@ -293,6 +325,20 @@ SteamworksResult EmulateSteamworks(const std::string& install_root, const std::sif (!WriteSettings(path.parent_path(), identity, original))return fail("Playden could not write the game's Steam settings.");}+ for (const auto& relative : identity.steam_api_copies) {+ const auto source = OriginalFor(root, result.found, relative);+ const auto original = !source.empty() && IsRegular(source) ? ReadFile(source, kMaxDllBytes) : std::nullopt;+ // A game whose folders changed in an update may no longer ask for this. It starts, or stops as it would have.+ if (!original || !RealFoldersTo(root, relative)) {+ result.skipped.push_back(relative);+ continue;+ }+ const auto path = root / relative;+ const auto current = IsRegular(path) ? ReadFile(path, kMaxDllBytes) : std::nullopt;+ if (current && *current == *original) continue;+ if (!WriteAtomic(path, *original)) return fail("Playden could not put a copy of the game's Steam library at " + relative + ".");+ result.changed.push_back(relative);+ }result.ok = true;return result;}@@ -376,10 +422,24 @@ SteamworksResult RemoveLegacySteam(const std::string& install_root, const std::vreturn result;}-SteamworksResult RestoreSteamworks(const std::string& install_root, const std::vector<std::string>& retired) {+SteamworksResult RestoreSteamworks(const std::string& install_root, const std::vector<std::string>& retired,+ const std::vector<std::string>& steam_api_copies) {SteamworksResult result;const fs::path root(install_root);result.found = FindSteamApi(install_root);+ DropSteamApiCopies(steam_api_copies, &result.found);+ for (const auto& relative : steam_api_copies) {+ const auto path = root / relative;+ const auto source = OriginalFor(root, result.found, relative);+ if (source.empty() || !IsRegular(source) || !IsRegular(path) || !RealFoldersTo(root, relative)) continue;+ const auto copy = ReadFile(path, kMaxDllBytes);+ if (!copy || copy != ReadFile(source, kMaxDllBytes)) continue; // not what Playden put there+ if (::unlink(path.c_str()) != 0) {+ result.message = "Playden could not remove its copy of the game's Steam library at " + relative + ".";+ return result;+ }+ result.changed.push_back(relative);+ }for (const auto& relative : result.found) {const auto path = root / relative;const auto current = ReadFile(path, kMaxDllBytes);diff --git a/src/runtime/steamworks.h b/src/runtime/steamworks.hindex 7f92faf..3032348 100644--- a/src/runtime/steamworks.h+++ b/src/runtime/steamworks.h@@ -44,13 +44,17 @@ struct SteamworksIdentity {// own steam_appid.txt or Game settings: the emulator reads steam_settings/steam_appid.txt, and a file// Playden left in the game's folder would later pass for the game's own.bool write_game_appid_file = true;+ // Relative paths that get a copy of the game's own DLL (the .orig) while the emulator stays where the game loads it+ // from, for a game that hashes the file it finds at one of these paths (GameRecipe::steam_api_copies).+ std::vector<std::string> steam_api_copies;};struct SteamworksResult {bool ok = false;std::string message; // on failure: a sentence for the playerstd::vector<std::string> changed; // DLL paths (relative) replaced or restored by this call- std::vector<std::string> found; // every steam_api DLL found (relative)+ std::vector<std::string> found; // every steam_api DLL found (relative), without steam_api_copies+ std::vector<std::string> skipped; // steam_api_copies with no folder to go in or no single original to copy};// steam_api.dll / steam_api64.dll below install_root (any case, at most 10 folders deep, no@@ -60,15 +64,17 @@ std::vector<std::string> FindSteamApi(const std::string& install_root);// Swaps every found DLL for the emulator and writes its steam_settings/. A DLL that already is// the emulator, or an earlier build of it (retired), needs its .orig, which must be the game's// own; a DLL that is neither (a newer original from an update) becomes the new .orig. No-// steam_api DLL: ok with nothing found.+// steam_api DLL: ok with nothing found. Then each of identity.steam_api_copies gets the .orig of the one found DLL with+// its file name; these paths are not swapped.SteamworksResult EmulateSteamworks(const std::string& install_root, const std::string& emulator_dir,const SteamworksIdentity& identity,const std::vector<std::string>& retired = RetiredSteamApiSha256());// Puts each .orig back over a swapped DLL (the emulator or a retired build); .orig and-// steam_settings/ stay.+// steam_settings/ stay. A file at one of steam_api_copies that holds a kept .orig is removed.SteamworksResult RestoreSteamworks(const std::string& install_root,- const std::vector<std::string>& retired = RetiredSteamApiSha256());+ const std::vector<std::string>& retired = RetiredSteamApiSha256(),+ const std::vector<std::string>& steam_api_copies = {});// Games from before Steamworks (GUN) load steam.dll from beside their program and quit with "Failed// to find Steam." without it. For a game with no steam_api DLL, puts the minimal steam.dlldiff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cppindex df59f6a..19cc3ac 100644--- a/tests/game_settings_test.cpp+++ b/tests/game_settings_test.cpp@@ -1575,6 +1575,42 @@ int main(int argc, char** argv) {CHECK(settings.values.at("steam_features").value == "emulate" && !settings.values.at("graphics").locked);CHECK(settings.launch && settings.launch->executable == "Binaries/ShippingPC-BmGame.exe" && settings.arguments.empty());}+ // Clair Obscur: Expedition 33 hashes the Steam library at its project path and loads the emulator from the Engine+ // path, so it needs both, and quits on the game's own files without a Steam client.+ {+ GameRecipe expedition;+ CHECK(ParseGameRecipe(ReadText(source / "runtime/recipes/steam-1903340-expedition33-v1.json"), &expedition, &reason));+ CHECK(expedition.app_id == 1903340 && expedition.launch_entries.size() == 1 &&+ expedition.launch_entries[0].executable == "Sandfall/Binaries/Win64/SandFall-Win64-Shipping.exe");+ CHECK(expedition.steam_api_copies == std::vector<std::string>{"Sandfall/Binaries/Win64/steam_api64.dll"});+ KitCapabilities kit;+ kit.vkd3d_proton = true;+ EffectiveSettings settings;+ SettingsError error;+ CHECK(BuildEffectiveSettings(expedition, nullptr, {}, kit, &settings, &error));+ CHECK(settings.graphics == "dxvk" && settings.arguments == "-dx12" && settings.vkd3d_proton);+ CHECK(settings.values.at("steam_features").value == "emulate" && settings.values.at("steam_features").locked);+ // The field survives a round trip, and only names a steam_api DLL inside the game's folders.+ GameRecipe again;+ CHECK(ParseGameRecipe(SerializeGameRecipe(expedition), &again, &reason) && again.steam_api_copies == expedition.steam_api_copies);+ const auto with_copies = [](const std::string& copies, const std::string& id = "steam-1903340-test-v1") {+ return R"({"recipe_id":")" + id + R"(","recipe_version":1,"app_id":1903340,"launch_entries":[{"id":"game","label":"G","executable":"g.exe"}],)"+ R"("architecture":"pe64","runtime":"wine-wow64","prefix":"game","graphics":"dxvk","steam_api_copies":)" + copies + "}";+ };+ GameRecipe parsed;+ CHECK(ParseGameRecipe(with_copies(R"(["Game/Binaries/STEAM_API64.dll"])"), &parsed, &reason));+ for (const auto* bad : {R"("Game/steam_api64.dll")", R"(["steam_api64.dll"])", R"(["Game/other.dll"])",+ R"(["../steam_api64.dll"])", R"(["Game/../steam_api64.dll"])", R"(["/Game/steam_api64.dll"])",+ R"(["Game\steam_api64.dll"])", R"([1])", R"(["A/steam_api.dll","a/STEAM_API.dll"])",+ R"(["A/steam_api.dll","B/steam_api.dll","C/steam_api.dll","D/steam_api.dll","E/steam_api.dll"])"})+ CHECK(!ParseGameRecipe(with_copies(bad), &parsed, &reason));+ // A community recipe can't place a file in the game folder.+ CHECK(!ParseGameRecipe(with_copies(R"(["Game/steam_api64.dll"])", "community-1903340-test"), &parsed, &reason));+ CommunityRecipe community;+ auto shared = with_copies(R"(["Game/steam_api64.dll"])");+ shared.replace(shared.size() - 1, 1, R"(,"steam_appid":1903340,"executable":"g.exe","community":{"format_version":1,"status":"works"}})");+ CHECK(!ParseCommunityRecipe(shared, &community, &reason) && reason.find("steam_api_copies") != std::string::npos);+ }// Batman: Arkham City is Asylum's sibling: BatmanAC.exe starts BmLauncher.exe and exits too while UserEngine.ini has// no Language.{@@ -1639,8 +1675,8 @@ int main(int argc, char** argv) {std::vector<SettingsPreset> loaded_presets;std::vector<GameRecipe> loaded_recipes;CHECK(LoadSettingsData((source / "runtime").string(), &loaded_presets, &loaded_recipes, &reason));- CHECK(loaded_presets.size() == 4 && loaded_recipes.size() == 7 && loaded_recipes.front().app_id == 220 &&- loaded_recipes.back().id == "steam-108600-projectzomboid-v1");+ CHECK(loaded_presets.size() == 4 && loaded_recipes.size() == 8 && loaded_recipes.front().app_id == 220 &&+ loaded_recipes.back().id == "steam-1903340-expedition33-v1");CHECK(!LoadSettingsData((source / "missing").string(), &loaded_presets, &loaded_recipes, &reason));// ApplyGameSettings writes the profile and a Playden dxvk.conf, removes it when nothing isdiff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cppindex 65f14d7..5ca4588 100644--- a/tests/homebrew_runtime_host_test.cpp+++ b/tests/homebrew_runtime_host_test.cpp@@ -4167,6 +4167,89 @@ void GeneratedRecipeGetsShippedIni() {host.Shutdown();}+// A copy of Clair Obscur: Expedition 33 prepared before Playden shipped its recipe keeps the recipe Playden generated,+// and still gets the shipped recipe's copy of its Steam library the next time it is played. The game's own Steam files+// take the copy away.+void GeneratedRecipeGetsShippedSteamApiCopy() {+ Fixture fixture;+ auto config = fixture.Config();+ const auto runtime = fixture.root / "runtime";+ Write(runtime / "presets.json", Read(fs::path(g_runtime_dir) / "presets.json"), 0644);+ Write(runtime / "recipes/steam-220-hl2-v1.json", Read(fs::path(g_runtime_dir) / "recipes/steam-220-hl2-v1.json"), 0644);+ Write(runtime / "recipes/recipes.lst", "steam-220-hl2-v1.json\n", 0644);+ config.runtime_dir = runtime.string();+ config.steamworks_dir = (fs::path(g_runtime_dir) / "steamworks").string();+ config.host_namespace_prefix = fixture.root;+ config.package_paths.console_data_root = "/data";+ config.package_paths.host_data_root = fixture.root / "data";+ config.package_operations.hash_file = HashArtifactFile;+ config.package_operations.hash_bytes = HashArtifactBytes;+ config.package_operations.free_space_unverifiable = true;+ config.package_operations.validate_bottle = [](const fs::path& bottle) {+ return fs::is_regular_file(bottle / "system.reg") && fs::is_regular_file(bottle / "user.reg");+ };+ const auto kit = SyntheticKit(fixture.root / "kit");+ config.admit_kit = [&kit](std::string*) { return std::optional<RuntimeKit>(kit); };+ unsigned uuids = 0;+ config.uuid = [&uuids]() -> std::optional<std::string> {+ ++uuids; return std::string("00000000-0000-4000-8000-00000000000") + std::to_string(uuids);+ };+ config.unix_time = [] { return std::int64_t{1760000000}; };+ std::map<std::string, std::string> saved_settings;+ config.settings_record = [&saved_settings](const playden::GameId&) -> std::optional<GameSettingsRecord> {+ if (saved_settings.empty()) return std::nullopt;+ GameSettingsRecord record;+ record.overrides = saved_settings;+ return record;+ };+ const auto game = fixture.root / "data/homebrew/FAKE77031/games/1903340";+ std::string pe(0x80 + 26, '\0');+ pe[0] = 'M'; pe[1] = 'Z'; pe[0x3c] = 0x40; pe[0x40] = 'P'; pe[0x41] = 'E';+ pe[0x44] = 0x64; pe[0x45] = static_cast<char>(0x86); pe[0x40 + 24] = 0x0b; pe[0x40 + 25] = 0x02;+ const std::string engine = "Engine/Binaries/ThirdParty/Steamworks/Steamv157/Win64/steam_api64.dll";+ const std::string copy = "Sandfall/Binaries/Win64/steam_api64.dll";+ const std::string own_api = pe + std::string("\0SteamUser021\0", 14);+ Write(game / "Sandfall/Binaries/Win64/SandFall-Win64-Shipping.exe", pe, 0644);+ Write(game / engine, own_api, 0644);+ CHECK(chmod(game.c_str(), 0755) == 0);+ RuntimePrepareRequest request{1903340, "/data/homebrew/FAKE77031/games/1903340", "internal", "Clair Obscur: Expedition 33"};+ request.launches = {{"", "", "Sandfall\\Binaries\\Win64\\SandFall-Win64-Shipping.exe", "", ""}};+ const auto prepared = [](const RuntimeSnapshot& s) {+ return !s.preparing_app && (s.refusals.count(1903340) || (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));+ };+ const auto emulator = Read(fs::path(g_runtime_dir) / "steamworks/steam_api64.dll");+ {+ RuntimeHost host(config);+ host.SetSteamAccount("player", 76561198000000001ull);+ CHECK(host.Start());+ CHECK(WaitFor(host, Started).kit_available);+ host.Prepare(request);+ const auto done = WaitFor(host, prepared, 60);+ if (done.refusals.count(1903340)) std::fprintf(stderr, "Prepare refused: %s\n", done.refusals.at(1903340).c_str());+ CHECK(!done.refusals.count(1903340) && done.installs.size() == 1);+ CHECK(Read(config.state_root / "installs.json").find("\"recipe_id\":\"steam-1903340-auto\"") != std::string::npos);+ CHECK(Read(game / engine) == emulator && !fs::exists(game / copy));+ host.Shutdown();+ }+ // Playden now ships the recipe: the game keeps its own, and its folder gets the copy.+ Write(runtime / "recipes/steam-1903340-expedition33-v1.json",+ Read(fs::path(g_runtime_dir) / "recipes/steam-1903340-expedition33-v1.json"), 0644);+ Write(runtime / "recipes/recipes.lst", "steam-220-hl2-v1.json\nsteam-1903340-expedition33-v1.json\n", 0644);+ RuntimeHost host(config);+ host.SetSteamAccount("player", 76561198000000001ull);+ CHECK(host.Start());+ CHECK(WaitFor(host, Started).kit_available);+ host.Play(1903340);+ WaitFor(host, [](const RuntimeSnapshot& s) { return s.plays_handled > 0; }, 30);+ CHECK(Read(config.state_root / "installs.json").find("\"recipe_id\":\"steam-1903340-auto\"") != std::string::npos);+ CHECK(Read(game / engine) == emulator && Read(game / copy) == own_api);+ saved_settings = {{"steam_features", "game"}};+ host.Play(1903340);+ WaitFor(host, [](const RuntimeSnapshot& s) { return s.plays_handled > 1; }, 30);+ CHECK(Read(game / engine) == own_api && !fs::exists(game / copy));+ host.Shutdown();+}+// A shipped recipe's requirements are checked against the kit's template, as the kit's packager// checks the kit's own recipe: without PS5 audio in the template, a recipe that needs it is refused.void ShippedRecipeRequirementsFollowTheKit(bool template_audio_ps5) {@@ -6245,6 +6328,7 @@ int main(int argc, char** argv) {ShippedRecipeWritesGameIni(false);ShippedRecipeWritesGameIni(true);GeneratedRecipeGetsShippedIni();+ GeneratedRecipeGetsShippedSteamApiCopy();RunsSetupProgramOnce();ShippedRecipeRequirementsFollowTheKit(false);ShippedRecipeRequirementsFollowTheKit(true);diff --git a/tests/runtime_steamworks_test.cpp b/tests/runtime_steamworks_test.cppindex 0774cce..a2e8f52 100644--- a/tests/runtime_steamworks_test.cpp+++ b/tests/runtime_steamworks_test.cpp@@ -235,6 +235,59 @@ int main(int argc, char** argv) {CHECK(RetiredSteamApiSha256().size() == 2);}+ { // A game that hashes its library at one path and loads it from another (Clair Obscur: Expedition 33).+ const auto game = root / "hashes-its-library";+ const std::string engine = "Engine/Binaries/ThirdParty/Steamworks/Steamv157/Win64/steam_api64.dll";+ const std::string copy = "Sandfall/Binaries/Win64/steam_api64.dll";+ const auto own = GameDll(true, "own");+ Write(game / engine, own);+ Write(game / "Sandfall/Binaries/Win64/Game.exe", "program");+ auto hashed = identity;+ hashed.steam_api_copies = {copy};+ auto swapped = EmulateSteamworks(game.string(), emulator, hashed);+ CHECK(swapped.ok && swapped.skipped.empty() && (swapped.found == std::vector<std::string>{engine}));+ CHECK((swapped.changed == std::vector<std::string>{engine, copy}));+ CHECK(Read(game / engine) == emulator64 && Read(game / (engine + ".orig")) == own && Read(game / copy) == own);+ CHECK(!fs::exists(game / "Sandfall/Binaries/Win64/steam_settings"));+ // Again: the copy isn't found as a library to swap, and nothing changes.+ swapped = EmulateSteamworks(game.string(), emulator, hashed);+ CHECK(swapped.ok && swapped.changed.empty() && swapped.found.size() == 1 && Read(game / copy) == own);+ // A game update brings a newer original: the copy follows it.+ const auto newer = GameDll(true, "newer");+ Write(game / engine, newer);+ swapped = EmulateSteamworks(game.string(), emulator, hashed);+ CHECK(swapped.ok && Read(game / engine) == emulator64 && Read(game / copy) == newer);+ // A link at the path is replaced, not followed.+ fs::remove(game / copy);+ Write(game / "elsewhere.dll", "elsewhere");+ fs::create_symlink(game / "elsewhere.dll", game / copy);+ swapped = EmulateSteamworks(game.string(), emulator, hashed);+ CHECK(swapped.ok && !fs::is_symlink(game / copy) && Read(game / copy) == newer && Read(game / "elsewhere.dll") == "elsewhere");+ // The game's own mode removes the copy and leaves a file Playden didn't put there.+ auto restored = RestoreSteamworks(game.string(), RetiredSteamApiSha256(), {copy});+ CHECK(restored.ok && (restored.changed == std::vector<std::string>{copy, engine}));+ CHECK(!fs::exists(game / copy) && Read(game / engine) == newer);+ Write(game / copy, "the player's file");+ restored = RestoreSteamworks(game.string(), RetiredSteamApiSha256(), {copy});+ CHECK(restored.ok && restored.changed.empty() && Read(game / copy) == "the player's file");+ fs::remove(game / copy);+ // Without the folder, nothing is made: the game's folders changed in an update.+ auto moved = hashed;+ moved.steam_api_copies = {"Moved/Binaries/Win64/steam_api64.dll"};+ swapped = EmulateSteamworks(game.string(), emulator, moved);+ CHECK(swapped.ok && (swapped.skipped == moved.steam_api_copies) && !fs::exists(game / "Moved"));+ // A linked folder on the way is not followed.+ fs::create_directories(game / "real-folder");+ fs::create_symlink(game / "real-folder", game / "Linked");+ moved.steam_api_copies = {"Linked/steam_api64.dll"};+ swapped = EmulateSteamworks(game.string(), emulator, moved);+ CHECK(swapped.ok && swapped.skipped.size() == 1 && !fs::exists(game / "real-folder/steam_api64.dll"));+ // Two libraries of that name: which original it wants isn't known, so nothing is copied.+ Write(game / "Other/steam_api64.dll", GameDll(true, "other"));+ swapped = EmulateSteamworks(game.string(), emulator, hashed);+ CHECK(swapped.ok && (swapped.skipped == hashed.steam_api_copies) && !fs::exists(game / copy));+ }+fs::remove_all(root);fs::remove_all(broken);std::puts("steamworks tests passed");