summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/loader/3dsx.cpp3
-rw-r--r--src/core/loader/elf.cpp3
-rw-r--r--src/core/loader/ncch.cpp11
3 files changed, 13 insertions, 4 deletions
diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp
index 873ee8b25..e239808f3 100644
--- a/src/core/loader/3dsx.cpp
+++ b/src/core/loader/3dsx.cpp
@@ -100,6 +100,9 @@ static THREEDSX_Error Load3DSXFile(FileUtil::IOFile& file, u32 base_addr)
if (!file.IsOpen())
return ERROR_FILE;
+ // Reset read pointer in case this file has been read before.
+ file.Seek(0, SEEK_SET);
+
THREEDSX_Header hdr;
if (file.ReadBytes(&hdr, sizeof(hdr)) != sizeof(hdr))
return ERROR_READ;
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index d1a1ef595..712d564d1 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -337,6 +337,9 @@ ResultStatus AppLoader_ELF::Load() {
if (!file->IsOpen())
return ResultStatus::Error;
+ // Reset read pointer in case this file has been read before.
+ file->Seek(0, SEEK_SET);
+
u32 size = static_cast<u32>(file->GetSize());
std::unique_ptr<u8[]> buffer(new u8[size]);
file->ReadBytes(&buffer[0], size);
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index eca57d14b..edf53c2c0 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -125,7 +125,7 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>&
s64 section_offset = (exefs_header.section[i].offset + exefs_offset +
sizeof(ExeFs_Header)+ncch_offset);
- file->Seek(section_offset, 0);
+ file->Seek(section_offset, SEEK_SET);
// Section is compressed...
if (i == 0 && is_compressed) {
@@ -165,13 +165,16 @@ ResultStatus AppLoader_NCCH::Load() {
if (!file->IsOpen())
return ResultStatus::Error;
+ // Reset read pointer in case this file has been read before.
+ file->Seek(0, SEEK_SET);
+
file->ReadBytes(&ncch_header, sizeof(NCCH_Header));
// Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)...
if (0 == memcmp(&ncch_header.magic, "NCSD", 4)) {
LOG_WARNING(Loader, "Only loading the first (bootable) NCCH within the NCSD file!");
ncch_offset = 0x4000;
- file->Seek(ncch_offset, 0);
+ file->Seek(ncch_offset, SEEK_SET);
file->ReadBytes(&ncch_header, sizeof(NCCH_Header));
}
@@ -198,7 +201,7 @@ ResultStatus AppLoader_NCCH::Load() {
LOG_DEBUG(Loader, "ExeFS offset: 0x%08X", exefs_offset);
LOG_DEBUG(Loader, "ExeFS size: 0x%08X", exefs_size);
- file->Seek(exefs_offset + ncch_offset, 0);
+ file->Seek(exefs_offset + ncch_offset, SEEK_SET);
file->ReadBytes(&exefs_header, sizeof(ExeFs_Header));
LoadExec(); // Load the executable into memory for booting
@@ -238,7 +241,7 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const {
buffer.resize(romfs_size);
- file->Seek(romfs_offset, 0);
+ file->Seek(romfs_offset, SEEK_SET);
file->ReadBytes(&buffer[0], romfs_size);
return ResultStatus::Success;