From d037ca1b7b09fb2a892bbf0011fe7e34956275ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Tue, 20 Oct 2026 17:43:14 +0200 Subject: [PATCH] PBPReader: Read part of a subfile GetSubFile() reads a whole subfile, and refuses those over 256MB. ReadSubFile() reads a range of one, for the PSAR of a PS1 EBOOT, which holds its disc image. --- Core/ELF/PBPReader.cpp | 11 +++++++++++ Core/ELF/PBPReader.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/Core/ELF/PBPReader.cpp b/Core/ELF/PBPReader.cpp index 96f9819352..cdcb9c963f 100644 --- a/Core/ELF/PBPReader.cpp +++ b/Core/ELF/PBPReader.cpp @@ -79,6 +79,17 @@ bool PBPReader::GetSubFile(PBPSubFile file, std::vector *out) const { return true; } +bool PBPReader::ReadSubFile(PBPSubFile file, u32 offset, size_t size, void *out) const { + if (!file_) { + return false; + } + const size_t subFileSize = GetSubFileSize(file); + if (offset > subFileSize || size > subFileSize - offset) { + return false; + } + return file_->ReadAt(header_.offsets[(int)file] + offset, size, out) == size; +} + bool PBPReader::GetSubFileAsString(PBPSubFile file, std::string *out) const { if (!file_) { out->clear(); diff --git a/Core/ELF/PBPReader.h b/Core/ELF/PBPReader.h index 8781aa66a7..b11ff11baa 100644 --- a/Core/ELF/PBPReader.h +++ b/Core/ELF/PBPReader.h @@ -53,6 +53,8 @@ public: bool GetSubFile(PBPSubFile file, std::vector *out) const; bool GetSubFileAsString(PBPSubFile file, std::string *out) const; + // Part of a subfile, for the large ones. False if it doesn't lie within it. + bool ReadSubFile(PBPSubFile file, u32 offset, size_t size, void *out) const; size_t GetSubFileSize(PBPSubFile file) const { const int num = (int)file;