mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-19 19:07:48 +02:00
Opening a .pkg now offers to install it, the way a .zip does - see the new InstallPkgScreen, which shows what the update patches, what it'll take up on disk (exact, since package contents aren't compressed) and where it's going. The package's PS3-style USRDIR/CONTENT wrapping is stripped so the files land where the PSP expects them, in PSP/GAME/<DISC_ID>. Booting a disc then looks for PSP/GAME/<DISC_ID>/PBOOT.PBP and boots that instead of the disc's own EBOOT, leaving the disc mounted - so the update overrides the files it ships and the disc supplies the rest. The update's DISC_ID has to match; a DISC_VERSION mismatch only warns, since updates do get used with slightly different dumps in practice. Verified against the whole corpus: every one installs, and the digital NP* update/base-image pairs that could be assembled all boot the patch rather than the disc's executable. That includes Super Robot Taisen Operation Extend from a real NPUMDIMG EBOOT.PBP, which settles that ISO.BIN.EDAT does not re-key the PBOOT - a digital title's patched EBOOT is encrypted exactly like a UMD one. On the UMD side, the patched LittleBigPlanet reads PATCH.ARC out of the install alongside the disc's own archive. The DISC_VERSION warning turns out to be load-bearing: many of the pairs mismatch, because the dumps in circulation are later disc revisions than the updates were built against. docs/pkg_notes.md has the numbers, and the one thing that doesn't work - PGD-wrapped .sprx modules, which sceKernelLoadModuleNpDrm can't load. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
130 lines
4.1 KiB
C++
130 lines
4.1 KiB
C++
// Copyright (c) 2013- PPSSPP Project.
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
// Official git repository and contact information can be found at
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
// Manages the PSP/GAME directory contents.
|
|
//
|
|
// Not concerned with full ISOs.
|
|
|
|
#pragma once
|
|
|
|
#include <thread>
|
|
#include <atomic>
|
|
#include <optional>
|
|
|
|
#include "Common/Net/HTTPClient.h"
|
|
|
|
enum class GameManagerState {
|
|
IDLE,
|
|
DOWNLOADING,
|
|
INSTALLING,
|
|
};
|
|
|
|
struct ZipFileTask {
|
|
std::optional<ZipFileInfo> zipFileInfo;
|
|
Path url; // Same as filename if installing from disk. Probably not really useful.
|
|
Path fileName;
|
|
Path destination; // If set, will override the default destination.
|
|
bool deleteAfter;
|
|
};
|
|
|
|
struct zip;
|
|
class FileLoader;
|
|
class Path;
|
|
struct ZipFileInfo;
|
|
|
|
class GameManager {
|
|
public:
|
|
GameManager();
|
|
|
|
bool IsGameInstalled(const std::string &name);
|
|
|
|
// This starts off a background process.
|
|
bool DownloadAndInstall(const std::string &storeZipUrl);
|
|
bool IsDownloading(const std::string &storeZipUrl);
|
|
|
|
// Cancels the download in progress, if any.
|
|
bool CancelDownload();
|
|
|
|
float DownloadSpeedKBps();
|
|
|
|
// Call from time to time to check on completed downloads from the
|
|
// main UI thread.
|
|
void Update();
|
|
|
|
GameManagerState GetState() {
|
|
if (InstallInProgress() || installDonePending_)
|
|
return GameManagerState::INSTALLING;
|
|
if (curDownload_)
|
|
return GameManagerState::DOWNLOADING;
|
|
return GameManagerState::IDLE;
|
|
}
|
|
|
|
float GetCurrentInstallProgressPercentage() const {
|
|
return installProgress_;
|
|
}
|
|
void ResetInstallError();
|
|
std::string GetInstallError() const {
|
|
return installError_;
|
|
}
|
|
|
|
// Only returns false if there's already an installation in progress.
|
|
bool InstallZipOnThread(ZipFileTask task);
|
|
|
|
// Installs a game update from a .pkg into PSP/GAME/<DISC_ID>. Same contract as the above -
|
|
// only returns false if something else is already installing. See Core/Util/PkgUnpack.h.
|
|
bool InstallPkgOnThread(const Path &pkgPath, bool deleteAfter);
|
|
|
|
// Separate kind of functionality from InstallZipOnThread, so doesn't re-use the task struct.
|
|
bool UninstallGameOnThread(const std::string &name);
|
|
|
|
// Extracts the contents of an open zip archive into dest. Exposed for testing.
|
|
// maxTotalSize limits the total decompressed size (zip bomb protection).
|
|
bool ExtractZipContents(struct zip *z, const Path &dest, const ZipFileInfo &info, bool allowRoot, int64_t maxTotalSize = 0x100000000ULL);
|
|
|
|
private:
|
|
void InstallZipContents(ZipFileTask task);
|
|
void InstallPkgContents(Path pkgPath, bool deleteAfter);
|
|
bool InstallMemstickZip(const Path &zipFile, const Path &dest, const ZipFileInfo &info);
|
|
bool InstallZippedISO(struct zip *z, int isoFileIndex, const Path &destDir);
|
|
void UninstallGame(const std::string &name);
|
|
|
|
void InstallDone();
|
|
|
|
bool ExtractFile(struct zip *z, int file_index, const Path &outFilename, int64_t *bytesCopied, int64_t allBytes, int64_t maxTotalSize = 0x100000000ULL);
|
|
bool DetectTexturePackDest(struct zip *z, int iniIndex, Path &dest);
|
|
void SetInstallError(std::string_view err);
|
|
|
|
bool InstallInProgress() const { return installThread_.joinable(); }
|
|
|
|
Path GetTempFilename() const;
|
|
std::string GetGameID(const Path &path) const;
|
|
std::string GetPBPGameID(FileLoader *loader) const;
|
|
std::string GetISOGameID(FileLoader *loader) const;
|
|
std::shared_ptr<http::Request> curDownload_;
|
|
std::thread installThread_;
|
|
std::atomic<bool> installDonePending_{};
|
|
std::atomic<bool> cleanRecentsAfter_{};
|
|
|
|
float installProgress_ = 0.0f;
|
|
std::string installError_;
|
|
};
|
|
|
|
extern GameManager g_GameManager;
|
|
|
|
bool ZipCanExtractWithoutOverwrite(struct zip *z, const Path &destination, int stripChars, int maxOkFiles);
|