summaryrefslogtreecommitdiff
path: root/src/core/loader.cpp
diff options
context:
space:
mode:
authorGravatar Mathieu Vaillancourt2014-04-21 23:09:10 -0400
committerGravatar Mathieu Vaillancourt2014-04-21 23:15:40 -0400
commit5ad1aa8b6821a86527a1afa455516d2d8f2291cd (patch)
tree246d55e5958eba861ac82629a933c8893e9cd391 /src/core/loader.cpp
parentfixed order of LogManager and System init (diff)
downloadyuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.tar.gz
yuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.tar.xz
yuzu-5ad1aa8b6821a86527a1afa455516d2d8f2291cd.zip
Add a quick way to load Launcher.dat files
Diffstat (limited to 'src/core/loader.cpp')
-rw-r--r--src/core/loader.cpp54
1 files changed, 54 insertions, 0 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 @@
11#include "core/file_sys/directory_file_system.h" 11#include "core/file_sys/directory_file_system.h"
12#include "core/elf/elf_reader.h" 12#include "core/elf/elf_reader.h"
13 13
14#include "core/mem_map.h"
15
14//////////////////////////////////////////////////////////////////////////////////////////////////// 16////////////////////////////////////////////////////////////////////////////////////////////////////
15 17
16/// Loads an extracted CXI from a directory 18/// Loads an extracted CXI from a directory
@@ -66,6 +68,52 @@ bool Load_ELF(std::string &filename) {
66 return true; 68 return true;
67} 69}
68 70
71/// Loads a Launcher DAT file
72bool Load_DAT(std::string &filename) {
73 std::string full_path = filename;
74 std::string path, file, extension;
75 SplitPath(ReplaceAll(full_path, "\\", "/"), &path, &file, &extension);
76#if EMU_PLATFORM == PLATFORM_WINDOWS
77 path = ReplaceAll(path, "/", "\\");
78#endif
79 File::IOFile f(filename, "rb");
80
81 if (f.IsOpen()) {
82 u64 size = f.GetSize();
83 u8* buffer = new u8[size];
84
85 f.ReadBytes(buffer, size);
86
87 /**
88 * (mattvail) We shouldn't really support this type of file
89 * but for the sake of making it easier... we'll temporarily/hackishly
90 * allow it. No sense in making a proper reader for this.
91 */
92 u32 entrypoint = 0x080c3ee0; // write to same entrypoint as elf
93 u32 payload_offset = 0x6F4;
94
95 const u8 *src = &buffer[payload_offset];
96 u8 *dst = Memory::GetPointer(entrypoint);
97 u32 srcSize = size - payload_offset; //just load everything...
98 u32 *s = (u32*)src;
99 u32 *d = (u32*)dst;
100 for (int j = 0; j < (int)(srcSize + 3) / 4; j++)
101 {
102 *d++ = (*s++);
103 }
104
105 Core::g_app_core->SetPC(entrypoint);
106
107 delete[] buffer;
108 }
109 else {
110 return false;
111 }
112 f.Close();
113
114 return true;
115}
116
69namespace Loader { 117namespace Loader {
70 118
71bool IsBootableDirectory() { 119bool IsBootableDirectory() {
@@ -97,6 +145,9 @@ FileType IdentifyFile(std::string &filename) {
97 else if (!strcasecmp(extension.c_str(), ".elf")) { 145 else if (!strcasecmp(extension.c_str(), ".elf")) {
98 return FILETYPE_CTR_ELF; // TODO(bunnei): Do some filetype checking :p 146 return FILETYPE_CTR_ELF; // TODO(bunnei): Do some filetype checking :p
99 } 147 }
148 else if (!strcasecmp(extension.c_str(), ".dat")) {
149 return FILETYPE_LAUNCHER_DAT;
150 }
100 else if (!strcasecmp(extension.c_str(), ".zip")) { 151 else if (!strcasecmp(extension.c_str(), ".zip")) {
101 return FILETYPE_ARCHIVE_ZIP; 152 return FILETYPE_ARCHIVE_ZIP;
102 } 153 }
@@ -127,6 +178,9 @@ bool LoadFile(std::string &filename, std::string *error_string) {
127 case FILETYPE_CTR_ELF: 178 case FILETYPE_CTR_ELF:
128 return Load_ELF(filename); 179 return Load_ELF(filename);
129 180
181 case FILETYPE_LAUNCHER_DAT:
182 return Load_DAT(filename);
183
130 case FILETYPE_DIRECTORY_CXI: 184 case FILETYPE_DIRECTORY_CXI:
131 return LoadDirectory_CXI(filename); 185 return LoadDirectory_CXI(filename);
132 186