From 85030c6e6bfe83b6671de45b25535fe3ef713319 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 6 Jan 2015 19:49:25 +0000 Subject: Loader: Never forget to change is_loaded. --- src/core/loader/ncch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/loader/ncch.h') diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index fd9258970..184a20d98 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -215,7 +215,7 @@ private: std::string filename; - bool is_loaded; + bool is_loaded = false; bool is_compressed; u32 entry_point; -- cgit v1.2.3 From 2d63df90a9d64d3961be07ef0a959bc48b42c73b Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 6 Jan 2015 21:10:12 +0000 Subject: Loader: Initialize the default NCCH values in the class declaration, not in the constructor. --- src/core/loader/ncch.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core/loader/ncch.h') diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index 184a20d98..578513f77 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -216,11 +216,11 @@ private: std::string filename; bool is_loaded = false; - bool is_compressed; + bool is_compressed = false; - u32 entry_point; - u32 ncch_offset; // Offset to NCCH header, can be 0 or after NCSD header - u32 exefs_offset; + u32 entry_point = 0; + u32 ncch_offset = 0; // Offset to NCCH header, can be 0 or after NCSD header + u32 exefs_offset = 0; NCCH_Header ncch_header; ExeFs_Header exefs_header; -- cgit v1.2.3 From b5237e885df72f6c37532fc8af9573966e7b07e5 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 6 Jan 2015 21:30:40 +0000 Subject: Loader: Keep a reference to the file and pass it to the correct AppLoader, instead of loading it multiple times. --- src/core/loader/ncch.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/core/loader/ncch.h') diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index 578513f77..d9d68f154 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -5,7 +5,6 @@ #pragma once #include "common/common.h" -#include "common/file_util.h" #include "core/loader/loader.h" @@ -147,8 +146,7 @@ namespace Loader { /// Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI) class AppLoader_NCCH final : public AppLoader { public: - AppLoader_NCCH(const std::string& filename); - ~AppLoader_NCCH() override; + AppLoader_NCCH(std::unique_ptr&& file) : AppLoader(std::move(file)) { } /** * Load the application @@ -213,9 +211,6 @@ private: */ ResultStatus LoadExec() const; - std::string filename; - - bool is_loaded = false; bool is_compressed = false; u32 entry_point = 0; -- cgit v1.2.3 From 82ec17db7df53ed1c376d1cdaa9a6587719a546d Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 6 Jan 2015 23:10:13 +0000 Subject: Loader: Guess filetype from the magic, or fallback to the extension. --- src/core/loader/ncch.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/core/loader/ncch.h') diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index d9d68f154..9ae2de99f 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -13,7 +13,7 @@ struct NCCH_Header { u8 signature[0x100]; - char magic[4]; + u32 magic; u32 content_size; u8 partition_id[8]; u16 maker_code; @@ -148,6 +148,13 @@ class AppLoader_NCCH final : public AppLoader { public: AppLoader_NCCH(std::unique_ptr&& file) : AppLoader(std::move(file)) { } + /** + * Returns the type of the file + * @param file FileUtil::IOFile open file + * @return FileType found, or FileType::Error if this loader doesn't know it + */ + static FileType IdentifyType(FileUtil::IOFile& file); + /** * Load the application * @return ResultStatus result of function -- cgit v1.2.3