diff options
Diffstat (limited to 'src/core/loader/loader.cpp')
| -rw-r--r-- | src/core/loader/loader.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 9bc3a8840..e4f5fd40c 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/file_util.h" | 10 | #include "common/file_util.h" |
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "common/string_util.h" | 12 | #include "common/string_util.h" |
| 13 | #include "core/core.h" | ||
| 13 | #include "core/hle/kernel/process.h" | 14 | #include "core/hle/kernel/process.h" |
| 14 | #include "core/loader/deconstructed_rom_directory.h" | 15 | #include "core/loader/deconstructed_rom_directory.h" |
| 15 | #include "core/loader/elf.h" | 16 | #include "core/loader/elf.h" |
| @@ -184,6 +185,10 @@ constexpr std::array<const char*, 66> RESULT_MESSAGES{ | |||
| 184 | "The INI file contains more than the maximum allowable number of KIP files.", | 185 | "The INI file contains more than the maximum allowable number of KIP files.", |
| 185 | }; | 186 | }; |
| 186 | 187 | ||
| 188 | std::string GetResultStatusString(ResultStatus status) { | ||
| 189 | return RESULT_MESSAGES.at(static_cast<std::size_t>(status)); | ||
| 190 | } | ||
| 191 | |||
| 187 | std::ostream& operator<<(std::ostream& os, ResultStatus status) { | 192 | std::ostream& operator<<(std::ostream& os, ResultStatus status) { |
| 188 | os << RESULT_MESSAGES.at(static_cast<std::size_t>(status)); | 193 | os << RESULT_MESSAGES.at(static_cast<std::size_t>(status)); |
| 189 | return os; | 194 | return os; |
| @@ -194,15 +199,15 @@ AppLoader::~AppLoader() = default; | |||
| 194 | 199 | ||
| 195 | /** | 200 | /** |
| 196 | * Get a loader for a file with a specific type | 201 | * Get a loader for a file with a specific type |
| 197 | * @param file The file to load | 202 | * @param system The system context to use. |
| 198 | * @param type The type of the file | 203 | * @param file The file to retrieve the loader for |
| 199 | * @param file the file to retrieve the loader for | 204 | * @param type The file type |
| 200 | * @param type the file type | 205 | * @param program_index Specifies the index within the container of the program to launch. |
| 201 | * @return std::unique_ptr<AppLoader> a pointer to a loader object; nullptr for unsupported type | 206 | * @return std::unique_ptr<AppLoader> a pointer to a loader object; nullptr for unsupported type |
| 202 | */ | 207 | */ |
| 203 | static std::unique_ptr<AppLoader> GetFileLoader(FileSys::VirtualFile file, FileType type) { | 208 | static std::unique_ptr<AppLoader> GetFileLoader(Core::System& system, FileSys::VirtualFile file, |
| 209 | FileType type, std::size_t program_index) { | ||
| 204 | switch (type) { | 210 | switch (type) { |
| 205 | |||
| 206 | // Standard ELF file format. | 211 | // Standard ELF file format. |
| 207 | case FileType::ELF: | 212 | case FileType::ELF: |
| 208 | return std::make_unique<AppLoader_ELF>(std::move(file)); | 213 | return std::make_unique<AppLoader_ELF>(std::move(file)); |
| @@ -221,7 +226,8 @@ static std::unique_ptr<AppLoader> GetFileLoader(FileSys::VirtualFile file, FileT | |||
| 221 | 226 | ||
| 222 | // NX XCI (nX Card Image) file format. | 227 | // NX XCI (nX Card Image) file format. |
| 223 | case FileType::XCI: | 228 | case FileType::XCI: |
| 224 | return std::make_unique<AppLoader_XCI>(std::move(file)); | 229 | return std::make_unique<AppLoader_XCI>(std::move(file), system.GetFileSystemController(), |
| 230 | system.GetContentProvider(), program_index); | ||
| 225 | 231 | ||
| 226 | // NX NAX (NintendoAesXts) file format. | 232 | // NX NAX (NintendoAesXts) file format. |
| 227 | case FileType::NAX: | 233 | case FileType::NAX: |
| @@ -229,7 +235,8 @@ static std::unique_ptr<AppLoader> GetFileLoader(FileSys::VirtualFile file, FileT | |||
| 229 | 235 | ||
| 230 | // NX NSP (Nintendo Submission Package) file format | 236 | // NX NSP (Nintendo Submission Package) file format |
| 231 | case FileType::NSP: | 237 | case FileType::NSP: |
| 232 | return std::make_unique<AppLoader_NSP>(std::move(file)); | 238 | return std::make_unique<AppLoader_NSP>(std::move(file), system.GetFileSystemController(), |
| 239 | system.GetContentProvider(), program_index); | ||
| 233 | 240 | ||
| 234 | // NX KIP (Kernel Internal Process) file format | 241 | // NX KIP (Kernel Internal Process) file format |
| 235 | case FileType::KIP: | 242 | case FileType::KIP: |
| @@ -244,20 +251,22 @@ static std::unique_ptr<AppLoader> GetFileLoader(FileSys::VirtualFile file, FileT | |||
| 244 | } | 251 | } |
| 245 | } | 252 | } |
| 246 | 253 | ||
| 247 | std::unique_ptr<AppLoader> GetLoader(FileSys::VirtualFile file) { | 254 | std::unique_ptr<AppLoader> GetLoader(Core::System& system, FileSys::VirtualFile file, |
| 255 | std::size_t program_index) { | ||
| 248 | FileType type = IdentifyFile(file); | 256 | FileType type = IdentifyFile(file); |
| 249 | FileType filename_type = GuessFromFilename(file->GetName()); | 257 | const FileType filename_type = GuessFromFilename(file->GetName()); |
| 250 | 258 | ||
| 251 | // Special case: 00 is either a NCA or NAX. | 259 | // Special case: 00 is either a NCA or NAX. |
| 252 | if (type != filename_type && !(file->GetName() == "00" && type == FileType::NAX)) { | 260 | if (type != filename_type && !(file->GetName() == "00" && type == FileType::NAX)) { |
| 253 | LOG_WARNING(Loader, "File {} has a different type than its extension.", file->GetName()); | 261 | LOG_WARNING(Loader, "File {} has a different type than its extension.", file->GetName()); |
| 254 | if (FileType::Unknown == type) | 262 | if (FileType::Unknown == type) { |
| 255 | type = filename_type; | 263 | type = filename_type; |
| 264 | } | ||
| 256 | } | 265 | } |
| 257 | 266 | ||
| 258 | LOG_DEBUG(Loader, "Loading file {} as {}...", file->GetName(), GetFileTypeString(type)); | 267 | LOG_DEBUG(Loader, "Loading file {} as {}...", file->GetName(), GetFileTypeString(type)); |
| 259 | 268 | ||
| 260 | return GetFileLoader(std::move(file), type); | 269 | return GetFileLoader(system, std::move(file), type, program_index); |
| 261 | } | 270 | } |
| 262 | 271 | ||
| 263 | } // namespace Loader | 272 | } // namespace Loader |