summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <ericbunnie@gmail.com>2014-05-01 05:50:14 +0200
committerbunnei <ericbunnie@gmail.com>2014-05-01 05:50:14 +0200
commitbb7fcf79fe4a768eb4e6d26c55c2b1eb8cd4fa07 (patch)
tree9cb9fdd8eb3e23de9fa782cc17eabfd9360b535f /src
parentadded symbol map load function to Qt GUI (diff)
downloadyuzu-bb7fcf79fe4a768eb4e6d26c55c2b1eb8cd4fa07.tar
yuzu-bb7fcf79fe4a768eb4e6d26c55c2b1eb8cd4fa07.tar.gz
yuzu-bb7fcf79fe4a768eb4e6d26c55c2b1eb8cd4fa07.tar.bz2
yuzu-bb7fcf79fe4a768eb4e6d26c55c2b1eb8cd4fa07.tar.lz
yuzu-bb7fcf79fe4a768eb4e6d26c55c2b1eb8cd4fa07.tar.xz
yuzu-bb7fcf79fe4a768eb4e6d26c55c2b1eb8cd4fa07.tar.zst
yuzu-bb7fcf79fe4a768eb4e6d26c55c2b1eb8cd4fa07.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/loader.cpp53
-rw-r--r--src/core/loader.h24
2 files changed, 63 insertions, 14 deletions
diff --git a/src/core/loader.cpp b/src/core/loader.cpp
index 7c1dfef61..8756588ae 100644
--- a/src/core/loader.cpp
+++ b/src/core/loader.cpp
@@ -89,8 +89,8 @@ bool Load_DAT(std::string &filename) {
* 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;
+ u32 entrypoint = 0x00100000; // write to same entrypoint as elf
+ u32 payload_offset = 0xA150;
const u8 *src = &buffer[payload_offset];
u8 *dst = Memory::GetPointer(entrypoint);
@@ -114,6 +114,47 @@ bool Load_DAT(std::string &filename) {
return true;
}
+
+/// Loads a CTR BIN file extracted from an ExeFS
+bool Load_BIN(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);
+
+ u32 entrypoint = 0x00100000; // Hardcoded, read from exheader
+
+ const u8 *src = buffer;
+ u8 *dst = Memory::GetPointer(entrypoint);
+ u32 srcSize = size;
+ 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() {
@@ -145,6 +186,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(), ".bin")) {
+ return FILETYPE_CTR_BIN;
+ }
else if (!strcasecmp(extension.c_str(), ".dat")) {
return FILETYPE_LAUNCHER_DAT;
}
@@ -178,6 +222,9 @@ bool LoadFile(std::string &filename, std::string *error_string) {
case FILETYPE_CTR_ELF:
return Load_ELF(filename);
+ case FILETYPE_CTR_BIN:
+ return Load_BIN(filename);
+
case FILETYPE_LAUNCHER_DAT:
return Load_DAT(filename);
@@ -215,7 +262,7 @@ bool LoadFile(std::string &filename, std::string *error_string) {
case FILETYPE_UNKNOWN:
default:
ERROR_LOG(LOADER, "Failed to identify file");
- *error_string = "Failed to identify file";
+ *error_string = " Failed to identify file";
break;
}
return false;
diff --git a/src/core/loader.h b/src/core/loader.h
index df30f16c7..9d4aaa874 100644
--- a/src/core/loader.h
+++ b/src/core/loader.h
@@ -17,19 +17,21 @@ enum FileType {
FILETYPE_CTR_CIA,
FILETYPE_CTR_CXI,
FILETYPE_CTR_ELF,
- FILETYPE_LAUNCHER_DAT,
-
- FILETYPE_DIRECTORY_CXI,
-
- FILETYPE_UNKNOWN_BIN,
- FILETYPE_UNKNOWN_ELF,
+ FILETYPE_CTR_BIN,
- FILETYPE_ARCHIVE_RAR,
- FILETYPE_ARCHIVE_ZIP,
-
- FILETYPE_NORMAL_DIRECTORY,
+ FILETYPE_LAUNCHER_DAT,
- FILETYPE_UNKNOWN
+ FILETYPE_DIRECTORY_CXI,
+
+ FILETYPE_UNKNOWN_BIN,
+ FILETYPE_UNKNOWN_ELF,
+
+ FILETYPE_ARCHIVE_RAR,
+ FILETYPE_ARCHIVE_ZIP,
+
+ FILETYPE_NORMAL_DIRECTORY,
+
+ FILETYPE_UNKNOWN
};
////////////////////////////////////////////////////////////////////////////////////////////////////