Play your Steam library's Windows games on a jailbroken PS5.
C++
Download MFC only for Play and work the player starts
Leonardo Lobato076352c302e8
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cppindex bb208a0..02ee03b 100644--- a/src/homebrew/controller.cpp+++ b/src/homebrew/controller.cpp@@ -1242,6 +1242,10 @@ void Controller::TickRuntime() {case LaunchState::kIdle: break;}}+ // What the latest Play went ahead without (Microsoft's MFC), unless something newer is said.+ if (const auto notice = snapshot.play_notices.find(NumberIn(snapshot, id));+ notice != snapshot.play_notices.end() && game.play_detail.empty())+ game.play_detail = notice->second;// One launch at a time: Play waits while any session is undecided.const bool busy = snapshot.launch && (snapshot.launch->state == runtime::LaunchState::kWaitingForCloud ||snapshot.launch->state == runtime::LaunchState::kReadyToHandoff ||diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cppindex a625dd7..63edba7 100644--- a/src/homebrew/ps5.cpp+++ b/src/homebrew/ps5.cpp@@ -512,10 +512,9 @@ int main() {// hand to other HTTPS addresses; the bytes are checked against their pinned SHA-256 afterwards.config.fetch_range = [client = std::make_shared<std::unique_ptr<playden::steam::HttpClient>>(),trust = paths.trust_store](const std::string& url, std::uint64_t offset,- std::uint64_t length,+ std::uint64_t length, const std::atomic<bool>& cancel,std::string* error) -> std::optional<std::string> {if (!*client) *client = std::make_unique<playden::steam::HttpClient>(trust);- static const std::atomic<bool> never{false};std::string target = url;for (int hop = 0; hop <= 5; ++hop) {playden::steam::HttpRequest request;@@ -524,7 +523,7 @@ int main() {{"Range", "bytes=" + std::to_string(offset) + "-" + std::to_string(offset + length - 1)}};request.timeout_ms = playden::steam::kMaxHttpTimeoutMs;request.max_response_bytes = static_cast<std::size_t>(length) + 1;- const auto response = (*client)->Perform(request, never);+ const auto response = (*client)->Perform(request, cancel);const long status = response.status_code;if (status == 301 || status == 302 || status == 303 || status == 307 || status == 308) {target.clear();diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cppindex ad5daee..f99d757 100644--- a/src/homebrew/runtime_host.cpp+++ b/src/homebrew/runtime_host.cpp@@ -372,6 +372,7 @@ bool RuntimeHost::Start() {void RuntimeHost::Shutdown() {pthread_t* thread = nullptr;+ cancel_downloads_ = true;{std::lock_guard<std::mutex> lock(mutex_);stopping_ = true;@@ -891,14 +892,27 @@ std::string RuntimeHost::InstallScriptsStep(const GameFiles& files) {return {};}+// Sets what MfcStep may do for the work in its scope (RedistWork), and puts the default back after it.+struct RuntimeHost::RedistWorkScope {+ RedistWork& work;+ RedistWorkScope(RedistWork& target, bool downloads, std::optional<std::uint32_t> play_app = std::nullopt)+ : work(target) {+ work = RedistWork{downloads, play_app, {}};+ }+ ~RedistWorkScope() { work = RedistWork{}; }+ RedistWorkScope(const RedistWorkScope&) = delete;+ RedistWorkScope& operator=(const RedistWorkScope&) = delete;+};+// Generic step: Microsoft's MFC for a game whose files import it (Wine has none; a Unity plugin of Moonlighter's// stops the game without it), downloaded once per console and installed into the bottle once. An upgrade, not a-// condition: a failed download or install is logged, the game still starts, and the next Play tries again.+// condition: a failed download or install is logged, the game still starts, and the next Play tries again. Only+// work the player started downloads (redist_work_); start-up and other background work install from a kept copy+// or leave it for Play.void RuntimeHost::MfcStep(const GameFiles& files) {- const auto needs = rt::FindMfcImports(files.root.string());const auto app = std::to_string(files.record.runtime_number);- if (needs.truncated) Log("mfc scan app=" + app + " stopped after " + std::to_string(needs.programs) + " programs");- if (needs.x86_program.empty() && needs.x64_program.empty()) return;+ struct stat hive {};+ if (::lstat((files.prefix + "/system.reg").c_str(), &hive) != 0) return; // the bottle comes later// Paths come from the game's files: one line each, whatever they hold.const auto field = [](std::string text) {if (text.size() > 240) text.resize(240);@@ -906,44 +920,87 @@ void RuntimeHost::MfcStep(const GameFiles& files) {if (static_cast<unsigned char>(value) < 0x20 || value == 0x7f) value = '?';return text;};- struct stat hive {};- if (::lstat((files.prefix + "/system.reg").c_str(), &hive) != 0) {- Log("mfc upgrade app=" + app + " skipped: the bottle is not made yet");- return;+ const auto redist_for = [&](const char* architecture) -> const rt::VcRedist* {+ for (const auto& candidate : config_.vc_redists)+ if (candidate.architecture == architecture) return &candidate;+ return nullptr;+ };+ // The latest scan stands while the game's files are the ones it read, or while everything it found is+ // installed; otherwise the folder is walked again.+ const auto fingerprint = rt::GameFilesFingerprint(files.root.string());+ auto scan = rt::ReadMfcScan(files.prefix);+ const auto installed = [&](const std::string& program, const char* architecture) {+ const auto* redist = redist_for(architecture);+ return program.empty() || (redist && rt::MfcInstalled(*redist, files.prefix));+ };+ const bool reuse = scan && ((!fingerprint.empty() && scan->fingerprint == fingerprint) ||+ ((!scan->x86_program.empty() || !scan->x64_program.empty()) &&+ installed(scan->x86_program, "x86") && installed(scan->x64_program, "x64")));+ if (!reuse) {+ const auto began = std::chrono::steady_clock::now();+ const auto found = rt::FindMfcImports(files.root.string());+ const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - began).count();+ Log("mfc scan app=" + app + " programs=" + std::to_string(found.programs) + " folders=" + std::to_string(found.folders) ++ " ms=" + std::to_string(ms) + (found.truncated ? " stopped early" : "") + " x86=" ++ (found.x86_program.empty() ? "-" : field(found.x86_program)) + " x64=" ++ (found.x64_program.empty() ? "-" : field(found.x64_program)));+ scan = rt::MfcScanRecord{fingerprint, found.x86_program, found.x64_program};+ if (!rt::WriteMfcScan(files.prefix, *scan)) Log("mfc scan app=" + app + " could not be kept in the bottle");}const auto cache = HostPath(config_.package_paths.console_data_root + "/playden/redist").string();- for (const auto& [architecture, program] : {std::pair<std::string, std::string>{"x86", needs.x86_program},- std::pair<std::string, std::string>{"x64", needs.x64_program}}) {+ for (const auto& [architecture, program] : {std::pair<const char*, std::string>{"x86", scan->x86_program},+ std::pair<const char*, std::string>{"x64", scan->x64_program}}) {if (program.empty()) continue;- const auto redist = std::find_if(config_.vc_redists.begin(), config_.vc_redists.end(),- [&](const rt::VcRedist& candidate) { return candidate.architecture == architecture; });+ const auto* redist = redist_for(architecture);const auto line = "mfc upgrade app=" + app + " arch=" + architecture + " program=" + field(program);- if (redist == config_.vc_redists.end()) {+ if (!redist) {Log(line + " skipped: no redistributable for it");continue;}+ if (rt::MfcInstalled(*redist, files.prefix)) continue;// A download that failed a moment ago (the same preparation, or a Play right after) isn't tried again yet;// a kept copy still installs.const auto began = std::chrono::steady_clock::now();const auto failed = redist_download_failed_.find(redist->sha256);const bool waits = failed != redist_download_failed_.end() && began - failed->second < config_.redist_retry_wait;- const auto result = rt::InstallMfcRuntime(*redist, cache, files.prefix, waits ? rt::RangeFetch{} : config_.fetch_range,- config_.unix_time());- if (result.result == "already") continue;+ const bool downloads = redist_work_.downloads && !waits && config_.fetch_range;+ bool shown = false;+ rt::RangeFetch fetch;+ if (downloads)+ fetch = [&](const std::string& url, std::uint64_t offset, std::uint64_t length, std::string* error) -> std::optional<std::string> {+ if (cancel_downloads_) {+ *error = "Playden is closing";+ return std::nullopt;+ }+ if (redist_work_.play_app && !shown) {+ shown = true;+ Publish([&](RuntimeSnapshot& s) { s.play_progress[*redist_work_.play_app] = kPlayDownloadingMfc; });+ }+ return config_.fetch_range(url, offset, length, cancel_downloads_, error);+ };+ const auto result = rt::InstallMfcRuntime(*redist, cache, files.prefix, fetch, config_.unix_time());+ if (shown) Publish([&](RuntimeSnapshot& s) { s.play_progress.erase(*redist_work_.play_app); });const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - began).count();- if (result.result != "installed") {- if (result.download_failed) redist_download_failed_[redist->sha256] = std::chrono::steady_clock::now();- if (waits && !result.download_failed)- Log(line + " skipped: its download failed " +- std::to_string(std::chrono::duration_cast<std::chrono::seconds>(began - failed->second).count()) +- " s ago; it is tried again from " + std::to_string(config_.redist_retry_wait.count()) + " s");- else- Log(line + " skipped: " + result.detail);+ if (result.result == "already") continue;+ if (result.result == "installed") {+ redist_download_failed_.erase(redist->sha256);+ Log(line + " installed files=" + std::to_string(result.files) + " from=" + result.source + " ms=" + std::to_string(ms) ++ (result.cache_problem.empty() ? std::string() : " not kept: " + result.cache_problem));continue;}- redist_download_failed_.erase(redist->sha256);- Log(line + " installed files=" + std::to_string(result.files) + " from=" + result.source + " ms=" + std::to_string(ms) +- (result.cache_problem.empty() ? std::string() : " not kept: " + result.cache_problem));+ if (result.download_failed) redist_download_failed_[redist->sha256] = std::chrono::steady_clock::now();+ const bool not_downloaded = !fetch && !waits; // no kept copy, and this work doesn't download+ if (not_downloaded)+ Log(line + " waits for Play: " + (redist_work_.downloads ? std::string("Playden can't download here")+ : std::string("start-up and background work don't download")));+ else if (waits && !result.download_failed)+ Log(line + " skipped: its download failed " ++ std::to_string(std::chrono::duration_cast<std::chrono::seconds>(began - failed->second).count()) ++ " s ago; it is tried again from " + std::to_string(config_.redist_retry_wait.count()) + " s");+ else+ Log(line + " skipped: " + result.detail);+ if (redist_work_.play_app)+ redist_work_.notice = result.download_failed || waits || not_downloaded ? kPlayMfcNotDownloaded : kPlayMfcNotInstalled;}}@@ -2149,6 +2206,8 @@ void RuntimeHost::PublishLaunch(Composition& c, const rt::LaunchSnapshot& launch}void RuntimeHost::RunPlay(Composition& c, std::uint32_t app_id) {+ // The player waits on this Play: Microsoft's MFC may be downloaded for it, with a progress line.+ RedistWorkScope redist(redist_work_, true, app_id);std::optional<rt::RuntimeInstall> record;for (const auto& candidate : c.repository.Snapshot())if (candidate.runtime_number == app_id) record = candidate;@@ -2212,6 +2271,9 @@ void RuntimeHost::RunPlay(Composition& c, std::uint32_t app_id) {++s.plays_handled;if (result.accepted) s.play_refusals.erase(app_id);else s.play_refusals[app_id] = result.message.empty() ? "The game could not start." : result.message;+ // What it went ahead without (Microsoft's MFC), until a Play gets it.+ if (result.accepted && !redist_work_.notice.empty()) s.play_notices[app_id] = redist_work_.notice;+ else if (result.accepted) s.play_notices.erase(app_id);});Log("play request app=" + std::to_string(app_id) + " accepted=" + std::to_string(result.accepted) +" session=" + result.session_id + " code=" + result.code + " message=" + result.message);@@ -3979,6 +4041,7 @@ void RuntimeHost::Run() {}for (const auto& [app, action] : maintenance) {bool ok = false;+ RedistWorkScope redist(redist_work_, true); // the player asked for itconst auto message = composition ? RunMaintenance(*composition, app, action, &ok): std::string("The runtime services are unavailable.");Log("maintenance app=" + std::to_string(app) + " action=" + std::to_string(static_cast<int>(action)) +@@ -4046,6 +4109,7 @@ void RuntimeHost::Run() {const auto current = Snapshot();refusal = current.reason.empty() ? "The runtime services are unavailable." : current.reason;} else {+ RedistWorkScope redist(redist_work_, true); // Prepare, Update and Recreate: the player asked for themrefusal = RunPrepare(*composition, request, &awaiting);// A resumed publication of a moved game may have been the last the 0.6 move waited for.FinishGamesMove(*composition);diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hppindex 631713a..9ec6204 100644--- a/src/homebrew/runtime_host.hpp+++ b/src/homebrew/runtime_host.hpp@@ -13,6 +13,7 @@#include "runtime/redist_install.h"#include <algorithm>+#include <atomic>#include <chrono>#include <condition_variable>#include "runtime/layout_migration.h"@@ -113,9 +114,12 @@ struct RuntimeHostConfig {// Named by the game, so a runtime number never reaches a store's artwork.std::function<std::optional<std::string>(const GameId& game)> title_icon;// One ranged HTTPS GET for what Playden downloads for a game's bottle: Microsoft's Visual C++ redistributable,- // for a game whose files import MFC (runtime/redist_install.h). Runs on the worker, while Play or a preparation- // waits. Empty: nothing is downloaded, and such games start without MFC.- runtime::RangeFetch fetch_range;+ // for a game whose files import MFC (runtime/redist_install.h). Runs on the worker, only for work the player+ // started (Play, Prepare, maintenance), never at start-up; it should give up soon after cancel turns true+ // (Shutdown). Empty: nothing is downloaded, and such games start without MFC.+ std::function<std::optional<std::string>(const std::string& url, std::uint64_t offset, std::uint64_t length,+ const std::atomic<bool>& cancel, std::string* error)>+ fetch_range;// The redistributables MFC comes from, by architecture; kept under <console data>/playden/redist.std::vector<runtime::VcRedist> vc_redists = runtime::MicrosoftVcRedists();// How long a failed download is not tried again (a preparation runs its steps more than once).@@ -333,6 +337,9 @@ struct RuntimeSnapshot {// What Play does before the launch is requested, per runtime number, while it runs: a game whose// folder moved in Playden 0.6 is republished first (kPlayUpdatingForLayout).std::map<std::uint32_t, std::string> play_progress;+ // What the latest Play from Playden went ahead without, per runtime number (Microsoft's MFC that could not be+ // downloaded): Play still starts the game, and the player sees why it may stop.+ std::map<std::uint32_t, std::string> play_notices;// The Steam app ID each game from another store was last prepared with, by runtime number. Steam// games are not listed: theirs is their own.std::map<std::uint32_t, SteamworksAppView> steamworks_apps;@@ -345,6 +352,9 @@ inline bool PrepareQueued(const RuntimeSnapshot& snapshot, std::uint32_t runtime}inline constexpr const char* kPlayUpdatingForLayout = "Updating this game for Playden 0.6…";+inline constexpr const char* kPlayDownloadingMfc = "Downloading Microsoft's MFC for this game…";+inline constexpr const char* kPlayMfcNotDownloaded = "Microsoft's MFC could not be downloaded. Play again to retry.";+inline constexpr const char* kPlayMfcNotInstalled = "Microsoft's MFC could not be installed for this game.";// A downloaded game to prepare. The game files stay at install_path.struct RuntimePrepareRequest {@@ -645,6 +655,18 @@ class RuntimeHost {// When each redistributable's download last failed (worker only): a preparation runs its steps more than once,// and Play shouldn't wait for a network that just failed.std::map<std::string, std::chrono::steady_clock::time_point> redist_download_failed_;+ // What the work in progress lets MfcStep do (worker only; RedistWorkScope sets it): download only for work the+ // player started, never at start-up or for other background republishing. play_app: the Play that waits, for+ // its progress line; notice: what that Play went ahead without.+ struct RedistWork {+ bool downloads = false;+ std::optional<std::uint32_t> play_app;+ std::string notice;+ };+ RedistWork redist_work_;+ struct RedistWorkScope;+ // Set by Shutdown: a download in progress gives up.+ std::atomic<bool> cancel_downloads_{false};mutable std::mutex mutex_;std::condition_variable wake_;std::condition_variable published_; // notified on every Publishdiff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cppindex d9426ac..a4c51b6 100644--- a/tests/homebrew_runtime_host_test.cpp+++ b/tests/homebrew_runtime_host_test.cpp@@ -3222,8 +3222,9 @@ std::string ImportingDll(bool pe64, const std::string& import) {}// A game whose plugin imports Microsoft's MFC gets MFC's files in its bottle from the Visual C++ redistributable.-// An upgrade, not a condition: the preparation that can't download it still ends Ready, and the next Play installs-// it (also for a game prepared before Playden knew of MFC); later Plays neither download nor install it again.+// An upgrade, not a condition: the preparation that can't download it still ends Ready. Start-up never downloads+// (settings published there leave MFC for Play); a Play that can't download it still starts the game with a notice,+// and the next Play installs it with a progress line; later Plays neither walk the folder nor download again.void PlayInstallsMfcForGameThatImportsIt() {Fixture fixture;auto config = fixture.Config();@@ -3241,7 +3242,7 @@ void PlayInstallsMfcForGameThatImportsIt() {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);+ ++uuids; return "00000000-0000-4000-8000-" + std::string(11 - std::to_string(uuids).size(), '0') + "1" + std::to_string(uuids);};config.unix_time = [] { return std::int64_t{1760000000}; };std::string session;@@ -3249,17 +3250,19 @@ void PlayInstallsMfcForGameThatImportsIt() {session = arguments.at(0).substr(8); // "session=<UUID>"return TitleResult{true, 0, "launch"};};+ GameSettingsRecord saved;+ config.settings_record = [&saved](const playden::GameId&) -> std::optional<GameSettingsRecord> { return saved; };std::vector<std::string> lines;std::mutex lines_mutex;config.log = [&](const std::string& line) {std::lock_guard<std::mutex> lock(lines_mutex);lines.push_back(line);};- const auto mfc_lines = [&] {+ const auto logged = [&](const char* prefix) {std::lock_guard<std::mutex> lock(lines_mutex);std::vector<std::string> found;for (const auto& line : lines)- if (line.rfind("mfc ", 0) == 0) found.push_back(line);+ if (line.rfind(prefix, 0) == 0) found.push_back(line);return found;};// Microsoft's bundles stand in for by synthetic ones, at their own pinned hashes.@@ -3272,9 +3275,15 @@ void PlayInstallsMfcForGameThatImportsIt() {config.redist_retry_wait = std::chrono::seconds(1);std::atomic<bool> online{false};std::atomic<int> fetches{0};- config.fetch_range = [&](const std::string& url, std::uint64_t offset, std::uint64_t length,+ std::atomic<RuntimeHost*> current_host{nullptr};+ std::atomic<bool> progress_shown{false};+ config.fetch_range = [&](const std::string& url, std::uint64_t offset, std::uint64_t length, const std::atomic<bool>&,std::string* error) -> std::optional<std::string> {++fetches;+ if (auto* host = current_host.load()) {+ const auto progress = host->Snapshot().play_progress;+ if (progress.count(220) && progress.at(220) == kPlayDownloadingMfc) progress_shown = true;+ }if (!online) {*error = "offline";return std::nullopt;@@ -3285,59 +3294,88 @@ void PlayInstallsMfcForGameThatImportsIt() {const auto game = fixture.root / "data/homebrew/FAKE77031/games/220";Write(game / "hl2.exe", "existing-game", 0644);Write(game / "bin/chroma.dll", ImportingDll(true, "MFC140U.dll"), 0644);+ const auto windows = fixture.root / "data/playden/games/steam-220/library/prefixes/game/drive_c/windows";+ {+ RuntimeHost host(config);+ CHECK(host.Start());+ CHECK(WaitFor(host, Started).kit_available);+ host.Prepare(Hl2());+ const auto done = WaitFor(host, [](const RuntimeSnapshot& s) {+ return !s.preparing_app && (s.refusals.count(220) || (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));+ }, 60);+ if (done.refusals.count(220)) std::fprintf(stderr, "Prepare refused: %s\n", done.refusals.at(220).c_str());+ CHECK(!done.refusals.count(220) && done.installs.size() == 1);+ const auto upgrades = logged("mfc upgrade ");+ CHECK(upgrades.size() == 2);+ CHECK(upgrades[0] == "mfc upgrade app=220 arch=x64 program=bin/chroma.dll skipped: the download failed at byte 0: offline");+ // Three attempts; the preparation's later pass over its steps doesn't wait for the network again.+ CHECK(upgrades[1] == "mfc upgrade app=220 arch=x64 program=bin/chroma.dll skipped: its download failed 0 s ago; "+ "it is tried again from 1 s");+ CHECK(fetches == 3);+ CHECK(logged("mfc scan app=220 programs=").size() >= 1);+ CHECK(!fs::exists(windows / "system32/mfc140u.dll"));+ host.Shutdown();+ }+ // Settings saved while Playden was closed are published at start-up, which doesn't download.+ saved.revision = 1;+ saved.overrides = {{"resolution", "1280x720"}};+ online = true;RuntimeHost host(config);+ current_host = &host;CHECK(host.Start());CHECK(WaitFor(host, Started).kit_available);- host.Prepare(Hl2());- const auto done = WaitFor(host, [](const RuntimeSnapshot& s) {- return !s.preparing_app && (s.refusals.count(220) || (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));- }, 60);- if (done.refusals.count(220)) std::fprintf(stderr, "Prepare refused: %s\n", done.refusals.at(220).c_str());- CHECK(!done.refusals.count(220) && done.installs.size() == 1);- auto logged = mfc_lines();- CHECK(logged.size() == 2);- CHECK(logged[0] == "mfc upgrade app=220 arch=x64 program=bin/chroma.dll skipped: the download failed at byte 0: offline");- // Three attempts; the preparation's later pass over its steps doesn't wait for the network again.- CHECK(logged[1] == "mfc upgrade app=220 arch=x64 program=bin/chroma.dll skipped: its download failed 0 s ago; "- "it is tried again from 1 s");+ CHECK(!logged("startup settings app=220 applied").empty());CHECK(fetches == 3);- const auto windows = fixture.root / "data/playden/games/steam-220/library/prefixes/game/drive_c/windows";- CHECK(!fs::exists(windows / "system32/mfc140u.dll"));+ CHECK(logged("mfc upgrade ").back() ==+ "mfc upgrade app=220 arch=x64 program=bin/chroma.dll waits for Play: start-up and background work don't download");+ const auto end_session = [&] {+ const auto sessions = fixture.root / "data/playden/games/steam-220/logs/sessions";+ fs::create_directories(sessions);+ CHECK(chmod((fixture.root / "data/playden/games/steam-220/logs").c_str(), 0700) == 0);+ CHECK(chmod(sessions.c_str(), 0700) == 0);+ Write(sessions / (session + ".json"),+ R"({"schema_version":1,"session_id":")" + session ++ R"(","install_id":"steam-220","title_id":"FAKE78001","origin":"playden","settings_revision":1,)"+ R"("runtime_bundle_id":"wine-wow64","phase":"exited"})" "\n", 0600);+ WaitFor(host, [](const RuntimeSnapshot& s) { return s.launch && s.launch->state == LaunchState::kExited; }, 30);+ };+ // A Play that can't download it still starts the game, and says why it may stop.+ online = false;+ host.Play(220);+ auto played = WaitFor(host, [](const RuntimeSnapshot& s) { return s.handoff_ready; }, 30);+ CHECK(played.play_notices.count(220) && played.play_notices.at(220) == kPlayMfcNotDownloaded);+ CHECK(!played.play_progress.count(220) && progress_shown);+ CHECK(host.Handoff());+ end_session();// The game updates with a 32-bit tool that needs MFC as well; the next Play installs both.Write(game / "tools/editor.dll", ImportingDll(false, "mfc140.dll"), 0644);online = true;- std::this_thread::sleep_for(std::chrono::milliseconds(1100));+ progress_shown = false;+ std::this_thread::sleep_for(std::chrono::milliseconds(1100)); // past the retry waithost.Play(220);- WaitFor(host, [](const RuntimeSnapshot& s) { return s.handoff_ready; }, 30);+ played = WaitFor(host, [](const RuntimeSnapshot& s) { return s.handoff_ready; }, 30);+ CHECK(progress_shown && !played.play_progress.count(220) && !played.play_notices.count(220));CHECK(Read(windows / "system32/mfc140u.dll") == "MFC64U" && Read(windows / "system32/mfcm140.dll") == "MFCM64");CHECK(Read(windows / "syswow64/mfc140u.dll") == "MFC32U");CHECK(!fs::exists(windows / "system32/msvcp140.dll") && !fs::exists(windows / "syswow64/msvcp140.dll"));CHECK(Read(fixture.root / "data/playden/redist/vc-14.44.35211/x64/VC_redist.x64.exe") == x64_bundle);CHECK(Read(fixture.root / "data/playden/redist/vc-14.44.35211/x86/VC_redist.x86.exe") == x86_bundle);- logged = mfc_lines();- CHECK(logged.size() >= 3);- CHECK(logged[logged.size() - 2].rfind("mfc upgrade app=220 arch=x86 program=tools/editor.dll installed files=2 from=download ms=", 0) == 0);- CHECK(logged.back().rfind("mfc upgrade app=220 arch=x64 program=bin/chroma.dll installed files=2 from=download ms=", 0) == 0);+ auto upgrades = logged("mfc upgrade ");+ CHECK(upgrades[upgrades.size() - 2].rfind("mfc upgrade app=220 arch=x86 program=tools/editor.dll installed files=2 from=download ms=", 0) == 0);+ CHECK(upgrades.back().rfind("mfc upgrade app=220 arch=x64 program=bin/chroma.dll installed files=2 from=download ms=", 0) == 0);CHECK(host.Handoff());- // The game runs and exits (the wrapper's session record).- const auto sessions = fixture.root / "data/playden/games/steam-220/logs/sessions";- fs::create_directories(sessions);- CHECK(chmod((fixture.root / "data/playden/games/steam-220/logs").c_str(), 0700) == 0);- CHECK(chmod(sessions.c_str(), 0700) == 0);- Write(sessions / (session + ".json"),- R"({"schema_version":1,"session_id":")" + session +- R"(","install_id":"steam-220","title_id":"FAKE78001","origin":"playden","settings_revision":0,)"- R"("runtime_bundle_id":"wine-wow64","phase":"exited"})" "\n", 0600);- WaitFor(host, [](const RuntimeSnapshot& s) { return s.launch && s.launch->state == LaunchState::kExited; }, 30);- // Installed once: the next Play only finds it there, without the kept download.- const auto count = logged.size();+ end_session();++ // Installed once: the next Play neither walks the game folder nor downloads, even without the kept copy.+ const auto count = logged("mfc ").size();const int fetched = fetches;fs::remove_all(fixture.root / "data/playden/redist");host.Play(220);WaitFor(host, [](const RuntimeSnapshot& s) { return s.handoff_ready; }, 30);- CHECK(mfc_lines().size() == count && fetches == fetched);+ CHECK(logged("mfc ").size() == count && fetches == fetched);CHECK(Read(windows / "system32/mfc140u.dll") == "MFC64U");+ current_host = nullptr;host.Shutdown();}