diff options
| author | 2015-01-06 22:47:43 +0000 | |
|---|---|---|
| committer | 2015-01-15 22:23:07 +0100 | |
| commit | 04622a859cc748745cbbeb0b332f930085438077 (patch) | |
| tree | 3aaf5244552971eb47bbbc8319f06fe4834f1460 /src/core/loader/ncch.cpp | |
| parent | Loader: Keep a reference to the file and pass it to the correct AppLoader, in... (diff) | |
| download | yuzu-04622a859cc748745cbbeb0b332f930085438077.tar.gz yuzu-04622a859cc748745cbbeb0b332f930085438077.tar.xz yuzu-04622a859cc748745cbbeb0b332f930085438077.zip | |
Loader: Don’t assume the file hasn’t been read before.
Diffstat (limited to 'src/core/loader/ncch.cpp')
| -rw-r--r-- | src/core/loader/ncch.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
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>& | |||
| 125 | 125 | ||
| 126 | s64 section_offset = (exefs_header.section[i].offset + exefs_offset + | 126 | s64 section_offset = (exefs_header.section[i].offset + exefs_offset + |
| 127 | sizeof(ExeFs_Header)+ncch_offset); | 127 | sizeof(ExeFs_Header)+ncch_offset); |
| 128 | file->Seek(section_offset, 0); | 128 | file->Seek(section_offset, SEEK_SET); |
| 129 | 129 | ||
| 130 | // Section is compressed... | 130 | // Section is compressed... |
| 131 | if (i == 0 && is_compressed) { | 131 | if (i == 0 && is_compressed) { |
| @@ -165,13 +165,16 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 165 | if (!file->IsOpen()) | 165 | if (!file->IsOpen()) |
| 166 | return ResultStatus::Error; | 166 | return ResultStatus::Error; |
| 167 | 167 | ||
| 168 | // Reset read pointer in case this file has been read before. | ||
| 169 | file->Seek(0, SEEK_SET); | ||
| 170 | |||
| 168 | file->ReadBytes(&ncch_header, sizeof(NCCH_Header)); | 171 | file->ReadBytes(&ncch_header, sizeof(NCCH_Header)); |
| 169 | 172 | ||
| 170 | // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)... | 173 | // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)... |
| 171 | if (0 == memcmp(&ncch_header.magic, "NCSD", 4)) { | 174 | if (0 == memcmp(&ncch_header.magic, "NCSD", 4)) { |
| 172 | LOG_WARNING(Loader, "Only loading the first (bootable) NCCH within the NCSD file!"); | 175 | LOG_WARNING(Loader, "Only loading the first (bootable) NCCH within the NCSD file!"); |
| 173 | ncch_offset = 0x4000; | 176 | ncch_offset = 0x4000; |
| 174 | file->Seek(ncch_offset, 0); | 177 | file->Seek(ncch_offset, SEEK_SET); |
| 175 | file->ReadBytes(&ncch_header, sizeof(NCCH_Header)); | 178 | file->ReadBytes(&ncch_header, sizeof(NCCH_Header)); |
| 176 | } | 179 | } |
| 177 | 180 | ||
| @@ -198,7 +201,7 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 198 | LOG_DEBUG(Loader, "ExeFS offset: 0x%08X", exefs_offset); | 201 | LOG_DEBUG(Loader, "ExeFS offset: 0x%08X", exefs_offset); |
| 199 | LOG_DEBUG(Loader, "ExeFS size: 0x%08X", exefs_size); | 202 | LOG_DEBUG(Loader, "ExeFS size: 0x%08X", exefs_size); |
| 200 | 203 | ||
| 201 | file->Seek(exefs_offset + ncch_offset, 0); | 204 | file->Seek(exefs_offset + ncch_offset, SEEK_SET); |
| 202 | file->ReadBytes(&exefs_header, sizeof(ExeFs_Header)); | 205 | file->ReadBytes(&exefs_header, sizeof(ExeFs_Header)); |
| 203 | 206 | ||
| 204 | LoadExec(); // Load the executable into memory for booting | 207 | LoadExec(); // Load the executable into memory for booting |
| @@ -238,7 +241,7 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const { | |||
| 238 | 241 | ||
| 239 | buffer.resize(romfs_size); | 242 | buffer.resize(romfs_size); |
| 240 | 243 | ||
| 241 | file->Seek(romfs_offset, 0); | 244 | file->Seek(romfs_offset, SEEK_SET); |
| 242 | file->ReadBytes(&buffer[0], romfs_size); | 245 | file->ReadBytes(&buffer[0], romfs_size); |
| 243 | 246 | ||
| 244 | return ResultStatus::Success; | 247 | return ResultStatus::Success; |