Skip to content

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

C++

Start Unreal games past their root launcher

Leonardo Lobatoaec89b100ac5
diff --git a/src/homebrew/host.cpp b/src/homebrew/host.cpp
index c057036..23ccc04 100644
--- a/src/homebrew/host.cpp
+++ b/src/homebrew/host.cpp
@@ -11,6 +11,7 @@
#include "stores/local/copy_runner.h"
#include "stores/local/library_source.h"
#include "app/diagnostic_log.h"
+#include "runtime/game_probe.h"
#include "runtime/settings_storage.h"
#include "homebrew/input_adapter.hpp"
#include "homebrew/json.hpp"
@@ -724,6 +725,9 @@ int main(int argc, char** argv) {
return runner->Move(*service, entry, source, runtime_number);
};
import_config.remove_copy_folder = [runner = copy_runner.get()](const std::string& root) { return runner->Remove(root).empty(); };
+ import_config.game_program = [](const std::string& folder, const std::string& program) {
+ return playden::runtime::UnrealGameProgram(folder, program);
+ };
auto local_library = std::make_unique<playden::stores::local::LocalLibrarySource>(*imports, std::move(import_config));
auto* local = local_library.get();
copy_runner->SetChanged([local] { local->Reload(); });
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index eadd503..e8f907e 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -15,6 +15,7 @@
#include "platform/ps5/title_remover.h"
#include "platform/ps5/title_runtime.h"
#include "platform/ps5/native_startup.h"
+#include "runtime/game_probe.h"
#include "runtime/settings_storage.h"
#include "runtime/writable_folders.h"
#include "homebrew/runtime_host.hpp"
@@ -832,6 +833,9 @@ int main() {
return runner->Move(installs, entry, source, runtime_number);
};
import_config.remove_copy_folder = [runner = copy_runner.get()](const std::string& root) { return runner->Remove(root).empty(); };
+ import_config.game_program = [](const std::string& folder, const std::string& program) {
+ return playden::runtime::UnrealGameProgram(folder, program);
+ };
auto source = std::make_unique<playden::stores::local::LocalLibrarySource>(*imports, std::move(import_config));
local_library = source.get();
copy_runner->SetChanged([local_library] { local_library->Reload(); });
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index 9f3cf2f..2e14402 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -906,6 +906,18 @@ void RuntimeHost::KitMonoStep(Composition& c, const rt::RuntimeInstall& record,
(ok ? " pointed at kit " + c.kit->view.kit_id : " failed=" + reason));
}
+// Generic step: the bottle's Visual C++ runtime key says the version of the kit's builtin DLLs, which Unreal's root
+// launcher checks before it starts the game. Logged, never a refusal: most games never read it, and the next Play
+// tries again.
+void RuntimeHost::VcRuntimeStep(const GameFiles& files) {
+ bool changed = false;
+ std::string reason;
+ const auto ok = rt::RaiseVcRuntimeVersion(files.prefix, config_.unix_time(), &changed, &reason);
+ if (changed || !ok)
+ Log("vc runtime app=" + std::to_string(files.record.runtime_number) +
+ (ok ? std::string(" version=") + rt::kVcRuntimeVersion : " failed=" + reason));
+}
+
// Generic step: vkd3d-proton's variables reach the game through the bottle's Environment key. Some change how
// it draws, so a bottle that exists but cannot take them stops the start; one not made yet gets them on the
// next Play.
@@ -1107,9 +1119,10 @@ std::string RuntimeHost::DotnetHeapStep(const GameFiles& files) {
return dotnet.ok ? std::string() : dotnet.message;
}
-// The steps run in this order for every game, whatever its store: generic ones (media, EULA, Direct3D 12,
-// the bottle's Environment, MFC, the recipe's registry and INI values, the .NET heap) and Steam-file ones, which act
-// only on the Steam files a game has (SteamStub, Steamworks and steam.dll, install scripts and redistributables).
+// The steps run in this order for every game, whatever its store: generic ones (media, EULA, Direct3D 12, Wine
+// Mono, the bottle's Environment, MFC, the Visual C++ runtime key, the recipe's registry and INI values, the .NET
+// heap) and Steam-file ones, which act only on the Steam files a game has (SteamStub, Steamworks and steam.dll,
+// install scripts and redistributables).
std::string RuntimeHost::ApplyPreparationSteps(Composition& c, const rt::RuntimeInstall& record, bool steam_account_known) {
MediaStep(c, record);
GameFiles files{record};
@@ -1156,6 +1169,8 @@ std::string RuntimeHost::ApplyPreparationSteps(Composition& c, const rt::Runtime
if (auto refused = BottleEnvironmentStep(files); !refused.empty()) return refused;
if (auto refused = InstallScriptsStep(files); !refused.empty()) return refused;
MfcStep(files);
+ // After the redistributables (install scripts, MFC): one that writes an older runtime key doesn't stay.
+ VcRuntimeStep(files);
if (auto refused = RecipeRegistryStep(files); !refused.empty()) return refused;
if (auto refused = RecipeIniStep(files); !refused.empty()) return refused;
return DotnetHeapStep(files);
diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hpp
index e010deb..3d98f3f 100644
--- a/src/homebrew/runtime_host.hpp
+++ b/src/homebrew/runtime_host.hpp
@@ -613,6 +613,7 @@ class RuntimeHost {
std::string Ue3EulaStep(const GameFiles& files);
std::string Direct3D12Step(Composition& composition, const GameFiles& files);
void KitMonoStep(Composition& composition, const runtime::RuntimeInstall& record, const char* when); // never stops the start
+ void VcRuntimeStep(const GameFiles& files); // never stops the start
std::string BottleEnvironmentStep(const GameFiles& files);
std::string RecipeRegistryStep(const GameFiles& files);
std::string RecipeIniStep(const GameFiles& files);
diff --git a/src/runtime/game_probe.cpp b/src/runtime/game_probe.cpp
index 81f1c3e..53a2ec9 100644
--- a/src/runtime/game_probe.cpp
+++ b/src/runtime/game_probe.cpp
@@ -264,24 +264,76 @@ std::optional<std::string> Find(const std::vector<std::pair<std::string, bool>>&
return std::nullopt;
}
-// The Unreal program under root: <Project>/Binaries/Win64/<Project>-Win64-Shipping.exe,
-// searched a few levels deep. Returns the path relative to root, or empty.
-std::string FindShipping(const fs::path& root, const std::string& relative, int depth) {
+// Unreal's own tools beside the game in <Project>/Binaries/Win64: never the game.
+constexpr const char* kUnrealToolWords[] = {"crashreport", "cefsubprocess", "epicwebhelper", "-cmd.exe"};
+
+bool UnrealTool(const std::string& lower) {
+ return std::any_of(std::begin(kInstallerWords), std::end(kInstallerWords),
+ [&](const char* word) { return lower.find(word) != std::string::npos; }) ||
+ std::any_of(std::begin(kUnrealToolWords), std::end(kUnrealToolWords),
+ [&](const char* word) { return lower.find(word) != std::string::npos; });
+}
+
+// The Unreal program under root: <Project>/Binaries/Win64/<Project>-Win64-Shipping.exe, searched a few levels
+// deep. With shipping false, a game that ships it under another name (TS2Prototype/Binaries/Win64/WondersOfSodor.exe)
+// is found instead, as the only program in a Binaries/Win64 folder or the one named like the root program
+// (launcher_stem, lower case) or the project. Returns the path relative to root, or empty.
+std::string FindUnrealProgram(const fs::path& root, const std::string& relative, int depth, bool shipping,
+ const std::string& launcher_stem, std::size_t launcher_folder) {
if (depth > 4) return {};
const auto entries = Entries(root / relative);
- for (const auto& [name, directory] : entries)
- if (!directory && EndsWith(Lower(name), "-shipping.exe") && Lower(relative).find("binaries/win64") != std::string::npos)
- return relative.empty() ? name : relative + "/" + name;
+ const auto lower_relative = Lower(relative);
+ const auto path_of = [&](const std::string& name) { return relative.empty() ? name : relative + "/" + name; };
+ if (shipping) {
+ for (const auto& [name, directory] : entries)
+ if (!directory && EndsWith(Lower(name), "-shipping.exe") && lower_relative.find("binaries/win64") != std::string::npos)
+ return path_of(name);
+ } else if (EndsWith(lower_relative, "binaries/win64")) {
+ // The project is the folder above Binaries, below the launcher's folder.
+ std::string project;
+ const fs::path parts(lower_relative.substr(std::min(launcher_folder, lower_relative.size())));
+ for (auto at = parts.begin(); at != parts.end(); ++at)
+ if (std::next(at) != parts.end() && *std::next(at) == "binaries") project = at->string();
+ std::vector<std::string> programs;
+ for (const auto& [name, directory] : entries) {
+ const auto lower = Lower(name);
+ if (!directory && EndsWith(lower, ".exe") && !UnrealTool(lower)) programs.push_back(name);
+ }
+ // Only in a project's folder: Unreal 3 keeps its own program in a Binaries/Win64 at the root.
+ if (!project.empty() && programs.size() == 1) return path_of(programs.front());
+ for (const auto& name : programs) {
+ const auto stem = Lower(name.substr(0, name.size() - 4));
+ if (!project.empty() && (stem == launcher_stem || stem == project)) return path_of(name);
+ }
+ }
for (const auto& [name, directory] : entries) {
if (!directory) continue;
const auto lower = Lower(name);
if (lower == "engine" || lower == "content" || lower == "saved" || lower == "plugins") continue;
- const auto found = FindShipping(root, relative.empty() ? name : relative + "/" + name, depth + 1);
+ const auto found = FindUnrealProgram(root, path_of(name), depth + 1, shipping, launcher_stem, launcher_folder);
if (!found.empty()) return found;
}
return {};
}
+// A *-Shipping.exe anywhere first, then a program named otherwise.
+std::string FindShipping(const fs::path& root, const std::string& relative, const std::string& launcher_stem) {
+ const auto launcher_folder = relative.empty() ? 0 : relative.size() + 1;
+ auto found = FindUnrealProgram(root, relative, 0, true, launcher_stem, launcher_folder);
+ return found.empty() ? FindUnrealProgram(root, relative, 0, false, launcher_stem, launcher_folder) : found;
+}
+
+// An Unreal root program: <Game>.exe beside the Engine folder, not an installer the game ships there.
+bool UnrealLauncher(const std::vector<std::pair<std::string, bool>>& here, const std::string& lower_file) {
+ return !EndsWith(lower_file, "-shipping.exe") && Find(here, "engine", true) &&
+ std::none_of(std::begin(kInstallerWords), std::end(kInstallerWords),
+ [&](const char* word) { return lower_file.find(word) != std::string::npos; });
+}
+
+std::string LowerStem(const std::string& lower_file) {
+ return EndsWith(lower_file, ".exe") ? lower_file.substr(0, lower_file.size() - 4) : lower_file;
+}
+
// Microsoft's MFC library, which Wine doesn't provide: mfc140.dll, mfc140u.dll, mfcm140.dll, mfcm140u.dll (and
// whatever later 140 builds add).
bool MfcLibrary(const std::string& lower) {
@@ -332,6 +384,19 @@ MfcImports FindMfcImports(const std::string& install_root) {
return out;
}
+std::string UnrealGameProgram(const std::string& install_root, const std::string& executable) {
+ const fs::path root(install_root);
+ const auto slash = executable.rfind('/');
+ const std::string folder = slash == std::string::npos ? std::string() : executable.substr(0, slash);
+ const auto file = slash == std::string::npos ? executable : executable.substr(slash + 1);
+ const auto lower_file = Lower(file);
+ const auto here = Entries(root / folder);
+ // As ProbeGame decides: a Unity program beside an Engine folder is Unity's.
+ if (Find(here, "unityplayer.dll", false) || Find(here, LowerStem(lower_file) + "_data", true)) return {};
+ if (!UnrealLauncher(here, lower_file)) return {};
+ return FindShipping(root, folder, LowerStem(lower_file));
+}
+
GameProbe ProbeGame(const std::string& install_root, const std::string& executable) {
GameProbe probe;
const fs::path root(install_root);
@@ -363,14 +428,10 @@ GameProbe ProbeGame(const std::string& install_root, const std::string& executab
probe.il2cpp = Find(here, "gameassembly.dll", false).has_value();
probe.legacy_unity = !unity;
if (unity) ScanNames((root / folder / *unity).string(), &probe.apis);
- } else if (EndsWith(lower_file, "-shipping.exe") ||
- (Find(here, "engine", true) && std::none_of(std::begin(kInstallerWords), std::end(kInstallerWords),
- [&](const char* word) {
- return lower_file.find(word) != std::string::npos;
- }))) {
+ } else if (EndsWith(lower_file, "-shipping.exe") || UnrealLauncher(here, lower_file)) {
probe.engine = "unreal";
if (!EndsWith(lower_file, "-shipping.exe")) {
- probe.unreal_program = FindShipping(root, folder, 0);
+ probe.unreal_program = FindShipping(root, folder, LowerStem(lower_file));
// The root program is only a launcher: the engine version is in the Shipping program.
std::set<std::string> shipping_apis;
if (!probe.unreal_program.empty())
diff --git a/src/runtime/game_probe.h b/src/runtime/game_probe.h
index 7a8d7d8..74f83c4 100644
--- a/src/runtime/game_probe.h
+++ b/src/runtime/game_probe.h
@@ -26,8 +26,9 @@ struct GameProbe {
bool shared_section = false;
bool anticheat = false; // an EasyAntiCheat or BattlEye folder in the game
// For an Unreal game started through its root program (which starts the real one as a
- // child process, which the console cannot do): the *-Shipping.exe to start instead,
- // relative to the install root, as spelled on disk.
+ // child process, which the console cannot do): the program to start instead (the
+ // *-Shipping.exe, or the one program in <Project>/Binaries/Win64), relative to the install
+ // root, as spelled on disk.
std::string unreal_program;
bool unreal5 = false; // Unreal Engine 5 (its Shipping program names Nanite's settings)
};
@@ -37,6 +38,11 @@ inline constexpr unsigned long long kProbeScanBytes = 256ull * 1024ull * 1024ull
// executable is relative to install_root with '/' separators, as spelled on disk.
GameProbe ProbeGame(const std::string& install_root, const std::string& executable);
+// The program that starts an Unreal game when executable (relative to install_root, '/' separators) is its root
+// launcher, which only starts that one as a child process, which the console cannot do; relative to install_root,
+// as spelled on disk. Empty for any other program. GameProbe::unreal_program, without reading the programs.
+std::string UnrealGameProgram(const std::string& install_root, const std::string& executable);
+
// Which of a game's programs and libraries import Microsoft's MFC library (mfc140*.dll, mfcm140*.dll, directly
// or delay-loaded), which Wine doesn't provide: Playden installs Microsoft's own into the game's bottle. Every
// .exe and .dll of the game folder is read, kMfcScanDepth folders deep, at most kMfcScanPrograms of them (headers
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index 8d1eeab..97aeb4d 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -7,6 +7,7 @@
#include "steam/backend/json.h"
#include <algorithm>
+#include <array>
#include <cctype>
#include <atomic>
#include <cerrno>
@@ -2961,6 +2962,56 @@ bool PointBottleAtKitMono(const std::string& template_dir, const std::string& pr
return true;
}
+bool RaiseVcRuntimeVersion(const std::string& prefix_dir, std::int64_t unix_time, bool* changed, std::string* reason) {
+ const auto fail = [&](std::string why) {
+ if (reason) *reason = std::move(why);
+ return false;
+ };
+ *changed = false;
+ constexpr std::size_t kMaxRegistryBytes = 32u * 1024u * 1024u;
+ auto bottle = ManagedDirectory::Open(prefix_dir, DirectoryPolicy::kPrivateTraversable);
+ if (!bottle) return errno == ENOENT ? true : fail("cannot open the bottle");
+ std::string system_reg;
+ const auto state = ReadRegularAt(*bottle, "system.reg", kMaxRegistryBytes, &system_reg, nullptr, true);
+ if (state == RelativeRead::kMissing) return true; // the bottle comes later
+ if (state != RelativeRead::kPresent) return fail("cannot read the bottle's system.reg");
+ const std::array<std::uint32_t, 4> wanted{kVcRuntimeMajor, kVcRuntimeMinor, kVcRuntimeBuild, kVcRuntimeRevision};
+ const auto dword = [](std::uint32_t value) {
+ char text[16];
+ std::snprintf(text, sizeof(text), "dword:%08x", static_cast<unsigned>(value));
+ return std::string(text);
+ };
+ std::vector<RegistryValue> values;
+ for (const char* key : {"Software\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64",
+ "Software\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64",
+ "Software\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x86"}) {
+ // A key a redistributable installer raised past the builtin DLLs stays as it is.
+ std::array<std::uint32_t, 4> current{};
+ bool readable = true;
+ const char* names[] = {"Major", "Minor", "Bld", "Rbld"};
+ for (std::size_t index = 0; index < current.size(); ++index) {
+ const auto data = RegistryData(system_reg, key, names[index]);
+ if (!data || data->size() != 14 || data->compare(0, 6, "dword:") != 0 ||
+ data->find_first_not_of("0123456789abcdefABCDEF", 6) != std::string::npos) {
+ readable = false;
+ break;
+ }
+ current[index] = static_cast<std::uint32_t>(std::strtoul(data->c_str() + 6, nullptr, 16));
+ }
+ if (readable && current >= wanted && RegistryData(system_reg, key, "Installed") == dword(1)) continue;
+ values.push_back({key, "Major", dword(kVcRuntimeMajor)});
+ values.push_back({key, "Minor", dword(kVcRuntimeMinor)});
+ values.push_back({key, "Bld", dword(kVcRuntimeBuild)});
+ values.push_back({key, "Rbld", dword(kVcRuntimeRevision)});
+ values.push_back({key, "Version", std::string("\"") + kVcRuntimeVersion + "\""});
+ values.push_back({key, "Installed", dword(1)});
+ }
+ if (values.empty()) return true;
+ if (!ApplyRegistryFileValues(values, prefix_dir, unix_time, reason, "system.reg")) return false;
+ *changed = true;
+ return true;
+}
+
bool ParseUe3InstallGuid(std::string_view install_info, std::string* guid) {
static constexpr std::string_view open = "<InstallGuidString>", close = "</InstallGuidString>";
const auto start = install_info.find(open);
diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.h
index b05dd65..1211cec 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -442,6 +442,17 @@ bool ApplyD3D12Library(const std::string& runtime_dir, const std::string& templa
bool PointBottleAtKitMono(const std::string& template_dir, const std::string& prefix_dir, std::int64_t unix_time,
bool* changed, std::string* reason);
+// The Visual C++ runtime the kit's builtin DLLs are (msvcp140.dll, vcruntime140*.dll in system32 and syswow64).
+inline constexpr std::uint32_t kVcRuntimeMajor = 14, kVcRuntimeMinor = 50, kVcRuntimeBuild = 35719, kVcRuntimeRevision = 0;
+inline constexpr const char* kVcRuntimeVersion = "14.50.35719.0";
+// Unreal's root launcher reads HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64 (Major, Minor, Bld,
+// Rbld) and asks for the Visual C++ redistributable when it is older than the one the game was built with; the kit
+// template says 14.42.34433.0 (Wine's wine.inf). This writes the builtin DLLs' version into the stopped bottle's
+// system.reg, for x64 and x86 in both registry views, with a system.reg.playden-backup as ApplyBottleRegistryValues
+// does. A key that already says this version or a later one is kept; a bottle not made yet is left for later.
+// changed tells whether system.reg was written.
+bool RaiseVcRuntimeVersion(const std::string& prefix_dir, std::int64_t unix_time, bool* changed, std::string* reason);
+
// The <InstallGuidString> of an Unreal Engine 3 (UDK) Binaries/InstallInfo.xml: exactly one,
// a 36-character 8-4-4-4-12 hex GUID once surrounding whitespace is trimmed.
bool ParseUe3InstallGuid(std::string_view install_info, std::string* guid);
diff --git a/src/stores/local/library_source.cpp b/src/stores/local/library_source.cpp
index f456142..32ce323 100644
--- a/src/stores/local/library_source.cpp
+++ b/src/stores/local/library_source.cpp
@@ -327,19 +327,26 @@ void LocalLibrarySource::Execute(const Job& job) {
const auto path = Join(volume->mount, folder);
// Opened first: a root-owned folder FTP made may not even be listable by the app user.
if (const auto opened = OpenDropFolder(*volume, path); !opened.empty()) return Outcome(job, false, {}, opened);
- const auto check = CheckProgram(HostPath(path), job.program);
+ auto program = job.program;
+ const auto check = CheckProgram(HostPath(path), program);
if (check != ProgramCheck::kOk) return Outcome(job, false, {}, ProgramWords(check));
+ if (config_.game_program)
+ if (auto game = config_.game_program(HostPath(path), program);
+ !game.empty() && game != program && CheckProgram(HostPath(path), game) == ProgramCheck::kOk) {
+ Log("import program volume=" + job.volume + " folder=" + folder + " launcher=" + program + " game=" + game);
+ program = std::move(game);
+ }
std::string title;
for (const auto& candidate : candidates_)
if (candidate.volume == job.volume && candidate.folder == folder) title = candidate.title;
if (title.empty()) title = TitleForFolder(path);
- const auto added = store_.Add(job.volume, folder, title, job.program);
+ const auto added = store_.Add(job.volume, folder, title, program);
if (!added.ok()) {
Log("import add failed volume=" + job.volume + " folder=" + folder + ": " + added.message());
return Outcome(job, false, {}, ImportWords(added.error()));
}
Log("import added id=" + added.value().id + " volume=" + job.volume + " folder=" + folder +
- " program=" + job.program);
+ " program=" + program);
for (auto& candidate : candidates_)
if (candidate.volume == job.volume && candidate.folder == folder) candidate.imported_id = added.value().id;
// Numbered here, on this worker, before the game is listed: the main thread never waits for it.
diff --git a/src/stores/local/library_source.h b/src/stores/local/library_source.h
index 5987a75..5d26732 100644
--- a/src/stores/local/library_source.h
+++ b/src/stores/local/library_source.h
@@ -98,6 +98,10 @@ struct LocalLibraryConfig {
// more; LocalCopyRunner::Remove, which only deletes what Playden recognizes as its own. Reconcile
// calls it. Empty: such folders stay.
std::function<bool(const std::string& root)> remove_copy_folder;
+ // The program that starts the game in place of `program` (relative to `folder`, as this process opens it), or
+ // empty to keep it: an Unreal root launcher only starts the real program as a child process, which the console
+ // cannot do (runtime::UnrealGameProgram). Called on the worker at Add. Empty: the chosen program is kept.
+ std::function<std::string(const std::string& folder, const std::string& program)> game_program;
};
// The words for a game that can't play from its folder because of its name (the descriptor rule).
diff --git a/tests/game_probe_test.cpp b/tests/game_probe_test.cpp
index 91b8885..719ee4c 100644
--- a/tests/game_probe_test.cpp
+++ b/tests/game_probe_test.cpp
@@ -392,6 +392,70 @@ int main() {
const auto launcher = ProbeGame(bare.string(), "Game.exe");
CHECK(launcher.engine == "unreal" && launcher.unreal_program.empty() && !launcher.unreal5);
}
+ { // An Unreal program not named *-Shipping.exe (Thomas & Friends: Wonders of Sodor): the only program in
+ // <Project>/Binaries/Win64 replaces the root launcher, past Unreal's own tools there.
+ const auto root = fresh();
+ WritePe(root / "WindowsNoEditor/WondersOfSodor.exe", {true, {"KERNEL32.dll"}});
+ fs::create_directories(root / "WindowsNoEditor/Engine/Binaries/Win64");
+ WritePe(root / "WindowsNoEditor/TS2Prototype/Binaries/Win64/WondersOfSodor.exe", {true, {"d3d11.dll"}});
+ WritePe(root / "WindowsNoEditor/TS2Prototype/Binaries/Win64/CrashReportClient.exe", {true, {"KERNEL32.dll"}});
+ WritePe(root / "WindowsNoEditor/TS2Prototype/Binaries/Win64/TS2Prototype-Cmd.exe", {true, {"KERNEL32.dll"}});
+ const auto probe = ProbeGame(root.string(), "WindowsNoEditor/WondersOfSodor.exe");
+ CHECK(probe.engine == "unreal" &&
+ probe.unreal_program == "WindowsNoEditor/TS2Prototype/Binaries/Win64/WondersOfSodor.exe");
+ CHECK(UnrealGameProgram(root.string(), "WindowsNoEditor/WondersOfSodor.exe") == probe.unreal_program);
+ GameRecipe recipe;
+ std::string reason;
+ CHECK(GenerateGameRecipe(9002, "Sodor", {{"", "", "WindowsNoEditor/WondersOfSodor.exe", "", ""}}, root.string(),
+ &recipe, &reason));
+ CHECK(recipe.launch_entries[0].executable == "WindowsNoEditor/TS2Prototype/Binaries/Win64/WondersOfSodor.exe");
+ CHECK(recipe.launch_entries[0].working_directory == "WindowsNoEditor/TS2Prototype/Binaries/Win64");
+ // Two programs: the one named like the project.
+ WritePe(root / "WindowsNoEditor/TS2Prototype/Binaries/Win64/Editor.exe", {true, {"KERNEL32.dll"}});
+ WritePe(root / "WindowsNoEditor/TS2Prototype/Binaries/Win64/TS2Prototype.exe", {true, {"KERNEL32.dll"}});
+ fs::remove(root / "WindowsNoEditor/TS2Prototype/Binaries/Win64/WondersOfSodor.exe");
+ CHECK(UnrealGameProgram(root.string(), "WindowsNoEditor/WondersOfSodor.exe") ==
+ "WindowsNoEditor/TS2Prototype/Binaries/Win64/TS2Prototype.exe");
+ // Two programs named like neither: none is guessed, the launcher stays.
+ fs::remove(root / "WindowsNoEditor/TS2Prototype/Binaries/Win64/TS2Prototype.exe");
+ WritePe(root / "WindowsNoEditor/TS2Prototype/Binaries/Win64/Other.exe", {true, {"KERNEL32.dll"}});
+ CHECK(UnrealGameProgram(root.string(), "WindowsNoEditor/WondersOfSodor.exe").empty());
+ // A Shipping program anywhere wins over a program named otherwise.
+ WritePe(root / "WindowsNoEditor/Other/Binaries/Win64/Other-Win64-Shipping.exe", {true, {"KERNEL32.dll"}});
+ CHECK(UnrealGameProgram(root.string(), "WindowsNoEditor/WondersOfSodor.exe") ==
+ "WindowsNoEditor/Other/Binaries/Win64/Other-Win64-Shipping.exe");
+ // The Shipping program itself and an installer beside Engine are not launchers.
+ CHECK(UnrealGameProgram(root.string(), "WindowsNoEditor/Other/Binaries/Win64/Other-Win64-Shipping.exe").empty());
+ WritePe(root / "WindowsNoEditor/UE4PrereqSetup_x64.exe", {true, {"KERNEL32.dll"}});
+ CHECK(UnrealGameProgram(root.string(), "WindowsNoEditor/UE4PrereqSetup_x64.exe").empty());
+ }
+ { // Satisfactory (Epic): the root FactoryGameEGS.exe starts FactoryGame/Binaries/Win64/*-Shipping.exe.
+ const auto root = fresh();
+ WritePe(root / "FactoryGameEGS.exe", {true, {"KERNEL32.dll"}});
+ WritePe(root / "Engine/Binaries/Win64/CrashReportClient.exe", {true, {"KERNEL32.dll"}});
+ WritePe(root / "FactoryGame/Binaries/Win64/FactoryGameEGS-Win64-Shipping.exe", {true, {"d3d11.dll", "d3d12.dll"}});
+ CHECK(UnrealGameProgram(root.string(), "FactoryGameEGS.exe") ==
+ "FactoryGame/Binaries/Win64/FactoryGameEGS-Win64-Shipping.exe");
+ // Unreal 3 keeps its own program in Binaries/Win64 at the root: it is not a project folder.
+ const auto udk = fresh();
+ WritePe(udk / "Launcher.exe", {true, {"KERNEL32.dll"}});
+ fs::create_directories(udk / "Engine");
+ WritePe(udk / "Binaries/Win64/UDK.exe", {true, {"KERNEL32.dll"}});
+ CHECK(UnrealGameProgram(udk.string(), "Launcher.exe").empty());
+ // The same under a folder of its own: that folder is not a project either.
+ const auto wrapped = fresh();
+ WritePe(wrapped / "Package/Launcher.exe", {true, {"KERNEL32.dll"}});
+ fs::create_directories(wrapped / "Package/Engine");
+ WritePe(wrapped / "Package/Binaries/Win64/UDK.exe", {true, {"KERNEL32.dll"}});
+ CHECK(UnrealGameProgram(wrapped.string(), "Package/Launcher.exe").empty());
+ // A Unity game beside an Engine folder is Unity's, as ProbeGame decides.
+ const auto unity = fresh();
+ WritePe(unity / "Game.exe", {true, {"KERNEL32.dll"}});
+ fs::create_directories(unity / "Game_Data");
+ fs::create_directories(unity / "Engine");
+ WritePe(unity / "Bonus/Binaries/Win64/Bonus-Win64-Shipping.exe", {true, {"KERNEL32.dll"}});
+ CHECK(UnrealGameProgram(unity.string(), "Game.exe").empty() && ProbeGame(unity.string(), "Game.exe").engine == "unity");
+ }
{ // Generated recipes: DXVK through overrides that follow the graphics value; graphics is open.
const auto root = fresh();
WritePe(root / "Balls.exe", {true, {"UnityPlayer.dll"}});
diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cpp
index ab0d4d3..4e40afc 100644
--- a/tests/game_settings_test.cpp
+++ b/tests/game_settings_test.cpp
@@ -1592,6 +1592,54 @@ int main(int argc, char** argv) {
CHECK(PointBottleAtKitMono(mono_template.string(), mono_bottle.string(), 1791600000, &changed, &reason) && !changed);
}
+ // Unreal's root launcher checks the Visual C++ runtime key: it is raised to the kit's builtin DLLs (14.50.35719.0)
+ // in both views, keeping the other values; a key a redistributable raised further is kept, and a bottle not made
+ // yet is left for later.
+ {
+ const auto vc_bottle = root / "vc-bottle";
+ std::filesystem::create_directories(vc_bottle);
+ std::filesystem::permissions(vc_bottle, std::filesystem::perms::owner_all);
+ const std::string head = "WINE REGISTRY Version 2\n;; All keys relative to \\\\Machine\n\n#arch=win64\n\n";
+ const auto runtime = [](const std::string& view, const std::string& arch, const std::string& minor,
+ const std::string& build, const std::string& version) {
+ return "[Software\\\\" + view + "Microsoft\\\\VisualStudio\\\\14.0\\\\VC\\\\Runtimes\\\\" + arch +
+ "] 1791500000\n#time=1dc2b\n\"Bld\"=dword:" + build + "\n\"Installed\"=dword:00000001\n" +
+ "\"Major\"=dword:0000000e\n\"Minor\"=dword:" + minor + "\n\"Rbld\"=dword:00000000\n\"Version\"=\"" + version +
+ "\"\n\n";
+ };
+ const auto old_runtime = [&](const std::string& view, const std::string& arch) {
+ return runtime(view, arch, "0000002a", "00008681", "14.42.34433.0");
+ };
+ const auto new_runtime = [&](const std::string& view, const std::string& arch) {
+ return runtime(view, arch, "00000032", "00008b87", "14.50.35719.0");
+ };
+ const std::string wbem = "[Software\\\\Microsoft\\\\WBEM] 1791500000\n\"Installation Directory\"=\"C:\\\\windows\\\\system32\\\\wbem\"\n\n";
+ const auto write_hive = [&](const std::string& text) {
+ std::ofstream(vc_bottle / "system.reg", std::ios::trunc) << text;
+ ::chmod((vc_bottle / "system.reg").c_str(), 0600);
+ };
+ write_hive(head + old_runtime("", "x64") + wbem + old_runtime("Wow6432Node\\\\", "x64") +
+ old_runtime("Wow6432Node\\\\", "x86"));
+ bool changed = false;
+ CHECK(RaiseVcRuntimeVersion(vc_bottle.string(), 1791600000, &changed, &reason) && changed);
+ const auto raised = head + new_runtime("", "x64") + wbem + new_runtime("Wow6432Node\\\\", "x64") +
+ new_runtime("Wow6432Node\\\\", "x86");
+ CHECK(ReadText(vc_bottle / "system.reg") == raised);
+ CHECK(ReadText(vc_bottle / "system.reg.playden-backup").find("14.42.34433.0") != std::string::npos);
+ CHECK(RaiseVcRuntimeVersion(vc_bottle.string(), 1791600000, &changed, &reason) && !changed);
+ CHECK(ReadText(vc_bottle / "system.reg") == raised);
+ // A later runtime stays; a missing view is added.
+ const auto later = runtime("", "x64", "00000033", "00000001", "14.51.1.0");
+ write_hive(head + later + wbem);
+ CHECK(RaiseVcRuntimeVersion(vc_bottle.string(), 1791600000, &changed, &reason) && changed);
+ const auto partial = ReadText(vc_bottle / "system.reg");
+ CHECK(partial.find(later) == head.size() && partial.find("14.51.1.0") != std::string::npos);
+ CHECK(partial.find("[Software\\\\Wow6432Node\\\\Microsoft\\\\VisualStudio\\\\14.0\\\\VC\\\\Runtimes\\\\x86]") !=
+ std::string::npos);
+ CHECK(partial.find("\"Version\"=\"14.50.35719.0\"") != std::string::npos);
+ CHECK(RaiseVcRuntimeVersion((root / "vc-no-bottle").string(), 1791600000, &changed, &reason) && !changed);
+ }
+
// vkd3d-proton's DLLs go into both windows folders of the bottle and come out again, replaced by the template's,
// without touching a bottle whose files were never vkd3d-proton's.
{
diff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cpp
index c22a9a3..e7d7a54 100644
--- a/tests/homebrew_runtime_host_test.cpp
+++ b/tests/homebrew_runtime_host_test.cpp
@@ -1257,7 +1257,9 @@ void PlaysReadyTitleThroughHandoff() {
const auto upgraded_hive = Read(hive);
CHECK(upgraded_hive.find("@=\"winegstreamer.dll\"") != std::string::npos &&
upgraded_hive.find("Wow6432Node") != std::string::npos);
- CHECK(Read(hive.string() + ".playden-backup") == "WINE REGISTRY Version 2\n");
+ // The backup is the hive before the merge: the Visual C++ runtime key the preparation wrote, no media values.
+ const auto media_backup = Read(hive.string() + ".playden-backup");
+ CHECK(media_backup.find("winegstreamer") == std::string::npos && media_backup.find("14.50.35719.0") != std::string::npos);
CHECK(Read(windows / "system32/winegstreamer.dll") == "dll x86_64-windows");
CHECK(Read(windows / "syswow64/winegstreamer.dll") == "dll i386-windows");
CHECK(prepared.launch && prepared.launch->runtime_number == 220 && prepared.launch->title_id == "FAKE78001");
@@ -3648,7 +3650,11 @@ void PreparesUdkGameWithEulaAccepted() {
const auto system_reg = Read(bottle / "system.reg");
CHECK(system_reg.find("[Software\\\\" + key) != std::string::npos);
CHECK(system_reg.find("[Software\\\\Wow6432Node\\\\" + key) != std::string::npos);
- CHECK(Read(bottle / "system.reg.playden-backup") == "WINE REGISTRY Version 2\n");
+ // The Visual C++ runtime key follows (VcRuntimeStep), so the backup is the hive with the EULA already in it.
+ CHECK(system_reg.find("[Software\\\\Microsoft\\\\VisualStudio\\\\14.0\\\\VC\\\\Runtimes\\\\x64]") != std::string::npos);
+ CHECK(system_reg.find("\"Version\"=\"14.50.35719.0\"") != std::string::npos);
+ CHECK(Read(bottle / "system.reg.playden-backup").find("[Software\\\\" + key) != std::string::npos);
+ CHECK(Read(bottle / "system.reg.playden-backup").find("VisualStudio") == std::string::npos);
auto logged = eula_lines();
CHECK(!logged.empty() && logged.front() == "ue3 eula app=219890 guid=dcf140f3-829e-4033-950d-b3be8d76b933 written=1");
@@ -4122,7 +4128,10 @@ void PrepareThenMoveGames(Fixture& fixture, const RuntimeHostConfig& config, Gam
CHECK(chmod((old_games / "220").c_str(), 0755) == 0);
Write(old_games / "220/installscript.vdf",
"\"InstallScript\"\n{\n \"Registry\"\n {\n \"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Valve\\\\HL2\"\n {\n"
- " \"string\"\n {\n \"Installed Path\" \"%INSTALLDIR%\\\\\"\n }\n }\n }\n}\n", 0644);
+ " \"string\"\n {\n \"Installed Path\" \"%INSTALLDIR%\\\\\"\n }\n }\n"
+ // A redistributable's older Visual C++ runtime key: the runtime key step runs after it and raises it.
+ " \"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\VisualStudio\\\\14.0\\\\VC\\\\Runtimes\\\\x64\"\n {\n"
+ " \"dword\"\n {\n \"Minor\" \"20\"\n }\n }\n }\n}\n", 0644);
{
RuntimeHost host(config);
CHECK(host.Start());
@@ -4243,6 +4252,9 @@ void CheckRepublishedAtNewRoot(Fixture& fixture) {
// The install script's path follows the folder (ApplyPreparationSteps runs in the republication).
const auto system_reg = Read(fixture.root / "data/playden/games/steam-220/library/prefixes/game/system.reg");
CHECK(system_reg.find("playden-games\\\\220") != std::string::npos && system_reg.find("FAKE77031") == std::string::npos);
+ // The install script's older Visual C++ runtime Minor (20) was raised to the builtin DLLs' 14.50 after it.
+ CHECK(system_reg.find("\"Minor\"=dword:00000032") != std::string::npos &&
+ system_reg.find("\"Minor\"=dword:00000014") == std::string::npos);
}
void MigrationRewritesInstallPathsAndRepublishes() {
diff --git a/tests/local_copy_test.cpp b/tests/local_copy_test.cpp
index f3d6c9e..5ce03ea 100644
--- a/tests/local_copy_test.cpp
+++ b/tests/local_copy_test.cpp
@@ -101,6 +101,7 @@ struct Fixture {
int next_id = 0;
std::atomic<bool> usb_present{true}; // the source drive
std::vector<InstallVolume> extra_volumes; // install volumes after the console storage
+ std::function<std::string(const std::string&, const std::string&)> game_program; // LocalLibraryConfig::game_program
Fixture() {
char name[] = "/tmp/playden-local-copy-XXXXXX";
@@ -151,6 +152,7 @@ struct Fixture {
return runner->Move(*service, entry, from, number);
};
config.remove_copy_folder = [this](const std::string& folder) { return runner->Remove(folder).empty(); };
+ config.game_program = game_program;
local = std::make_unique<LocalLibrarySource>(*store, std::move(config));
runner->SetChanged([source = local.get()] { source->Reload(); });
WaitFor([&] { return local->Snapshot()->loaded || !local->Snapshot()->load_error.empty(); }, "imports loaded");
@@ -695,6 +697,27 @@ void ProgramMissingIsRefused() {
CHECK(fixture.State() == ImportState::kInPlace && !fs::exists(fixture.Dest()));
}
+// An Unreal root launcher chosen at Add is replaced by the program it starts (LocalLibraryConfig::game_program),
+// when that one is in the folder; otherwise the chosen program is kept.
+void AddReplacesUnrealLauncher() {
+ for (const bool present : {true, false}) {
+ Fixture fixture;
+ if (present) Write(fixture.source / "Rally/Binaries/Win64/Rally-Win64-Shipping.exe", "x");
+ std::string asked_folder, asked_program;
+ fixture.game_program = [&](const std::string& folder, const std::string& program) {
+ asked_folder = folder;
+ asked_program = program;
+ return std::string("Rally/Binaries/Win64/Rally-Win64-Shipping.exe");
+ };
+ fixture.Start();
+ const auto request = fixture.local->Add("usb0", "playden/import/Rally", "Bin/Rally.exe");
+ CHECK(fixture.Outcome(request).ok);
+ CHECK(asked_folder == fixture.source.string() && asked_program == "Bin/Rally.exe");
+ const auto entry = fixture.store->Find(kId);
+ CHECK(entry && entry->program == (present ? "Rally/Binaries/Win64/Rally-Win64-Shipping.exe" : "Bin/Rally.exe"));
+ }
+}
+
// The copy lives on Playden's storage: it uninstalls, and its game leaves the library, while the
// drive it was copied from is unplugged.
void UninstallWithoutTheSourceDrive() {
@@ -1146,6 +1169,7 @@ int main() {
CancelLeavesNothing();
ChangedSourceFails();
ProgramMissingIsRefused();
+ AddReplacesUnrealLauncher();
CrashBetweenCommitSteps();
ReconcileWithoutJob();
OrphanCopyFoldersRemoved();