summaryrefslogtreecommitdiff
path: root/src/core/loader
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/loader')
-rw-r--r--src/core/loader/elf.cpp2
-rw-r--r--src/core/loader/elf.h5
-rw-r--r--src/core/loader/loader.cpp10
-rw-r--r--src/core/loader/loader.h3
-rw-r--r--src/core/loader/nro.cpp2
-rw-r--r--src/core/loader/nro.h6
-rw-r--r--src/core/loader/nso.cpp3
-rw-r--r--src/core/loader/nso.h7
8 files changed, 19 insertions, 19 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 9ba913dbe..a41d0b94a 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -364,7 +364,7 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const
364 364
365namespace Loader { 365namespace Loader {
366 366
367FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) { 367FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file, const std::string&) {
368 static constexpr u16 ELF_MACHINE_ARM{0x28}; 368 static constexpr u16 ELF_MACHINE_ARM{0x28};
369 369
370 u32 magic = 0; 370 u32 magic = 0;
diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h
index 113da5917..a5158338f 100644
--- a/src/core/loader/elf.h
+++ b/src/core/loader/elf.h
@@ -22,12 +22,13 @@ public:
22 /** 22 /**
23 * Returns the type of the file 23 * Returns the type of the file
24 * @param file FileUtil::IOFile open file 24 * @param file FileUtil::IOFile open file
25 * @param filepath Path of the file that we are opening.
25 * @return FileType found, or FileType::Error if this loader doesn't know it 26 * @return FileType found, or FileType::Error if this loader doesn't know it
26 */ 27 */
27 static FileType IdentifyType(FileUtil::IOFile& file); 28 static FileType IdentifyType(FileUtil::IOFile& file, const std::string& filepath);
28 29
29 FileType GetFileType() override { 30 FileType GetFileType() override {
30 return IdentifyType(file); 31 return IdentifyType(file, filename);
31 } 32 }
32 33
33 ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override; 34 ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 92defd381..2ecccdd4f 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -21,11 +21,11 @@ const std::initializer_list<Kernel::AddressMapping> default_address_mappings = {
21 {0x1F000000, 0x600000, false}, // entire VRAM 21 {0x1F000000, 0x600000, false}, // entire VRAM
22}; 22};
23 23
24FileType IdentifyFile(FileUtil::IOFile& file) { 24FileType IdentifyFile(FileUtil::IOFile& file, const std::string& filepath) {
25 FileType type; 25 FileType type;
26 26
27#define CHECK_TYPE(loader) \ 27#define CHECK_TYPE(loader) \
28 type = AppLoader_##loader::IdentifyType(file); \ 28 type = AppLoader_##loader::IdentifyType(file, filepath); \
29 if (FileType::Error != type) \ 29 if (FileType::Error != type) \
30 return type; 30 return type;
31 31
@@ -45,13 +45,13 @@ FileType IdentifyFile(const std::string& file_name) {
45 return FileType::Unknown; 45 return FileType::Unknown;
46 } 46 }
47 47
48 return IdentifyFile(file); 48 return IdentifyFile(file, file_name);
49} 49}
50 50
51FileType GuessFromExtension(const std::string& extension_) { 51FileType GuessFromExtension(const std::string& extension_) {
52 std::string extension = Common::ToLower(extension_); 52 std::string extension = Common::ToLower(extension_);
53 53
54 if (extension == ".elf" || extension == ".axf") 54 if (extension == ".elf")
55 return FileType::ELF; 55 return FileType::ELF;
56 else if (extension == ".nro") 56 else if (extension == ".nro")
57 return FileType::NRO; 57 return FileType::NRO;
@@ -117,7 +117,7 @@ std::unique_ptr<AppLoader> GetLoader(const std::string& filename) {
117 std::string filename_filename, filename_extension; 117 std::string filename_filename, filename_extension;
118 Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension); 118 Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension);
119 119
120 FileType type = IdentifyFile(file); 120 FileType type = IdentifyFile(file, filename);
121 FileType filename_type = GuessFromExtension(filename_extension); 121 FileType filename_type = GuessFromExtension(filename_extension);
122 122
123 if (type != filename_type) { 123 if (type != filename_type) {
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index dd6bb4e64..f7828b7ad 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -37,9 +37,10 @@ enum class FileType {
37/** 37/**
38 * Identifies the type of a bootable file based on the magic value in its header. 38 * Identifies the type of a bootable file based on the magic value in its header.
39 * @param file open file 39 * @param file open file
40 * @param filepath Path of the file that we are opening.
40 * @return FileType of file 41 * @return FileType of file
41 */ 42 */
42FileType IdentifyFile(FileUtil::IOFile& file); 43FileType IdentifyFile(FileUtil::IOFile& file, const std::string& filepath);
43 44
44/** 45/**
45 * Identifies the type of a bootable file based on the magic value in its header. 46 * Identifies the type of a bootable file based on the magic value in its header.
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index 6864a1926..ac730f8a3 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -45,7 +45,7 @@ struct ModHeader {
45}; 45};
46static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size."); 46static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size.");
47 47
48FileType AppLoader_NRO::IdentifyType(FileUtil::IOFile& file) { 48FileType AppLoader_NRO::IdentifyType(FileUtil::IOFile& file, const std::string&) {
49 // Read NSO header 49 // Read NSO header
50 NroHeader nro_header{}; 50 NroHeader nro_header{};
51 file.Seek(0, SEEK_SET); 51 file.Seek(0, SEEK_SET);
diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h
index e20fa1555..ae4c84fb7 100644
--- a/src/core/loader/nro.h
+++ b/src/core/loader/nro.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <map>
8#include <string> 7#include <string>
9#include "common/common_types.h" 8#include "common/common_types.h"
10#include "common/file_util.h" 9#include "common/file_util.h"
@@ -23,12 +22,13 @@ public:
23 /** 22 /**
24 * Returns the type of the file 23 * Returns the type of the file
25 * @param file FileUtil::IOFile open file 24 * @param file FileUtil::IOFile open file
25 * @param filepath Path of the file that we are opening.
26 * @return FileType found, or FileType::Error if this loader doesn't know it 26 * @return FileType found, or FileType::Error if this loader doesn't know it
27 */ 27 */
28 static FileType IdentifyType(FileUtil::IOFile& file); 28 static FileType IdentifyType(FileUtil::IOFile& file, const std::string& filepath);
29 29
30 FileType GetFileType() override { 30 FileType GetFileType() override {
31 return IdentifyType(file); 31 return IdentifyType(file, filepath);
32 } 32 }
33 33
34 ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override; 34 ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 77b4f93eb..c80f2a100 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -4,7 +4,6 @@
4 4
5#include <vector> 5#include <vector>
6#include <lz4.h> 6#include <lz4.h>
7
8#include "common/common_funcs.h" 7#include "common/common_funcs.h"
9#include "common/logging/log.h" 8#include "common/logging/log.h"
10#include "common/swap.h" 9#include "common/swap.h"
@@ -47,7 +46,7 @@ struct ModHeader {
47}; 46};
48static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size."); 47static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size.");
49 48
50FileType AppLoader_NSO::IdentifyType(FileUtil::IOFile& file) { 49FileType AppLoader_NSO::IdentifyType(FileUtil::IOFile& file, const std::string&) {
51 u32 magic = 0; 50 u32 magic = 0;
52 file.Seek(0, SEEK_SET); 51 file.Seek(0, SEEK_SET);
53 if (1 != file.ReadArray<u32>(&magic, 1)) { 52 if (1 != file.ReadArray<u32>(&magic, 1)) {
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h
index 44d6dbbd9..f6a2b214f 100644
--- a/src/core/loader/nso.h
+++ b/src/core/loader/nso.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <map>
8#include <string> 7#include <string>
9#include "common/common_types.h" 8#include "common/common_types.h"
10#include "common/file_util.h" 9#include "common/file_util.h"
@@ -23,12 +22,13 @@ public:
23 /** 22 /**
24 * Returns the type of the file 23 * Returns the type of the file
25 * @param file FileUtil::IOFile open file 24 * @param file FileUtil::IOFile open file
25 * @param filepath Path of the file that we are opening.
26 * @return FileType found, or FileType::Error if this loader doesn't know it 26 * @return FileType found, or FileType::Error if this loader doesn't know it
27 */ 27 */
28 static FileType IdentifyType(FileUtil::IOFile& file); 28 static FileType IdentifyType(FileUtil::IOFile& file, const std::string& filepath);
29 29
30 FileType GetFileType() override { 30 FileType GetFileType() override {
31 return IdentifyType(file); 31 return IdentifyType(file, filepath);
32 } 32 }
33 33
34 static VAddr LoadModule(const std::string& path, VAddr load_base); 34 static VAddr LoadModule(const std::string& path, VAddr load_base);
@@ -36,7 +36,6 @@ public:
36 ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override; 36 ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
37 37
38private: 38private:
39
40 std::string filepath; 39 std::string filepath;
41}; 40};
42 41