Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Install Microsoft's MFC files into a game's bottle

Leonardo Lobato13425c4519f3
diff --git a/src/runtime/redist_install.cpp b/src/runtime/redist_install.cpp
index 6408ba7..ded554d 100644
--- a/src/runtime/redist_install.cpp
+++ b/src/runtime/redist_install.cpp
@@ -2,6 +2,7 @@
#include "platform/managed_directory.h"
#include "runtime/artifact_hash.h"
+#include "runtime/burn_bundle.h"
#include "runtime/game_settings.h"
#include "runtime/msi_package.h"
@@ -10,6 +11,7 @@
#include <chrono>
#include <fcntl.h>
#include <filesystem>
+#include <functional>
#include <map>
#include <set>
#include <unistd.h>
@@ -252,25 +254,38 @@ bool RecordPackage(const std::filesystem::path& prefix, const std::string& sha25
return directory && WriteFileAt(*directory, kStateFile, text);
}
-// Installs one package; returns the number of files written, or a reason in *reason.
-bool InstallPackage(const std::filesystem::path& package_path, const std::filesystem::path& prefix,
- const RedistEntry& entry, std::int64_t unix_time, std::size_t* files, std::string* reason) {
- std::string package;
- if (!ReadFile(package_path, kMaxPackageBytes, &package)) {
- *reason = "the package could not be read";
- return false;
- }
+// Reads a cabinet the package names as a file beside it into *bytes.
+using CabinetSource = std::function<bool(const std::string& name, std::string* bytes)>;
+
+// Installs one package: its files (those keep accepts, when given) and its registry and PATH values.
+// Counts the files written in *files, or gives a reason in *reason.
+bool InstallPlan(std::string_view package, const CabinetSource& beside, const std::filesystem::path& prefix,
+ const RedistEntry& entry, std::int64_t unix_time, const std::function<bool(const MsiFile&)>& keep,
+ std::size_t* files, std::string* reason) {
MsiInstallPlan plan;
if (!ReadMsiPackage(package, &plan, reason)) return false;
if (plan.unsupported_files) {
*reason = std::to_string(plan.unsupported_files) + " of the package's files are stored in a way Playden can't install";
return false;
}
+ if (keep) {
+ plan.files.erase(std::remove_if(plan.files.begin(), plan.files.end(), [&](const MsiFile& file) { return !keep(file); }),
+ plan.files.end());
+ if (plan.files.empty()) {
+ *reason = "the package has none of the files Playden takes from it";
+ return false;
+ }
+ }
std::map<std::string, std::vector<const MsiFile*>> wanted; // member → files
- for (const auto& file : plan.files) wanted[file.member].push_back(&file);
+ std::set<std::size_t> used; // cabinets holding a wanted file
+ for (const auto& file : plan.files) {
+ wanted[file.member].push_back(&file);
+ used.insert(file.cabinet);
+ }
std::set<const MsiFile*> delivered;
const auto drive = prefix / "drive_c";
for (std::size_t index = 0; index < plan.cabinets.size(); ++index) {
+ if (!used.count(index)) continue;
const auto& cabinet = plan.cabinets[index];
std::string bytes;
if (cabinet.embedded) {
@@ -281,7 +296,7 @@ bool InstallPackage(const std::filesystem::path& package_path, const std::filesy
}
bytes = std::move(*stream);
} else if (cabinet.name.find('/') != std::string::npos || cabinet.name.find('\\') != std::string::npos ||
- !ReadFile(package_path.parent_path() / cabinet.name, kMaxPackageBytes, &bytes)) {
+ !beside(cabinet.name, &bytes)) {
*reason = "the cabinet " + cabinet.name + " beside the package could not be read";
return false;
}
@@ -333,6 +348,20 @@ bool InstallPackage(const std::filesystem::path& package_path, const std::filesy
return true;
}
+// Installs a package from the game folder, its external cabinets beside it.
+bool InstallPackage(const std::filesystem::path& package_path, const std::filesystem::path& prefix,
+ const RedistEntry& entry, std::int64_t unix_time, std::size_t* files, std::string* reason) {
+ std::string package;
+ if (!ReadFile(package_path, kMaxPackageBytes, &package)) {
+ *reason = "the package could not be read";
+ return false;
+ }
+ const auto beside = [&](const std::string& name, std::string* bytes) {
+ return ReadFile(package_path.parent_path() / name, kMaxPackageBytes, bytes);
+ };
+ return InstallPlan(package, beside, prefix, entry, unix_time, {}, files, reason);
+}
+
} // namespace
RedistAction ClassifyRedist(const RedistEntry& entry, const std::string& install_dir, std::string* package) {
@@ -360,6 +389,118 @@ RedistAction ClassifyRedist(const RedistEntry& entry, const std::string& install
return RedistAction::kNotRun;
}
+std::vector<VcRedist> MicrosoftVcRedists() {
+ constexpr const char* kBase = "https://download.visualstudio.microsoft.com/download/pr/990c720a-46ce-4dc7-87b9-c2eb615d34b9/";
+ return {
+ {"x86", std::string(kBase) + "0C09F2611660441084CE0DF425C51C11E147E6447963C3690F97E0B25C55ED64/VC_redist.x86.exe",
+ "0c09f2611660441084ce0df425c51c11e147e6447963c3690f97e0b25c55ed64", 13953392, "vcRuntimeAdditional_x86", "14.44.35211"},
+ {"x64", std::string(kBase) + "CC0FF0EB1DC3F5188AE6300FAEF32BF5BEEBA4BDD6E8E445A9184072096B713B/VC_redist.x64.exe",
+ "cc0ff0eb1dc3f5188ae6300faef32bf5beeba4bdd6e8e445a9184072096b713b", 25635768, "vcRuntimeAdditional_x64", "14.44.35211"},
+ };
+}
+
+bool MfcFileName(std::string_view name) {
+ const auto lower = Lower(name);
+ return (lower.rfind("mfc140", 0) == 0 || lower.rfind("mfcm140", 0) == 0) && lower.size() > 4 &&
+ lower.compare(lower.size() - 4, 4, ".dll") == 0 && lower.find('/') == std::string::npos;
+}
+
+MfcInstallResult InstallMfcRuntime(const VcRedist& redist, const std::string& cache_root, const std::string& prefix_dir,
+ const RangeFetch& fetch, std::int64_t unix_time) {
+ MfcInstallResult out;
+ const auto fail = [&](std::string why) {
+ out.result = "failed";
+ out.detail = std::move(why);
+ return out;
+ };
+ const std::filesystem::path prefix(prefix_dir);
+ if (InstalledPackages(prefix).count(redist.sha256)) {
+ out.result = "already";
+ return out;
+ }
+ const auto slash = redist.url.rfind('/');
+ const auto file_name = slash == std::string::npos ? std::string() : redist.url.substr(slash + 1);
+ if (file_name.empty() || file_name == "." || file_name == ".." || redist.bytes == 0 || redist.bytes > kMaxPackageBytes)
+ return fail("the redistributable's download is not one Playden can use");
+ const auto folder = std::filesystem::path(cache_root) / ("vc-" + redist.version) / redist.architecture;
+ const auto cached = folder / file_name;
+ // The kept copy, when it is still the pinned one.
+ std::string bundle;
+ if (ReadFile(cached, redist.bytes + 1, &bundle) && bundle.size() == redist.bytes &&
+ HashArtifactBytes(bundle).value_or("") == redist.sha256) {
+ out.source = "cache";
+ } else {
+ bundle.clear();
+ std::error_code ignored;
+ std::filesystem::remove(cached, ignored);
+ if (!fetch) return fail("Playden can't download it here");
+ // In ranges: one HTTP response is kept small.
+ bundle.reserve(redist.bytes);
+ for (std::uint64_t offset = 0; offset < redist.bytes;) {
+ const auto length = std::min<std::uint64_t>(kRedistChunkBytes, redist.bytes - offset);
+ std::optional<std::string> chunk;
+ std::string error;
+ for (int attempt = 0; attempt < 3 && !chunk; ++attempt) {
+ chunk = fetch(redist.url, offset, length, &error);
+ if (chunk && chunk->size() != length) {
+ error = "the server sent " + std::to_string(chunk->size()) + " bytes for " + std::to_string(length);
+ chunk.reset();
+ }
+ }
+ if (!chunk) return fail("the download failed at byte " + std::to_string(offset) + ": " + error);
+ bundle += *chunk;
+ offset += length;
+ }
+ if (HashArtifactBytes(bundle).value_or("") != redist.sha256)
+ return fail("the download is not the redistributable Playden expects (SHA-256 mismatch)");
+ out.source = "download";
+ // Kept for other games: written beside, then renamed into place.
+ std::error_code error;
+ std::filesystem::create_directories(folder, error);
+ const auto temporary = folder / (file_name + ".part-" + std::to_string(static_cast<long long>(::getpid())));
+ const int file = error ? -1 : ::open(temporary.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW | O_CLOEXEC, 0644);
+ std::size_t written = 0;
+ if (file >= 0) {
+ while (written < bundle.size()) {
+ const auto count = ::write(file, bundle.data() + written, bundle.size() - written);
+ if (count < 0 && errno == EINTR) continue;
+ if (count <= 0) break;
+ written += static_cast<std::size_t>(count);
+ }
+ const bool synced = ::fsync(file) == 0;
+ const bool closed = ::close(file) == 0;
+ if (written != bundle.size() || !synced || !closed || ::rename(temporary.c_str(), cached.c_str()) != 0) {
+ out.cache_problem = "could not write " + cached.string() + " (errno " + std::to_string(errno) + ")";
+ ::unlink(temporary.c_str());
+ }
+ } else {
+ out.cache_problem = "could not create " + folder.string() + (error ? ": " + error.message() : " (errno " + std::to_string(errno) + ")");
+ }
+ }
+ BurnMsiPackage package;
+ std::string reason;
+ if (!ReadBurnMsiPackage(bundle, redist.package_id, &package, &reason)) return fail(reason);
+ bundle = std::string(); // its packages are copied out; the console's memory is better spent elsewhere
+ const auto beside = [&](const std::string& name, std::string* bytes) {
+ for (const auto& [candidate, data] : package.beside)
+ if (Lower(candidate) == Lower(name)) {
+ *bytes = data;
+ return true;
+ }
+ return false;
+ };
+ const auto keep = [](const MsiFile& file) {
+ const auto slash = file.target.rfind('/');
+ return MfcFileName(slash == std::string::npos ? file.target : file.target.substr(slash + 1));
+ };
+ if (!InstallPlan(package.msi, beside, prefix, RedistEntry{}, unix_time, keep, &out.files, &reason))
+ return fail(package.msi_name + ": " + reason);
+ if (!RecordPackage(prefix, redist.sha256, "vc-" + redist.version + "-" + redist.architecture + "-mfc"))
+ return fail("installed, but could not be recorded");
+ out.result = "installed";
+ return out;
+}
+
std::string ExtendPath(const std::string& current, const std::vector<std::string>& prepend,
const std::vector<std::string>& append) {
std::vector<std::string> entries;
diff --git a/src/runtime/redist_install.h b/src/runtime/redist_install.h
index 4ab1619..f7cb1af 100644
--- a/src/runtime/redist_install.h
+++ b/src/runtime/redist_install.h
@@ -3,6 +3,8 @@
#include "runtime/install_script.h"
#include <cstdint>
+#include <functional>
+#include <optional>
#include <string>
#include <string_view>
#include <vector>
@@ -40,6 +42,46 @@ struct RedistInstallResult {
RedistInstallResult InstallRedistributables(const std::string& game_root, const std::string& install_dir,
const std::string& prefix_dir, std::int64_t unix_time);
+// Microsoft's MFC library, which Wine doesn't provide, for the games that import it (runtime/game_probe.h
+// FindMfcImports): Playden downloads Microsoft's Visual C++ 2015-2022 redistributable once per console, keeps the
+// verified setup program, and installs only the MFC files of its "Additional" package into a game's bottle.
+
+// The redistributable for one architecture, pinned to a release: the URL embeds its SHA-256.
+struct VcRedist {
+ std::string architecture; // "x86" or "x64"
+ std::string url;
+ std::string sha256; // lower case
+ std::uint64_t bytes = 0;
+ std::string package_id; // the bundle's MsiPackage with MFC
+ std::string version; // names the cache folder
+};
+// Microsoft's 14.44.35211 for x86 and x64.
+std::vector<VcRedist> MicrosoftVcRedists();
+
+// Whether a file the package installs is one of MFC's (mfc140*.dll, mfcm140*.dll): the only ones Playden takes
+// from it, so the C runtime never replaces the kit's Wine builtins.
+bool MfcFileName(std::string_view name);
+
+// One ranged GET: the bytes [offset, offset + length) of url, or nothing with a reason.
+using RangeFetch = std::function<std::optional<std::string>(const std::string& url, std::uint64_t offset,
+ std::uint64_t length, std::string* error)>;
+inline constexpr std::uint64_t kRedistChunkBytes = 8ull << 20;
+
+struct MfcInstallResult {
+ std::string result; // "installed", "already" or "failed"
+ std::string detail; // why it failed
+ std::string source; // "download" or "cache", when installed
+ std::size_t files = 0;
+ std::string cache_problem; // the download installed but could not be kept for other games: why
+};
+
+// Installs redist's MFC files into the stopped bottle at prefix_dir, once: the bottle's .playden-redist lists the
+// bundle's SHA-256 afterwards. The bundle is <cache_root>/vc-<version>/<architecture>/<file name of url> when that
+// file has the pinned SHA-256 (a file that doesn't is removed), otherwise fetched in kRedistChunkBytes ranges,
+// verified, and kept there for other games.
+MfcInstallResult InstallMfcRuntime(const VcRedist& redist, const std::string& cache_root, const std::string& prefix_dir,
+ const RangeFetch& fetch, std::int64_t unix_time);
+
// Adds folders to a PATH value: prepend in order before the existing entries, append after
// them, each only when not already listed (case-insensitive).
std::string ExtendPath(const std::string& current, const std::vector<std::string>& prepend,
diff --git a/tests/runtime_redist_test.cpp b/tests/runtime_redist_test.cpp
index cbb393b..608182d 100644
--- a/tests/runtime_redist_test.cpp
+++ b/tests/runtime_redist_test.cpp
@@ -1,3 +1,4 @@
+#include "runtime/artifact_hash.h"
#include "runtime/burn_bundle.h"
#include "runtime/install_script.h"
#include "runtime/msi_package.h"
@@ -353,6 +354,172 @@ void TestInstall() {
std::filesystem::remove_all(base);
}
+// A bottle as Wine makes it: hives and the system folders, private to Playden.
+std::filesystem::path MakeBottle(const std::filesystem::path& prefix) {
+ WriteText(prefix / "system.reg", "WINE REGISTRY Version 2\n;; All keys relative to \\\\Machine\n\n#arch=win64\n");
+ WriteText(prefix / "user.reg", "WINE REGISTRY Version 2\n;; All keys relative to \\\\User\\\\S-1-5-21-0-0-0-1000\n\n#arch=win64\n");
+ std::filesystem::create_directories(prefix / "drive_c/windows/system32");
+ std::filesystem::create_directories(prefix / "drive_c/windows/syswow64");
+ WriteText(prefix / "drive_c/windows/system32/msvcp140.dll", "WINE-BUILTIN");
+ std::filesystem::permissions(prefix, std::filesystem::perms::owner_all, std::filesystem::perm_options::replace);
+ return prefix;
+}
+
+VcRedist SyntheticRedist(bool x64, const std::string& bundle) {
+ const std::string arch = x64 ? "x64" : "x86";
+ return {arch, "https://download.example/pr/" + *HashArtifactBytes(bundle) + "/VC_redist." + arch + ".exe",
+ *HashArtifactBytes(bundle), bundle.size(), "vcRuntimeAdditional_" + arch, "14.44.35211"};
+}
+
+void TestMfcFilter() {
+ CHECK(MfcFileName("mfc140u.dll") && MfcFileName("MFC140.DLL") && MfcFileName("mfcm140u.dll") && MfcFileName("mfc140chs.dll"));
+ CHECK(!MfcFileName("msvcp140.dll") && !MfcFileName("vcruntime140.dll") && !MfcFileName("concrt140.dll"));
+ CHECK(!MfcFileName("mfc42.dll") && !MfcFileName("mfc140u.pdb") && !MfcFileName("mfc140u.dll.bak"));
+ // The package's own folder mapping: x64 files go to system32, x86 ones to SysWOW64 (64-bit Windows).
+ for (const bool x64 : {true, false}) {
+ MsiInstallPlan plan;
+ std::string reason;
+ CHECK(ReadMsiPackage(MfcPackage(x64), &plan, &reason));
+ CHECK(plan.files.size() == 3 && plan.cabinets.size() == 1 && plan.cabinets[0].name == "cab1.cab" && !plan.cabinets[0].embedded);
+ CHECK(plan.files[0].target == std::string(x64 ? "windows/system32" : "windows/syswow64") + "/mfc140u.dll");
+ }
+}
+
+void TestMfcInstall() {
+ char pattern[] = "/tmp/playden-mfc-XXXXXX";
+ CHECK(::mkdtemp(pattern));
+ const auto base = std::filesystem::canonical(pattern);
+ const auto cache = base / "data/playden/redist";
+ // Padded past one range, so the download takes two.
+ const auto x64_bundle = MfcBundle(true) + std::string(kRedistChunkBytes, '\0');
+ const auto x64 = SyntheticRedist(true, x64_bundle);
+ int fetches = 0, failures_left = 1;
+ std::string served = x64_bundle;
+ const RangeFetch fetch = [&](const std::string& url, std::uint64_t offset, std::uint64_t length,
+ std::string* error) -> std::optional<std::string> {
+ ++fetches;
+ if (failures_left > 0) { // one network error, which the next attempt gets past
+ --failures_left;
+ *error = "timed out";
+ return std::nullopt;
+ }
+ CHECK(url.rfind("https://download.example/pr/" + *HashArtifactBytes(served) + "/VC_redist.", 0) == 0 ||
+ (url == x64.url && served.size() == x64.bytes));
+ if (offset >= served.size()) return std::string();
+ return served.substr(offset, length);
+ };
+ // Installed from the download: only MFC, the bottle's Wine msvcp140 stays.
+ const auto first = MakeBottle(base / "one");
+ auto result = InstallMfcRuntime(x64, cache.string(), first.string(), fetch, 1700000000);
+ if (result.result != "installed") std::fprintf(stderr, "mfc: %s\n", result.detail.c_str());
+ CHECK(result.result == "installed" && result.source == "download" && result.files == 2 && result.cache_problem.empty());
+ CHECK(fetches == 3); // the failed attempt and two ranges
+ CHECK(ReadText(first / "drive_c/windows/system32/mfc140u.dll") == "MFC64U");
+ CHECK(ReadText(first / "drive_c/windows/system32/mfcm140.dll") == "MFCM64");
+ CHECK(ReadText(first / "drive_c/windows/system32/msvcp140.dll") == "WINE-BUILTIN");
+ CHECK(!std::filesystem::exists(first / "drive_c/windows/syswow64/mfc140u.dll"));
+ CHECK(ReadText(first / "system.reg").find("RuntimeAdditional]") != std::string::npos);
+ CHECK(ReadText(first / ".playden-redist") == x64.sha256 + " vc-14.44.35211-x64-mfc\n");
+ const auto kept = cache / "vc-14.44.35211/x64/VC_redist.x64.exe";
+ CHECK(ReadText(kept) == x64_bundle);
+ // Once per bottle: nothing is read or fetched again.
+ result = InstallMfcRuntime(x64, cache.string(), first.string(), fetch, 1700000100);
+ CHECK(result.result == "already" && fetches == 3);
+ // Another game's bottle takes the kept copy.
+ const auto second = MakeBottle(base / "two");
+ result = InstallMfcRuntime(x64, cache.string(), second.string(), nullptr, 1700000200);
+ CHECK(result.result == "installed" && result.source == "cache" && fetches == 3);
+ CHECK(ReadText(second / "drive_c/windows/system32/mfc140u.dll") == "MFC64U");
+ // A kept copy that isn't the pinned one counts as missing: removed and fetched again.
+ WriteText(kept, "damaged");
+ const auto third = MakeBottle(base / "three");
+ result = InstallMfcRuntime(x64, cache.string(), third.string(), nullptr, 1700000300);
+ CHECK(result.result == "failed" && result.detail == "Playden can't download it here" && !std::filesystem::exists(kept));
+ CHECK(!std::filesystem::exists(third / ".playden-redist"));
+ result = InstallMfcRuntime(x64, cache.string(), third.string(), fetch, 1700000300);
+ CHECK(result.result == "installed" && result.source == "download" && ReadText(kept) == x64_bundle);
+ // A download that isn't the pinned bundle is refused before it is read, and not kept.
+ served[served.size() - 1] = 'x';
+ std::filesystem::remove(kept);
+ const auto fourth = MakeBottle(base / "four");
+ result = InstallMfcRuntime(x64, cache.string(), fourth.string(), fetch, 1700000400);
+ CHECK(result.result == "failed" && result.detail.find("SHA-256 mismatch") != std::string::npos);
+ CHECK(!std::filesystem::exists(kept) && !std::filesystem::exists(fourth / ".playden-redist"));
+ CHECK(!std::filesystem::exists(fourth / "drive_c/windows/system32/mfc140u.dll"));
+ // A server that keeps failing.
+ failures_left = 100;
+ result = InstallMfcRuntime(x64, cache.string(), fourth.string(), fetch, 1700000400);
+ CHECK(result.result == "failed" && result.detail == "the download failed at byte 0: timed out");
+ // x86: into SysWOW64, from its own folder of the cache.
+ failures_left = 0;
+ served = MfcBundle(false);
+ const auto x86 = SyntheticRedist(false, served);
+ result = InstallMfcRuntime(x86, cache.string(), fourth.string(), fetch, 1700000500);
+ CHECK(result.result == "installed" && result.files == 2);
+ CHECK(ReadText(fourth / "drive_c/windows/syswow64/mfc140u.dll") == "MFC32U");
+ CHECK(!std::filesystem::exists(fourth / "drive_c/windows/syswow64/msvcp140.dll"));
+ CHECK(std::filesystem::exists(cache / "vc-14.44.35211/x86/VC_redist.x86.exe"));
+ // A bundle whose package has no MFC files installs nothing.
+ served = MfcBundle(true);
+ auto minimum_only = SyntheticRedist(true, served);
+ minimum_only.package_id = "vcRuntimeMinimum_x64";
+ minimum_only.version = "other";
+ const auto fifth = MakeBottle(base / "five");
+ result = InstallMfcRuntime(minimum_only, cache.string(), fifth.string(), fetch, 1700000600);
+ CHECK(result.result == "failed" && !std::filesystem::exists(fifth / ".playden-redist"));
+ // The cache can't be written: the game still gets MFC.
+ served = MfcBundle(true);
+ auto uncached = SyntheticRedist(true, served);
+ WriteText(base / "blocked", "a file where the cache folder would be");
+ const auto sixth = MakeBottle(base / "six");
+ result = InstallMfcRuntime(uncached, (base / "blocked").string(), sixth.string(), fetch, 1700000700);
+ CHECK(result.result == "installed" && !result.cache_problem.empty());
+ std::filesystem::remove_all(base);
+}
+
+// Microsoft's own bundles, when PLAYDEN_TEST_VC_REDIST_X64 / _X86 name copies: read, mapped and installed (from a
+// cache seeded with the copy, so nothing is downloaded).
+void TestMicrosoftVcRedist() {
+ for (const auto& redist : MicrosoftVcRedists()) {
+ const char* path = std::getenv(redist.architecture == "x64" ? "PLAYDEN_TEST_VC_REDIST_X64" : "PLAYDEN_TEST_VC_REDIST_X86");
+ if (!path || !*path) continue;
+ const auto bundle = ReadText(path);
+ CHECK(bundle.size() == redist.bytes && HashArtifactBytes(bundle) == redist.sha256);
+ BurnMsiPackage package;
+ std::string reason;
+ CHECK(ReadBurnMsiPackage(bundle, redist.package_id, &package, &reason));
+ MsiInstallPlan plan;
+ CHECK(ReadMsiPackage(package.msi, &plan, &reason));
+ const auto system = redist.architecture == "x64" ? "windows/system32/" : "windows/syswow64/";
+ std::size_t mfc = 0;
+ for (const auto& file : plan.files) {
+ const bool kept = MfcFileName(file.target.substr(file.target.rfind('/') + 1));
+ std::fprintf(stderr, "%s %s %s\n", redist.architecture.c_str(), kept ? "mfc " : "other", file.target.c_str());
+ if (!kept) continue;
+ CHECK(file.target.rfind(system, 0) == 0);
+ ++mfc;
+ }
+ for (const auto& value : plan.machine)
+ std::fprintf(stderr, "%s registry %s \\ %s = %s\n", redist.architecture.c_str(), value.key.c_str(), value.name.c_str(),
+ value.data.c_str());
+ std::fprintf(stderr, "%s: %s, %zu files (%zu MFC), %zu cabinets, %zu custom actions, %zu machine values\n",
+ redist.architecture.c_str(), package.msi_name.c_str(), plan.files.size(), mfc, plan.cabinets.size(),
+ plan.custom_actions, plan.machine.size());
+ CHECK(mfc >= 4);
+ char pattern[] = "/tmp/playden-vc-redist-XXXXXX";
+ CHECK(::mkdtemp(pattern));
+ const auto base = std::filesystem::canonical(pattern);
+ WriteText(base / "cache" / ("vc-" + redist.version) / redist.architecture / ("VC_redist." + redist.architecture + ".exe"), bundle);
+ const auto prefix = MakeBottle(base / "prefix");
+ const auto result = InstallMfcRuntime(redist, (base / "cache").string(), prefix.string(), nullptr, 1700000000);
+ if (result.result != "installed") std::fprintf(stderr, "install: %s\n", result.detail.c_str());
+ CHECK(result.result == "installed" && result.source == "cache" && result.files == mfc);
+ CHECK(std::filesystem::file_size(prefix / "drive_c" / system / "mfc140u.dll") > 1000000);
+ CHECK(ReadText(prefix / "drive_c/windows/system32/msvcp140.dll") == "WINE-BUILTIN");
+ std::filesystem::remove_all(base);
+ }
+}
+
// NVIDIA's legacy PhysX package (Bullet Witch's), when PLAYDEN_TEST_PHYSX_MSI names a copy.
void TestPhysxPackage() {
const char* path = std::getenv("PLAYDEN_TEST_PHYSX_MSI");
@@ -404,5 +571,8 @@ int main() {
TestScripts();
TestInstall();
TestPhysxPackage();
+ TestMfcFilter();
+ TestMfcInstall();
+ TestMicrosoftVcRedist();
return 0;
}