summaryrefslogtreecommitdiffstats
path: root/src/core/loader/ncch.cpp
diff options
context:
space:
mode:
authorbunnei <ericbunnie@gmail.com>2014-06-19 06:11:45 +0200
committerbunnei <ericbunnie@gmail.com>2014-06-25 01:30:06 +0200
commita8c46485203d3ab00ef478bbf9daa7450df14dfd (patch)
tree0f30ad4e7442a13e2e4e9aa68e687b677375c4d0 /src/core/loader/ncch.cpp
parentNCCH: Fixes reduce unnecessary logging and load logo/banner/etc. sections correctly. (diff)
downloadyuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.tar
yuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.tar.gz
yuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.tar.bz2
yuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.tar.lz
yuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.tar.xz
yuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.tar.zst
yuzu-a8c46485203d3ab00ef478bbf9daa7450df14dfd.zip
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
}
/**
+ * Reads RomFS of an NCCH file into AppLoader
+ * @param file Handle to file to read from
+ * @return ResultStatus result of function
+ */
+const ResultStatus AppLoader_NCCH::LoadRomFS(File::IOFile& file) {
+ // Check if the NCCH has a RomFS...
+ if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) {
+ u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000;
+ u32 romfs_size = (ncch_header.romfs_size * kBlockSize) - 0x1000;
+
+ INFO_LOG(LOADER, "RomFS offset: 0x%08X", romfs_offset);
+ INFO_LOG(LOADER, "RomFS size: 0x%08X", romfs_size);
+
+ romfs.resize(romfs_size);
+
+ file.Seek(romfs_offset, 0);
+ file.ReadBytes(&romfs[0], romfs_size);
+
+ return ResultStatus::Success;
+ } else {
+ NOTICE_LOG(LOADER, "RomFS unused");
+ }
+ return ResultStatus::ErrorNotUsed;
+}
+
+/**
* Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI)
* @param error_string Pointer to string to put error message if an error has occurred
* @todo Move NCSD parsing out of here and create a separate function for loading these
@@ -193,7 +219,6 @@ const ResultStatus AppLoader_NCCH::Load() {
File::IOFile file(filename, "rb");
if (file.IsOpen()) {
- NCCH_Header ncch_header;
file.ReadBytes(&ncch_header, sizeof(NCCH_Header));
// Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)...
@@ -237,6 +262,8 @@ const ResultStatus AppLoader_NCCH::Load() {
LoadSectionExeFS(file, "icon", icon);
LoadSectionExeFS(file, "logo", logo);
+ LoadRomFS(file);
+
is_loaded = true; // Set state to loaded
LoadExec(); // Load the executable into memory for booting