Skip to content

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

C++

Install without a borrowed depot whose key the account is refused

Leonardo Lobato156d09b9cec6
diff --git a/src/steam/backend/cm_client.cpp b/src/steam/backend/cm_client.cpp
index 61640e7..5e15f80 100644
--- a/src/steam/backend/cm_client.cpp
+++ b/src/steam/backend/cm_client.cpp
@@ -811,6 +811,10 @@ DepotAccessResult CmClient::FetchDepotAccess(const StoredSession& stored, std::u
return finish(call);
cm::DepotKeyResponse key;
if (!cm::DecodeDepotKeyResponse(reply, &key)) return finish(CmError::kProtocol);
+ if (key.eresult == cm::kEResultAccessDenied && depot.optional) {
+ result.skipped.push_back(depot.depot_id);
+ continue;
+ }
if (key.eresult != cm::kEResultOk) {
result.detail = "depot key refused eresult=" + std::to_string(key.eresult);
return finish(CmError::kRejected);
diff --git a/src/steam/backend/cm_client.h b/src/steam/backend/cm_client.h
index 10b8cf1..c5e6067 100644
--- a/src/steam/backend/cm_client.h
+++ b/src/steam/backend/cm_client.h
@@ -75,6 +75,9 @@ struct AppInfoBuffers {
struct DepotRequest {
std::uint32_t depot_id = 0;
std::uint64_t manifest_gid = 0;
+ // A depot the game borrows from another app (depotfromapp): an account that doesn't own that app is
+ // refused its key, and the game installs without it.
+ bool optional = false;
};
struct DepotGrant {
std::uint32_t depot_id = 0;
@@ -84,7 +87,8 @@ struct DepotGrant {
};
struct DepotAccessResult {
CmError error = CmError::kProtocol;
- std::vector<DepotGrant> grants; // one per requested depot, in request order
+ std::vector<DepotGrant> grants; // one per requested depot, in request order, except skipped ones
+ std::vector<std::uint32_t> skipped; // optional depots whose key the account was refused
std::string detail; // which step refused, with Steam's result code
bool ok() const { return error == CmError::kNone; }
};
diff --git a/src/steam/backend/depot_installer.cpp b/src/steam/backend/depot_installer.cpp
index 764e37d..b83f847 100644
--- a/src/steam/backend/depot_installer.cpp
+++ b/src/steam/backend/depot_installer.cpp
@@ -335,7 +335,7 @@ InstallOutcome DepotInstaller::Run(const StoredSession& session, const InstallTa
std::vector<DepotRequest> requests;
for (const auto& depot : target.depots) {
if (!depot.manifest_gid || *depot.manifest_gid == 0) return fail(InstallError::kProtocol, "depot without manifest");
- requests.push_back({depot.id, *depot.manifest_gid});
+ requests.push_back({depot.id, *depot.manifest_gid, depot.depot_from_app.has_value()});
}
const auto access = hooks_.access(session, target.app_id, requests, cancel);
if (!access.ok()) {
@@ -343,7 +343,9 @@ InstallOutcome DepotInstaller::Run(const StoredSession& session, const InstallTa
outcome.detail = access.detail.empty() ? "depot access failed" : access.detail;
return outcome;
}
- if (access.grants.size() != requests.size()) return fail(InstallError::kProtocol, "incomplete depot access");
+ if (access.grants.empty() || access.grants.size() + access.skipped.size() != requests.size())
+ return fail(InstallError::kProtocol, "incomplete depot access");
+ outcome.skipped_depots = access.skipped;
stats.access_ms = Milliseconds(Clock::now() - phase_start);
phase_start = Clock::now();
diff --git a/src/steam/backend/depot_installer.h b/src/steam/backend/depot_installer.h
index fffb8a3..0fd7d7e 100644
--- a/src/steam/backend/depot_installer.h
+++ b/src/steam/backend/depot_installer.h
@@ -67,6 +67,7 @@ struct InstallOutcome {
InstallError error = InstallError::kProtocol;
InstallProgress progress;
std::string detail; // short and identifier-free
+ std::vector<std::uint32_t> skipped_depots; // borrowed depots the account was refused, installed without
};
// Seams for tests; the defaults use CmClient, CdnClient and the real filesystem.
diff --git a/src/steam/backend/steam_install_runner.cpp b/src/steam/backend/steam_install_runner.cpp
index 3365770..0771e43 100644
--- a/src/steam/backend/steam_install_runner.cpp
+++ b/src/steam/backend/steam_install_runner.cpp
@@ -144,12 +144,19 @@ InstallRunner::Result SteamInstallRunner::Install(const StoredSession& session,
const auto outcome = installer_.Run(session, target, cancel, [&](const InstallProgress& state) {
if (progress) progress(state.download_done, state.download_total, state.held_bytes);
});
+ if (!outcome.skipped_depots.empty()) {
+ std::string skipped;
+ for (const auto id : outcome.skipped_depots) skipped += (skipped.empty() ? "" : " ") + std::to_string(id);
+ log("depots", "skipped", ("borrowed-refused=" + skipped).c_str());
+ }
log("install", InstallErrorName(outcome.error), outcome.detail.c_str());
result.ok = outcome.error == InstallError::kNone;
if (result.ok) {
// What the Steamworks emulator needs later, while the licenses are at hand: installed depots and owned DLC.
std::vector<std::uint32_t> depots, dlc;
- for (const auto& depot : target.depots) depots.push_back(depot.id);
+ for (const auto& depot : target.depots)
+ if (std::find(outcome.skipped_depots.begin(), outcome.skipped_depots.end(), depot.id) == outcome.skipped_depots.end())
+ depots.push_back(depot.id);
for (const auto app_id : app->dlc_app_ids)
if (entitlements.owned_apps.count(app_id)) dlc.push_back(app_id);
if (!runtime::WriteSteamworksFacts(root, depots, dlc)) log("steamworks_facts", "write-failed", root.c_str());
diff --git a/tests/cm_client_test.cpp b/tests/cm_client_test.cpp
index 3de3ba3..2a40d7b 100644
--- a/tests/cm_client_test.cpp
+++ b/tests/cm_client_test.cpp
@@ -729,6 +729,10 @@ void DepotAccessReturnsKeysAndManifestCodes() {
}
auto refused = MakeClient(DepotScript(cm::kEResultAccessDenied, 1));
assert(refused.FetchDepotAccess(Session(), 440, {{441, 11}}, cancel).error == CmError::kRejected);
+ // A depot borrowed from another app the account doesn't own is skipped, not a refusal (Slay the Spire's 877621).
+ auto borrowed = MakeClient(DepotScript(cm::kEResultAccessDenied, 1));
+ const auto skipped = borrowed.FetchDepotAccess(Session(), 440, {{441, 11, true}}, cancel);
+ assert(skipped.ok() && skipped.grants.empty() && skipped.skipped == std::vector<std::uint32_t>{441});
auto no_code = MakeClient(DepotScript(cm::kEResultOk, 0));
assert(no_code.FetchDepotAccess(Session(), 440, {{441, 11}}, cancel).error == CmError::kRejected);
}
diff --git a/tests/depot_installer_test.cpp b/tests/depot_installer_test.cpp
index 419694d..e312e4b 100644
--- a/tests/depot_installer_test.cpp
+++ b/tests/depot_installer_test.cpp
@@ -507,6 +507,35 @@ void ParallelMergedAndFullyResumed(const std::filesystem::path& root) {
CHECK(Read(resumed / "game.exe") == "MZ-executable-second-chunk");
}
+// A depot borrowed from another app the account doesn't own: its key is refused, and the game installs without it.
+void BorrowedDepotRefusedIsSkipped(const std::filesystem::path& root) {
+ auto world = MakeWorld();
+ auto hooks = world.Hooks();
+ bool asked_optional = false;
+ hooks.access = [&](const StoredSession&, std::uint32_t, const std::vector<DepotRequest>& depots,
+ const std::atomic<bool>&) {
+ DepotAccessResult result;
+ result.error = CmError::kNone;
+ for (const auto& depot : depots) {
+ if (depot.optional) {
+ asked_optional = true;
+ result.skipped.push_back(depot.depot_id);
+ continue;
+ }
+ result.grants.push_back({depot.depot_id, depot.manifest_gid, kKey, 77});
+ }
+ return result;
+ };
+ DepotInstaller installer(hooks);
+ std::atomic<bool> cancel{false};
+ auto target = Target(root);
+ target.depots[1].depot_from_app = 877620;
+ const auto outcome = installer.Run({}, target, cancel);
+ CHECK(outcome.error == InstallError::kNone && asked_optional);
+ CHECK(outcome.skipped_depots == std::vector<std::uint32_t>{442});
+ CHECK(Read(root / "data/level.dat") == "level-one");
+}
+
void TuningFileDefaultsAndValidation(const std::filesystem::path& root) {
std::filesystem::create_directories(root);
const auto path = (root / "tuning").string();
@@ -981,6 +1010,7 @@ int main() {
FileCreationAheadIsBounded(base / "ahead");
TuningFileDefaultsAndValidation(base / "tuning");
ParallelMergedAndFullyResumed(base / "parallel-merged");
+ BorrowedDepotRefusedIsSkipped(base / "borrowed-depot");
CountsActualUsefulCompressedBytes(base / "actual-compressed");
StorageFailureEndsStats(base / "storage-stats");
StatsAndRemovalLogs(base / "removal");