summaryrefslogtreecommitdiffstats
path: root/src/core/loader/ncch.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/loader/ncch.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 87603d198..2bf1a6a26 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -299,7 +299,7 @@ ResultStatus AppLoader_NCCH::ReadLogo(std::vector<u8>& buffer) const {
return LoadSectionExeFS("logo", buffer);
}
-ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const {
+ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, u64& size) const {
if (!file->IsOpen())
return ResultStatus::Error;
@@ -311,12 +311,17 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const {
LOG_DEBUG(Loader, "RomFS offset: 0x%08X", romfs_offset);
LOG_DEBUG(Loader, "RomFS size: 0x%08X", romfs_size);
- buffer.resize(romfs_size);
+ if (file->GetSize () < romfs_offset + romfs_size)
+ return ResultStatus::Error;
- file->Seek(romfs_offset, SEEK_SET);
- if (file->ReadBytes(&buffer[0], romfs_size) != romfs_size)
+ // We reopen the file, to allow its position to be independent from file's
+ romfs_file = std::make_shared<FileUtil::IOFile>(filepath, "rb");
+ if (!romfs_file->IsOpen())
return ResultStatus::Error;
+ offset = romfs_offset;
+ size = romfs_size;
+
return ResultStatus::Success;
}
LOG_DEBUG(Loader, "NCCH has no RomFS");