From a7f1c544909ee1034356666e04bea3a4b4609a95 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 22 Jun 2014 15:40:21 -0400 Subject: Loader: Refactored loading functions to only read data from binary if called. NCCH: Updated LoadExec to use Memory::WriteBlock function to load binary code. --- src/core/loader/ncch.h | 57 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 13 deletions(-) (limited to 'src/core/loader/ncch.h') diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index 126eb4c8..bf65425a 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -156,35 +156,66 @@ public: */ ResultStatus Load(); -private: + /** + * Get the code (typically .code section) of the application + * @param error ResultStatus result of function + * @return Reference to code buffer + */ + const std::vector& ReadCode(ResultStatus& error); /** - * Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.) - * @param file Handle to file to read from - * @param name Name of section to read out of NCCH file - * @param buffer Buffer to read section into. - * @return ResultStatus result of function + * Get the icon (typically icon section) of the application + * @param error ResultStatus result of function + * @return Reference to icon buffer */ - ResultStatus LoadSectionExeFS(File::IOFile& file, const char* name, std::vector& buffer); + const std::vector& ReadIcon(ResultStatus& error); /** - * Reads RomFS of an NCCH file into AppLoader - * @param file Handle to file to read from - * @return ResultStatus result of function + * Get the banner (typically banner section) of the application + * @param error ResultStatus result of function + * @return Reference to banner buffer + */ + const std::vector& ReadBanner(ResultStatus& error); + + /** + * Get the logo (typically logo section) of the application + * @param error ResultStatus result of function + * @return Reference to logo buffer */ - ResultStatus LoadRomFS(File::IOFile& file); + const std::vector& ReadLogo(ResultStatus& error); + + /** + * Get the RomFs archive of the application + * @param error ResultStatus result of function + * @return Reference to RomFs archive buffer + */ + const std::vector& ReadRomFS(ResultStatus& error); + +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 + */ + const std::vector& LoadSectionExeFS(const char* name, std::vector& buffer, + ResultStatus& error); /** * Loads .code section into memory for booting * @return ResultStatus result of function */ - ResultStatus LoadExec() const; + ResultStatus LoadExec(); + File::IOFile file; std::string filename; + bool is_loaded; bool is_compressed; - u32 entry_point; + u32 entry_point; u32 ncch_offset; // Offset to NCCH header, can be 0 or after NCSD header u32 exefs_offset; -- cgit v1.2.3