Merge pull request #6250 from lioncash/loader-shadow
loader: Resolve instances of variable shadowing
This commit is contained in:
commit
b096ec68cd
@ -24,10 +24,10 @@ namespace Loader {
|
||||
AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_,
|
||||
bool override_update)
|
||||
: AppLoader(std::move(file_)), override_update(override_update) {
|
||||
const auto dir = file->GetContainingDirectory();
|
||||
const auto file_dir = file->GetContainingDirectory();
|
||||
|
||||
// Title ID
|
||||
const auto npdm = dir->GetFile("main.npdm");
|
||||
const auto npdm = file_dir->GetFile("main.npdm");
|
||||
if (npdm != nullptr) {
|
||||
const auto res = metadata.Load(npdm);
|
||||
if (res == ResultStatus::Success)
|
||||
@ -37,7 +37,7 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys
|
||||
// Icon
|
||||
FileSys::VirtualFile icon_file = nullptr;
|
||||
for (const auto& language : FileSys::LANGUAGE_NAMES) {
|
||||
icon_file = dir->GetFile("icon_" + std::string(language) + ".dat");
|
||||
icon_file = file_dir->GetFile("icon_" + std::string(language) + ".dat");
|
||||
if (icon_file != nullptr) {
|
||||
icon_data = icon_file->ReadAllBytes();
|
||||
break;
|
||||
@ -46,7 +46,7 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys
|
||||
|
||||
if (icon_data.empty()) {
|
||||
// Any png, jpeg, or bmp file
|
||||
const auto& files = dir->GetFiles();
|
||||
const auto& files = file_dir->GetFiles();
|
||||
const auto icon_iter =
|
||||
std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) {
|
||||
return file->GetExtension() == "png" || file->GetExtension() == "jpg" ||
|
||||
@ -57,9 +57,9 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys
|
||||
}
|
||||
|
||||
// Metadata
|
||||
FileSys::VirtualFile nacp_file = dir->GetFile("control.nacp");
|
||||
FileSys::VirtualFile nacp_file = file_dir->GetFile("control.nacp");
|
||||
if (nacp_file == nullptr) {
|
||||
const auto& files = dir->GetFiles();
|
||||
const auto& files = file_dir->GetFiles();
|
||||
const auto nacp_iter =
|
||||
std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) {
|
||||
return file->GetExtension() == "nacp";
|
||||
@ -200,17 +200,21 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect
|
||||
LoadParameters{metadata.GetMainThreadPriority(), metadata.GetMainThreadStackSize()}};
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_DeconstructedRomDirectory::ReadRomFS(FileSys::VirtualFile& dir) {
|
||||
if (romfs == nullptr)
|
||||
ResultStatus AppLoader_DeconstructedRomDirectory::ReadRomFS(FileSys::VirtualFile& out_dir) {
|
||||
if (romfs == nullptr) {
|
||||
return ResultStatus::ErrorNoRomFS;
|
||||
dir = romfs;
|
||||
}
|
||||
|
||||
out_dir = romfs;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_DeconstructedRomDirectory::ReadIcon(std::vector<u8>& buffer) {
|
||||
if (icon_data.empty())
|
||||
ResultStatus AppLoader_DeconstructedRomDirectory::ReadIcon(std::vector<u8>& out_buffer) {
|
||||
if (icon_data.empty()) {
|
||||
return ResultStatus::ErrorNoIcon;
|
||||
buffer = icon_data;
|
||||
}
|
||||
|
||||
out_buffer = icon_data;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
@ -219,10 +223,12 @@ ResultStatus AppLoader_DeconstructedRomDirectory::ReadProgramId(u64& out_program
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_DeconstructedRomDirectory::ReadTitle(std::string& title) {
|
||||
if (name.empty())
|
||||
ResultStatus AppLoader_DeconstructedRomDirectory::ReadTitle(std::string& out_title) {
|
||||
if (name.empty()) {
|
||||
return ResultStatus::ErrorNoControl;
|
||||
title = name;
|
||||
}
|
||||
|
||||
out_title = name;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
@ -230,12 +236,12 @@ bool AppLoader_DeconstructedRomDirectory::IsRomFSUpdatable() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_DeconstructedRomDirectory::ReadNSOModules(Modules& modules) {
|
||||
ResultStatus AppLoader_DeconstructedRomDirectory::ReadNSOModules(Modules& out_modules) {
|
||||
if (!is_loaded) {
|
||||
return ResultStatus::ErrorNotInitialized;
|
||||
}
|
||||
|
||||
modules = this->modules;
|
||||
out_modules = this->modules;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,13 @@ public:
|
||||
|
||||
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||
|
||||
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
||||
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
||||
ResultStatus ReadRomFS(FileSys::VirtualFile& out_dir) override;
|
||||
ResultStatus ReadIcon(std::vector<u8>& out_buffer) override;
|
||||
ResultStatus ReadProgramId(u64& out_program_id) override;
|
||||
ResultStatus ReadTitle(std::string& title) override;
|
||||
bool IsRomFSUpdatable() const override;
|
||||
|
||||
ResultStatus ReadNSOModules(Modules& modules) override;
|
||||
ResultStatus ReadNSOModules(Modules& out_modules) override;
|
||||
|
||||
private:
|
||||
FileSys::ProgramMetadata metadata;
|
||||
|
@ -364,21 +364,24 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const
|
||||
|
||||
namespace Loader {
|
||||
|
||||
AppLoader_ELF::AppLoader_ELF(FileSys::VirtualFile file) : AppLoader(std::move(file)) {}
|
||||
AppLoader_ELF::AppLoader_ELF(FileSys::VirtualFile file_) : AppLoader(std::move(file_)) {}
|
||||
|
||||
FileType AppLoader_ELF::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
FileType AppLoader_ELF::IdentifyType(const FileSys::VirtualFile& elf_file) {
|
||||
static constexpr u16 ELF_MACHINE_ARM{0x28};
|
||||
|
||||
u32 magic = 0;
|
||||
if (4 != file->ReadObject(&magic))
|
||||
if (4 != elf_file->ReadObject(&magic)) {
|
||||
return FileType::Error;
|
||||
}
|
||||
|
||||
u16 machine = 0;
|
||||
if (2 != file->ReadObject(&machine, 18))
|
||||
if (2 != elf_file->ReadObject(&machine, 18)) {
|
||||
return FileType::Error;
|
||||
}
|
||||
|
||||
if (Common::MakeMagic('\x7f', 'E', 'L', 'F') == magic && ELF_MACHINE_ARM == machine)
|
||||
if (Common::MakeMagic('\x7f', 'E', 'L', 'F') == magic && ELF_MACHINE_ARM == machine) {
|
||||
return FileType::ELF;
|
||||
}
|
||||
|
||||
return FileType::Error;
|
||||
}
|
||||
|
@ -20,11 +20,13 @@ public:
|
||||
explicit AppLoader_ELF(FileSys::VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
* Identifies whether or not the given file is an ELF file.
|
||||
*
|
||||
* @param elf_file The file to identify.
|
||||
*
|
||||
* @return FileType::ELF, or FileType::Error if the file is not an ELF file.
|
||||
*/
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& elf_file);
|
||||
|
||||
FileType GetFileType() const override {
|
||||
return IdentifyType(file);
|
||||
|
@ -24,9 +24,9 @@ AppLoader_KIP::AppLoader_KIP(FileSys::VirtualFile file_)
|
||||
|
||||
AppLoader_KIP::~AppLoader_KIP() = default;
|
||||
|
||||
FileType AppLoader_KIP::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
FileType AppLoader_KIP::IdentifyType(const FileSys::VirtualFile& in_file) {
|
||||
u32_le magic{};
|
||||
if (file->GetSize() < sizeof(u32) || file->ReadObject(&magic) != sizeof(u32)) {
|
||||
if (in_file->GetSize() < sizeof(u32) || in_file->ReadObject(&magic) != sizeof(u32)) {
|
||||
return FileType::Error;
|
||||
}
|
||||
|
||||
@ -56,10 +56,10 @@ AppLoader::LoadResult AppLoader_KIP::Load(Kernel::Process& process,
|
||||
return {kip->GetStatus(), {}};
|
||||
}
|
||||
|
||||
const auto get_kip_address_space_type = [](const auto& kip) {
|
||||
return kip.Is64Bit()
|
||||
? (kip.Is39BitAddressSpace() ? FileSys::ProgramAddressSpaceType::Is39Bit
|
||||
: FileSys::ProgramAddressSpaceType::Is36Bit)
|
||||
const auto get_kip_address_space_type = [](const auto& kip_type) {
|
||||
return kip_type.Is64Bit()
|
||||
? (kip_type.Is39BitAddressSpace() ? FileSys::ProgramAddressSpaceType::Is39Bit
|
||||
: FileSys::ProgramAddressSpaceType::Is36Bit)
|
||||
: FileSys::ProgramAddressSpaceType::Is32Bit;
|
||||
};
|
||||
|
||||
|
@ -22,11 +22,13 @@ public:
|
||||
~AppLoader_KIP() override;
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
* Identifies whether or not the given file is a KIP.
|
||||
*
|
||||
* @param in_file The file to identify.
|
||||
*
|
||||
* @return FileType::KIP if found, or FileType::Error if unknown.
|
||||
*/
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& in_file);
|
||||
|
||||
FileType GetFileType() const override;
|
||||
|
||||
|
@ -152,21 +152,26 @@ public:
|
||||
|
||||
/**
|
||||
* Returns the type of this file
|
||||
*
|
||||
* @return FileType corresponding to the loaded file
|
||||
*/
|
||||
virtual FileType GetFileType() const = 0;
|
||||
|
||||
/**
|
||||
* Load the application and return the created Process instance
|
||||
*
|
||||
* @param process The newly created process.
|
||||
* @param system The system that this process is being loaded under.
|
||||
*
|
||||
* @return The status result of the operation.
|
||||
*/
|
||||
virtual LoadResult Load(Kernel::Process& process, Core::System& system) = 0;
|
||||
|
||||
/**
|
||||
* Get the code (typically .code section) of the application
|
||||
* @param buffer Reference to buffer to store data
|
||||
*
|
||||
* @param[out] buffer Reference to buffer to store data
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadCode(std::vector<u8>& buffer) {
|
||||
@ -175,7 +180,9 @@ public:
|
||||
|
||||
/**
|
||||
* Get the icon (typically icon section) of the application
|
||||
* @param buffer Reference to buffer to store data
|
||||
*
|
||||
* @param[out] buffer Reference to buffer to store data
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadIcon(std::vector<u8>& buffer) {
|
||||
@ -186,7 +193,9 @@ public:
|
||||
* Get the banner (typically banner section) of the application
|
||||
* In the context of NX, this is the animation that displays in the bottom right of the screen
|
||||
* when a game boots. Stored in GIF format.
|
||||
* @param buffer Reference to buffer to store data
|
||||
*
|
||||
* @param[out] buffer Reference to buffer to store data
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadBanner(std::vector<u8>& buffer) {
|
||||
@ -197,7 +206,9 @@ public:
|
||||
* Get the logo (typically logo section) of the application
|
||||
* In the context of NX, this is the static image that displays in the top left of the screen
|
||||
* when a game boots. Stored in JPEG format.
|
||||
* @param buffer Reference to buffer to store data
|
||||
*
|
||||
* @param[out] buffer Reference to buffer to store data
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadLogo(std::vector<u8>& buffer) {
|
||||
@ -206,7 +217,9 @@ public:
|
||||
|
||||
/**
|
||||
* Get the program id of the application
|
||||
* @param out_program_id Reference to store program id into
|
||||
*
|
||||
* @param[out] out_program_id Reference to store program id into
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadProgramId(u64& out_program_id) {
|
||||
@ -216,19 +229,23 @@ public:
|
||||
/**
|
||||
* Get the RomFS of the application
|
||||
* Since the RomFS can be huge, we return a file reference instead of copying to a buffer
|
||||
* @param file The directory containing the RomFS
|
||||
*
|
||||
* @param[out] out_file The directory containing the RomFS
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadRomFS(FileSys::VirtualFile& file) {
|
||||
virtual ResultStatus ReadRomFS(FileSys::VirtualFile& out_file) {
|
||||
return ResultStatus::ErrorNotImplemented;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw update of the application, should it come packed with one
|
||||
* @param file The raw update NCA file (Program-type
|
||||
*
|
||||
* @param[out] out_file The raw update NCA file (Program-type)
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) {
|
||||
virtual ResultStatus ReadUpdateRaw(FileSys::VirtualFile& out_file) {
|
||||
return ResultStatus::ErrorNotImplemented;
|
||||
}
|
||||
|
||||
@ -236,7 +253,8 @@ public:
|
||||
* Get whether or not updates can be applied to the RomFS.
|
||||
* By default, this is true, however for formats where it cannot be guaranteed that the RomFS is
|
||||
* the base game it should be set to false.
|
||||
* @return bool whether or not updatable.
|
||||
*
|
||||
* @return bool indicating whether or not the RomFS is updatable.
|
||||
*/
|
||||
virtual bool IsRomFSUpdatable() const {
|
||||
return true;
|
||||
@ -244,8 +262,9 @@ public:
|
||||
|
||||
/**
|
||||
* Gets the difference between the start of the IVFC header and the start of level 6 (RomFS)
|
||||
* data. Needed for bktr patching.
|
||||
* @return IVFC offset for romfs.
|
||||
* data. Needed for BKTR patching.
|
||||
*
|
||||
* @return IVFC offset for RomFS.
|
||||
*/
|
||||
virtual u64 ReadRomFSIVFCOffset() const {
|
||||
return 0;
|
||||
@ -253,7 +272,9 @@ public:
|
||||
|
||||
/**
|
||||
* Get the title of the application
|
||||
* @param title Reference to store the application title into
|
||||
*
|
||||
* @param[out] title Reference to store the application title into
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadTitle(std::string& title) {
|
||||
@ -262,7 +283,9 @@ public:
|
||||
|
||||
/**
|
||||
* Get the control data (CNMT) of the application
|
||||
* @param control Reference to store the application control data into
|
||||
*
|
||||
* @param[out] control Reference to store the application control data into
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadControlData(FileSys::NACP& control) {
|
||||
@ -271,10 +294,12 @@ public:
|
||||
|
||||
/**
|
||||
* Get the RomFS of the manual of the application
|
||||
* @param file The raw manual RomFS of the game
|
||||
*
|
||||
* @param[out] out_file The raw manual RomFS of the game
|
||||
*
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) {
|
||||
virtual ResultStatus ReadManualRomFS(FileSys::VirtualFile& out_file) {
|
||||
return ResultStatus::ErrorNotImplemented;
|
||||
}
|
||||
|
||||
|
@ -26,14 +26,14 @@ FileType IdentifyTypeImpl(const FileSys::NAX& nax) {
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
AppLoader_NAX::AppLoader_NAX(FileSys::VirtualFile file)
|
||||
: AppLoader(file), nax(std::make_unique<FileSys::NAX>(file)),
|
||||
AppLoader_NAX::AppLoader_NAX(FileSys::VirtualFile file_)
|
||||
: AppLoader(file_), nax(std::make_unique<FileSys::NAX>(file_)),
|
||||
nca_loader(std::make_unique<AppLoader_NCA>(nax->GetDecrypted())) {}
|
||||
|
||||
AppLoader_NAX::~AppLoader_NAX() = default;
|
||||
|
||||
FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
const FileSys::NAX nax(file);
|
||||
FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& nax_file) {
|
||||
const FileSys::NAX nax(nax_file);
|
||||
return IdentifyTypeImpl(nax);
|
||||
}
|
||||
|
||||
@ -41,8 +41,7 @@ FileType AppLoader_NAX::GetFileType() const {
|
||||
return IdentifyTypeImpl(*nax);
|
||||
}
|
||||
|
||||
AppLoader_NAX::LoadResult AppLoader_NAX::Load(Kernel::Process& process,
|
||||
[[maybe_unused]] Core::System& system) {
|
||||
AppLoader_NAX::LoadResult AppLoader_NAX::Load(Kernel::Process& process, Core::System& system) {
|
||||
if (is_loaded) {
|
||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||
}
|
||||
|
@ -23,15 +23,17 @@ class AppLoader_NCA;
|
||||
/// Loads a NAX file
|
||||
class AppLoader_NAX final : public AppLoader {
|
||||
public:
|
||||
explicit AppLoader_NAX(FileSys::VirtualFile file);
|
||||
explicit AppLoader_NAX(FileSys::VirtualFile file_);
|
||||
~AppLoader_NAX() override;
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
* Identifies whether or not the given file is a NAX file.
|
||||
*
|
||||
* @param nax_file The file to identify.
|
||||
*
|
||||
* @return FileType::NAX, or FileType::Error if the file is not a NAX file.
|
||||
*/
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& nax_file);
|
||||
|
||||
FileType GetFileType() const override;
|
||||
|
||||
|
@ -21,12 +21,13 @@ AppLoader_NCA::AppLoader_NCA(FileSys::VirtualFile file_)
|
||||
|
||||
AppLoader_NCA::~AppLoader_NCA() = default;
|
||||
|
||||
FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
FileSys::NCA nca(file);
|
||||
FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& nca_file) {
|
||||
const FileSys::NCA nca(nca_file);
|
||||
|
||||
if (nca.GetStatus() == ResultStatus::Success &&
|
||||
nca.GetType() == FileSys::NCAContentType::Program)
|
||||
nca.GetType() == FileSys::NCAContentType::Program) {
|
||||
return FileType::NCA;
|
||||
}
|
||||
|
||||
return FileType::Error;
|
||||
}
|
||||
@ -67,43 +68,59 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::Process& process, Core::Sy
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) {
|
||||
if (nca == nullptr)
|
||||
if (nca == nullptr) {
|
||||
return ResultStatus::ErrorNotInitialized;
|
||||
if (nca->GetRomFS() == nullptr || nca->GetRomFS()->GetSize() == 0)
|
||||
}
|
||||
|
||||
if (nca->GetRomFS() == nullptr || nca->GetRomFS()->GetSize() == 0) {
|
||||
return ResultStatus::ErrorNoRomFS;
|
||||
}
|
||||
|
||||
dir = nca->GetRomFS();
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
u64 AppLoader_NCA::ReadRomFSIVFCOffset() const {
|
||||
if (nca == nullptr)
|
||||
if (nca == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return nca->GetBaseIVFCOffset();
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) {
|
||||
if (nca == nullptr || nca->GetStatus() != ResultStatus::Success)
|
||||
if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) {
|
||||
return ResultStatus::ErrorNotInitialized;
|
||||
}
|
||||
|
||||
out_program_id = nca->GetTitleId();
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NCA::ReadBanner(std::vector<u8>& buffer) {
|
||||
if (nca == nullptr || nca->GetStatus() != ResultStatus::Success)
|
||||
if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) {
|
||||
return ResultStatus::ErrorNotInitialized;
|
||||
}
|
||||
|
||||
const auto logo = nca->GetLogoPartition();
|
||||
if (logo == nullptr)
|
||||
if (logo == nullptr) {
|
||||
return ResultStatus::ErrorNoIcon;
|
||||
}
|
||||
|
||||
buffer = logo->GetFile("StartupMovie.gif")->ReadAllBytes();
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NCA::ReadLogo(std::vector<u8>& buffer) {
|
||||
if (nca == nullptr || nca->GetStatus() != ResultStatus::Success)
|
||||
if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) {
|
||||
return ResultStatus::ErrorNotInitialized;
|
||||
}
|
||||
|
||||
const auto logo = nca->GetLogoPartition();
|
||||
if (logo == nullptr)
|
||||
if (logo == nullptr) {
|
||||
return ResultStatus::ErrorNoIcon;
|
||||
}
|
||||
|
||||
buffer = logo->GetFile("NintendoLogo.png")->ReadAllBytes();
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
@ -23,15 +23,17 @@ class AppLoader_DeconstructedRomDirectory;
|
||||
/// Loads an NCA file
|
||||
class AppLoader_NCA final : public AppLoader {
|
||||
public:
|
||||
explicit AppLoader_NCA(FileSys::VirtualFile file);
|
||||
explicit AppLoader_NCA(FileSys::VirtualFile file_);
|
||||
~AppLoader_NCA() override;
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
* Identifies whether or not the given file is an NCA file.
|
||||
*
|
||||
* @param nca_file The file to identify.
|
||||
*
|
||||
* @return FileType::NCA, or FileType::Error if the file is not an NCA file.
|
||||
*/
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& nca_file);
|
||||
|
||||
FileType GetFileType() const override {
|
||||
return IdentifyType(file);
|
||||
|
@ -72,7 +72,7 @@ struct AssetHeader {
|
||||
};
|
||||
static_assert(sizeof(AssetHeader) == 0x38, "AssetHeader has incorrect size.");
|
||||
|
||||
AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) {
|
||||
AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file_) : AppLoader(std::move(file_)) {
|
||||
NroHeader nro_header{};
|
||||
if (file->ReadObject(&nro_header) != sizeof(NroHeader)) {
|
||||
return;
|
||||
@ -114,10 +114,10 @@ AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) {
|
||||
|
||||
AppLoader_NRO::~AppLoader_NRO() = default;
|
||||
|
||||
FileType AppLoader_NRO::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
FileType AppLoader_NRO::IdentifyType(const FileSys::VirtualFile& nro_file) {
|
||||
// Read NSO header
|
||||
NroHeader nro_header{};
|
||||
if (sizeof(NroHeader) != file->ReadObject(&nro_header)) {
|
||||
if (sizeof(NroHeader) != nro_file->ReadObject(&nro_header)) {
|
||||
return FileType::Error;
|
||||
}
|
||||
if (nro_header.magic == Common::MakeMagic('N', 'R', 'O', '0')) {
|
||||
@ -130,8 +130,7 @@ static constexpr u32 PageAlignSize(u32 size) {
|
||||
return static_cast<u32>((size + Core::Memory::PAGE_MASK) & ~Core::Memory::PAGE_MASK);
|
||||
}
|
||||
|
||||
static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data,
|
||||
const std::string& name) {
|
||||
static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data) {
|
||||
if (data.size() < sizeof(NroHeader)) {
|
||||
return {};
|
||||
}
|
||||
@ -200,8 +199,8 @@ static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& file) {
|
||||
return LoadNroImpl(process, file.ReadAllBytes(), file.GetName());
|
||||
bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& nro_file) {
|
||||
return LoadNroImpl(process, nro_file.ReadAllBytes());
|
||||
}
|
||||
|
||||
AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process, Core::System& system) {
|
||||
|
@ -27,15 +27,17 @@ namespace Loader {
|
||||
/// Loads an NRO file
|
||||
class AppLoader_NRO final : public AppLoader {
|
||||
public:
|
||||
explicit AppLoader_NRO(FileSys::VirtualFile file);
|
||||
explicit AppLoader_NRO(FileSys::VirtualFile file_);
|
||||
~AppLoader_NRO() override;
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
* Identifies whether or not the given file is an NRO file.
|
||||
*
|
||||
* @param nro_file The file to identify.
|
||||
*
|
||||
* @return FileType::NRO, or FileType::Error if the file is not an NRO file.
|
||||
*/
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& nro_file);
|
||||
|
||||
FileType GetFileType() const override {
|
||||
return IdentifyType(file);
|
||||
@ -51,7 +53,7 @@ public:
|
||||
bool IsRomFSUpdatable() const override;
|
||||
|
||||
private:
|
||||
bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& file);
|
||||
bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& nro_file);
|
||||
|
||||
std::vector<u8> icon_data;
|
||||
std::unique_ptr<FileSys::NACP> nacp;
|
||||
|
@ -56,11 +56,11 @@ bool NSOHeader::IsSegmentCompressed(size_t segment_num) const {
|
||||
return ((flags >> segment_num) & 1) != 0;
|
||||
}
|
||||
|
||||
AppLoader_NSO::AppLoader_NSO(FileSys::VirtualFile file) : AppLoader(std::move(file)) {}
|
||||
AppLoader_NSO::AppLoader_NSO(FileSys::VirtualFile file_) : AppLoader(std::move(file_)) {}
|
||||
|
||||
FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& in_file) {
|
||||
u32 magic = 0;
|
||||
if (file->ReadObject(&magic) != sizeof(magic)) {
|
||||
if (in_file->ReadObject(&magic) != sizeof(magic)) {
|
||||
return FileType::Error;
|
||||
}
|
||||
|
||||
@ -72,15 +72,15 @@ FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
}
|
||||
|
||||
std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::System& system,
|
||||
const FileSys::VfsFile& file, VAddr load_base,
|
||||
const FileSys::VfsFile& nso_file, VAddr load_base,
|
||||
bool should_pass_arguments, bool load_into_process,
|
||||
std::optional<FileSys::PatchManager> pm) {
|
||||
if (file.GetSize() < sizeof(NSOHeader)) {
|
||||
if (nso_file.GetSize() < sizeof(NSOHeader)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
NSOHeader nso_header{};
|
||||
if (sizeof(NSOHeader) != file.ReadObject(&nso_header)) {
|
||||
if (sizeof(NSOHeader) != nso_file.ReadObject(&nso_header)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@ -92,8 +92,8 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::S
|
||||
Kernel::CodeSet codeset;
|
||||
Kernel::PhysicalMemory program_image;
|
||||
for (std::size_t i = 0; i < nso_header.segments.size(); ++i) {
|
||||
std::vector<u8> data =
|
||||
file.ReadBytes(nso_header.segments_compressed_size[i], nso_header.segments[i].offset);
|
||||
std::vector<u8> data = nso_file.ReadBytes(nso_header.segments_compressed_size[i],
|
||||
nso_header.segments[i].offset);
|
||||
if (nso_header.IsSegmentCompressed(i)) {
|
||||
data = DecompressSegment(data, nso_header.segments[i]);
|
||||
}
|
||||
@ -136,7 +136,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::S
|
||||
pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.data(),
|
||||
program_image.data() + program_image.size());
|
||||
|
||||
pi_header = pm->PatchNSO(pi_header, file.GetName());
|
||||
pi_header = pm->PatchNSO(pi_header, nso_file.GetName());
|
||||
|
||||
std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.data());
|
||||
}
|
||||
@ -183,8 +183,8 @@ AppLoader_NSO::LoadResult AppLoader_NSO::Load(Kernel::Process& process, Core::Sy
|
||||
Core::Memory::DEFAULT_STACK_SIZE}};
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NSO::ReadNSOModules(Modules& modules) {
|
||||
modules = this->modules;
|
||||
ResultStatus AppLoader_NSO::ReadNSOModules(Modules& out_modules) {
|
||||
out_modules = this->modules;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
|
@ -71,27 +71,29 @@ static_assert(sizeof(NSOArgumentHeader) == 0x20, "NSOArgumentHeader has incorrec
|
||||
/// Loads an NSO file
|
||||
class AppLoader_NSO final : public AppLoader {
|
||||
public:
|
||||
explicit AppLoader_NSO(FileSys::VirtualFile file);
|
||||
explicit AppLoader_NSO(FileSys::VirtualFile file_);
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
* Identifies whether or not the given file is a form of NSO file.
|
||||
*
|
||||
* @param in_file The file to be identified.
|
||||
*
|
||||
* @return FileType::NSO if found, or FileType::Error if some other type of file.
|
||||
*/
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& in_file);
|
||||
|
||||
FileType GetFileType() const override {
|
||||
return IdentifyType(file);
|
||||
}
|
||||
|
||||
static std::optional<VAddr> LoadModule(Kernel::Process& process, Core::System& system,
|
||||
const FileSys::VfsFile& file, VAddr load_base,
|
||||
const FileSys::VfsFile& nso_file, VAddr load_base,
|
||||
bool should_pass_arguments, bool load_into_process,
|
||||
std::optional<FileSys::PatchManager> pm = {});
|
||||
|
||||
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||
|
||||
ResultStatus ReadNSOModules(Modules& modules) override;
|
||||
ResultStatus ReadNSOModules(Modules& out_modules) override;
|
||||
|
||||
private:
|
||||
Modules modules;
|
||||
|
@ -21,11 +21,11 @@
|
||||
|
||||
namespace Loader {
|
||||
|
||||
AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file,
|
||||
AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file_,
|
||||
const Service::FileSystem::FileSystemController& fsc,
|
||||
const FileSys::ContentProvider& content_provider,
|
||||
std::size_t program_index)
|
||||
: AppLoader(file), nsp(std::make_unique<FileSys::NSP>(file, program_index)),
|
||||
: AppLoader(file_), nsp(std::make_unique<FileSys::NSP>(file_, program_index)),
|
||||
title_id(nsp->GetProgramTitleID()) {
|
||||
|
||||
if (nsp->GetStatus() != ResultStatus::Success) {
|
||||
@ -57,8 +57,8 @@ AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file,
|
||||
|
||||
AppLoader_NSP::~AppLoader_NSP() = default;
|
||||
|
||||
FileType AppLoader_NSP::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
FileSys::NSP nsp(file);
|
||||
FileType AppLoader_NSP::IdentifyType(const FileSys::VirtualFile& nsp_file) {
|
||||
const FileSys::NSP nsp(nsp_file);
|
||||
|
||||
if (nsp.GetStatus() == ResultStatus::Success) {
|
||||
// Extracted Type case
|
||||
@ -121,67 +121,80 @@ AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::Process& process, Core::Sy
|
||||
return result;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NSP::ReadRomFS(FileSys::VirtualFile& file) {
|
||||
return secondary_loader->ReadRomFS(file);
|
||||
ResultStatus AppLoader_NSP::ReadRomFS(FileSys::VirtualFile& out_file) {
|
||||
return secondary_loader->ReadRomFS(out_file);
|
||||
}
|
||||
|
||||
u64 AppLoader_NSP::ReadRomFSIVFCOffset() const {
|
||||
return secondary_loader->ReadRomFSIVFCOffset();
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NSP::ReadUpdateRaw(FileSys::VirtualFile& file) {
|
||||
if (nsp->IsExtractedType())
|
||||
ResultStatus AppLoader_NSP::ReadUpdateRaw(FileSys::VirtualFile& out_file) {
|
||||
if (nsp->IsExtractedType()) {
|
||||
return ResultStatus::ErrorNoPackedUpdate;
|
||||
}
|
||||
|
||||
const auto read =
|
||||
nsp->GetNCAFile(FileSys::GetUpdateTitleID(title_id), FileSys::ContentRecordType::Program);
|
||||
|
||||
if (read == nullptr)
|
||||
if (read == nullptr) {
|
||||
return ResultStatus::ErrorNoPackedUpdate;
|
||||
}
|
||||
|
||||
const auto nca_test = std::make_shared<FileSys::NCA>(read);
|
||||
|
||||
if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS)
|
||||
if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) {
|
||||
return nca_test->GetStatus();
|
||||
}
|
||||
|
||||
file = read;
|
||||
out_file = read;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NSP::ReadProgramId(u64& out_program_id) {
|
||||
if (title_id == 0)
|
||||
if (title_id == 0) {
|
||||
return ResultStatus::ErrorNotInitialized;
|
||||
}
|
||||
|
||||
out_program_id = title_id;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NSP::ReadIcon(std::vector<u8>& buffer) {
|
||||
if (icon_file == nullptr)
|
||||
if (icon_file == nullptr) {
|
||||
return ResultStatus::ErrorNoControl;
|
||||
}
|
||||
|
||||
buffer = icon_file->ReadAllBytes();
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NSP::ReadTitle(std::string& title) {
|
||||
if (nacp_file == nullptr)
|
||||
if (nacp_file == nullptr) {
|
||||
return ResultStatus::ErrorNoControl;
|
||||
}
|
||||
|
||||
title = nacp_file->GetApplicationName();
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NSP::ReadControlData(FileSys::NACP& nacp) {
|
||||
if (nacp_file == nullptr)
|
||||
if (nacp_file == nullptr) {
|
||||
return ResultStatus::ErrorNoControl;
|
||||
}
|
||||
|
||||
nacp = *nacp_file;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NSP::ReadManualRomFS(FileSys::VirtualFile& file) {
|
||||
ResultStatus AppLoader_NSP::ReadManualRomFS(FileSys::VirtualFile& out_file) {
|
||||
const auto nca =
|
||||
nsp->GetNCA(nsp->GetProgramTitleID(), FileSys::ContentRecordType::HtmlDocument);
|
||||
if (nsp->GetStatus() != ResultStatus::Success || nca == nullptr)
|
||||
if (nsp->GetStatus() != ResultStatus::Success || nca == nullptr) {
|
||||
return ResultStatus::ErrorNoRomFS;
|
||||
file = nca->GetRomFS();
|
||||
return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success;
|
||||
}
|
||||
|
||||
out_file = nca->GetRomFS();
|
||||
return out_file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NSP::ReadBanner(std::vector<u8>& buffer) {
|
||||
|
@ -26,18 +26,20 @@ class AppLoader_NCA;
|
||||
/// Loads an XCI file
|
||||
class AppLoader_NSP final : public AppLoader {
|
||||
public:
|
||||
explicit AppLoader_NSP(FileSys::VirtualFile file,
|
||||
explicit AppLoader_NSP(FileSys::VirtualFile file_,
|
||||
const Service::FileSystem::FileSystemController& fsc,
|
||||
const FileSys::ContentProvider& content_provider,
|
||||
std::size_t program_index);
|
||||
~AppLoader_NSP() override;
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
* Identifies whether or not the given file is an NSP file.
|
||||
*
|
||||
* @param nsp_file The file to identify.
|
||||
*
|
||||
* @return FileType::NSP, or FileType::Error if the file is not an NSP.
|
||||
*/
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& nsp_file);
|
||||
|
||||
FileType GetFileType() const override {
|
||||
return IdentifyType(file);
|
||||
@ -45,14 +47,14 @@ public:
|
||||
|
||||
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||
|
||||
ResultStatus ReadRomFS(FileSys::VirtualFile& file) override;
|
||||
ResultStatus ReadRomFS(FileSys::VirtualFile& out_file) override;
|
||||
u64 ReadRomFSIVFCOffset() const override;
|
||||
ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) override;
|
||||
ResultStatus ReadUpdateRaw(FileSys::VirtualFile& out_file) override;
|
||||
ResultStatus ReadProgramId(u64& out_program_id) override;
|
||||
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
||||
ResultStatus ReadTitle(std::string& title) override;
|
||||
ResultStatus ReadControlData(FileSys::NACP& nacp) override;
|
||||
ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override;
|
||||
ResultStatus ReadManualRomFS(FileSys::VirtualFile& out_file) override;
|
||||
|
||||
ResultStatus ReadBanner(std::vector<u8>& buffer) override;
|
||||
ResultStatus ReadLogo(std::vector<u8>& buffer) override;
|
||||
|
@ -20,11 +20,11 @@
|
||||
|
||||
namespace Loader {
|
||||
|
||||
AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file,
|
||||
AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file_,
|
||||
const Service::FileSystem::FileSystemController& fsc,
|
||||
const FileSys::ContentProvider& content_provider,
|
||||
std::size_t program_index)
|
||||
: AppLoader(file), xci(std::make_unique<FileSys::XCI>(file, program_index)),
|
||||
: AppLoader(file_), xci(std::make_unique<FileSys::XCI>(file_, program_index)),
|
||||
nca_loader(std::make_unique<AppLoader_NCA>(xci->GetProgramNCAFile())) {
|
||||
if (xci->GetStatus() != ResultStatus::Success) {
|
||||
return;
|
||||
@ -43,8 +43,8 @@ AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file,
|
||||
|
||||
AppLoader_XCI::~AppLoader_XCI() = default;
|
||||
|
||||
FileType AppLoader_XCI::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
FileSys::XCI xci(file);
|
||||
FileType AppLoader_XCI::IdentifyType(const FileSys::VirtualFile& xci_file) {
|
||||
const FileSys::XCI xci(xci_file);
|
||||
|
||||
if (xci.GetStatus() == ResultStatus::Success &&
|
||||
xci.GetNCAByType(FileSys::NCAContentType::Program) != nullptr &&
|
||||
@ -87,31 +87,33 @@ AppLoader_XCI::LoadResult AppLoader_XCI::Load(Kernel::Process& process, Core::Sy
|
||||
return result;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& file) {
|
||||
return nca_loader->ReadRomFS(file);
|
||||
ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& out_file) {
|
||||
return nca_loader->ReadRomFS(out_file);
|
||||
}
|
||||
|
||||
u64 AppLoader_XCI::ReadRomFSIVFCOffset() const {
|
||||
return nca_loader->ReadRomFSIVFCOffset();
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& file) {
|
||||
ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& out_file) {
|
||||
u64 program_id{};
|
||||
nca_loader->ReadProgramId(program_id);
|
||||
if (program_id == 0)
|
||||
if (program_id == 0) {
|
||||
return ResultStatus::ErrorXCIMissingProgramNCA;
|
||||
}
|
||||
|
||||
const auto read = xci->GetSecurePartitionNSP()->GetNCAFile(
|
||||
FileSys::GetUpdateTitleID(program_id), FileSys::ContentRecordType::Program);
|
||||
|
||||
if (read == nullptr)
|
||||
if (read == nullptr) {
|
||||
return ResultStatus::ErrorNoPackedUpdate;
|
||||
}
|
||||
|
||||
const auto nca_test = std::make_shared<FileSys::NCA>(read);
|
||||
|
||||
if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS)
|
||||
if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) {
|
||||
return nca_test->GetStatus();
|
||||
}
|
||||
|
||||
file = read;
|
||||
out_file = read;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
@ -120,33 +122,41 @@ ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) {
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_XCI::ReadIcon(std::vector<u8>& buffer) {
|
||||
if (icon_file == nullptr)
|
||||
if (icon_file == nullptr) {
|
||||
return ResultStatus::ErrorNoControl;
|
||||
}
|
||||
|
||||
buffer = icon_file->ReadAllBytes();
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_XCI::ReadTitle(std::string& title) {
|
||||
if (nacp_file == nullptr)
|
||||
if (nacp_file == nullptr) {
|
||||
return ResultStatus::ErrorNoControl;
|
||||
}
|
||||
|
||||
title = nacp_file->GetApplicationName();
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_XCI::ReadControlData(FileSys::NACP& control) {
|
||||
if (nacp_file == nullptr)
|
||||
if (nacp_file == nullptr) {
|
||||
return ResultStatus::ErrorNoControl;
|
||||
}
|
||||
|
||||
control = *nacp_file;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_XCI::ReadManualRomFS(FileSys::VirtualFile& file) {
|
||||
ResultStatus AppLoader_XCI::ReadManualRomFS(FileSys::VirtualFile& out_file) {
|
||||
const auto nca = xci->GetSecurePartitionNSP()->GetNCA(xci->GetProgramTitleID(),
|
||||
FileSys::ContentRecordType::HtmlDocument);
|
||||
if (xci->GetStatus() != ResultStatus::Success || nca == nullptr)
|
||||
if (xci->GetStatus() != ResultStatus::Success || nca == nullptr) {
|
||||
return ResultStatus::ErrorXCIMissingPartition;
|
||||
file = nca->GetRomFS();
|
||||
return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success;
|
||||
}
|
||||
|
||||
out_file = nca->GetRomFS();
|
||||
return out_file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_XCI::ReadBanner(std::vector<u8>& buffer) {
|
||||
|
@ -26,18 +26,20 @@ class AppLoader_NCA;
|
||||
/// Loads an XCI file
|
||||
class AppLoader_XCI final : public AppLoader {
|
||||
public:
|
||||
explicit AppLoader_XCI(FileSys::VirtualFile file,
|
||||
explicit AppLoader_XCI(FileSys::VirtualFile file_,
|
||||
const Service::FileSystem::FileSystemController& fsc,
|
||||
const FileSys::ContentProvider& content_provider,
|
||||
std::size_t program_index);
|
||||
~AppLoader_XCI() override;
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
* Identifies whether or not the given file is an XCI file.
|
||||
*
|
||||
* @param xci_file The file to identify.
|
||||
*
|
||||
* @return FileType::XCI, or FileType::Error if the file is not an XCI file.
|
||||
*/
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||
static FileType IdentifyType(const FileSys::VirtualFile& xci_file);
|
||||
|
||||
FileType GetFileType() const override {
|
||||
return IdentifyType(file);
|
||||
@ -45,14 +47,14 @@ public:
|
||||
|
||||
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||
|
||||
ResultStatus ReadRomFS(FileSys::VirtualFile& file) override;
|
||||
ResultStatus ReadRomFS(FileSys::VirtualFile& out_file) override;
|
||||
u64 ReadRomFSIVFCOffset() const override;
|
||||
ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) override;
|
||||
ResultStatus ReadUpdateRaw(FileSys::VirtualFile& out_file) override;
|
||||
ResultStatus ReadProgramId(u64& out_program_id) override;
|
||||
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
||||
ResultStatus ReadTitle(std::string& title) override;
|
||||
ResultStatus ReadControlData(FileSys::NACP& control) override;
|
||||
ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override;
|
||||
ResultStatus ReadManualRomFS(FileSys::VirtualFile& out_file) override;
|
||||
|
||||
ResultStatus ReadBanner(std::vector<u8>& buffer) override;
|
||||
ResultStatus ReadLogo(std::vector<u8>& buffer) override;
|
||||
|
Loading…
Reference in New Issue
Block a user