From df5b75694f5abde94ccf05fa6c7a557b1ba9079b Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Fri, 27 Jul 2018 23:55:23 -0400 Subject: Remove files that are not used --- src/core/loader/xci.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/core/loader/xci.cpp (limited to 'src/core/loader/xci.cpp') diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp new file mode 100644 index 000000000..9759e33d1 --- /dev/null +++ b/src/core/loader/xci.cpp @@ -0,0 +1,67 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include + +#include "common/file_util.h" +#include "common/logging/log.h" +#include "common/string_util.h" +#include "common/swap.h" +#include "core/core.h" +#include "core/file_sys/content_archive.h" +#include "core/file_sys/control_metadata.h" +#include "core/file_sys/program_metadata.h" +#include "core/file_sys/romfs.h" +#include "core/gdbstub/gdbstub.h" +#include "core/hle/kernel/process.h" +#include "core/hle/kernel/resource_limit.h" +#include "core/hle/service/filesystem/filesystem.h" +#include "core/loader/nso.h" +#include "core/loader/xci.h" +#include "core/memory.h" + +namespace Loader { + +AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file) + : AppLoader(file), xci(std::make_unique(file)), + nca_loader(std::make_unique( + xci->GetNCAFileByType(FileSys::NCAContentType::Program))) {} + +FileType AppLoader_XCI::IdentifyType(const FileSys::VirtualFile& file) { + FileSys::XCI xci(file); + + if (xci.GetStatus() == ResultStatus::Success && + xci.GetNCAByType(FileSys::NCAContentType::Program) != nullptr && + AppLoader_NCA::IdentifyType(xci.GetNCAFileByType(FileSys::NCAContentType::Program)) == + FileType::NCA) + return FileType::XCI; + + return FileType::Error; +} + +ResultStatus AppLoader_XCI::Load(Kernel::SharedPtr& process) { + if (is_loaded) { + return ResultStatus::ErrorAlreadyLoaded; + } + + auto result = nca_loader->Load(process); + if (result != ResultStatus::Success) + return result; + + is_loaded = true; + + return ResultStatus::Success; +} + +ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& dir) { + return nca_loader->ReadRomFS(dir); +} + +ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) { + return nca_loader->ReadProgramId(out_program_id); +} + +AppLoader_XCI::~AppLoader_XCI() = default; + +} // namespace Loader -- cgit v1.2.3 From 239a3113e4c6a53a2c7b12e67a0f21afae24b0aa Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 28 Jul 2018 21:39:42 -0400 Subject: Make XCI comply to review and style guidelines --- src/core/loader/xci.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/core/loader/xci.cpp') diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index 9759e33d1..b4de5bd16 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -28,14 +28,17 @@ AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file) nca_loader(std::make_unique( xci->GetNCAFileByType(FileSys::NCAContentType::Program))) {} +AppLoader_XCI::~AppLoader_XCI() = default; + FileType AppLoader_XCI::IdentifyType(const FileSys::VirtualFile& file) { FileSys::XCI xci(file); if (xci.GetStatus() == ResultStatus::Success && xci.GetNCAByType(FileSys::NCAContentType::Program) != nullptr && AppLoader_NCA::IdentifyType(xci.GetNCAFileByType(FileSys::NCAContentType::Program)) == - FileType::NCA) + FileType::NCA) { return FileType::XCI; + } return FileType::Error; } @@ -62,6 +65,4 @@ ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) { return nca_loader->ReadProgramId(out_program_id); } -AppLoader_XCI::~AppLoader_XCI() = default; - } // namespace Loader -- cgit v1.2.3 From a9c921a41dec63f76f80df1f0d5dc3be40fa80de Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 29 Jul 2018 20:47:33 -0400 Subject: Use ErrorEncrypted where applicable and fix no keys crash --- src/core/loader/xci.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core/loader/xci.cpp') diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index b4de5bd16..74940fb83 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -48,6 +48,10 @@ ResultStatus AppLoader_XCI::Load(Kernel::SharedPtr& process) { return ResultStatus::ErrorAlreadyLoaded; } + if (xci->GetNCAFileByType(FileSys::NCAContentType::Program) == nullptr) { + return ResultStatus::ErrorEncrypted; + } + auto result = nca_loader->Load(process); if (result != ResultStatus::Success) return result; -- cgit v1.2.3 From 187d8e215fb157edaa9f3976bebba9a9a7ed103d Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Mon, 30 Jul 2018 12:46:23 -0400 Subject: Use more descriptive error codes and messages --- src/core/loader/xci.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/loader/xci.cpp') diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index 74940fb83..d757862f0 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -49,7 +49,7 @@ ResultStatus AppLoader_XCI::Load(Kernel::SharedPtr& process) { } if (xci->GetNCAFileByType(FileSys::NCAContentType::Program) == nullptr) { - return ResultStatus::ErrorEncrypted; + return ResultStatus::ErrorDecrypting; } auto result = nca_loader->Load(process); -- cgit v1.2.3 From 0497bb5528f62f9e3db887988f0f93b4a1653a42 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Mon, 30 Jul 2018 22:04:51 -0400 Subject: Fix merge conflicts with opus and update docs --- src/core/loader/xci.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/loader/xci.cpp') diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index d757862f0..eb4dee2c2 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -49,6 +49,8 @@ ResultStatus AppLoader_XCI::Load(Kernel::SharedPtr& process) { } if (xci->GetNCAFileByType(FileSys::NCAContentType::Program) == nullptr) { + if (!Core::Crypto::KeyManager::KeyFileExists(false)) + return ResultStatus::ErrorMissingKeys; return ResultStatus::ErrorDecrypting; } -- cgit v1.2.3