summaryrefslogtreecommitdiffstats
path: root/src/core/loader/nax.cpp
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-08-16 23:02:31 +0200
committerZach Hilman <zachhilman@gmail.com>2018-08-23 17:52:44 +0200
commit2164702cf7f878c84a1f148daca2416911e6e939 (patch)
tree73db8e3ffb79e5b219cc23b935008a29a26b0de7 /src/core/loader/nax.cpp
parentxts_encryption_layer: Implement XTSEncryptionLayer (diff)
downloadyuzu-2164702cf7f878c84a1f148daca2416911e6e939.tar
yuzu-2164702cf7f878c84a1f148daca2416911e6e939.tar.gz
yuzu-2164702cf7f878c84a1f148daca2416911e6e939.tar.bz2
yuzu-2164702cf7f878c84a1f148daca2416911e6e939.tar.lz
yuzu-2164702cf7f878c84a1f148daca2416911e6e939.tar.xz
yuzu-2164702cf7f878c84a1f148daca2416911e6e939.tar.zst
yuzu-2164702cf7f878c84a1f148daca2416911e6e939.zip
Diffstat (limited to 'src/core/loader/nax.cpp')
-rw-r--r--src/core/loader/nax.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp
new file mode 100644
index 000000000..76390bf46
--- /dev/null
+++ b/src/core/loader/nax.cpp
@@ -0,0 +1,65 @@
+// Copyright 2018 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "common/logging/log.h"
+#include "core/core.h"
+#include "core/file_sys/content_archive.h"
+#include "core/file_sys/romfs.h"
+#include "core/hle/kernel/process.h"
+#include "core/loader/nax.h"
+
+namespace Loader {
+
+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) {
+ FileSys::NAX nax(file);
+
+ if (nax.GetStatus() == ResultStatus::Success && nax.AsNCA() != nullptr &&
+ nax.AsNCA()->GetStatus() == ResultStatus::Success) {
+ return FileType::NAX;
+ }
+
+ return FileType::Error;
+}
+
+ResultStatus AppLoader_NAX::Load(Kernel::SharedPtr<Kernel::Process>& process) {
+ if (is_loaded) {
+ return ResultStatus::ErrorAlreadyLoaded;
+ }
+
+ if (nax->GetStatus() != ResultStatus::Success)
+ return nax->GetStatus();
+
+ const auto nca = nax->AsNCA();
+ if (nca == nullptr) {
+ if (!Core::Crypto::KeyManager::KeyFileExists(false))
+ return ResultStatus::ErrorMissingProductionKeyFile;
+ return ResultStatus::ErrorNAXInconvertibleToNCA;
+ }
+
+ if (nca->GetStatus() != ResultStatus::Success)
+ return nca->GetStatus();
+
+ const auto result = nca_loader->Load(process);
+ if (result != ResultStatus::Success)
+ return result;
+
+ is_loaded = true;
+
+ return ResultStatus::Success;
+}
+
+ResultStatus AppLoader_NAX::ReadRomFS(FileSys::VirtualFile& dir) {
+ return nca_loader->ReadRomFS(dir);
+}
+
+ResultStatus AppLoader_NAX::ReadProgramId(u64& out_program_id) {
+ return nca_loader->ReadProgramId(out_program_id);
+}
+} // namespace Loader