diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/archive_romfs.cpp | 2 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.h | 2 | ||||
| -rw-r--r-- | src/core/loader/3dsx.cpp | 4 | ||||
| -rw-r--r-- | src/core/loader/3dsx.h | 2 | ||||
| -rw-r--r-- | src/core/loader/elf.cpp | 8 | ||||
| -rw-r--r-- | src/core/loader/elf.h | 2 | ||||
| -rw-r--r-- | src/core/loader/loader.cpp | 6 | ||||
| -rw-r--r-- | src/core/loader/loader.h | 16 | ||||
| -rw-r--r-- | src/core/loader/ncch.cpp | 42 | ||||
| -rw-r--r-- | src/core/loader/ncch.h | 16 |
10 files changed, 50 insertions, 50 deletions
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index b792b1c8c..696b51a94 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | namespace FileSys { | 18 | namespace FileSys { |
| 19 | 19 | ||
| 20 | ArchiveFactory_RomFS::ArchiveFactory_RomFS(const Loader::AppLoader& app_loader) { | 20 | ArchiveFactory_RomFS::ArchiveFactory_RomFS(Loader::AppLoader& app_loader) { |
| 21 | // Load the RomFS from the app | 21 | // Load the RomFS from the app |
| 22 | if (Loader::ResultStatus::Success != app_loader.ReadRomFS(romfs_file, data_offset, data_size)) { | 22 | if (Loader::ResultStatus::Success != app_loader.ReadRomFS(romfs_file, data_offset, data_size)) { |
| 23 | LOG_ERROR(Service_FS, "Unable to read RomFS!"); | 23 | LOG_ERROR(Service_FS, "Unable to read RomFS!"); |
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h index 0ef67c557..2bedfa9c6 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h | |||
| @@ -22,7 +22,7 @@ namespace FileSys { | |||
| 22 | /// File system interface to the RomFS archive | 22 | /// File system interface to the RomFS archive |
| 23 | class ArchiveFactory_RomFS final : public ArchiveFactory { | 23 | class ArchiveFactory_RomFS final : public ArchiveFactory { |
| 24 | public: | 24 | public: |
| 25 | ArchiveFactory_RomFS(const Loader::AppLoader& app_loader); | 25 | ArchiveFactory_RomFS(Loader::AppLoader& app_loader); |
| 26 | 26 | ||
| 27 | std::string GetName() const override { return "RomFS"; } | 27 | std::string GetName() const override { return "RomFS"; } |
| 28 | ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override; | 28 | ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override; |
diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp index 055661363..d043fa9bd 100644 --- a/src/core/loader/3dsx.cpp +++ b/src/core/loader/3dsx.cpp | |||
| @@ -246,11 +246,11 @@ ResultStatus AppLoader_THREEDSX::Load() { | |||
| 246 | if (is_loaded) | 246 | if (is_loaded) |
| 247 | return ResultStatus::ErrorAlreadyLoaded; | 247 | return ResultStatus::ErrorAlreadyLoaded; |
| 248 | 248 | ||
| 249 | if (!file->IsOpen()) | 249 | if (!file.IsOpen()) |
| 250 | return ResultStatus::Error; | 250 | return ResultStatus::Error; |
| 251 | 251 | ||
| 252 | SharedPtr<CodeSet> codeset; | 252 | SharedPtr<CodeSet> codeset; |
| 253 | if (Load3DSXFile(*file, Memory::PROCESS_IMAGE_VADDR, &codeset) != ERROR_NONE) | 253 | if (Load3DSXFile(file, Memory::PROCESS_IMAGE_VADDR, &codeset) != ERROR_NONE) |
| 254 | return ResultStatus::Error; | 254 | return ResultStatus::Error; |
| 255 | codeset->name = filename; | 255 | codeset->name = filename; |
| 256 | 256 | ||
diff --git a/src/core/loader/3dsx.h b/src/core/loader/3dsx.h index 096b3ec20..a0aa0c533 100644 --- a/src/core/loader/3dsx.h +++ b/src/core/loader/3dsx.h | |||
| @@ -17,7 +17,7 @@ namespace Loader { | |||
| 17 | /// Loads an 3DSX file | 17 | /// Loads an 3DSX file |
| 18 | class AppLoader_THREEDSX final : public AppLoader { | 18 | class AppLoader_THREEDSX final : public AppLoader { |
| 19 | public: | 19 | public: |
| 20 | AppLoader_THREEDSX(std::unique_ptr<FileUtil::IOFile>&& file, std::string filename) | 20 | AppLoader_THREEDSX(FileUtil::IOFile&& file, std::string filename) |
| 21 | : AppLoader(std::move(file)), filename(std::move(filename)) {} | 21 | : AppLoader(std::move(file)), filename(std::move(filename)) {} |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index ca3c18a9f..09a2275a1 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp | |||
| @@ -392,15 +392,15 @@ ResultStatus AppLoader_ELF::Load() { | |||
| 392 | if (is_loaded) | 392 | if (is_loaded) |
| 393 | return ResultStatus::ErrorAlreadyLoaded; | 393 | return ResultStatus::ErrorAlreadyLoaded; |
| 394 | 394 | ||
| 395 | if (!file->IsOpen()) | 395 | if (!file.IsOpen()) |
| 396 | return ResultStatus::Error; | 396 | return ResultStatus::Error; |
| 397 | 397 | ||
| 398 | // Reset read pointer in case this file has been read before. | 398 | // Reset read pointer in case this file has been read before. |
| 399 | file->Seek(0, SEEK_SET); | 399 | file.Seek(0, SEEK_SET); |
| 400 | 400 | ||
| 401 | u32 size = static_cast<u32>(file->GetSize()); | 401 | u32 size = static_cast<u32>(file.GetSize()); |
| 402 | std::unique_ptr<u8[]> buffer(new u8[size]); | 402 | std::unique_ptr<u8[]> buffer(new u8[size]); |
| 403 | if (file->ReadBytes(&buffer[0], size) != size) | 403 | if (file.ReadBytes(&buffer[0], size) != size) |
| 404 | return ResultStatus::Error; | 404 | return ResultStatus::Error; |
| 405 | 405 | ||
| 406 | ElfReader elf_reader(&buffer[0]); | 406 | ElfReader elf_reader(&buffer[0]); |
diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h index 32841606a..c6a5ebe99 100644 --- a/src/core/loader/elf.h +++ b/src/core/loader/elf.h | |||
| @@ -17,7 +17,7 @@ namespace Loader { | |||
| 17 | /// Loads an ELF/AXF file | 17 | /// Loads an ELF/AXF file |
| 18 | class AppLoader_ELF final : public AppLoader { | 18 | class AppLoader_ELF final : public AppLoader { |
| 19 | public: | 19 | public: |
| 20 | AppLoader_ELF(std::unique_ptr<FileUtil::IOFile>&& file, std::string filename) | 20 | AppLoader_ELF(FileUtil::IOFile&& file, std::string filename) |
| 21 | : AppLoader(std::move(file)), filename(std::move(filename)) { } | 21 | : AppLoader(std::move(file)), filename(std::move(filename)) { } |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index b6549daf2..9ef2f8900 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp | |||
| @@ -90,8 +90,8 @@ static const char* GetFileTypeString(FileType type) { | |||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | ResultStatus LoadFile(const std::string& filename) { | 92 | ResultStatus LoadFile(const std::string& filename) { |
| 93 | std::unique_ptr<FileUtil::IOFile> file(new FileUtil::IOFile(filename, "rb")); | 93 | FileUtil::IOFile file(filename, "rb"); |
| 94 | if (!file->IsOpen()) { | 94 | if (!file.IsOpen()) { |
| 95 | LOG_ERROR(Loader, "Failed to load file %s", filename.c_str()); | 95 | LOG_ERROR(Loader, "Failed to load file %s", filename.c_str()); |
| 96 | return ResultStatus::Error; | 96 | return ResultStatus::Error; |
| 97 | } | 97 | } |
| @@ -99,7 +99,7 @@ ResultStatus LoadFile(const std::string& filename) { | |||
| 99 | std::string filename_filename, filename_extension; | 99 | std::string filename_filename, filename_extension; |
| 100 | Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension); | 100 | Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension); |
| 101 | 101 | ||
| 102 | FileType type = IdentifyFile(*file); | 102 | FileType type = IdentifyFile(file); |
| 103 | FileType filename_type = GuessFromExtension(filename_extension); | 103 | FileType filename_type = GuessFromExtension(filename_extension); |
| 104 | 104 | ||
| 105 | if (type != filename_type) { | 105 | if (type != filename_type) { |
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index ff298222b..a37d3348c 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h | |||
| @@ -52,7 +52,7 @@ static inline u32 MakeMagic(char a, char b, char c, char d) { | |||
| 52 | /// Interface for loading an application | 52 | /// Interface for loading an application |
| 53 | class AppLoader : NonCopyable { | 53 | class AppLoader : NonCopyable { |
| 54 | public: | 54 | public: |
| 55 | AppLoader(std::unique_ptr<FileUtil::IOFile>&& file) : file(std::move(file)) { } | 55 | AppLoader(FileUtil::IOFile&& file) : file(std::move(file)) { } |
| 56 | virtual ~AppLoader() { } | 56 | virtual ~AppLoader() { } |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| @@ -66,7 +66,7 @@ public: | |||
| 66 | * @param buffer Reference to buffer to store data | 66 | * @param buffer Reference to buffer to store data |
| 67 | * @return ResultStatus result of function | 67 | * @return ResultStatus result of function |
| 68 | */ | 68 | */ |
| 69 | virtual ResultStatus ReadCode(std::vector<u8>& buffer) const { | 69 | virtual ResultStatus ReadCode(std::vector<u8>& buffer) { |
| 70 | return ResultStatus::ErrorNotImplemented; | 70 | return ResultStatus::ErrorNotImplemented; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| @@ -75,7 +75,7 @@ public: | |||
| 75 | * @param buffer Reference to buffer to store data | 75 | * @param buffer Reference to buffer to store data |
| 76 | * @return ResultStatus result of function | 76 | * @return ResultStatus result of function |
| 77 | */ | 77 | */ |
| 78 | virtual ResultStatus ReadIcon(std::vector<u8>& buffer) const { | 78 | virtual ResultStatus ReadIcon(std::vector<u8>& buffer) { |
| 79 | return ResultStatus::ErrorNotImplemented; | 79 | return ResultStatus::ErrorNotImplemented; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| @@ -84,7 +84,7 @@ public: | |||
| 84 | * @param buffer Reference to buffer to store data | 84 | * @param buffer Reference to buffer to store data |
| 85 | * @return ResultStatus result of function | 85 | * @return ResultStatus result of function |
| 86 | */ | 86 | */ |
| 87 | virtual ResultStatus ReadBanner(std::vector<u8>& buffer) const { | 87 | virtual ResultStatus ReadBanner(std::vector<u8>& buffer) { |
| 88 | return ResultStatus::ErrorNotImplemented; | 88 | return ResultStatus::ErrorNotImplemented; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| @@ -93,7 +93,7 @@ public: | |||
| 93 | * @param buffer Reference to buffer to store data | 93 | * @param buffer Reference to buffer to store data |
| 94 | * @return ResultStatus result of function | 94 | * @return ResultStatus result of function |
| 95 | */ | 95 | */ |
| 96 | virtual ResultStatus ReadLogo(std::vector<u8>& buffer) const { | 96 | virtual ResultStatus ReadLogo(std::vector<u8>& buffer) { |
| 97 | return ResultStatus::ErrorNotImplemented; | 97 | return ResultStatus::ErrorNotImplemented; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| @@ -105,13 +105,13 @@ public: | |||
| 105 | * @param size The size of the romfs | 105 | * @param size The size of the romfs |
| 106 | * @return ResultStatus result of function | 106 | * @return ResultStatus result of function |
| 107 | */ | 107 | */ |
| 108 | virtual ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, u64& size) const { | 108 | virtual ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, u64& size) { |
| 109 | return ResultStatus::ErrorNotImplemented; | 109 | return ResultStatus::ErrorNotImplemented; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | protected: | 112 | protected: |
| 113 | std::unique_ptr<FileUtil::IOFile> file; | 113 | FileUtil::IOFile file; |
| 114 | bool is_loaded = false; | 114 | bool is_loaded = false; |
| 115 | }; | 115 | }; |
| 116 | 116 | ||
| 117 | /** | 117 | /** |
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 2bf1a6a26..094d74100 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp | |||
| @@ -117,7 +117,7 @@ FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) { | |||
| 117 | return FileType::Error; | 117 | return FileType::Error; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | ResultStatus AppLoader_NCCH::LoadExec() const { | 120 | ResultStatus AppLoader_NCCH::LoadExec() { |
| 121 | using Kernel::SharedPtr; | 121 | using Kernel::SharedPtr; |
| 122 | using Kernel::CodeSet; | 122 | using Kernel::CodeSet; |
| 123 | 123 | ||
| @@ -171,8 +171,8 @@ ResultStatus AppLoader_NCCH::LoadExec() const { | |||
| 171 | return ResultStatus::Error; | 171 | return ResultStatus::Error; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer) const { | 174 | ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer) { |
| 175 | if (!file->IsOpen()) | 175 | if (!file.IsOpen()) |
| 176 | return ResultStatus::Error; | 176 | return ResultStatus::Error; |
| 177 | 177 | ||
| 178 | LOG_DEBUG(Loader, "%d sections:", kMaxSections); | 178 | LOG_DEBUG(Loader, "%d sections:", kMaxSections); |
| @@ -186,7 +186,7 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& | |||
| 186 | section.offset, section.size, section.name); | 186 | section.offset, section.size, section.name); |
| 187 | 187 | ||
| 188 | s64 section_offset = (section.offset + exefs_offset + sizeof(ExeFs_Header) + ncch_offset); | 188 | s64 section_offset = (section.offset + exefs_offset + sizeof(ExeFs_Header) + ncch_offset); |
| 189 | file->Seek(section_offset, SEEK_SET); | 189 | file.Seek(section_offset, SEEK_SET); |
| 190 | 190 | ||
| 191 | if (is_compressed) { | 191 | if (is_compressed) { |
| 192 | // Section is compressed, read compressed .code section... | 192 | // Section is compressed, read compressed .code section... |
| @@ -197,7 +197,7 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& | |||
| 197 | return ResultStatus::ErrorMemoryAllocationFailed; | 197 | return ResultStatus::ErrorMemoryAllocationFailed; |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | if (file->ReadBytes(&temp_buffer[0], section.size) != section.size) | 200 | if (file.ReadBytes(&temp_buffer[0], section.size) != section.size) |
| 201 | return ResultStatus::Error; | 201 | return ResultStatus::Error; |
| 202 | 202 | ||
| 203 | // Decompress .code section... | 203 | // Decompress .code section... |
| @@ -208,7 +208,7 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& | |||
| 208 | } else { | 208 | } else { |
| 209 | // Section is uncompressed... | 209 | // Section is uncompressed... |
| 210 | buffer.resize(section.size); | 210 | buffer.resize(section.size); |
| 211 | if (file->ReadBytes(&buffer[0], section.size) != section.size) | 211 | if (file.ReadBytes(&buffer[0], section.size) != section.size) |
| 212 | return ResultStatus::Error; | 212 | return ResultStatus::Error; |
| 213 | } | 213 | } |
| 214 | return ResultStatus::Success; | 214 | return ResultStatus::Success; |
| @@ -221,21 +221,21 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 221 | if (is_loaded) | 221 | if (is_loaded) |
| 222 | return ResultStatus::ErrorAlreadyLoaded; | 222 | return ResultStatus::ErrorAlreadyLoaded; |
| 223 | 223 | ||
| 224 | if (!file->IsOpen()) | 224 | if (!file.IsOpen()) |
| 225 | return ResultStatus::Error; | 225 | return ResultStatus::Error; |
| 226 | 226 | ||
| 227 | // Reset read pointer in case this file has been read before. | 227 | // Reset read pointer in case this file has been read before. |
| 228 | file->Seek(0, SEEK_SET); | 228 | file.Seek(0, SEEK_SET); |
| 229 | 229 | ||
| 230 | if (file->ReadBytes(&ncch_header, sizeof(NCCH_Header)) != sizeof(NCCH_Header)) | 230 | if (file.ReadBytes(&ncch_header, sizeof(NCCH_Header)) != sizeof(NCCH_Header)) |
| 231 | return ResultStatus::Error; | 231 | return ResultStatus::Error; |
| 232 | 232 | ||
| 233 | // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)... | 233 | // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)... |
| 234 | if (MakeMagic('N', 'C', 'S', 'D') == ncch_header.magic) { | 234 | if (MakeMagic('N', 'C', 'S', 'D') == ncch_header.magic) { |
| 235 | LOG_WARNING(Loader, "Only loading the first (bootable) NCCH within the NCSD file!"); | 235 | LOG_WARNING(Loader, "Only loading the first (bootable) NCCH within the NCSD file!"); |
| 236 | ncch_offset = 0x4000; | 236 | ncch_offset = 0x4000; |
| 237 | file->Seek(ncch_offset, SEEK_SET); | 237 | file.Seek(ncch_offset, SEEK_SET); |
| 238 | file->ReadBytes(&ncch_header, sizeof(NCCH_Header)); | 238 | file.ReadBytes(&ncch_header, sizeof(NCCH_Header)); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | // Verify we are loading the correct file type... | 241 | // Verify we are loading the correct file type... |
| @@ -244,7 +244,7 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 244 | 244 | ||
| 245 | // Read ExHeader... | 245 | // Read ExHeader... |
| 246 | 246 | ||
| 247 | if (file->ReadBytes(&exheader_header, sizeof(ExHeader_Header)) != sizeof(ExHeader_Header)) | 247 | if (file.ReadBytes(&exheader_header, sizeof(ExHeader_Header)) != sizeof(ExHeader_Header)) |
| 248 | return ResultStatus::Error; | 248 | return ResultStatus::Error; |
| 249 | 249 | ||
| 250 | is_compressed = (exheader_header.codeset_info.flags.flag & 1) == 1; | 250 | is_compressed = (exheader_header.codeset_info.flags.flag & 1) == 1; |
| @@ -274,8 +274,8 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 274 | LOG_DEBUG(Loader, "ExeFS offset: 0x%08X", exefs_offset); | 274 | LOG_DEBUG(Loader, "ExeFS offset: 0x%08X", exefs_offset); |
| 275 | LOG_DEBUG(Loader, "ExeFS size: 0x%08X", exefs_size); | 275 | LOG_DEBUG(Loader, "ExeFS size: 0x%08X", exefs_size); |
| 276 | 276 | ||
| 277 | file->Seek(exefs_offset + ncch_offset, SEEK_SET); | 277 | file.Seek(exefs_offset + ncch_offset, SEEK_SET); |
| 278 | if (file->ReadBytes(&exefs_header, sizeof(ExeFs_Header)) != sizeof(ExeFs_Header)) | 278 | if (file.ReadBytes(&exefs_header, sizeof(ExeFs_Header)) != sizeof(ExeFs_Header)) |
| 279 | return ResultStatus::Error; | 279 | return ResultStatus::Error; |
| 280 | 280 | ||
| 281 | is_loaded = true; // Set state to loaded | 281 | is_loaded = true; // Set state to loaded |
| @@ -283,24 +283,24 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 283 | return LoadExec(); // Load the executable into memory for booting | 283 | return LoadExec(); // Load the executable into memory for booting |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | ResultStatus AppLoader_NCCH::ReadCode(std::vector<u8>& buffer) const { | 286 | ResultStatus AppLoader_NCCH::ReadCode(std::vector<u8>& buffer) { |
| 287 | return LoadSectionExeFS(".code", buffer); | 287 | return LoadSectionExeFS(".code", buffer); |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | ResultStatus AppLoader_NCCH::ReadIcon(std::vector<u8>& buffer) const { | 290 | ResultStatus AppLoader_NCCH::ReadIcon(std::vector<u8>& buffer) { |
| 291 | return LoadSectionExeFS("icon", buffer); | 291 | return LoadSectionExeFS("icon", buffer); |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | ResultStatus AppLoader_NCCH::ReadBanner(std::vector<u8>& buffer) const { | 294 | ResultStatus AppLoader_NCCH::ReadBanner(std::vector<u8>& buffer) { |
| 295 | return LoadSectionExeFS("banner", buffer); | 295 | return LoadSectionExeFS("banner", buffer); |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | ResultStatus AppLoader_NCCH::ReadLogo(std::vector<u8>& buffer) const { | 298 | ResultStatus AppLoader_NCCH::ReadLogo(std::vector<u8>& buffer) { |
| 299 | return LoadSectionExeFS("logo", buffer); | 299 | return LoadSectionExeFS("logo", buffer); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, u64& size) const { | 302 | ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, u64& size) { |
| 303 | if (!file->IsOpen()) | 303 | if (!file.IsOpen()) |
| 304 | return ResultStatus::Error; | 304 | return ResultStatus::Error; |
| 305 | 305 | ||
| 306 | // Check if the NCCH has a RomFS... | 306 | // Check if the NCCH has a RomFS... |
| @@ -311,7 +311,7 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_ | |||
| 311 | LOG_DEBUG(Loader, "RomFS offset: 0x%08X", romfs_offset); | 311 | LOG_DEBUG(Loader, "RomFS offset: 0x%08X", romfs_offset); |
| 312 | LOG_DEBUG(Loader, "RomFS size: 0x%08X", romfs_size); | 312 | LOG_DEBUG(Loader, "RomFS size: 0x%08X", romfs_size); |
| 313 | 313 | ||
| 314 | if (file->GetSize () < romfs_offset + romfs_size) | 314 | if (file.GetSize () < romfs_offset + romfs_size) |
| 315 | return ResultStatus::Error; | 315 | return ResultStatus::Error; |
| 316 | 316 | ||
| 317 | // We reopen the file, to allow its position to be independent from file's | 317 | // We reopen the file, to allow its position to be independent from file's |
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index d180e77ed..b4374a476 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h | |||
| @@ -163,7 +163,7 @@ namespace Loader { | |||
| 163 | /// Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI) | 163 | /// Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI) |
| 164 | class AppLoader_NCCH final : public AppLoader { | 164 | class AppLoader_NCCH final : public AppLoader { |
| 165 | public: | 165 | public: |
| 166 | AppLoader_NCCH(std::unique_ptr<FileUtil::IOFile>&& file, const std::string& filepath) | 166 | AppLoader_NCCH(FileUtil::IOFile&& file, const std::string& filepath) |
| 167 | : AppLoader(std::move(file)), filepath(filepath) { } | 167 | : AppLoader(std::move(file)), filepath(filepath) { } |
| 168 | 168 | ||
| 169 | /** | 169 | /** |
| @@ -184,35 +184,35 @@ public: | |||
| 184 | * @param buffer Reference to buffer to store data | 184 | * @param buffer Reference to buffer to store data |
| 185 | * @return ResultStatus result of function | 185 | * @return ResultStatus result of function |
| 186 | */ | 186 | */ |
| 187 | ResultStatus ReadCode(std::vector<u8>& buffer) const override; | 187 | ResultStatus ReadCode(std::vector<u8>& buffer) override; |
| 188 | 188 | ||
| 189 | /** | 189 | /** |
| 190 | * Get the icon (typically icon section) of the application | 190 | * Get the icon (typically icon section) of the application |
| 191 | * @param buffer Reference to buffer to store data | 191 | * @param buffer Reference to buffer to store data |
| 192 | * @return ResultStatus result of function | 192 | * @return ResultStatus result of function |
| 193 | */ | 193 | */ |
| 194 | ResultStatus ReadIcon(std::vector<u8>& buffer) const override; | 194 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; |
| 195 | 195 | ||
| 196 | /** | 196 | /** |
| 197 | * Get the banner (typically banner section) of the application | 197 | * Get the banner (typically banner section) of the application |
| 198 | * @param buffer Reference to buffer to store data | 198 | * @param buffer Reference to buffer to store data |
| 199 | * @return ResultStatus result of function | 199 | * @return ResultStatus result of function |
| 200 | */ | 200 | */ |
| 201 | ResultStatus ReadBanner(std::vector<u8>& buffer) const override; | 201 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; |
| 202 | 202 | ||
| 203 | /** | 203 | /** |
| 204 | * Get the logo (typically logo section) of the application | 204 | * Get the logo (typically logo section) of the application |
| 205 | * @param buffer Reference to buffer to store data | 205 | * @param buffer Reference to buffer to store data |
| 206 | * @return ResultStatus result of function | 206 | * @return ResultStatus result of function |
| 207 | */ | 207 | */ |
| 208 | ResultStatus ReadLogo(std::vector<u8>& buffer) const override; | 208 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; |
| 209 | 209 | ||
| 210 | /** | 210 | /** |
| 211 | * Get the RomFS of the application | 211 | * Get the RomFS of the application |
| 212 | * @param buffer Reference to buffer to store data | 212 | * @param buffer Reference to buffer to store data |
| 213 | * @return ResultStatus result of function | 213 | * @return ResultStatus result of function |
| 214 | */ | 214 | */ |
| 215 | ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, u64& size) const override; | 215 | ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, u64& size) override; |
| 216 | 216 | ||
| 217 | private: | 217 | private: |
| 218 | 218 | ||
| @@ -222,13 +222,13 @@ private: | |||
| 222 | * @param buffer Vector to read data into | 222 | * @param buffer Vector to read data into |
| 223 | * @return ResultStatus result of function | 223 | * @return ResultStatus result of function |
| 224 | */ | 224 | */ |
| 225 | ResultStatus LoadSectionExeFS(const char* name, std::vector<u8>& buffer) const; | 225 | ResultStatus LoadSectionExeFS(const char* name, std::vector<u8>& buffer); |
| 226 | 226 | ||
| 227 | /** | 227 | /** |
| 228 | * Loads .code section into memory for booting | 228 | * Loads .code section into memory for booting |
| 229 | * @return ResultStatus result of function | 229 | * @return ResultStatus result of function |
| 230 | */ | 230 | */ |
| 231 | ResultStatus LoadExec() const; | 231 | ResultStatus LoadExec(); |
| 232 | 232 | ||
| 233 | bool is_compressed = false; | 233 | bool is_compressed = false; |
| 234 | 234 | ||