diff options
author | Mathieu Vaillancourt <vaillancourtm@gmail.com> | 2014-04-22 05:09:10 +0200 |
---|---|---|
committer | Mathieu Vaillancourt <vaillancourtm@gmail.com> | 2014-04-22 05:15:40 +0200 |
commit | 5ad1aa8b6821a86527a1afa455516d2d8f2291cd (patch) | |
tree | 246d55e5958eba861ac82629a933c8893e9cd391 | |
parent | fixed order of LogManager and System init (diff) | |
download | yuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.tar yuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.tar.gz yuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.tar.bz2 yuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.tar.lz yuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.tar.xz yuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.tar.zst yuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.zip |
-rw-r--r-- | src/core/loader.cpp | 54 | ||||
-rw-r--r-- | src/core/loader.h | 11 |
2 files changed, 60 insertions, 5 deletions
diff --git a/src/core/loader.cpp b/src/core/loader.cpp index 8c6d54a68..7c1dfef61 100644 --- a/src/core/loader.cpp +++ b/src/core/loader.cpp @@ -11,6 +11,8 @@ #include "core/file_sys/directory_file_system.h" #include "core/elf/elf_reader.h" +#include "core/mem_map.h" + //////////////////////////////////////////////////////////////////////////////////////////////////// /// Loads an extracted CXI from a directory @@ -66,6 +68,52 @@ bool Load_ELF(std::string &filename) { return true; } +/// Loads a Launcher DAT file +bool Load_DAT(std::string &filename) { + std::string full_path = filename; + std::string path, file, extension; + SplitPath(ReplaceAll(full_path, "\\", "/"), &path, &file, &extension); +#if EMU_PLATFORM == PLATFORM_WINDOWS + path = ReplaceAll(path, "/", "\\"); +#endif + File::IOFile f(filename, "rb"); + + if (f.IsOpen()) { + u64 size = f.GetSize(); + u8* buffer = new u8[size]; + + f.ReadBytes(buffer, size); + + /** + * (mattvail) We shouldn't really support this type of file + * but for the sake of making it easier... we'll temporarily/hackishly + * allow it. No sense in making a proper reader for this. + */ + u32 entrypoint = 0x080c3ee0; // write to same entrypoint as elf + u32 payload_offset = 0x6F4; + + const u8 *src = &buffer[payload_offset]; + u8 *dst = Memory::GetPointer(entrypoint); + u32 srcSize = size - payload_offset; //just load everything... + u32 *s = (u32*)src; + u32 *d = (u32*)dst; + for (int j = 0; j < (int)(srcSize + 3) / 4; j++) + { + *d++ = (*s++); + } + + Core::g_app_core->SetPC(entrypoint); + + delete[] buffer; + } + else { + return false; + } + f.Close(); + + return true; +} + namespace Loader { bool IsBootableDirectory() { @@ -97,6 +145,9 @@ FileType IdentifyFile(std::string &filename) { else if (!strcasecmp(extension.c_str(), ".elf")) { return FILETYPE_CTR_ELF; // TODO(bunnei): Do some filetype checking :p } + else if (!strcasecmp(extension.c_str(), ".dat")) { + return FILETYPE_LAUNCHER_DAT; + } else if (!strcasecmp(extension.c_str(), ".zip")) { return FILETYPE_ARCHIVE_ZIP; } @@ -127,6 +178,9 @@ bool LoadFile(std::string &filename, std::string *error_string) { case FILETYPE_CTR_ELF: return Load_ELF(filename); + case FILETYPE_LAUNCHER_DAT: + return Load_DAT(filename); + case FILETYPE_DIRECTORY_CXI: return LoadDirectory_CXI(filename); diff --git a/src/core/loader.h b/src/core/loader.h index 3dd8c471d..df30f16c7 100644 --- a/src/core/loader.h +++ b/src/core/loader.h @@ -11,12 +11,13 @@ namespace Loader { enum FileType { - FILETYPE_ERROR, + FILETYPE_ERROR, - FILETYPE_CTR_CCI, - FILETYPE_CTR_CIA, - FILETYPE_CTR_CXI, - FILETYPE_CTR_ELF, + FILETYPE_CTR_CCI, + FILETYPE_CTR_CIA, + FILETYPE_CTR_CXI, + FILETYPE_CTR_ELF, + FILETYPE_LAUNCHER_DAT, FILETYPE_DIRECTORY_CXI, |