Play your Steam library's Windows games on a jailbroken PS5.
C++
Read install scripts that carry Steam's signature block
Leonardo Lobato27011a638c72
diff --git a/src/runtime/install_script.cpp b/src/runtime/install_script.cppindex cd702c2..1fcef5a 100644--- a/src/runtime/install_script.cpp+++ b/src/runtime/install_script.cpp@@ -84,6 +84,14 @@ std::string RegistryString(std::string_view text) {return out + "\"";}+// The top level is "InstallScript" { ... } (any case), often followed by Steam's "kvsignatures"+// block; a lone section of another name or a bare section list is read the same way.+const steam::VdfNode* ScriptSection(const steam::VdfNode& root) {+ if (const auto* script = root.Find("InstallScript"); script && script->is_dict) return script;+ if (root.children.size() == 1 && root.children.front().second.is_dict) return &root.children.front().second;+ return &root;+}+bool ReadScript(const std::filesystem::path& path, std::string* text) {const int file = ::open(path.c_str(), O_RDONLY | O_NOFOLLOW | O_CLOEXEC);if (file < 0) return false;@@ -112,10 +120,7 @@ bool ParseInstallScript(std::string_view text, const std::string& install_dir, Iwhile (!utf8.empty() && utf8.back() == '\0') utf8.pop_back();const auto root = steam::ParseVdf(utf8);if (!root) return fail("not a valid install script");- // The top level is "InstallScript" { ... } (any case); a bare section list is read the same way.- const steam::VdfNode* script = root->children.size() == 1 && root->children.front().second.is_dict- ? &root->children.front().second- : &*root;+ const auto* script = ScriptSection(*root);const auto* registry = script->Find("Registry");if (!registry) return true;for (const auto& [path, key] : registry->children) {@@ -168,9 +173,7 @@ bool ParseRunProcess(std::string_view text, const std::string& install_dir, std:while (!utf8.empty() && utf8.back() == '\0') utf8.pop_back();const auto root = steam::ParseVdf(utf8);if (!root) return fail("not a valid install script");- const steam::VdfNode* script = root->children.size() == 1 && root->children.front().second.is_dict- ? &root->children.front().second- : &*root;+ const auto* script = ScriptSection(*root);const auto* run = script->Find("Run Process");if (!run) return true;for (const auto& [name, node] : run->children) {diff --git a/tests/runtime_redist_test.cpp b/tests/runtime_redist_test.cppindex 56ba060..3fb20e6 100644--- a/tests/runtime_redist_test.cpp+++ b/tests/runtime_redist_test.cpp@@ -448,7 +448,8 @@ void TestScripts() {"\t\t\t\"command 1\"\t\t\"/i \\\"%INSTALLDIR%\\\\_CommonRedist\\\\PhysX\\\\9.13.0604\\\\PhysX.msi\\\" /quiet /norestart\"\n""\t\t}\n\t\t\"DirectX\"\n\t\t{\n\t\t\t\"process 1\"\t\"%INSTALLDIR%\\\\DirectX\\\\DXSETUP.exe\"\n\t\t}\n""\t\t\"Launcher\"\n\t\t{\n\t\t\t\"process 1\"\t\"%INSTALLDIR%\\\\Setup.exe\"\n\t\t}\n"- "\t\t\"Lang\"\n\t\t{\n\t\t\t\"process 1\"\t\"%LANGUAGE%.exe\"\n\t\t}\n\t}\n}\n";+ "\t\t\"Lang\"\n\t\t{\n\t\t\t\"process 1\"\t\"%LANGUAGE%.exe\"\n\t\t}\n\t}\n}\n"+ "\"kvsignatures\"\n{\n\t\"InstallScript\"\t\t\"8ed8c256\"\n}\n";std::vector<RedistEntry> entries;std::string reason;CHECK(ParseRunProcess(script, "Z:\\data\\games\\696180", &entries, &reason));@@ -466,6 +467,12 @@ void TestScripts() {CHECK(ClassifyRedist(outside, "Z:\\data\\games\\696180", &package) == RedistAction::kNotRun);RedistEntry climbing{"X", "msiexec", "/i Z:\\data\\games\\696180\\..\\x.msi", ""};CHECK(ClassifyRedist(climbing, "Z:\\data\\games\\696180", &package) == RedistAction::kNotRun);+ // Steam's signature block after the script doesn't hide its sections.+ InstallScriptValues values;+ CHECK(ParseInstallScript("\"InstallScript\" { \"Registry\" { \"HKEY_LOCAL_MACHINE\\\\Software\\\\Studio\" { \"string\" { "+ "\"Path\" \"%INSTALLDIR%\" } } } } \"kvsignatures\" { \"InstallScript\" \"00\" }",+ "Z:\\games\\1", &values, &reason));+ CHECK(values.machine.size() == 2);RedistEntry direct{"X", "Z:\\data\\games\\696180\\redist\\x.msi", "", ""};CHECK(ClassifyRedist(direct, "Z:\\data\\games\\696180", &package) == RedistAction::kMsi && package == "redist/x.msi");}@@ -480,7 +487,8 @@ void TestInstall() {"\"HasRunKey\" \"HKEY_LOCAL_MACHINE\\\\Software\\\\Valve\\\\Steam\\\\Apps\\\\42\" ""\"process 1\" \"msiexec\" ""\"command 1\" \"/i \\\"%INSTALLDIR%\\\\_CommonRedist\\\\Sample\\\\1.0\\\\sample.msi\\\" /quiet\" } "- "\"VC\" { \"process 1\" \"%INSTALLDIR%\\\\_CommonRedist\\\\vcredist_x86.exe\" } } }");+ "\"VC\" { \"process 1\" \"%INSTALLDIR%\\\\_CommonRedist\\\\vcredist_x86.exe\" } } } "+ "\"kvsignatures\" { \"InstallScript\" \"00\" }");WriteText(game / "_CommonRedist/Sample/1.0/sample.msi", SamplePackage());WriteText(game / "data/deep/installscript.vdf", "\"InstallScript\" { \"Run Process\" { \"Ignored\" { \"process 1\" \"x.exe\" } } }");WriteText(prefix / "system.reg",