aboutsummaryrefslogtreecommitdiff
path: root/src/core/file_sys/ips_layer.cpp
diff options
context:
space:
mode:
authorPavelBARABANOV <pavelbarabanov94@gmail.com>2026-09-23 00:36:47 +0200
committercrueter <crueter@eden-emu.dev>2026-09-23 00:36:47 +0200
commit3266c20e3f27a459449b77214182be3f0332e8f4 (patch)
treef04e763e3cd2907efe2bf2c0ce13691145659d51 /src/core/file_sys/ips_layer.cpp
parent9cd24e85c2c24016cfdba50e3533395561536f7e (diff)
[ips_layer] read magic from IPS file and fix EOF check (#4469)
- [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- PatchIPS was reading the magic bytes from the target file instead of the IPS patch, and IsEOF used a strict > comparison that never matched for 3-byte IPS EOF markers. This caused IPS patches to be silently skipped, breaking the Russian localization mod for Persona 5. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4469 Reviewed-by: lizzie <lizzie@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'src/core/file_sys/ips_layer.cpp')
-rw-r--r--src/core/file_sys/ips_layer.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp
index 5a0ddb44f8..32e9041017 100644
--- a/src/core/file_sys/ips_layer.cpp
+++ b/src/core/file_sys/ips_layer.cpp
@@ -35,19 +35,22 @@ static IPSFileType IdentifyMagic(std::span<const u8> magic) {
}
static bool IsEOF(IPSFileType type, std::span<const u8> magic) {
- return (type == IPSFileType::IPS && magic.size() > 3 && std::memcmp(magic.data(), "EOF", 3) == 0)
- || (type == IPSFileType::IPS32 && magic.size() > 4 && std::memcmp(magic.data(), "EEOF", 4) == 0);
+ return (type == IPSFileType::IPS && magic.size() >= 3 && std::memcmp(magic.data(), "EOF", 3) == 0)
+ || (type == IPSFileType::IPS32 && magic.size() >= 4 && std::memcmp(magic.data(), "EEOF", 4) == 0);
}
VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) {
if (in == nullptr || ips == nullptr)
return nullptr;
- auto in_data = in->ReadAllBytes();
- auto const type = IdentifyMagic(in_data);
+ const auto type = IdentifyMagic(ips->ReadBytes(0x5));
if (type == IPSFileType::Error)
return nullptr;
+ auto in_data = in->ReadAllBytes();
+ if (in_data.size() == 0)
+ return nullptr;
+
std::vector<u8> temp(type == IPSFileType::IPS ? 3 : 4);
u64 offset = 5; // After header
while (ips->Read(temp.data(), temp.size(), offset) == temp.size()) {