file_sys: Use common KeyManager in NCA container types
Creates a single KeyManager for the entire container and then passes it into the NCA constructor, eliminating several unnecessary KeyManager reads.
This commit is contained in:
parent
e20db909ee
commit
97d425c304
|
@ -176,7 +176,7 @@ Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) {
|
||||||
for (const VirtualFile& file : partitions[static_cast<std::size_t>(part)]->GetFiles()) {
|
for (const VirtualFile& file : partitions[static_cast<std::size_t>(part)]->GetFiles()) {
|
||||||
if (file->GetExtension() != "nca")
|
if (file->GetExtension() != "nca")
|
||||||
continue;
|
continue;
|
||||||
auto nca = std::make_shared<NCA>(file);
|
auto nca = std::make_shared<NCA>(file, nullptr, 0, keys);
|
||||||
// TODO(DarkLordZach): Add proper Rev1+ Support
|
// TODO(DarkLordZach): Add proper Rev1+ Support
|
||||||
if (nca->IsUpdate())
|
if (nca->IsUpdate())
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
|
#include "core/crypto/key_manager.h"
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
@ -107,5 +108,7 @@ private:
|
||||||
std::shared_ptr<NSP> secure_partition;
|
std::shared_ptr<NSP> secure_partition;
|
||||||
std::shared_ptr<NCA> program;
|
std::shared_ptr<NCA> program;
|
||||||
std::vector<std::shared_ptr<NCA>> ncas;
|
std::vector<std::shared_ptr<NCA>> ncas;
|
||||||
|
|
||||||
|
Core::Crypto::KeyManager keys;
|
||||||
};
|
};
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
|
|
@ -106,9 +106,12 @@ static ContentRecordType GetCRTypeFromNCAType(NCAContentType type) {
|
||||||
|
|
||||||
VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir,
|
VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir,
|
||||||
std::string_view path) const {
|
std::string_view path) const {
|
||||||
if (dir->GetFileRelative(path) != nullptr)
|
const auto file = dir->GetFileRelative(path);
|
||||||
return dir->GetFileRelative(path);
|
if (file != nullptr)
|
||||||
if (dir->GetDirectoryRelative(path) != nullptr) {
|
return file;
|
||||||
|
|
||||||
|
const auto nca_dir = dir->GetDirectoryRelative(path);
|
||||||
|
if (nca_dir != nullptr) {
|
||||||
const auto nca_dir = dir->GetDirectoryRelative(path);
|
const auto nca_dir = dir->GetDirectoryRelative(path);
|
||||||
VirtualFile file = nullptr;
|
VirtualFile file = nullptr;
|
||||||
|
|
||||||
|
@ -225,7 +228,7 @@ void RegisteredCache::ProcessFiles(const std::vector<NcaID>& ids) {
|
||||||
|
|
||||||
if (file == nullptr)
|
if (file == nullptr)
|
||||||
continue;
|
continue;
|
||||||
const auto nca = std::make_shared<NCA>(parser(file, id));
|
const auto nca = std::make_shared<NCA>(parser(file, id), nullptr, 0, keys);
|
||||||
if (nca->GetStatus() != Loader::ResultStatus::Success ||
|
if (nca->GetStatus() != Loader::ResultStatus::Success ||
|
||||||
nca->GetType() != NCAContentType::Meta) {
|
nca->GetType() != NCAContentType::Meta) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -315,7 +318,7 @@ std::unique_ptr<NCA> RegisteredCache::GetEntry(u64 title_id, ContentRecordType t
|
||||||
const auto raw = GetEntryRaw(title_id, type);
|
const auto raw = GetEntryRaw(title_id, type);
|
||||||
if (raw == nullptr)
|
if (raw == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return std::make_unique<NCA>(raw);
|
return std::make_unique<NCA>(raw, nullptr, 0, keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<NCA> RegisteredCache::GetEntry(RegisteredCacheEntry entry) const {
|
std::unique_ptr<NCA> RegisteredCache::GetEntry(RegisteredCacheEntry entry) const {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/container/flat_map.hpp>
|
#include <boost/container/flat_map.hpp>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/crypto/key_manager.h"
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
@ -133,6 +134,8 @@ private:
|
||||||
|
|
||||||
VirtualDir dir;
|
VirtualDir dir;
|
||||||
RegisteredCacheParsingFunction parser;
|
RegisteredCacheParsingFunction parser;
|
||||||
|
Core::Crypto::KeyManager keys;
|
||||||
|
|
||||||
// maps tid -> NcaID of meta
|
// maps tid -> NcaID of meta
|
||||||
boost::container::flat_map<u64, NcaID> meta_id;
|
boost::container::flat_map<u64, NcaID> meta_id;
|
||||||
// maps tid -> meta
|
// maps tid -> meta
|
||||||
|
|
|
@ -252,7 +252,7 @@ void NSP::ReadNCAs(const std::vector<VirtualFile>& files) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto next_nca = std::make_shared<NCA>(next_file);
|
auto next_nca = std::make_shared<NCA>(next_file, nullptr, 0, keys);
|
||||||
if (next_nca->GetType() == NCAContentType::Program)
|
if (next_nca->GetType() == NCAContentType::Program)
|
||||||
program_status[cnmt.GetTitleID()] = next_nca->GetStatus();
|
program_status[cnmt.GetTitleID()] = next_nca->GetStatus();
|
||||||
if (next_nca->GetStatus() == Loader::ResultStatus::Success ||
|
if (next_nca->GetStatus() == Loader::ResultStatus::Success ||
|
||||||
|
|
|
@ -70,6 +70,8 @@ private:
|
||||||
std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> ncas;
|
std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> ncas;
|
||||||
std::vector<VirtualFile> ticket_files;
|
std::vector<VirtualFile> ticket_files;
|
||||||
|
|
||||||
|
Core::Crypto::KeyManager keys;
|
||||||
|
|
||||||
VirtualFile romfs;
|
VirtualFile romfs;
|
||||||
VirtualDir exefs;
|
VirtualDir exefs;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue