summaryrefslogtreecommitdiff
path: root/src/core/loader/ncch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/loader/ncch.cpp')
-rw-r--r--src/core/loader/ncch.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 4cf805ba0..6423da8f9 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -179,6 +179,32 @@ const ResultStatus AppLoader_NCCH::LoadSectionExeFS(File::IOFile& file, const ch
179} 179}
180 180
181/** 181/**
182 * Reads RomFS of an NCCH file into AppLoader
183 * @param file Handle to file to read from
184 * @return ResultStatus result of function
185 */
186const ResultStatus AppLoader_NCCH::LoadRomFS(File::IOFile& file) {
187 // Check if the NCCH has a RomFS...
188 if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) {
189 u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000;
190 u32 romfs_size = (ncch_header.romfs_size * kBlockSize) - 0x1000;
191
192 INFO_LOG(LOADER, "RomFS offset: 0x%08X", romfs_offset);
193 INFO_LOG(LOADER, "RomFS size: 0x%08X", romfs_size);
194
195 romfs.resize(romfs_size);
196
197 file.Seek(romfs_offset, 0);
198 file.ReadBytes(&romfs[0], romfs_size);
199
200 return ResultStatus::Success;
201 } else {
202 NOTICE_LOG(LOADER, "RomFS unused");
203 }
204 return ResultStatus::ErrorNotUsed;
205}
206
207/**
182 * Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI) 208 * Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI)
183 * @param error_string Pointer to string to put error message if an error has occurred 209 * @param error_string Pointer to string to put error message if an error has occurred
184 * @todo Move NCSD parsing out of here and create a separate function for loading these 210 * @todo Move NCSD parsing out of here and create a separate function for loading these
@@ -193,7 +219,6 @@ const ResultStatus AppLoader_NCCH::Load() {
193 File::IOFile file(filename, "rb"); 219 File::IOFile file(filename, "rb");
194 220
195 if (file.IsOpen()) { 221 if (file.IsOpen()) {
196 NCCH_Header ncch_header;
197 file.ReadBytes(&ncch_header, sizeof(NCCH_Header)); 222 file.ReadBytes(&ncch_header, sizeof(NCCH_Header));
198 223
199 // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)... 224 // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)...
@@ -237,6 +262,8 @@ const ResultStatus AppLoader_NCCH::Load() {
237 LoadSectionExeFS(file, "icon", icon); 262 LoadSectionExeFS(file, "icon", icon);
238 LoadSectionExeFS(file, "logo", logo); 263 LoadSectionExeFS(file, "logo", logo);
239 264
265 LoadRomFS(file);
266
240 is_loaded = true; // Set state to loaded 267 is_loaded = true; // Set state to loaded
241 268
242 LoadExec(); // Load the executable into memory for booting 269 LoadExec(); // Load the executable into memory for booting