diff options
| author | 2014-06-27 15:33:23 -0400 | |
|---|---|---|
| committer | 2014-06-27 17:49:01 -0400 | |
| commit | d8da707bb90c233d5e815a508bea3473e6e50afa (patch) | |
| tree | dd9056678f602276691bb4613ea38c7c2ac9126f /src/core/loader | |
| parent | FS: Added stubbed code to intercept and decode file system service functions. (diff) | |
| download | yuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.tar.gz yuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.tar.xz yuzu-d8da707bb90c233d5e815a508bea3473e6e50afa.zip | |
Loader: Refactored interface such that data is no longer stored by loader.
NCCH: Removed extra qualification ‘Loader::AppLoader_NCCH::’.
Diffstat (limited to 'src/core/loader')
| -rw-r--r-- | src/core/loader/loader.h | 54 | ||||
| -rw-r--r-- | src/core/loader/ncch.cpp | 77 | ||||
| -rw-r--r-- | src/core/loader/ncch.h | 38 |
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: | |||
| 48 | 48 | ||
| 49 | /** | 49 | /** |
| 50 | * Get the code (typically .code section) of the application | 50 | * Get the code (typically .code section) of the application |
| 51 | * @param error ResultStatus result of function | 51 | * @param buffer Reference to buffer to store data |
| 52 | * @return Reference to code buffer | 52 | * @return ResultStatus result of function |
| 53 | */ | 53 | */ |
| 54 | virtual const std::vector<u8>& ReadCode(ResultStatus& error) const { | 54 | virtual ResultStatus ReadCode(std::vector<u8>& buffer) { |
| 55 | error = ResultStatus::ErrorNotImplemented; | 55 | return ResultStatus::ErrorNotImplemented; |
| 56 | return code; | ||
| 57 | } | 56 | } |
| 58 | 57 | ||
| 59 | /** | 58 | /** |
| 60 | * Get the icon (typically icon section) of the application | 59 | * Get the icon (typically icon section) of the application |
| 61 | * @param error ResultStatus result of function | 60 | * @param buffer Reference to buffer to store data |
| 62 | * @return Reference to icon buffer | 61 | * @return ResultStatus result of function |
| 63 | */ | 62 | */ |
| 64 | virtual const std::vector<u8>& ReadIcon(ResultStatus& error) const { | 63 | virtual ResultStatus ReadIcon(std::vector<u8>& buffer) { |
| 65 | error = ResultStatus::ErrorNotImplemented; | 64 | return ResultStatus::ErrorNotImplemented; |
| 66 | return icon; | ||
| 67 | } | 65 | } |
| 68 | 66 | ||
| 69 | /** | 67 | /** |
| 70 | * Get the banner (typically banner section) of the application | 68 | * Get the banner (typically banner section) of the application |
| 71 | * @param error ResultStatus result of function | 69 | * @param buffer Reference to buffer to store data |
| 72 | * @return Reference to banner buffer | 70 | * @return ResultStatus result of function |
| 73 | */ | 71 | */ |
| 74 | virtual const std::vector<u8>& ReadBanner(ResultStatus& error) const { | 72 | virtual ResultStatus ReadBanner(std::vector<u8>& buffer) { |
| 75 | error = ResultStatus::ErrorNotImplemented; | 73 | return ResultStatus::ErrorNotImplemented; |
| 76 | return banner; | ||
| 77 | } | 74 | } |
| 78 | 75 | ||
| 79 | /** | 76 | /** |
| 80 | * Get the logo (typically logo section) of the application | 77 | * Get the logo (typically logo section) of the application |
| 81 | * @param error ResultStatus result of function | 78 | * @param buffer Reference to buffer to store data |
| 82 | * @return Reference to logo buffer | 79 | * @return ResultStatus result of function |
| 83 | */ | 80 | */ |
| 84 | virtual const std::vector<u8>& ReadLogo(ResultStatus& error) const { | 81 | virtual ResultStatus ReadLogo(std::vector<u8>& buffer) { |
| 85 | error = ResultStatus::ErrorNotImplemented; | 82 | return ResultStatus::ErrorNotImplemented; |
| 86 | return logo; | ||
| 87 | } | 83 | } |
| 88 | 84 | ||
| 89 | /** | 85 | /** |
| 90 | * Get the RomFs archive of the application | 86 | * Get the RomFS of the application |
| 91 | * @param error ResultStatus result of function | 87 | * @param buffer Reference to buffer to store data |
| 92 | * @return Reference to RomFs archive buffer | 88 | * @return ResultStatus result of function |
| 93 | */ | 89 | */ |
| 94 | virtual const std::vector<u8>& ReadRomFS(ResultStatus& error) const { | 90 | virtual ResultStatus ReadRomFS(std::vector<u8>& buffer) { |
| 95 | error = ResultStatus::ErrorNotImplemented; | 91 | return ResultStatus::ErrorNotImplemented; |
| 96 | return romfs; | ||
| 97 | } | 92 | } |
| 98 | |||
| 99 | protected: | ||
| 100 | std::vector<u8> code; ///< ExeFS .code section | ||
| 101 | std::vector<u8> icon; ///< ExeFS .icon section | ||
| 102 | std::vector<u8> banner; ///< ExeFS .banner section | ||
| 103 | std::vector<u8> logo; ///< ExeFS .logo section | ||
| 104 | std::vector<u8> romfs; ///< RomFs archive | ||
| 105 | }; | 93 | }; |
| 106 | 94 | ||
| 107 | /** | 95 | /** |
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() { | |||
| 125 | if (!is_loaded) | 125 | if (!is_loaded) |
| 126 | return ResultStatus::ErrorNotLoaded; | 126 | return ResultStatus::ErrorNotLoaded; |
| 127 | 127 | ||
| 128 | ResultStatus res; | 128 | std::vector<u8> code; |
| 129 | code = ReadCode(res); | 129 | if (ResultStatus::Success == ReadCode(code)) { |
| 130 | |||
| 131 | if (ResultStatus::Success == res) { | ||
| 132 | Memory::WriteBlock(entry_point, &code[0], code.size()); | 130 | Memory::WriteBlock(entry_point, &code[0], code.size()); |
| 133 | Kernel::LoadExec(entry_point); | 131 | Kernel::LoadExec(entry_point); |
| 132 | return ResultStatus::Success; | ||
| 134 | } | 133 | } |
| 135 | return res; | 134 | return ResultStatus::Error; |
| 136 | } | 135 | } |
| 137 | 136 | ||
| 138 | /** | 137 | /** |
| 139 | * Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.) | 138 | * Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.) |
| 140 | * @param name Name of section to read out of NCCH file | 139 | * @param name Name of section to read out of NCCH file |
| 141 | * @param buffer Vector to read data into | 140 | * @param buffer Vector to read data into |
| 142 | * @param error ResultStatus result of function | 141 | * @return ResultStatus result of function |
| 143 | * @return Reference to buffer of data that was read | ||
| 144 | */ | 142 | */ |
| 145 | const std::vector<u8>& AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer, | 143 | ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer) { |
| 146 | ResultStatus& error) { | ||
| 147 | // Iterate through the ExeFs archive until we find the .code file... | 144 | // Iterate through the ExeFs archive until we find the .code file... |
| 148 | for (int i = 0; i < kMaxSections; i++) { | 145 | for (int i = 0; i < kMaxSections; i++) { |
| 149 | // Load the specified section... | 146 | // Load the specified section... |
| @@ -169,20 +166,17 @@ const std::vector<u8>& AppLoader_NCCH::LoadSectionExeFS(const char* name, std::v | |||
| 169 | buffer.resize(decompressed_size); | 166 | buffer.resize(decompressed_size); |
| 170 | if (!LZSS_Decompress(&temp_buffer[0], exefs_header.section[i].size, &buffer[0], | 167 | if (!LZSS_Decompress(&temp_buffer[0], exefs_header.section[i].size, &buffer[0], |
| 171 | decompressed_size)) { | 168 | decompressed_size)) { |
| 172 | error = ResultStatus::ErrorInvalidFormat; | 169 | return ResultStatus::ErrorInvalidFormat; |
| 173 | return buffer; | ||
| 174 | } | 170 | } |
| 175 | // Section is uncompressed... | 171 | // Section is uncompressed... |
| 176 | } else { | 172 | } else { |
| 177 | buffer.resize(exefs_header.section[i].size); | 173 | buffer.resize(exefs_header.section[i].size); |
| 178 | file.ReadBytes(&buffer[0], exefs_header.section[i].size); | 174 | file.ReadBytes(&buffer[0], exefs_header.section[i].size); |
| 179 | } | 175 | } |
| 180 | error = ResultStatus::Success; | 176 | return ResultStatus::Success; |
| 181 | return buffer; | ||
| 182 | } | 177 | } |
| 183 | } | 178 | } |
| 184 | error = ResultStatus::ErrorNotUsed; | 179 | return ResultStatus::ErrorNotUsed; |
| 185 | return buffer; | ||
| 186 | } | 180 | } |
| 187 | 181 | ||
| 188 | /** | 182 | /** |
| @@ -247,46 +241,46 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 247 | 241 | ||
| 248 | /** | 242 | /** |
| 249 | * Get the code (typically .code section) of the application | 243 | * Get the code (typically .code section) of the application |
| 250 | * @param error ResultStatus result of function | 244 | * @param buffer Reference to buffer to store data |
| 251 | * @return Reference to code buffer | 245 | * @return ResultStatus result of function |
| 252 | */ | 246 | */ |
| 253 | const std::vector<u8>& AppLoader_NCCH::ReadCode(ResultStatus& error) { | 247 | ResultStatus AppLoader_NCCH::ReadCode(std::vector<u8>& buffer) { |
| 254 | return LoadSectionExeFS(".code", code, error); | 248 | return LoadSectionExeFS(".code", buffer); |
| 255 | } | 249 | } |
| 256 | 250 | ||
| 257 | /** | 251 | /** |
| 258 | * Get the icon (typically icon section) of the application | 252 | * Get the icon (typically icon section) of the application |
| 259 | * @param error ResultStatus result of function | 253 | * @param buffer Reference to buffer to store data |
| 260 | * @return Reference to icon buffer | 254 | * @return ResultStatus result of function |
| 261 | */ | 255 | */ |
| 262 | const std::vector<u8>& AppLoader_NCCH::ReadIcon(ResultStatus& error) { | 256 | ResultStatus AppLoader_NCCH::ReadIcon(std::vector<u8>& buffer) { |
| 263 | return LoadSectionExeFS("icon", icon, error); | 257 | return LoadSectionExeFS("icon", buffer); |
| 264 | } | 258 | } |
| 265 | 259 | ||
| 266 | /** | 260 | /** |
| 267 | * Get the banner (typically banner section) of the application | 261 | * Get the banner (typically banner section) of the application |
| 268 | * @param error ResultStatus result of function | 262 | * @param buffer Reference to buffer to store data |
| 269 | * @return Reference to banner buffer | 263 | * @return ResultStatus result of function |
| 270 | */ | 264 | */ |
| 271 | const std::vector<u8>& AppLoader_NCCH::ReadBanner(ResultStatus& error) { | 265 | ResultStatus AppLoader_NCCH::ReadBanner(std::vector<u8>& buffer) { |
| 272 | return LoadSectionExeFS("banner", banner, error); | 266 | return LoadSectionExeFS("banner", buffer); |
| 273 | } | 267 | } |
| 274 | 268 | ||
| 275 | /** | 269 | /** |
| 276 | * Get the logo (typically logo section) of the application | 270 | * Get the logo (typically logo section) of the application |
| 277 | * @param error ResultStatus result of function | 271 | * @param buffer Reference to buffer to store data |
| 278 | * @return Reference to logo buffer | 272 | * @return ResultStatus result of function |
| 279 | */ | 273 | */ |
| 280 | const std::vector<u8>& AppLoader_NCCH::ReadLogo(ResultStatus& error) { | 274 | ResultStatus AppLoader_NCCH::ReadLogo(std::vector<u8>& buffer) { |
| 281 | return LoadSectionExeFS("logo", logo, error); | 275 | return LoadSectionExeFS("logo", buffer); |
| 282 | } | 276 | } |
| 283 | 277 | ||
| 284 | /** | 278 | /** |
| 285 | * Get the RomFs archive of the application | 279 | * Get the RomFS of the application |
| 286 | * @param error ResultStatus result of function | 280 | * @param buffer Reference to buffer to store data |
| 287 | * @return Reference to RomFs archive buffer | 281 | * @return ResultStatus result of function |
| 288 | */ | 282 | */ |
| 289 | const std::vector<u8>& AppLoader_NCCH::ReadRomFS(ResultStatus& error) { | 283 | ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) { |
| 290 | // Check if the NCCH has a RomFS... | 284 | // Check if the NCCH has a RomFS... |
| 291 | if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) { | 285 | if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) { |
| 292 | u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000; | 286 | u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000; |
| @@ -295,18 +289,15 @@ const std::vector<u8>& AppLoader_NCCH::ReadRomFS(ResultStatus& error) { | |||
| 295 | INFO_LOG(LOADER, "RomFS offset: 0x%08X", romfs_offset); | 289 | INFO_LOG(LOADER, "RomFS offset: 0x%08X", romfs_offset); |
| 296 | INFO_LOG(LOADER, "RomFS size: 0x%08X", romfs_size); | 290 | INFO_LOG(LOADER, "RomFS size: 0x%08X", romfs_size); |
| 297 | 291 | ||
| 298 | romfs.resize(romfs_size); | 292 | buffer.resize(romfs_size); |
| 299 | 293 | ||
| 300 | file.Seek(romfs_offset, 0); | 294 | file.Seek(romfs_offset, 0); |
| 301 | file.ReadBytes(&romfs[0], romfs_size); | 295 | file.ReadBytes(&buffer[0], romfs_size); |
| 302 | 296 | ||
| 303 | error = ResultStatus::Success; | 297 | return ResultStatus::Success; |
| 304 | return romfs; | ||
| 305 | } else { | ||
| 306 | NOTICE_LOG(LOADER, "RomFS unused"); | ||
| 307 | } | 298 | } |
| 308 | error = ResultStatus::ErrorNotUsed; | 299 | NOTICE_LOG(LOADER, "RomFS unused"); |
| 309 | return romfs; | 300 | return ResultStatus::ErrorNotUsed; |
| 310 | } | 301 | } |
| 311 | 302 | ||
| 312 | } // namespace Loader | 303 | } // 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: | |||
| 158 | 158 | ||
| 159 | /** | 159 | /** |
| 160 | * Get the code (typically .code section) of the application | 160 | * Get the code (typically .code section) of the application |
| 161 | * @param error ResultStatus result of function | 161 | * @param buffer Reference to buffer to store data |
| 162 | * @return Reference to code buffer | 162 | * @return ResultStatus result of function |
| 163 | */ | 163 | */ |
| 164 | const std::vector<u8>& ReadCode(ResultStatus& error); | 164 | ResultStatus ReadCode(std::vector<u8>& buffer); |
| 165 | 165 | ||
| 166 | /** | 166 | /** |
| 167 | * Get the icon (typically icon section) of the application | 167 | * Get the icon (typically icon section) of the application |
| 168 | * @param error ResultStatus result of function | 168 | * @param buffer Reference to buffer to store data |
| 169 | * @return Reference to icon buffer | 169 | * @return ResultStatus result of function |
| 170 | */ | 170 | */ |
| 171 | const std::vector<u8>& ReadIcon(ResultStatus& error); | 171 | ResultStatus ReadIcon(std::vector<u8>& buffer); |
| 172 | 172 | ||
| 173 | /** | 173 | /** |
| 174 | * Get the banner (typically banner section) of the application | 174 | * Get the banner (typically banner section) of the application |
| 175 | * @param error ResultStatus result of function | 175 | * @param buffer Reference to buffer to store data |
| 176 | * @return Reference to banner buffer | 176 | * @return ResultStatus result of function |
| 177 | */ | 177 | */ |
| 178 | const std::vector<u8>& ReadBanner(ResultStatus& error); | 178 | ResultStatus ReadBanner(std::vector<u8>& buffer); |
| 179 | 179 | ||
| 180 | /** | 180 | /** |
| 181 | * Get the logo (typically logo section) of the application | 181 | * Get the logo (typically logo section) of the application |
| 182 | * @param error ResultStatus result of function | 182 | * @param buffer Reference to buffer to store data |
| 183 | * @return Reference to logo buffer | 183 | * @return ResultStatus result of function |
| 184 | */ | 184 | */ |
| 185 | const std::vector<u8>& ReadLogo(ResultStatus& error); | 185 | ResultStatus ReadLogo(std::vector<u8>& buffer); |
| 186 | 186 | ||
| 187 | /** | 187 | /** |
| 188 | * Get the RomFs archive of the application | 188 | * Get the RomFS of the application |
| 189 | * @param error ResultStatus result of function | 189 | * @param buffer Reference to buffer to store data |
| 190 | * @return Reference to RomFs archive buffer | 190 | * @return ResultStatus result of function |
| 191 | */ | 191 | */ |
| 192 | const std::vector<u8>& ReadRomFS(ResultStatus& error); | 192 | ResultStatus ReadRomFS(std::vector<u8>& buffer); |
| 193 | 193 | ||
| 194 | private: | 194 | private: |
| 195 | 195 | ||
| @@ -197,11 +197,9 @@ private: | |||
| 197 | * Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.) | 197 | * Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.) |
| 198 | * @param name Name of section to read out of NCCH file | 198 | * @param name Name of section to read out of NCCH file |
| 199 | * @param buffer Vector to read data into | 199 | * @param buffer Vector to read data into |
| 200 | * @param error ResultStatus result of function | 200 | * @return ResultStatus result of function |
| 201 | * @return Reference to buffer of data that was read | ||
| 202 | */ | 201 | */ |
| 203 | const std::vector<u8>& LoadSectionExeFS(const char* name, std::vector<u8>& buffer, | 202 | ResultStatus LoadSectionExeFS(const char* name, std::vector<u8>& buffer); |
| 204 | ResultStatus& error); | ||
| 205 | 203 | ||
| 206 | /** | 204 | /** |
| 207 | * Loads .code section into memory for booting | 205 | * Loads .code section into memory for booting |