summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/crypto/key_manager.cpp3
-rw-r--r--src/core/file_sys/patch_manager.cpp13
-rw-r--r--src/core/file_sys/romfs_factory.cpp2
-rw-r--r--src/core/file_sys/submission_package.cpp13
-rw-r--r--src/core/file_sys/submission_package.h11
-rw-r--r--src/core/hle/service/aoc/aoc_u.cpp4
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp11
-rw-r--r--src/core/hle/service/filesystem/filesystem.h2
8 files changed, 32 insertions, 27 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp
index dfac9a4b3..dc006e2bb 100644
--- a/src/core/crypto/key_manager.cpp
+++ b/src/core/crypto/key_manager.cpp
@@ -22,6 +22,7 @@
22#include "common/file_util.h" 22#include "common/file_util.h"
23#include "common/hex_util.h" 23#include "common/hex_util.h"
24#include "common/logging/log.h" 24#include "common/logging/log.h"
25#include "core/core.h"
25#include "core/crypto/aes_util.h" 26#include "core/crypto/aes_util.h"
26#include "core/crypto/key_manager.h" 27#include "core/crypto/key_manager.h"
27#include "core/crypto/partition_data_manager.h" 28#include "core/crypto/partition_data_manager.h"
@@ -794,7 +795,7 @@ void KeyManager::DeriveBase() {
794 795
795void KeyManager::DeriveETicket(PartitionDataManager& data) { 796void KeyManager::DeriveETicket(PartitionDataManager& data) {
796 // ETicket keys 797 // ETicket keys
797 const auto es = Service::FileSystem::GetUnionContents().GetEntry( 798 const auto es = Core::System::GetInstance().GetContentProvider().GetEntry(
798 0x0100000000000033, FileSys::ContentRecordType::Program); 799 0x0100000000000033, FileSys::ContentRecordType::Program);
799 800
800 if (es == nullptr) 801 if (es == nullptr)
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index e11217708..ccb38ba03 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -10,6 +10,7 @@
10#include "common/file_util.h" 10#include "common/file_util.h"
11#include "common/hex_util.h" 11#include "common/hex_util.h"
12#include "common/logging/log.h" 12#include "common/logging/log.h"
13#include "core/core.h"
13#include "core/file_sys/content_archive.h" 14#include "core/file_sys/content_archive.h"
14#include "core/file_sys/control_metadata.h" 15#include "core/file_sys/control_metadata.h"
15#include "core/file_sys/ips_layer.h" 16#include "core/file_sys/ips_layer.h"
@@ -69,7 +70,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
69 } 70 }
70 } 71 }
71 72
72 const auto installed = Service::FileSystem::GetUnionContents(); 73 const auto& installed = Core::System::GetInstance().GetContentProvider();
73 74
74 const auto& disabled = Settings::values.disabled_addons[title_id]; 75 const auto& disabled = Settings::values.disabled_addons[title_id];
75 const auto update_disabled = 76 const auto update_disabled =
@@ -345,7 +346,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content
345 if (romfs == nullptr) 346 if (romfs == nullptr)
346 return romfs; 347 return romfs;
347 348
348 const auto installed = Service::FileSystem::GetUnionContents(); 349 const auto& installed = Core::System::GetInstance().GetContentProvider();
349 350
350 // Game Updates 351 // Game Updates
351 const auto update_tid = GetUpdateTitleID(title_id); 352 const auto update_tid = GetUpdateTitleID(title_id);
@@ -392,7 +393,7 @@ static bool IsDirValidAndNonEmpty(const VirtualDir& dir) {
392std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNames( 393std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNames(
393 VirtualFile update_raw) const { 394 VirtualFile update_raw) const {
394 std::map<std::string, std::string, std::less<>> out; 395 std::map<std::string, std::string, std::less<>> out;
395 const auto installed = Service::FileSystem::GetUnionContents(); 396 const auto& installed = Core::System::GetInstance().GetContentProvider();
396 const auto& disabled = Settings::values.disabled_addons[title_id]; 397 const auto& disabled = Settings::values.disabled_addons[title_id];
397 398
398 // Game Updates 399 // Game Updates
@@ -466,10 +467,10 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam
466 467
467 // DLC 468 // DLC
468 const auto dlc_entries = installed.ListEntriesFilter(TitleType::AOC, ContentRecordType::Data); 469 const auto dlc_entries = installed.ListEntriesFilter(TitleType::AOC, ContentRecordType::Data);
469 std::vector<RegisteredCacheEntry> dlc_match; 470 std::vector<ContentProviderEntry> dlc_match;
470 dlc_match.reserve(dlc_entries.size()); 471 dlc_match.reserve(dlc_entries.size());
471 std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), 472 std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match),
472 [this, &installed](const RegisteredCacheEntry& entry) { 473 [this, &installed](const ContentProviderEntry& entry) {
473 return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id && 474 return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id &&
474 installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success; 475 installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success;
475 }); 476 });
@@ -492,7 +493,7 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam
492} 493}
493 494
494std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const { 495std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const {
495 const auto installed{Service::FileSystem::GetUnionContents()}; 496 const auto& installed = Core::System::GetInstance().GetContentProvider();
496 497
497 const auto base_control_nca = installed.GetEntry(title_id, ContentRecordType::Control); 498 const auto base_control_nca = installed.GetEntry(title_id, ContentRecordType::Control);
498 if (base_control_nca == nullptr) 499 if (base_control_nca == nullptr)
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index 6ad1e4f86..b2ccb2926 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -48,7 +48,7 @@ ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, Conte
48 48
49 switch (storage) { 49 switch (storage) {
50 case StorageId::None: 50 case StorageId::None:
51 res = Service::FileSystem::GetUnionContents().GetEntry(title_id, type); 51 res = Core::System::GetInstance().GetContentProvider().GetEntry(title_id, type);
52 break; 52 break;
53 case StorageId::NandSystem: 53 case StorageId::NandSystem:
54 res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type); 54 res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type);
diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp
index e1a4210db..c69caae0f 100644
--- a/src/core/file_sys/submission_package.cpp
+++ b/src/core/file_sys/submission_package.cpp
@@ -143,11 +143,12 @@ std::multimap<u64, std::shared_ptr<NCA>> NSP::GetNCAsByTitleID() const {
143 return out; 143 return out;
144} 144}
145 145
146std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> NSP::GetNCAs() const { 146std::map<u64, std::map<std::pair<TitleType, ContentRecordType>, std::shared_ptr<NCA>>>
147NSP::GetNCAs() const {
147 return ncas; 148 return ncas;
148} 149}
149 150
150std::shared_ptr<NCA> NSP::GetNCA(u64 title_id, ContentRecordType type) const { 151std::shared_ptr<NCA> NSP::GetNCA(u64 title_id, ContentRecordType type, TitleType title_type) const {
151 if (extracted) 152 if (extracted)
152 LOG_WARNING(Service_FS, "called on an NSP that is of type extracted."); 153 LOG_WARNING(Service_FS, "called on an NSP that is of type extracted.");
153 154
@@ -155,14 +156,14 @@ std::shared_ptr<NCA> NSP::GetNCA(u64 title_id, ContentRecordType type) const {
155 if (title_id_iter == ncas.end()) 156 if (title_id_iter == ncas.end())
156 return nullptr; 157 return nullptr;
157 158
158 const auto type_iter = title_id_iter->second.find(type); 159 const auto type_iter = title_id_iter->second.find({title_type, type});
159 if (type_iter == title_id_iter->second.end()) 160 if (type_iter == title_id_iter->second.end())
160 return nullptr; 161 return nullptr;
161 162
162 return type_iter->second; 163 return type_iter->second;
163} 164}
164 165
165VirtualFile NSP::GetNCAFile(u64 title_id, ContentRecordType type) const { 166VirtualFile NSP::GetNCAFile(u64 title_id, ContentRecordType type, TitleType title_type) const {
166 if (extracted) 167 if (extracted)
167 LOG_WARNING(Service_FS, "called on an NSP that is of type extracted."); 168 LOG_WARNING(Service_FS, "called on an NSP that is of type extracted.");
168 const auto nca = GetNCA(title_id, type); 169 const auto nca = GetNCA(title_id, type);
@@ -240,7 +241,7 @@ void NSP::ReadNCAs(const std::vector<VirtualFile>& files) {
240 const CNMT cnmt(inner_file); 241 const CNMT cnmt(inner_file);
241 auto& ncas_title = ncas[cnmt.GetTitleID()]; 242 auto& ncas_title = ncas[cnmt.GetTitleID()];
242 243
243 ncas_title[ContentRecordType::Meta] = nca; 244 ncas_title[{cnmt.GetType(), ContentRecordType::Meta}] = nca;
244 for (const auto& rec : cnmt.GetContentRecords()) { 245 for (const auto& rec : cnmt.GetContentRecords()) {
245 const auto id_string = Common::HexArrayToString(rec.nca_id, false); 246 const auto id_string = Common::HexArrayToString(rec.nca_id, false);
246 const auto next_file = pfs->GetFile(fmt::format("{}.nca", id_string)); 247 const auto next_file = pfs->GetFile(fmt::format("{}.nca", id_string));
@@ -258,7 +259,7 @@ void NSP::ReadNCAs(const std::vector<VirtualFile>& files) {
258 if (next_nca->GetStatus() == Loader::ResultStatus::Success || 259 if (next_nca->GetStatus() == Loader::ResultStatus::Success ||
259 (next_nca->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS && 260 (next_nca->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS &&
260 (cnmt.GetTitleID() & 0x800) != 0)) { 261 (cnmt.GetTitleID() & 0x800) != 0)) {
261 ncas_title[rec.type] = std::move(next_nca); 262 ncas_title[{cnmt.GetType(), rec.type}] = std::move(next_nca);
262 } 263 }
263 } 264 }
264 265
diff --git a/src/core/file_sys/submission_package.h b/src/core/file_sys/submission_package.h
index 9a28ed5bb..ee9b6ce17 100644
--- a/src/core/file_sys/submission_package.h
+++ b/src/core/file_sys/submission_package.h
@@ -42,9 +42,12 @@ public:
42 // Type 0 Only (Collection of NCAs + Certificate + Ticket + Meta XML) 42 // Type 0 Only (Collection of NCAs + Certificate + Ticket + Meta XML)
43 std::vector<std::shared_ptr<NCA>> GetNCAsCollapsed() const; 43 std::vector<std::shared_ptr<NCA>> GetNCAsCollapsed() const;
44 std::multimap<u64, std::shared_ptr<NCA>> GetNCAsByTitleID() const; 44 std::multimap<u64, std::shared_ptr<NCA>> GetNCAsByTitleID() const;
45 std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> GetNCAs() const; 45 std::map<u64, std::map<std::pair<TitleType, ContentRecordType>, std::shared_ptr<NCA>>> GetNCAs()
46 std::shared_ptr<NCA> GetNCA(u64 title_id, ContentRecordType type) const; 46 const;
47 VirtualFile GetNCAFile(u64 title_id, ContentRecordType type) const; 47 std::shared_ptr<NCA> GetNCA(u64 title_id, ContentRecordType type,
48 TitleType title_type = TitleType::Application) const;
49 VirtualFile GetNCAFile(u64 title_id, ContentRecordType type,
50 TitleType title_type = TitleType::Application) const;
48 std::vector<Core::Crypto::Key128> GetTitlekey() const; 51 std::vector<Core::Crypto::Key128> GetTitlekey() const;
49 52
50 std::vector<VirtualFile> GetFiles() const override; 53 std::vector<VirtualFile> GetFiles() const override;
@@ -67,7 +70,7 @@ private:
67 70
68 std::shared_ptr<PartitionFilesystem> pfs; 71 std::shared_ptr<PartitionFilesystem> pfs;
69 // Map title id -> {map type -> NCA} 72 // Map title id -> {map type -> NCA}
70 std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> ncas; 73 std::map<u64, std::map<std::pair<TitleType, ContentRecordType>, std::shared_ptr<NCA>>> ncas;
71 std::vector<VirtualFile> ticket_files; 74 std::vector<VirtualFile> ticket_files;
72 75
73 Core::Crypto::KeyManager keys; 76 Core::Crypto::KeyManager keys;
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp
index b506bc3dd..2d768d9fc 100644
--- a/src/core/hle/service/aoc/aoc_u.cpp
+++ b/src/core/hle/service/aoc/aoc_u.cpp
@@ -33,11 +33,11 @@ static bool CheckAOCTitleIDMatchesBase(u64 title_id, u64 base) {
33 33
34static std::vector<u64> AccumulateAOCTitleIDs() { 34static std::vector<u64> AccumulateAOCTitleIDs() {
35 std::vector<u64> add_on_content; 35 std::vector<u64> add_on_content;
36 const auto rcu = FileSystem::GetUnionContents(); 36 const auto& rcu = Core::System::GetInstance().GetContentProvider();
37 const auto list = 37 const auto list =
38 rcu.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); 38 rcu.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
39 std::transform(list.begin(), list.end(), std::back_inserter(add_on_content), 39 std::transform(list.begin(), list.end(), std::back_inserter(add_on_content),
40 [](const FileSys::RegisteredCacheEntry& rce) { return rce.title_id; }); 40 [](const FileSys::ContentProviderEntry& rce) { return rce.title_id; });
41 add_on_content.erase( 41 add_on_content.erase(
42 std::remove_if( 42 std::remove_if(
43 add_on_content.begin(), add_on_content.end(), 43 add_on_content.begin(), add_on_content.end(),
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index c6da2df43..db5017dd5 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -388,11 +388,6 @@ void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
388 save_data_factory->WriteSaveDataSize(type, title_id, user_id, new_value); 388 save_data_factory->WriteSaveDataSize(type, title_id, user_id, new_value);
389} 389}
390 390
391FileSys::RegisteredCacheUnion GetUnionContents() {
392 return FileSys::RegisteredCacheUnion{
393 {GetSystemNANDContents(), GetUserNANDContents(), GetSDMCContents()}};
394}
395
396FileSys::RegisteredCache* GetSystemNANDContents() { 391FileSys::RegisteredCache* GetSystemNANDContents() {
397 LOG_TRACE(Service_FS, "Opening System NAND Contents"); 392 LOG_TRACE(Service_FS, "Opening System NAND Contents");
398 393
@@ -457,6 +452,10 @@ void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) {
457 if (bis_factory == nullptr) { 452 if (bis_factory == nullptr) {
458 bis_factory = 453 bis_factory =
459 std::make_unique<FileSys::BISFactory>(nand_directory, load_directory, dump_directory); 454 std::make_unique<FileSys::BISFactory>(nand_directory, load_directory, dump_directory);
455 Core::System::GetInstance().RegisterContentProvider(
456 FileSys::ContentProviderUnionSlot::SysNAND, bis_factory->GetSystemNANDContents());
457 Core::System::GetInstance().RegisterContentProvider(
458 FileSys::ContentProviderUnionSlot::UserNAND, bis_factory->GetUserNANDContents());
460 } 459 }
461 460
462 if (save_data_factory == nullptr) { 461 if (save_data_factory == nullptr) {
@@ -465,6 +464,8 @@ void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) {
465 464
466 if (sdmc_factory == nullptr) { 465 if (sdmc_factory == nullptr) {
467 sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory)); 466 sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory));
467 Core::System::GetInstance().RegisterContentProvider(FileSys::ContentProviderUnionSlot::SDMC,
468 sdmc_factory->GetSDMCContents());
468 } 469 }
469} 470}
470 471
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h
index 6fd5e7b23..d1789b0f4 100644
--- a/src/core/hle/service/filesystem/filesystem.h
+++ b/src/core/hle/service/filesystem/filesystem.h
@@ -54,8 +54,6 @@ FileSys::SaveDataSize ReadSaveDataSize(FileSys::SaveDataType type, u64 title_id,
54void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id, 54void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
55 FileSys::SaveDataSize new_value); 55 FileSys::SaveDataSize new_value);
56 56
57FileSys::RegisteredCacheUnion GetUnionContents();
58
59FileSys::RegisteredCache* GetSystemNANDContents(); 57FileSys::RegisteredCache* GetSystemNANDContents();
60FileSys::RegisteredCache* GetUserNANDContents(); 58FileSys::RegisteredCache* GetUserNANDContents();
61FileSys::RegisteredCache* GetSDMCContents(); 59FileSys::RegisteredCache* GetSDMCContents();