summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <ericbunnie@gmail.com>2014-06-27 21:33:23 +0200
committerbunnei <ericbunnie@gmail.com>2014-06-27 23:49:01 +0200
commitd8da707bb90c233d5e815a508bea3473e6e50afa (patch)
treedd9056678f602276691bb4613ea38c7c2ac9126f /src
parentFS: Added stubbed code to intercept and decode file system service functions. (diff)
downloadyuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.tar
yuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.tar.gz
yuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.tar.bz2
yuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.tar.lz
yuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.tar.xz
yuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.tar.zst
yuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.zip
Diffstat (limited to '')
-rw-r--r--src/core/loader/loader.h54
-rw-r--r--src/core/loader/ncch.cpp77
-rw-r--r--src/core/loader/ncch.h38
3 files changed, 73 insertions, 96 deletions
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 95f16fcb1..7891c1ed7 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -48,60 +48,48 @@ public:
/**
* Get the code (typically .code section) of the application
- * @param error ResultStatus result of function
- * @return Reference to code buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- virtual const std::vector<u8>& ReadCode(ResultStatus& error) const {
- error = ResultStatus::ErrorNotImplemented;
- return code;
+ virtual ResultStatus ReadCode(std::vector<u8>& buffer) {
+ return ResultStatus::ErrorNotImplemented;
}
/**
* Get the icon (typically icon section) of the application
- * @param error ResultStatus result of function
- * @return Reference to icon buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- virtual const std::vector<u8>& ReadIcon(ResultStatus& error) const {
- error = ResultStatus::ErrorNotImplemented;
- return icon;
+ virtual ResultStatus ReadIcon(std::vector<u8>& buffer) {
+ return ResultStatus::ErrorNotImplemented;
}
/**
* Get the banner (typically banner section) of the application
- * @param error ResultStatus result of function
- * @return Reference to banner buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- virtual const std::vector<u8>& ReadBanner(ResultStatus& error) const {
- error = ResultStatus::ErrorNotImplemented;
- return banner;
+ virtual ResultStatus ReadBanner(std::vector<u8>& buffer) {
+ return ResultStatus::ErrorNotImplemented;
}
/**
* Get the logo (typically logo section) of the application
- * @param error ResultStatus result of function
- * @return Reference to logo buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- virtual const std::vector<u8>& ReadLogo(ResultStatus& error) const {
- error = ResultStatus::ErrorNotImplemented;
- return logo;
+ virtual ResultStatus ReadLogo(std::vector<u8>& buffer) {
+ return ResultStatus::ErrorNotImplemented;
}
/**
- * Get the RomFs archive of the application
- * @param error ResultStatus result of function
- * @return Reference to RomFs archive buffer
+ * Get the RomFS of the application
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- virtual const std::vector<u8>& ReadRomFS(ResultStatus& error) const {
- error = ResultStatus::ErrorNotImplemented;
- return romfs;
+ virtual ResultStatus ReadRomFS(std::vector<u8>& buffer) {
+ return ResultStatus::ErrorNotImplemented;
}
-
-protected:
- std::vector<u8> code; ///< ExeFS .code section
- std::vector<u8> icon; ///< ExeFS .icon section
- std::vector<u8> banner; ///< ExeFS .banner section
- std::vector<u8> logo; ///< ExeFS .logo section
- std::vector<u8> romfs; ///< RomFs archive
};
/**
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 60505bdfa..0e3f768ce 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -125,25 +125,22 @@ ResultStatus AppLoader_NCCH::LoadExec() {
if (!is_loaded)
return ResultStatus::ErrorNotLoaded;
- ResultStatus res;
- code = ReadCode(res);
-
- if (ResultStatus::Success == res) {
+ std::vector<u8> code;
+ if (ResultStatus::Success == ReadCode(code)) {
Memory::WriteBlock(entry_point, &code[0], code.size());
Kernel::LoadExec(entry_point);
+ return ResultStatus::Success;
}
- return res;
+ return ResultStatus::Error;
}
/**
* Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)
* @param name Name of section to read out of NCCH file
* @param buffer Vector to read data into
- * @param error ResultStatus result of function
- * @return Reference to buffer of data that was read
+ * @return ResultStatus result of function
*/
-const std::vector<u8>& AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer,
- ResultStatus& error) {
+ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer) {
// Iterate through the ExeFs archive until we find the .code file...
for (int i = 0; i < kMaxSections; i++) {
// Load the specified section...
@@ -169,20 +166,17 @@ const std::vector<u8>& AppLoader_NCCH::LoadSectionExeFS(const char* name, std::v
buffer.resize(decompressed_size);
if (!LZSS_Decompress(&temp_buffer[0], exefs_header.section[i].size, &buffer[0],
decompressed_size)) {
- error = ResultStatus::ErrorInvalidFormat;
- return buffer;
+ return ResultStatus::ErrorInvalidFormat;
}
// Section is uncompressed...
} else {
buffer.resize(exefs_header.section[i].size);
file.ReadBytes(&buffer[0], exefs_header.section[i].size);
}
- error = ResultStatus::Success;
- return buffer;
+ return ResultStatus::Success;
}
}
- error = ResultStatus::ErrorNotUsed;
- return buffer;
+ return ResultStatus::ErrorNotUsed;
}
/**
@@ -247,46 +241,46 @@ ResultStatus AppLoader_NCCH::Load() {
/**
* Get the code (typically .code section) of the application
- * @param error ResultStatus result of function
- * @return Reference to code buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
-const std::vector<u8>& AppLoader_NCCH::ReadCode(ResultStatus& error) {
- return LoadSectionExeFS(".code", code, error);
+ResultStatus AppLoader_NCCH::ReadCode(std::vector<u8>& buffer) {
+ return LoadSectionExeFS(".code", buffer);
}
/**
* Get the icon (typically icon section) of the application
- * @param error ResultStatus result of function
- * @return Reference to icon buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
-const std::vector<u8>& AppLoader_NCCH::ReadIcon(ResultStatus& error) {
- return LoadSectionExeFS("icon", icon, error);
+ResultStatus AppLoader_NCCH::ReadIcon(std::vector<u8>& buffer) {
+ return LoadSectionExeFS("icon", buffer);
}
/**
* Get the banner (typically banner section) of the application
- * @param error ResultStatus result of function
- * @return Reference to banner buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
-const std::vector<u8>& AppLoader_NCCH::ReadBanner(ResultStatus& error) {
- return LoadSectionExeFS("banner", banner, error);
+ResultStatus AppLoader_NCCH::ReadBanner(std::vector<u8>& buffer) {
+ return LoadSectionExeFS("banner", buffer);
}
/**
* Get the logo (typically logo section) of the application
- * @param error ResultStatus result of function
- * @return Reference to logo buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
-const std::vector<u8>& AppLoader_NCCH::ReadLogo(ResultStatus& error) {
- return LoadSectionExeFS("logo", logo, error);
+ResultStatus AppLoader_NCCH::ReadLogo(std::vector<u8>& buffer) {
+ return LoadSectionExeFS("logo", buffer);
}
/**
- * Get the RomFs archive of the application
- * @param error ResultStatus result of function
- * @return Reference to RomFs archive buffer
+ * Get the RomFS of the application
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
-const std::vector<u8>& AppLoader_NCCH::ReadRomFS(ResultStatus& error) {
+ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) {
// 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;
@@ -295,18 +289,15 @@ const std::vector<u8>& AppLoader_NCCH::ReadRomFS(ResultStatus& error) {
INFO_LOG(LOADER, "RomFS offset: 0x%08X", romfs_offset);
INFO_LOG(LOADER, "RomFS size: 0x%08X", romfs_size);
- romfs.resize(romfs_size);
+ buffer.resize(romfs_size);
file.Seek(romfs_offset, 0);
- file.ReadBytes(&romfs[0], romfs_size);
+ file.ReadBytes(&buffer[0], romfs_size);
- error = ResultStatus::Success;
- return romfs;
- } else {
- NOTICE_LOG(LOADER, "RomFS unused");
+ return ResultStatus::Success;
}
- error = ResultStatus::ErrorNotUsed;
- return romfs;
+ NOTICE_LOG(LOADER, "RomFS unused");
+ return ResultStatus::ErrorNotUsed;
}
} // namespace Loader
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index bf65425a4..99753b244 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -158,38 +158,38 @@ public:
/**
* Get the code (typically .code section) of the application
- * @param error ResultStatus result of function
- * @return Reference to code buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- const std::vector<u8>& ReadCode(ResultStatus& error);
+ ResultStatus ReadCode(std::vector<u8>& buffer);
/**
* Get the icon (typically icon section) of the application
- * @param error ResultStatus result of function
- * @return Reference to icon buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- const std::vector<u8>& ReadIcon(ResultStatus& error);
+ ResultStatus ReadIcon(std::vector<u8>& buffer);
/**
* Get the banner (typically banner section) of the application
- * @param error ResultStatus result of function
- * @return Reference to banner buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- const std::vector<u8>& ReadBanner(ResultStatus& error);
+ ResultStatus ReadBanner(std::vector<u8>& buffer);
/**
* Get the logo (typically logo section) of the application
- * @param error ResultStatus result of function
- * @return Reference to logo buffer
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- const std::vector<u8>& ReadLogo(ResultStatus& error);
+ ResultStatus ReadLogo(std::vector<u8>& buffer);
/**
- * Get the RomFs archive of the application
- * @param error ResultStatus result of function
- * @return Reference to RomFs archive buffer
+ * Get the RomFS of the application
+ * @param buffer Reference to buffer to store data
+ * @return ResultStatus result of function
*/
- const std::vector<u8>& ReadRomFS(ResultStatus& error);
+ ResultStatus ReadRomFS(std::vector<u8>& buffer);
private:
@@ -197,11 +197,9 @@ private:
* Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)
* @param name Name of section to read out of NCCH file
* @param buffer Vector to read data into
- * @param error ResultStatus result of function
- * @return Reference to buffer of data that was read
+ * @return ResultStatus result of function
*/
- const std::vector<u8>& LoadSectionExeFS(const char* name, std::vector<u8>& buffer,
- ResultStatus& error);
+ ResultStatus LoadSectionExeFS(const char* name, std::vector<u8>& buffer);
/**
* Loads .code section into memory for booting