diff options
Diffstat (limited to 'src/core/loader')
-rw-r--r-- | src/core/loader/deconstructed_rom_directory.cpp | 3 | ||||
-rw-r--r-- | src/core/loader/deconstructed_rom_directory.h | 2 | ||||
-rw-r--r-- | src/core/loader/elf.h | 2 | ||||
-rw-r--r-- | src/core/loader/loader.h | 12 | ||||
-rw-r--r-- | src/core/loader/nax.cpp | 2 | ||||
-rw-r--r-- | src/core/loader/nax.h | 2 | ||||
-rw-r--r-- | src/core/loader/nca.h | 2 | ||||
-rw-r--r-- | src/core/loader/nro.cpp | 15 | ||||
-rw-r--r-- | src/core/loader/nro.h | 10 | ||||
-rw-r--r-- | src/core/loader/nso.cpp | 8 | ||||
-rw-r--r-- | src/core/loader/nso.h | 10 | ||||
-rw-r--r-- | src/core/loader/nsp.cpp | 7 | ||||
-rw-r--r-- | src/core/loader/nsp.h | 3 | ||||
-rw-r--r-- | src/core/loader/xci.cpp | 7 | ||||
-rw-r--r-- | src/core/loader/xci.h | 3 |
15 files changed, 59 insertions, 29 deletions
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 8518dddcb..ac04d72d7 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp @@ -7,7 +7,6 @@ #include "common/common_funcs.h" #include "common/file_util.h" #include "common/logging/log.h" -#include "core/core.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/patch_manager.h" @@ -146,7 +145,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process) const VAddr load_addr = next_load_addr; const bool should_pass_arguments = std::strcmp(module, "rtld") == 0; const auto tentative_next_load_addr = - AppLoader_NSO::LoadModule(*module_file, load_addr, should_pass_arguments, pm); + AppLoader_NSO::LoadModule(process, *module_file, load_addr, should_pass_arguments, pm); if (!tentative_next_load_addr) { return ResultStatus::ErrorLoadingNSO; } diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.h index d109ed2b5..1615cb5a8 100644 --- a/src/core/loader/deconstructed_rom_directory.h +++ b/src/core/loader/deconstructed_rom_directory.h @@ -33,7 +33,7 @@ public: */ static FileType IdentifyType(const FileSys::VirtualFile& file); - FileType GetFileType() override { + FileType GetFileType() const override { return IdentifyType(file); } diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h index 6af76441c..a2d33021c 100644 --- a/src/core/loader/elf.h +++ b/src/core/loader/elf.h @@ -22,7 +22,7 @@ public: */ static FileType IdentifyType(const FileSys::VirtualFile& file); - FileType GetFileType() override { + FileType GetFileType() const override { return IdentifyType(file); } diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 7686634bf..0838e303b 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -12,6 +12,7 @@ #include <vector> #include "common/common_types.h" +#include "core/file_sys/control_metadata.h" #include "core/file_sys/vfs.h" namespace Kernel { @@ -131,7 +132,7 @@ public: * Returns the type of this file * @return FileType corresponding to the loaded file */ - virtual FileType GetFileType() = 0; + virtual FileType GetFileType() const = 0; /** * Load the application and return the created Process instance @@ -243,6 +244,15 @@ public: return ResultStatus::ErrorNotImplemented; } + /** + * Get the developer of the application + * @param developer Reference to store the application developer into + * @return ResultStatus result of function + */ + virtual ResultStatus ReadDeveloper(std::string& developer) { + return ResultStatus::ErrorNotImplemented; + } + protected: FileSys::VirtualFile file; bool is_loaded = false; diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp index 42f4a777b..a093e3d36 100644 --- a/src/core/loader/nax.cpp +++ b/src/core/loader/nax.cpp @@ -37,7 +37,7 @@ FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) { return IdentifyTypeImpl(nax); } -FileType AppLoader_NAX::GetFileType() { +FileType AppLoader_NAX::GetFileType() const { return IdentifyTypeImpl(*nax); } diff --git a/src/core/loader/nax.h b/src/core/loader/nax.h index b4d93bd01..0a97511b8 100644 --- a/src/core/loader/nax.h +++ b/src/core/loader/nax.h @@ -31,7 +31,7 @@ public: */ static FileType IdentifyType(const FileSys::VirtualFile& file); - FileType GetFileType() override; + FileType GetFileType() const override; ResultStatus Load(Kernel::Process& process) override; diff --git a/src/core/loader/nca.h b/src/core/loader/nca.h index 95d9b73a1..cbbe701d2 100644 --- a/src/core/loader/nca.h +++ b/src/core/loader/nca.h @@ -29,7 +29,7 @@ public: */ static FileType IdentifyType(const FileSys::VirtualFile& file); - FileType GetFileType() override { + FileType GetFileType() const override { return IdentifyType(file); } diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index fbbd6b0de..4fad0c0dd 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp @@ -10,7 +10,6 @@ #include "common/file_util.h" #include "common/logging/log.h" #include "common/swap.h" -#include "core/core.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/romfs_factory.h" #include "core/file_sys/vfs_offset.h" @@ -129,9 +128,8 @@ static constexpr u32 PageAlignSize(u32 size) { return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; } -/*static*/ bool AppLoader_NRO::LoadNro(const std::vector<u8>& data, const std::string& name, - VAddr load_base) { - +static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data, + const std::string& name, VAddr load_base) { if (data.size() < sizeof(NroHeader)) { return {}; } @@ -189,7 +187,7 @@ static constexpr u32 PageAlignSize(u32 size) { // Load codeset for current process codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); - Core::CurrentProcess()->LoadModule(std::move(codeset), load_base); + process.LoadModule(std::move(codeset), load_base); // Register module with GDBStub GDBStub::RegisterModule(name, load_base, load_base); @@ -197,8 +195,9 @@ static constexpr u32 PageAlignSize(u32 size) { return true; } -bool AppLoader_NRO::LoadNro(const FileSys::VfsFile& file, VAddr load_base) { - return AppLoader_NRO::LoadNro(file.ReadAllBytes(), file.GetName(), load_base); +bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& file, + VAddr load_base) { + return LoadNroImpl(process, file.ReadAllBytes(), file.GetName(), load_base); } ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { @@ -209,7 +208,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { // Load NRO const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); - if (!LoadNro(*file, base_address)) { + if (!LoadNro(process, *file, base_address)) { return ResultStatus::ErrorLoadingNRO; } diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h index 3e6959302..013d629c0 100644 --- a/src/core/loader/nro.h +++ b/src/core/loader/nro.h @@ -14,6 +14,10 @@ namespace FileSys { class NACP; } +namespace Kernel { +class Process; +} + namespace Loader { /// Loads an NRO file @@ -29,7 +33,7 @@ public: */ static FileType IdentifyType(const FileSys::VirtualFile& file); - FileType GetFileType() override { + FileType GetFileType() const override { return IdentifyType(file); } @@ -41,10 +45,8 @@ public: ResultStatus ReadTitle(std::string& title) override; bool IsRomFSUpdatable() const override; - static bool LoadNro(const std::vector<u8>& data, const std::string& name, VAddr load_base); - private: - bool LoadNro(const FileSys::VfsFile& file, VAddr load_base); + bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& file, VAddr load_base); std::vector<u8> icon_data; std::unique_ptr<FileSys::NACP> nacp; diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index aaf006309..6ded0b707 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -9,7 +9,6 @@ #include "common/file_util.h" #include "common/logging/log.h" #include "common/swap.h" -#include "core/core.h" #include "core/file_sys/patch_manager.h" #include "core/gdbstub/gdbstub.h" #include "core/hle/kernel/process.h" @@ -93,7 +92,8 @@ static constexpr u32 PageAlignSize(u32 size) { return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; } -std::optional<VAddr> AppLoader_NSO::LoadModule(const FileSys::VfsFile& file, VAddr load_base, +std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, + const FileSys::VfsFile& file, VAddr load_base, bool should_pass_arguments, std::optional<FileSys::PatchManager> pm) { if (file.GetSize() < sizeof(NsoHeader)) @@ -166,7 +166,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(const FileSys::VfsFile& file, VAd // Load codeset for current process codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); - Core::CurrentProcess()->LoadModule(std::move(codeset), load_base); + process.LoadModule(std::move(codeset), load_base); // Register module with GDBStub GDBStub::RegisterModule(file.GetName(), load_base, load_base); @@ -181,7 +181,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::Process& process) { // Load module const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); - if (!LoadModule(*file, base_address, true)) { + if (!LoadModule(process, *file, base_address, true)) { return ResultStatus::ErrorLoadingNSO; } LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h index 433306139..135b6ea5a 100644 --- a/src/core/loader/nso.h +++ b/src/core/loader/nso.h @@ -10,6 +10,10 @@ #include "core/loader/linker.h" #include "core/loader/loader.h" +namespace Kernel { +class Process; +} + namespace Loader { constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000; @@ -33,12 +37,12 @@ public: */ static FileType IdentifyType(const FileSys::VirtualFile& file); - FileType GetFileType() override { + FileType GetFileType() const override { return IdentifyType(file); } - static std::optional<VAddr> LoadModule(const FileSys::VfsFile& file, VAddr load_base, - bool should_pass_arguments, + static std::optional<VAddr> LoadModule(Kernel::Process& process, const FileSys::VfsFile& file, + VAddr load_base, bool should_pass_arguments, std::optional<FileSys::PatchManager> pm = {}); ResultStatus Load(Kernel::Process& process) override; diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index 080d89904..b4ab88ae8 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp @@ -151,4 +151,11 @@ ResultStatus AppLoader_NSP::ReadTitle(std::string& title) { title = nacp_file->GetApplicationName(); return ResultStatus::Success; } + +ResultStatus AppLoader_NSP::ReadDeveloper(std::string& developer) { + if (nacp_file == nullptr) + return ResultStatus::ErrorNoControl; + developer = nacp_file->GetDeveloperName(); + return ResultStatus::Success; +} } // namespace Loader diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h index db91cd01e..2b1e0719b 100644 --- a/src/core/loader/nsp.h +++ b/src/core/loader/nsp.h @@ -31,7 +31,7 @@ public: */ static FileType IdentifyType(const FileSys::VirtualFile& file); - FileType GetFileType() override { + FileType GetFileType() const override { return IdentifyType(file); } @@ -43,6 +43,7 @@ public: ResultStatus ReadProgramId(u64& out_program_id) override; ResultStatus ReadIcon(std::vector<u8>& buffer) override; ResultStatus ReadTitle(std::string& title) override; + ResultStatus ReadDeveloper(std::string& developer) override; private: std::unique_ptr<FileSys::NSP> nsp; diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index 461607c95..bd5a83b49 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -120,4 +120,11 @@ ResultStatus AppLoader_XCI::ReadTitle(std::string& title) { title = nacp_file->GetApplicationName(); return ResultStatus::Success; } + +ResultStatus AppLoader_XCI::ReadDeveloper(std::string& developer) { + if (nacp_file == nullptr) + return ResultStatus::ErrorNoControl; + developer = nacp_file->GetDeveloperName(); + return ResultStatus::Success; +} } // namespace Loader diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h index 46f8dfc9e..15d1b1a23 100644 --- a/src/core/loader/xci.h +++ b/src/core/loader/xci.h @@ -31,7 +31,7 @@ public: */ static FileType IdentifyType(const FileSys::VirtualFile& file); - FileType GetFileType() override { + FileType GetFileType() const override { return IdentifyType(file); } @@ -43,6 +43,7 @@ public: ResultStatus ReadProgramId(u64& out_program_id) override; ResultStatus ReadIcon(std::vector<u8>& buffer) override; ResultStatus ReadTitle(std::string& title) override; + ResultStatus ReadDeveloper(std::string& developer) override; private: std::unique_ptr<FileSys::XCI> xci; |