diff options
| author | 2018-08-24 23:47:46 -0400 | |
|---|---|---|
| committer | 2018-08-24 23:47:46 -0400 | |
| commit | 6426b0f5514d6a7c5cc369368947eceb380bfc85 (patch) | |
| tree | b7acdc39a4344570a6f2c098c30ad20114bf84db /src/core/loader/nax.cpp | |
| parent | Merge pull request #1065 from DarkLordZach/window-title (diff) | |
| parent | file_sys/crypto: Fix missing/unnecessary includes (diff) | |
| download | yuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.tar.gz yuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.tar.xz yuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.zip | |
Merge pull request #1094 from DarkLordZach/nax0
file_sys: Add support for NAX archives
Diffstat (limited to 'src/core/loader/nax.cpp')
| -rw-r--r-- | src/core/loader/nax.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp new file mode 100644 index 000000000..b46d81c02 --- /dev/null +++ b/src/core/loader/nax.cpp | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/logging/log.h" | ||
| 6 | #include "core/file_sys/content_archive.h" | ||
| 7 | #include "core/file_sys/romfs.h" | ||
| 8 | #include "core/file_sys/xts_archive.h" | ||
| 9 | #include "core/hle/kernel/process.h" | ||
| 10 | #include "core/loader/nax.h" | ||
| 11 | #include "core/loader/nca.h" | ||
| 12 | |||
| 13 | namespace Loader { | ||
| 14 | |||
| 15 | AppLoader_NAX::AppLoader_NAX(FileSys::VirtualFile file) | ||
| 16 | : AppLoader(file), nax(std::make_unique<FileSys::NAX>(file)), | ||
| 17 | nca_loader(std::make_unique<AppLoader_NCA>(nax->GetDecrypted())) {} | ||
| 18 | |||
| 19 | AppLoader_NAX::~AppLoader_NAX() = default; | ||
| 20 | |||
| 21 | FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) { | ||
| 22 | FileSys::NAX nax(file); | ||
| 23 | |||
| 24 | if (nax.GetStatus() == ResultStatus::Success && nax.AsNCA() != nullptr && | ||
| 25 | nax.AsNCA()->GetStatus() == ResultStatus::Success) { | ||
| 26 | return FileType::NAX; | ||
| 27 | } | ||
| 28 | |||
| 29 | return FileType::Error; | ||
| 30 | } | ||
| 31 | |||
| 32 | ResultStatus AppLoader_NAX::Load(Kernel::SharedPtr<Kernel::Process>& process) { | ||
| 33 | if (is_loaded) { | ||
| 34 | return ResultStatus::ErrorAlreadyLoaded; | ||
| 35 | } | ||
| 36 | |||
| 37 | if (nax->GetStatus() != ResultStatus::Success) | ||
| 38 | return nax->GetStatus(); | ||
| 39 | |||
| 40 | const auto nca = nax->AsNCA(); | ||
| 41 | if (nca == nullptr) { | ||
| 42 | if (!Core::Crypto::KeyManager::KeyFileExists(false)) | ||
| 43 | return ResultStatus::ErrorMissingProductionKeyFile; | ||
| 44 | return ResultStatus::ErrorNAXInconvertibleToNCA; | ||
| 45 | } | ||
| 46 | |||
| 47 | if (nca->GetStatus() != ResultStatus::Success) | ||
| 48 | return nca->GetStatus(); | ||
| 49 | |||
| 50 | const auto result = nca_loader->Load(process); | ||
| 51 | if (result != ResultStatus::Success) | ||
| 52 | return result; | ||
| 53 | |||
| 54 | is_loaded = true; | ||
| 55 | |||
| 56 | return ResultStatus::Success; | ||
| 57 | } | ||
| 58 | |||
| 59 | ResultStatus AppLoader_NAX::ReadRomFS(FileSys::VirtualFile& dir) { | ||
| 60 | return nca_loader->ReadRomFS(dir); | ||
| 61 | } | ||
| 62 | |||
| 63 | ResultStatus AppLoader_NAX::ReadProgramId(u64& out_program_id) { | ||
| 64 | return nca_loader->ReadProgramId(out_program_id); | ||
| 65 | } | ||
| 66 | } // namespace Loader | ||