diff --git a/app/src/main/cpp/skyline/loader/xci.cpp b/app/src/main/cpp/skyline/loader/xci.cpp index 782994f1..8e9300bb 100644 --- a/app/src/main/cpp/skyline/loader/xci.cpp +++ b/app/src/main/cpp/skyline/loader/xci.cpp @@ -36,7 +36,7 @@ namespace skyline::loader { continue; try { - auto nca{vfs::NCA(secure->OpenFile(entry.name), keyStore)}; + auto nca{vfs::NCA(secure->OpenFile(entry.name), keyStore, true)}; if (nca.contentType == vfs::NcaContentType::Program && nca.romFs != nullptr && nca.exeFs != nullptr) programNca = std::move(nca); diff --git a/app/src/main/cpp/skyline/vfs/nca.cpp b/app/src/main/cpp/skyline/vfs/nca.cpp index b276845c..6871eca3 100644 --- a/app/src/main/cpp/skyline/vfs/nca.cpp +++ b/app/src/main/cpp/skyline/vfs/nca.cpp @@ -14,7 +14,7 @@ namespace skyline::vfs { using namespace loader; - NCA::NCA(std::shared_ptr pBacking, std::shared_ptr pKeyStore) : backing(std::move(pBacking)), keyStore(std::move(pKeyStore)) { + NCA::NCA(std::shared_ptr pBacking, std::shared_ptr pKeyStore, bool pUseKeyArea) : backing(std::move(pBacking)), keyStore(std::move(pKeyStore)), useKeyArea(pUseKeyArea) { header = backing->Read(); if (header.magic != util::MakeMagic("NCA3")) { @@ -78,7 +78,7 @@ namespace skyline::vfs { return rawBacking; case NcaSectionEncryptionType::CTR: case NcaSectionEncryptionType::BKTR: { - auto key{!rightsIdEmpty ? GetTitleKey() : GetKeyAreaKey(sectionHeader.encryptionType)}; + auto key{!(rightsIdEmpty || useKeyArea) ? GetTitleKey() : GetKeyAreaKey(sectionHeader.encryptionType)}; std::array ctr{}; u32 secureValueLE{__builtin_bswap32(sectionHeader.secureValue)}; diff --git a/app/src/main/cpp/skyline/vfs/nca.h b/app/src/main/cpp/skyline/vfs/nca.h index ca2a8296..945bafb9 100644 --- a/app/src/main/cpp/skyline/vfs/nca.h +++ b/app/src/main/cpp/skyline/vfs/nca.h @@ -173,6 +173,7 @@ namespace skyline { std::shared_ptr keyStore; bool encrypted{false}; bool rightsIdEmpty; + bool useKeyArea; void ReadPfs0(const NcaSectionHeader §ionHeader, const NcaFsEntry &entry); @@ -193,7 +194,7 @@ namespace skyline { std::shared_ptr romFs; //!< The backing for this NCA's RomFS section NcaContentType contentType; //!< The content type of the NCA - NCA(std::shared_ptr backing, std::shared_ptr keyStore); + NCA(std::shared_ptr backing, std::shared_ptr keyStore, bool useKeyArea = false); }; } }