diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.cpp | 26 | ||||
| -rw-r--r-- | src/core/core.h | 14 | ||||
| -rw-r--r-- | src/core/crypto/key_manager.cpp | 3 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 22 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/registered_cache.cpp | 275 | ||||
| -rw-r--r-- | src/core/file_sys/registered_cache.h | 156 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.cpp | 2 | ||||
| -rw-r--r-- | src/core/file_sys/submission_package.cpp | 13 | ||||
| -rw-r--r-- | src/core/file_sys/submission_package.h | 11 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/web_browser.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/aoc/aoc_u.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 11 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.h | 2 | ||||
| -rw-r--r-- | src/core/loader/nso.cpp | 6 |
15 files changed, 362 insertions, 187 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 4fe77c25b..bc9e887b6 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "core/core_timing.h" | 17 | #include "core/core_timing.h" |
| 18 | #include "core/cpu_core_manager.h" | 18 | #include "core/cpu_core_manager.h" |
| 19 | #include "core/file_sys/mode.h" | 19 | #include "core/file_sys/mode.h" |
| 20 | #include "core/file_sys/registered_cache.h" | ||
| 20 | #include "core/file_sys/vfs_concat.h" | 21 | #include "core/file_sys/vfs_concat.h" |
| 21 | #include "core/file_sys/vfs_real.h" | 22 | #include "core/file_sys/vfs_real.h" |
| 22 | #include "core/gdbstub/gdbstub.h" | 23 | #include "core/gdbstub/gdbstub.h" |
| @@ -108,6 +109,8 @@ struct System::Impl { | |||
| 108 | // Create a default fs if one doesn't already exist. | 109 | // Create a default fs if one doesn't already exist. |
| 109 | if (virtual_filesystem == nullptr) | 110 | if (virtual_filesystem == nullptr) |
| 110 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); | 111 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); |
| 112 | if (content_provider == nullptr) | ||
| 113 | content_provider = std::make_unique<FileSys::ContentProviderUnion>(); | ||
| 111 | 114 | ||
| 112 | /// Create default implementations of applets if one is not provided. | 115 | /// Create default implementations of applets if one is not provided. |
| 113 | if (profile_selector == nullptr) | 116 | if (profile_selector == nullptr) |
| @@ -249,6 +252,8 @@ struct System::Impl { | |||
| 249 | Kernel::KernelCore kernel; | 252 | Kernel::KernelCore kernel; |
| 250 | /// RealVfsFilesystem instance | 253 | /// RealVfsFilesystem instance |
| 251 | FileSys::VirtualFilesystem virtual_filesystem; | 254 | FileSys::VirtualFilesystem virtual_filesystem; |
| 255 | /// ContentProviderUnion instance | ||
| 256 | std::unique_ptr<FileSys::ContentProviderUnion> content_provider; | ||
| 252 | /// AppLoader used to load the current executing application | 257 | /// AppLoader used to load the current executing application |
| 253 | std::unique_ptr<Loader::AppLoader> app_loader; | 258 | std::unique_ptr<Loader::AppLoader> app_loader; |
| 254 | std::unique_ptr<VideoCore::RendererBase> renderer; | 259 | std::unique_ptr<VideoCore::RendererBase> renderer; |
| @@ -488,6 +493,27 @@ const Frontend::SoftwareKeyboardApplet& System::GetSoftwareKeyboard() const { | |||
| 488 | return *impl->software_keyboard; | 493 | return *impl->software_keyboard; |
| 489 | } | 494 | } |
| 490 | 495 | ||
| 496 | void System::SetContentProvider(std::unique_ptr<FileSys::ContentProviderUnion> provider) { | ||
| 497 | impl->content_provider = std::move(provider); | ||
| 498 | } | ||
| 499 | |||
| 500 | FileSys::ContentProvider& System::GetContentProvider() { | ||
| 501 | return *impl->content_provider; | ||
| 502 | } | ||
| 503 | |||
| 504 | const FileSys::ContentProvider& System::GetContentProvider() const { | ||
| 505 | return *impl->content_provider; | ||
| 506 | } | ||
| 507 | |||
| 508 | void System::RegisterContentProvider(FileSys::ContentProviderUnionSlot slot, | ||
| 509 | FileSys::ContentProvider* provider) { | ||
| 510 | impl->content_provider->SetSlot(slot, provider); | ||
| 511 | } | ||
| 512 | |||
| 513 | void System::ClearContentProvider(FileSys::ContentProviderUnionSlot slot) { | ||
| 514 | impl->content_provider->ClearSlot(slot); | ||
| 515 | } | ||
| 516 | |||
| 491 | void System::SetWebBrowser(std::unique_ptr<Frontend::WebBrowserApplet> applet) { | 517 | void System::SetWebBrowser(std::unique_ptr<Frontend::WebBrowserApplet> applet) { |
| 492 | impl->web_browser = std::move(applet); | 518 | impl->web_browser = std::move(applet); |
| 493 | } | 519 | } |
diff --git a/src/core/core.h b/src/core/core.h index 4d83b93cc..82b2e087e 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -21,6 +21,9 @@ class WebBrowserApplet; | |||
| 21 | 21 | ||
| 22 | namespace FileSys { | 22 | namespace FileSys { |
| 23 | class CheatList; | 23 | class CheatList; |
| 24 | class ContentProvider; | ||
| 25 | class ContentProviderUnion; | ||
| 26 | enum class ContentProviderUnionSlot; | ||
| 24 | class VfsFilesystem; | 27 | class VfsFilesystem; |
| 25 | } // namespace FileSys | 28 | } // namespace FileSys |
| 26 | 29 | ||
| @@ -270,6 +273,17 @@ public: | |||
| 270 | Frontend::WebBrowserApplet& GetWebBrowser(); | 273 | Frontend::WebBrowserApplet& GetWebBrowser(); |
| 271 | const Frontend::WebBrowserApplet& GetWebBrowser() const; | 274 | const Frontend::WebBrowserApplet& GetWebBrowser() const; |
| 272 | 275 | ||
| 276 | void SetContentProvider(std::unique_ptr<FileSys::ContentProviderUnion> provider); | ||
| 277 | |||
| 278 | FileSys::ContentProvider& GetContentProvider(); | ||
| 279 | |||
| 280 | const FileSys::ContentProvider& GetContentProvider() const; | ||
| 281 | |||
| 282 | void RegisterContentProvider(FileSys::ContentProviderUnionSlot slot, | ||
| 283 | FileSys::ContentProvider* provider); | ||
| 284 | |||
| 285 | void ClearContentProvider(FileSys::ContentProviderUnionSlot slot); | ||
| 286 | |||
| 273 | private: | 287 | private: |
| 274 | System(); | 288 | System(); |
| 275 | 289 | ||
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 | ||
| 795 | void KeyManager::DeriveETicket(PartitionDataManager& data) { | 796 | void 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..78dbadee3 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 = |
| @@ -155,7 +156,7 @@ std::vector<VirtualFile> PatchManager::CollectPatches(const std::vector<VirtualD | |||
| 155 | return out; | 156 | return out; |
| 156 | } | 157 | } |
| 157 | 158 | ||
| 158 | std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso) const { | 159 | std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso, const std::string& name) const { |
| 159 | if (nso.size() < sizeof(Loader::NSOHeader)) { | 160 | if (nso.size() < sizeof(Loader::NSOHeader)) { |
| 160 | return nso; | 161 | return nso; |
| 161 | } | 162 | } |
| @@ -171,18 +172,19 @@ std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso) const { | |||
| 171 | const auto build_id = build_id_raw.substr(0, build_id_raw.find_last_not_of('0') + 1); | 172 | const auto build_id = build_id_raw.substr(0, build_id_raw.find_last_not_of('0') + 1); |
| 172 | 173 | ||
| 173 | if (Settings::values.dump_nso) { | 174 | if (Settings::values.dump_nso) { |
| 174 | LOG_INFO(Loader, "Dumping NSO for build_id={}, title_id={:016X}", build_id, title_id); | 175 | LOG_INFO(Loader, "Dumping NSO for name={}, build_id={}, title_id={:016X}", name, build_id, |
| 176 | title_id); | ||
| 175 | const auto dump_dir = Service::FileSystem::GetModificationDumpRoot(title_id); | 177 | const auto dump_dir = Service::FileSystem::GetModificationDumpRoot(title_id); |
| 176 | if (dump_dir != nullptr) { | 178 | if (dump_dir != nullptr) { |
| 177 | const auto nso_dir = GetOrCreateDirectoryRelative(dump_dir, "/nso"); | 179 | const auto nso_dir = GetOrCreateDirectoryRelative(dump_dir, "/nso"); |
| 178 | const auto file = nso_dir->CreateFile(fmt::format("{}.nso", build_id)); | 180 | const auto file = nso_dir->CreateFile(fmt::format("{}-{}.nso", name, build_id)); |
| 179 | 181 | ||
| 180 | file->Resize(nso.size()); | 182 | file->Resize(nso.size()); |
| 181 | file->WriteBytes(nso); | 183 | file->WriteBytes(nso); |
| 182 | } | 184 | } |
| 183 | } | 185 | } |
| 184 | 186 | ||
| 185 | LOG_INFO(Loader, "Patching NSO for build_id={}", build_id); | 187 | LOG_INFO(Loader, "Patching NSO for name={}, build_id={}", name, build_id); |
| 186 | 188 | ||
| 187 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); | 189 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); |
| 188 | auto patch_dirs = load_dir->GetSubdirectories(); | 190 | auto patch_dirs = load_dir->GetSubdirectories(); |
| @@ -345,7 +347,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content | |||
| 345 | if (romfs == nullptr) | 347 | if (romfs == nullptr) |
| 346 | return romfs; | 348 | return romfs; |
| 347 | 349 | ||
| 348 | const auto installed = Service::FileSystem::GetUnionContents(); | 350 | const auto& installed = Core::System::GetInstance().GetContentProvider(); |
| 349 | 351 | ||
| 350 | // Game Updates | 352 | // Game Updates |
| 351 | const auto update_tid = GetUpdateTitleID(title_id); | 353 | const auto update_tid = GetUpdateTitleID(title_id); |
| @@ -392,7 +394,7 @@ static bool IsDirValidAndNonEmpty(const VirtualDir& dir) { | |||
| 392 | std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNames( | 394 | std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNames( |
| 393 | VirtualFile update_raw) const { | 395 | VirtualFile update_raw) const { |
| 394 | std::map<std::string, std::string, std::less<>> out; | 396 | std::map<std::string, std::string, std::less<>> out; |
| 395 | const auto installed = Service::FileSystem::GetUnionContents(); | 397 | const auto& installed = Core::System::GetInstance().GetContentProvider(); |
| 396 | const auto& disabled = Settings::values.disabled_addons[title_id]; | 398 | const auto& disabled = Settings::values.disabled_addons[title_id]; |
| 397 | 399 | ||
| 398 | // Game Updates | 400 | // Game Updates |
| @@ -466,10 +468,10 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 466 | 468 | ||
| 467 | // DLC | 469 | // DLC |
| 468 | const auto dlc_entries = installed.ListEntriesFilter(TitleType::AOC, ContentRecordType::Data); | 470 | const auto dlc_entries = installed.ListEntriesFilter(TitleType::AOC, ContentRecordType::Data); |
| 469 | std::vector<RegisteredCacheEntry> dlc_match; | 471 | std::vector<ContentProviderEntry> dlc_match; |
| 470 | dlc_match.reserve(dlc_entries.size()); | 472 | dlc_match.reserve(dlc_entries.size()); |
| 471 | std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), | 473 | std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), |
| 472 | [this, &installed](const RegisteredCacheEntry& entry) { | 474 | [this, &installed](const ContentProviderEntry& entry) { |
| 473 | return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id && | 475 | return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id && |
| 474 | installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success; | 476 | installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success; |
| 475 | }); | 477 | }); |
| @@ -492,7 +494,7 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 492 | } | 494 | } |
| 493 | 495 | ||
| 494 | std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const { | 496 | std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const { |
| 495 | const auto installed{Service::FileSystem::GetUnionContents()}; | 497 | const auto& installed = Core::System::GetInstance().GetContentProvider(); |
| 496 | 498 | ||
| 497 | const auto base_control_nca = installed.GetEntry(title_id, ContentRecordType::Control); | 499 | const auto base_control_nca = installed.GetEntry(title_id, ContentRecordType::Control); |
| 498 | if (base_control_nca == nullptr) | 500 | if (base_control_nca == nullptr) |
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index de2672c76..769f8c6f0 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h | |||
| @@ -44,7 +44,7 @@ public: | |||
| 44 | // Currently tracked NSO patches: | 44 | // Currently tracked NSO patches: |
| 45 | // - IPS | 45 | // - IPS |
| 46 | // - IPSwitch | 46 | // - IPSwitch |
| 47 | std::vector<u8> PatchNSO(const std::vector<u8>& nso) const; | 47 | std::vector<u8> PatchNSO(const std::vector<u8>& nso, const std::string& name) const; |
| 48 | 48 | ||
| 49 | // Checks to see if PatchNSO() will have any effect given the NSO's build ID. | 49 | // Checks to see if PatchNSO() will have any effect given the NSO's build ID. |
| 50 | // Used to prevent expensive copies in NSO loader. | 50 | // Used to prevent expensive copies in NSO loader. |
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 1c6bacace..3946ff871 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp | |||
| @@ -23,19 +23,19 @@ namespace FileSys { | |||
| 23 | // The size of blocks to use when vfs raw copying into nand. | 23 | // The size of blocks to use when vfs raw copying into nand. |
| 24 | constexpr size_t VFS_RC_LARGE_COPY_BLOCK = 0x400000; | 24 | constexpr size_t VFS_RC_LARGE_COPY_BLOCK = 0x400000; |
| 25 | 25 | ||
| 26 | std::string RegisteredCacheEntry::DebugInfo() const { | 26 | std::string ContentProviderEntry::DebugInfo() const { |
| 27 | return fmt::format("title_id={:016X}, content_type={:02X}", title_id, static_cast<u8>(type)); | 27 | return fmt::format("title_id={:016X}, content_type={:02X}", title_id, static_cast<u8>(type)); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) { | 30 | bool operator<(const ContentProviderEntry& lhs, const ContentProviderEntry& rhs) { |
| 31 | return (lhs.title_id < rhs.title_id) || (lhs.title_id == rhs.title_id && lhs.type < rhs.type); | 31 | return (lhs.title_id < rhs.title_id) || (lhs.title_id == rhs.title_id && lhs.type < rhs.type); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | bool operator==(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) { | 34 | bool operator==(const ContentProviderEntry& lhs, const ContentProviderEntry& rhs) { |
| 35 | return std::tie(lhs.title_id, lhs.type) == std::tie(rhs.title_id, rhs.type); | 35 | return std::tie(lhs.title_id, lhs.type) == std::tie(rhs.title_id, rhs.type); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | bool operator!=(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) { | 38 | bool operator!=(const ContentProviderEntry& lhs, const ContentProviderEntry& rhs) { |
| 39 | return !operator==(lhs, rhs); | 39 | return !operator==(lhs, rhs); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| @@ -84,7 +84,7 @@ static std::string GetCNMTName(TitleType type, u64 title_id) { | |||
| 84 | return fmt::format("{}_{:016x}.cnmt", TITLE_TYPE_NAMES[index], title_id); | 84 | return fmt::format("{}_{:016x}.cnmt", TITLE_TYPE_NAMES[index], title_id); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | static ContentRecordType GetCRTypeFromNCAType(NCAContentType type) { | 87 | ContentRecordType GetCRTypeFromNCAType(NCAContentType type) { |
| 88 | switch (type) { | 88 | switch (type) { |
| 89 | case NCAContentType::Program: | 89 | case NCAContentType::Program: |
| 90 | // TODO(DarkLordZach): Differentiate between Program and Patch | 90 | // TODO(DarkLordZach): Differentiate between Program and Patch |
| @@ -104,6 +104,28 @@ static ContentRecordType GetCRTypeFromNCAType(NCAContentType type) { | |||
| 104 | } | 104 | } |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | ContentProvider::~ContentProvider() = default; | ||
| 108 | |||
| 109 | bool ContentProvider::HasEntry(ContentProviderEntry entry) const { | ||
| 110 | return HasEntry(entry.title_id, entry.type); | ||
| 111 | } | ||
| 112 | |||
| 113 | VirtualFile ContentProvider::GetEntryUnparsed(ContentProviderEntry entry) const { | ||
| 114 | return GetEntryUnparsed(entry.title_id, entry.type); | ||
| 115 | } | ||
| 116 | |||
| 117 | VirtualFile ContentProvider::GetEntryRaw(ContentProviderEntry entry) const { | ||
| 118 | return GetEntryRaw(entry.title_id, entry.type); | ||
| 119 | } | ||
| 120 | |||
| 121 | std::unique_ptr<NCA> ContentProvider::GetEntry(ContentProviderEntry entry) const { | ||
| 122 | return GetEntry(entry.title_id, entry.type); | ||
| 123 | } | ||
| 124 | |||
| 125 | std::vector<ContentProviderEntry> ContentProvider::ListEntries() const { | ||
| 126 | return ListEntriesFilter(std::nullopt, std::nullopt, std::nullopt); | ||
| 127 | } | ||
| 128 | |||
| 107 | VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir, | 129 | VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir, |
| 108 | std::string_view path) const { | 130 | std::string_view path) const { |
| 109 | const auto file = dir->GetFileRelative(path); | 131 | const auto file = dir->GetFileRelative(path); |
| @@ -161,8 +183,8 @@ VirtualFile RegisteredCache::GetFileAtID(NcaID id) const { | |||
| 161 | return file; | 183 | return file; |
| 162 | } | 184 | } |
| 163 | 185 | ||
| 164 | static std::optional<NcaID> CheckMapForContentRecord( | 186 | static std::optional<NcaID> CheckMapForContentRecord(const std::map<u64, CNMT>& map, u64 title_id, |
| 165 | const boost::container::flat_map<u64, CNMT>& map, u64 title_id, ContentRecordType type) { | 187 | ContentRecordType type) { |
| 166 | if (map.find(title_id) == map.end()) | 188 | if (map.find(title_id) == map.end()) |
| 167 | return {}; | 189 | return {}; |
| 168 | 190 | ||
| @@ -268,7 +290,7 @@ void RegisteredCache::Refresh() { | |||
| 268 | AccumulateYuzuMeta(); | 290 | AccumulateYuzuMeta(); |
| 269 | } | 291 | } |
| 270 | 292 | ||
| 271 | RegisteredCache::RegisteredCache(VirtualDir dir_, RegisteredCacheParsingFunction parsing_function) | 293 | RegisteredCache::RegisteredCache(VirtualDir dir_, ContentProviderParsingFunction parsing_function) |
| 272 | : dir(std::move(dir_)), parser(std::move(parsing_function)) { | 294 | : dir(std::move(dir_)), parser(std::move(parsing_function)) { |
| 273 | Refresh(); | 295 | Refresh(); |
| 274 | } | 296 | } |
| @@ -279,19 +301,11 @@ bool RegisteredCache::HasEntry(u64 title_id, ContentRecordType type) const { | |||
| 279 | return GetEntryRaw(title_id, type) != nullptr; | 301 | return GetEntryRaw(title_id, type) != nullptr; |
| 280 | } | 302 | } |
| 281 | 303 | ||
| 282 | bool RegisteredCache::HasEntry(RegisteredCacheEntry entry) const { | ||
| 283 | return GetEntryRaw(entry) != nullptr; | ||
| 284 | } | ||
| 285 | |||
| 286 | VirtualFile RegisteredCache::GetEntryUnparsed(u64 title_id, ContentRecordType type) const { | 304 | VirtualFile RegisteredCache::GetEntryUnparsed(u64 title_id, ContentRecordType type) const { |
| 287 | const auto id = GetNcaIDFromMetadata(title_id, type); | 305 | const auto id = GetNcaIDFromMetadata(title_id, type); |
| 288 | return id ? GetFileAtID(*id) : nullptr; | 306 | return id ? GetFileAtID(*id) : nullptr; |
| 289 | } | 307 | } |
| 290 | 308 | ||
| 291 | VirtualFile RegisteredCache::GetEntryUnparsed(RegisteredCacheEntry entry) const { | ||
| 292 | return GetEntryUnparsed(entry.title_id, entry.type); | ||
| 293 | } | ||
| 294 | |||
| 295 | std::optional<u32> RegisteredCache::GetEntryVersion(u64 title_id) const { | 309 | std::optional<u32> RegisteredCache::GetEntryVersion(u64 title_id) const { |
| 296 | const auto meta_iter = meta.find(title_id); | 310 | const auto meta_iter = meta.find(title_id); |
| 297 | if (meta_iter != meta.end()) | 311 | if (meta_iter != meta.end()) |
| @@ -309,10 +323,6 @@ VirtualFile RegisteredCache::GetEntryRaw(u64 title_id, ContentRecordType type) c | |||
| 309 | return id ? parser(GetFileAtID(*id), *id) : nullptr; | 323 | return id ? parser(GetFileAtID(*id), *id) : nullptr; |
| 310 | } | 324 | } |
| 311 | 325 | ||
| 312 | VirtualFile RegisteredCache::GetEntryRaw(RegisteredCacheEntry entry) const { | ||
| 313 | return GetEntryRaw(entry.title_id, entry.type); | ||
| 314 | } | ||
| 315 | |||
| 316 | std::unique_ptr<NCA> RegisteredCache::GetEntry(u64 title_id, ContentRecordType type) const { | 326 | std::unique_ptr<NCA> RegisteredCache::GetEntry(u64 title_id, ContentRecordType type) const { |
| 317 | const auto raw = GetEntryRaw(title_id, type); | 327 | const auto raw = GetEntryRaw(title_id, type); |
| 318 | if (raw == nullptr) | 328 | if (raw == nullptr) |
| @@ -320,10 +330,6 @@ std::unique_ptr<NCA> RegisteredCache::GetEntry(u64 title_id, ContentRecordType t | |||
| 320 | return std::make_unique<NCA>(raw, nullptr, 0, keys); | 330 | return std::make_unique<NCA>(raw, nullptr, 0, keys); |
| 321 | } | 331 | } |
| 322 | 332 | ||
| 323 | std::unique_ptr<NCA> RegisteredCache::GetEntry(RegisteredCacheEntry entry) const { | ||
| 324 | return GetEntry(entry.title_id, entry.type); | ||
| 325 | } | ||
| 326 | |||
| 327 | template <typename T> | 333 | template <typename T> |
| 328 | void RegisteredCache::IterateAllMetadata( | 334 | void RegisteredCache::IterateAllMetadata( |
| 329 | std::vector<T>& out, std::function<T(const CNMT&, const ContentRecord&)> proc, | 335 | std::vector<T>& out, std::function<T(const CNMT&, const ContentRecord&)> proc, |
| @@ -348,25 +354,14 @@ void RegisteredCache::IterateAllMetadata( | |||
| 348 | } | 354 | } |
| 349 | } | 355 | } |
| 350 | 356 | ||
| 351 | std::vector<RegisteredCacheEntry> RegisteredCache::ListEntries() const { | 357 | std::vector<ContentProviderEntry> RegisteredCache::ListEntriesFilter( |
| 352 | std::vector<RegisteredCacheEntry> out; | ||
| 353 | IterateAllMetadata<RegisteredCacheEntry>( | ||
| 354 | out, | ||
| 355 | [](const CNMT& c, const ContentRecord& r) { | ||
| 356 | return RegisteredCacheEntry{c.GetTitleID(), r.type}; | ||
| 357 | }, | ||
| 358 | [](const CNMT& c, const ContentRecord& r) { return true; }); | ||
| 359 | return out; | ||
| 360 | } | ||
| 361 | |||
| 362 | std::vector<RegisteredCacheEntry> RegisteredCache::ListEntriesFilter( | ||
| 363 | std::optional<TitleType> title_type, std::optional<ContentRecordType> record_type, | 358 | std::optional<TitleType> title_type, std::optional<ContentRecordType> record_type, |
| 364 | std::optional<u64> title_id) const { | 359 | std::optional<u64> title_id) const { |
| 365 | std::vector<RegisteredCacheEntry> out; | 360 | std::vector<ContentProviderEntry> out; |
| 366 | IterateAllMetadata<RegisteredCacheEntry>( | 361 | IterateAllMetadata<ContentProviderEntry>( |
| 367 | out, | 362 | out, |
| 368 | [](const CNMT& c, const ContentRecord& r) { | 363 | [](const CNMT& c, const ContentRecord& r) { |
| 369 | return RegisteredCacheEntry{c.GetTitleID(), r.type}; | 364 | return ContentProviderEntry{c.GetTitleID(), r.type}; |
| 370 | }, | 365 | }, |
| 371 | [&title_type, &record_type, &title_id](const CNMT& c, const ContentRecord& r) { | 366 | [&title_type, &record_type, &title_id](const CNMT& c, const ContentRecord& r) { |
| 372 | if (title_type && *title_type != c.GetType()) | 367 | if (title_type && *title_type != c.GetType()) |
| @@ -521,37 +516,56 @@ bool RegisteredCache::RawInstallYuzuMeta(const CNMT& cnmt) { | |||
| 521 | }) != yuzu_meta.end(); | 516 | }) != yuzu_meta.end(); |
| 522 | } | 517 | } |
| 523 | 518 | ||
| 524 | RegisteredCacheUnion::RegisteredCacheUnion(std::vector<RegisteredCache*> caches) | 519 | ContentProviderUnion::~ContentProviderUnion() = default; |
| 525 | : caches(std::move(caches)) {} | ||
| 526 | 520 | ||
| 527 | void RegisteredCacheUnion::Refresh() { | 521 | void ContentProviderUnion::SetSlot(ContentProviderUnionSlot slot, ContentProvider* provider) { |
| 528 | for (const auto& c : caches) | 522 | providers[slot] = provider; |
| 529 | c->Refresh(); | ||
| 530 | } | 523 | } |
| 531 | 524 | ||
| 532 | bool RegisteredCacheUnion::HasEntry(u64 title_id, ContentRecordType type) const { | 525 | void ContentProviderUnion::ClearSlot(ContentProviderUnionSlot slot) { |
| 533 | return std::any_of(caches.begin(), caches.end(), [title_id, type](const auto& cache) { | 526 | providers[slot] = nullptr; |
| 534 | return cache->HasEntry(title_id, type); | ||
| 535 | }); | ||
| 536 | } | 527 | } |
| 537 | 528 | ||
| 538 | bool RegisteredCacheUnion::HasEntry(RegisteredCacheEntry entry) const { | 529 | void ContentProviderUnion::Refresh() { |
| 539 | return HasEntry(entry.title_id, entry.type); | 530 | for (auto& provider : providers) { |
| 531 | if (provider.second == nullptr) | ||
| 532 | continue; | ||
| 533 | |||
| 534 | provider.second->Refresh(); | ||
| 535 | } | ||
| 540 | } | 536 | } |
| 541 | 537 | ||
| 542 | std::optional<u32> RegisteredCacheUnion::GetEntryVersion(u64 title_id) const { | 538 | bool ContentProviderUnion::HasEntry(u64 title_id, ContentRecordType type) const { |
| 543 | for (const auto& c : caches) { | 539 | for (const auto& provider : providers) { |
| 544 | const auto res = c->GetEntryVersion(title_id); | 540 | if (provider.second == nullptr) |
| 545 | if (res) | 541 | continue; |
| 542 | |||
| 543 | if (provider.second->HasEntry(title_id, type)) | ||
| 544 | return true; | ||
| 545 | } | ||
| 546 | |||
| 547 | return false; | ||
| 548 | } | ||
| 549 | |||
| 550 | std::optional<u32> ContentProviderUnion::GetEntryVersion(u64 title_id) const { | ||
| 551 | for (const auto& provider : providers) { | ||
| 552 | if (provider.second == nullptr) | ||
| 553 | continue; | ||
| 554 | |||
| 555 | const auto res = provider.second->GetEntryVersion(title_id); | ||
| 556 | if (res != std::nullopt) | ||
| 546 | return res; | 557 | return res; |
| 547 | } | 558 | } |
| 548 | 559 | ||
| 549 | return {}; | 560 | return std::nullopt; |
| 550 | } | 561 | } |
| 551 | 562 | ||
| 552 | VirtualFile RegisteredCacheUnion::GetEntryUnparsed(u64 title_id, ContentRecordType type) const { | 563 | VirtualFile ContentProviderUnion::GetEntryUnparsed(u64 title_id, ContentRecordType type) const { |
| 553 | for (const auto& c : caches) { | 564 | for (const auto& provider : providers) { |
| 554 | const auto res = c->GetEntryUnparsed(title_id, type); | 565 | if (provider.second == nullptr) |
| 566 | continue; | ||
| 567 | |||
| 568 | const auto res = provider.second->GetEntryUnparsed(title_id, type); | ||
| 555 | if (res != nullptr) | 569 | if (res != nullptr) |
| 556 | return res; | 570 | return res; |
| 557 | } | 571 | } |
| @@ -559,13 +573,12 @@ VirtualFile RegisteredCacheUnion::GetEntryUnparsed(u64 title_id, ContentRecordTy | |||
| 559 | return nullptr; | 573 | return nullptr; |
| 560 | } | 574 | } |
| 561 | 575 | ||
| 562 | VirtualFile RegisteredCacheUnion::GetEntryUnparsed(RegisteredCacheEntry entry) const { | 576 | VirtualFile ContentProviderUnion::GetEntryRaw(u64 title_id, ContentRecordType type) const { |
| 563 | return GetEntryUnparsed(entry.title_id, entry.type); | 577 | for (const auto& provider : providers) { |
| 564 | } | 578 | if (provider.second == nullptr) |
| 579 | continue; | ||
| 565 | 580 | ||
| 566 | VirtualFile RegisteredCacheUnion::GetEntryRaw(u64 title_id, ContentRecordType type) const { | 581 | const auto res = provider.second->GetEntryRaw(title_id, type); |
| 567 | for (const auto& c : caches) { | ||
| 568 | const auto res = c->GetEntryRaw(title_id, type); | ||
| 569 | if (res != nullptr) | 582 | if (res != nullptr) |
| 570 | return res; | 583 | return res; |
| 571 | } | 584 | } |
| @@ -573,30 +586,56 @@ VirtualFile RegisteredCacheUnion::GetEntryRaw(u64 title_id, ContentRecordType ty | |||
| 573 | return nullptr; | 586 | return nullptr; |
| 574 | } | 587 | } |
| 575 | 588 | ||
| 576 | VirtualFile RegisteredCacheUnion::GetEntryRaw(RegisteredCacheEntry entry) const { | 589 | std::unique_ptr<NCA> ContentProviderUnion::GetEntry(u64 title_id, ContentRecordType type) const { |
| 577 | return GetEntryRaw(entry.title_id, entry.type); | 590 | for (const auto& provider : providers) { |
| 578 | } | 591 | if (provider.second == nullptr) |
| 592 | continue; | ||
| 579 | 593 | ||
| 580 | std::unique_ptr<NCA> RegisteredCacheUnion::GetEntry(u64 title_id, ContentRecordType type) const { | 594 | auto res = provider.second->GetEntry(title_id, type); |
| 581 | const auto raw = GetEntryRaw(title_id, type); | 595 | if (res != nullptr) |
| 582 | if (raw == nullptr) | 596 | return res; |
| 583 | return nullptr; | 597 | } |
| 584 | return std::make_unique<NCA>(raw); | 598 | |
| 599 | return nullptr; | ||
| 585 | } | 600 | } |
| 586 | 601 | ||
| 587 | std::unique_ptr<NCA> RegisteredCacheUnion::GetEntry(RegisteredCacheEntry entry) const { | 602 | std::vector<ContentProviderEntry> ContentProviderUnion::ListEntriesFilter( |
| 588 | return GetEntry(entry.title_id, entry.type); | 603 | std::optional<TitleType> title_type, std::optional<ContentRecordType> record_type, |
| 604 | std::optional<u64> title_id) const { | ||
| 605 | std::vector<ContentProviderEntry> out; | ||
| 606 | |||
| 607 | for (const auto& provider : providers) { | ||
| 608 | if (provider.second == nullptr) | ||
| 609 | continue; | ||
| 610 | |||
| 611 | const auto vec = provider.second->ListEntriesFilter(title_type, record_type, title_id); | ||
| 612 | std::copy(vec.begin(), vec.end(), std::back_inserter(out)); | ||
| 613 | } | ||
| 614 | |||
| 615 | std::sort(out.begin(), out.end()); | ||
| 616 | out.erase(std::unique(out.begin(), out.end()), out.end()); | ||
| 617 | return out; | ||
| 589 | } | 618 | } |
| 590 | 619 | ||
| 591 | std::vector<RegisteredCacheEntry> RegisteredCacheUnion::ListEntries() const { | 620 | std::vector<std::pair<ContentProviderUnionSlot, ContentProviderEntry>> |
| 592 | std::vector<RegisteredCacheEntry> out; | 621 | ContentProviderUnion::ListEntriesFilterOrigin(std::optional<ContentProviderUnionSlot> origin, |
| 593 | for (const auto& c : caches) { | 622 | std::optional<TitleType> title_type, |
| 594 | c->IterateAllMetadata<RegisteredCacheEntry>( | 623 | std::optional<ContentRecordType> record_type, |
| 595 | out, | 624 | std::optional<u64> title_id) const { |
| 596 | [](const CNMT& c, const ContentRecord& r) { | 625 | std::vector<std::pair<ContentProviderUnionSlot, ContentProviderEntry>> out; |
| 597 | return RegisteredCacheEntry{c.GetTitleID(), r.type}; | 626 | |
| 598 | }, | 627 | for (const auto& provider : providers) { |
| 599 | [](const CNMT& c, const ContentRecord& r) { return true; }); | 628 | if (provider.second == nullptr) |
| 629 | continue; | ||
| 630 | |||
| 631 | if (origin.has_value() && *origin != provider.first) | ||
| 632 | continue; | ||
| 633 | |||
| 634 | const auto vec = provider.second->ListEntriesFilter(title_type, record_type, title_id); | ||
| 635 | std::transform(vec.begin(), vec.end(), std::back_inserter(out), | ||
| 636 | [&provider](const ContentProviderEntry& entry) { | ||
| 637 | return std::make_pair(provider.first, entry); | ||
| 638 | }); | ||
| 600 | } | 639 | } |
| 601 | 640 | ||
| 602 | std::sort(out.begin(), out.end()); | 641 | std::sort(out.begin(), out.end()); |
| @@ -604,25 +643,61 @@ std::vector<RegisteredCacheEntry> RegisteredCacheUnion::ListEntries() const { | |||
| 604 | return out; | 643 | return out; |
| 605 | } | 644 | } |
| 606 | 645 | ||
| 607 | std::vector<RegisteredCacheEntry> RegisteredCacheUnion::ListEntriesFilter( | 646 | ManualContentProvider::~ManualContentProvider() = default; |
| 647 | |||
| 648 | void ManualContentProvider::AddEntry(TitleType title_type, ContentRecordType content_type, | ||
| 649 | u64 title_id, VirtualFile file) { | ||
| 650 | entries.insert_or_assign({title_type, content_type, title_id}, file); | ||
| 651 | } | ||
| 652 | |||
| 653 | void ManualContentProvider::ClearAllEntries() { | ||
| 654 | entries.clear(); | ||
| 655 | } | ||
| 656 | |||
| 657 | void ManualContentProvider::Refresh() {} | ||
| 658 | |||
| 659 | bool ManualContentProvider::HasEntry(u64 title_id, ContentRecordType type) const { | ||
| 660 | return GetEntryRaw(title_id, type) != nullptr; | ||
| 661 | } | ||
| 662 | |||
| 663 | std::optional<u32> ManualContentProvider::GetEntryVersion(u64 title_id) const { | ||
| 664 | return std::nullopt; | ||
| 665 | } | ||
| 666 | |||
| 667 | VirtualFile ManualContentProvider::GetEntryUnparsed(u64 title_id, ContentRecordType type) const { | ||
| 668 | return GetEntryRaw(title_id, type); | ||
| 669 | } | ||
| 670 | |||
| 671 | VirtualFile ManualContentProvider::GetEntryRaw(u64 title_id, ContentRecordType type) const { | ||
| 672 | const auto iter = | ||
| 673 | std::find_if(entries.begin(), entries.end(), [title_id, type](const auto& entry) { | ||
| 674 | const auto [title_type, content_type, e_title_id] = entry.first; | ||
| 675 | return content_type == type && e_title_id == title_id; | ||
| 676 | }); | ||
| 677 | if (iter == entries.end()) | ||
| 678 | return nullptr; | ||
| 679 | return iter->second; | ||
| 680 | } | ||
| 681 | |||
| 682 | std::unique_ptr<NCA> ManualContentProvider::GetEntry(u64 title_id, ContentRecordType type) const { | ||
| 683 | const auto res = GetEntryRaw(title_id, type); | ||
| 684 | if (res == nullptr) | ||
| 685 | return nullptr; | ||
| 686 | return std::make_unique<NCA>(res, nullptr, 0, keys); | ||
| 687 | } | ||
| 688 | |||
| 689 | std::vector<ContentProviderEntry> ManualContentProvider::ListEntriesFilter( | ||
| 608 | std::optional<TitleType> title_type, std::optional<ContentRecordType> record_type, | 690 | std::optional<TitleType> title_type, std::optional<ContentRecordType> record_type, |
| 609 | std::optional<u64> title_id) const { | 691 | std::optional<u64> title_id) const { |
| 610 | std::vector<RegisteredCacheEntry> out; | 692 | std::vector<ContentProviderEntry> out; |
| 611 | for (const auto& c : caches) { | 693 | |
| 612 | c->IterateAllMetadata<RegisteredCacheEntry>( | 694 | for (const auto& entry : entries) { |
| 613 | out, | 695 | const auto [e_title_type, e_content_type, e_title_id] = entry.first; |
| 614 | [](const CNMT& c, const ContentRecord& r) { | 696 | if ((title_type == std::nullopt || e_title_type == *title_type) && |
| 615 | return RegisteredCacheEntry{c.GetTitleID(), r.type}; | 697 | (record_type == std::nullopt || e_content_type == *record_type) && |
| 616 | }, | 698 | (title_id == std::nullopt || e_title_id == *title_id)) { |
| 617 | [&title_type, &record_type, &title_id](const CNMT& c, const ContentRecord& r) { | 699 | out.emplace_back(ContentProviderEntry{e_title_id, e_content_type}); |
| 618 | if (title_type && *title_type != c.GetType()) | 700 | } |
| 619 | return false; | ||
| 620 | if (record_type && *record_type != r.type) | ||
| 621 | return false; | ||
| 622 | if (title_id && *title_id != c.GetTitleID()) | ||
| 623 | return false; | ||
| 624 | return true; | ||
| 625 | }); | ||
| 626 | } | 701 | } |
| 627 | 702 | ||
| 628 | std::sort(out.begin(), out.end()); | 703 | std::sort(out.begin(), out.end()); |
diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 3b77af4e0..ec9052653 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h | |||
| @@ -21,12 +21,13 @@ class NSP; | |||
| 21 | class XCI; | 21 | class XCI; |
| 22 | 22 | ||
| 23 | enum class ContentRecordType : u8; | 23 | enum class ContentRecordType : u8; |
| 24 | enum class NCAContentType : u8; | ||
| 24 | enum class TitleType : u8; | 25 | enum class TitleType : u8; |
| 25 | 26 | ||
| 26 | struct ContentRecord; | 27 | struct ContentRecord; |
| 27 | 28 | ||
| 28 | using NcaID = std::array<u8, 0x10>; | 29 | using NcaID = std::array<u8, 0x10>; |
| 29 | using RegisteredCacheParsingFunction = std::function<VirtualFile(const VirtualFile&, const NcaID&)>; | 30 | using ContentProviderParsingFunction = std::function<VirtualFile(const VirtualFile&, const NcaID&)>; |
| 30 | using VfsCopyFunction = std::function<bool(const VirtualFile&, const VirtualFile&, size_t)>; | 31 | using VfsCopyFunction = std::function<bool(const VirtualFile&, const VirtualFile&, size_t)>; |
| 31 | 32 | ||
| 32 | enum class InstallResult { | 33 | enum class InstallResult { |
| @@ -36,7 +37,7 @@ enum class InstallResult { | |||
| 36 | ErrorMetaFailed, | 37 | ErrorMetaFailed, |
| 37 | }; | 38 | }; |
| 38 | 39 | ||
| 39 | struct RegisteredCacheEntry { | 40 | struct ContentProviderEntry { |
| 40 | u64 title_id; | 41 | u64 title_id; |
| 41 | ContentRecordType type; | 42 | ContentRecordType type; |
| 42 | 43 | ||
| @@ -47,12 +48,46 @@ constexpr u64 GetUpdateTitleID(u64 base_title_id) { | |||
| 47 | return base_title_id | 0x800; | 48 | return base_title_id | 0x800; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 51 | ContentRecordType GetCRTypeFromNCAType(NCAContentType type); | ||
| 52 | |||
| 50 | // boost flat_map requires operator< for O(log(n)) lookups. | 53 | // boost flat_map requires operator< for O(log(n)) lookups. |
| 51 | bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); | 54 | bool operator<(const ContentProviderEntry& lhs, const ContentProviderEntry& rhs); |
| 52 | 55 | ||
| 53 | // std unique requires operator== to identify duplicates. | 56 | // std unique requires operator== to identify duplicates. |
| 54 | bool operator==(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); | 57 | bool operator==(const ContentProviderEntry& lhs, const ContentProviderEntry& rhs); |
| 55 | bool operator!=(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); | 58 | bool operator!=(const ContentProviderEntry& lhs, const ContentProviderEntry& rhs); |
| 59 | |||
| 60 | class ContentProvider { | ||
| 61 | public: | ||
| 62 | virtual ~ContentProvider(); | ||
| 63 | |||
| 64 | virtual void Refresh() = 0; | ||
| 65 | |||
| 66 | virtual bool HasEntry(u64 title_id, ContentRecordType type) const = 0; | ||
| 67 | virtual bool HasEntry(ContentProviderEntry entry) const; | ||
| 68 | |||
| 69 | virtual std::optional<u32> GetEntryVersion(u64 title_id) const = 0; | ||
| 70 | |||
| 71 | virtual VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const = 0; | ||
| 72 | virtual VirtualFile GetEntryUnparsed(ContentProviderEntry entry) const; | ||
| 73 | |||
| 74 | virtual VirtualFile GetEntryRaw(u64 title_id, ContentRecordType type) const = 0; | ||
| 75 | virtual VirtualFile GetEntryRaw(ContentProviderEntry entry) const; | ||
| 76 | |||
| 77 | virtual std::unique_ptr<NCA> GetEntry(u64 title_id, ContentRecordType type) const = 0; | ||
| 78 | virtual std::unique_ptr<NCA> GetEntry(ContentProviderEntry entry) const; | ||
| 79 | |||
| 80 | virtual std::vector<ContentProviderEntry> ListEntries() const; | ||
| 81 | |||
| 82 | // If a parameter is not std::nullopt, it will be filtered for from all entries. | ||
| 83 | virtual std::vector<ContentProviderEntry> ListEntriesFilter( | ||
| 84 | std::optional<TitleType> title_type = {}, std::optional<ContentRecordType> record_type = {}, | ||
| 85 | std::optional<u64> title_id = {}) const = 0; | ||
| 86 | |||
| 87 | protected: | ||
| 88 | // A single instance of KeyManager to be used by GetEntry() | ||
| 89 | Core::Crypto::KeyManager keys; | ||
| 90 | }; | ||
| 56 | 91 | ||
| 57 | /* | 92 | /* |
| 58 | * A class that catalogues NCAs in the registered directory structure. | 93 | * A class that catalogues NCAs in the registered directory structure. |
| @@ -67,39 +102,32 @@ bool operator!=(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs | |||
| 67 | * (This impl also supports substituting the nca dir for an nca file, as that's more convenient | 102 | * (This impl also supports substituting the nca dir for an nca file, as that's more convenient |
| 68 | * when 4GB splitting can be ignored.) | 103 | * when 4GB splitting can be ignored.) |
| 69 | */ | 104 | */ |
| 70 | class RegisteredCache { | 105 | class RegisteredCache : public ContentProvider { |
| 71 | friend class RegisteredCacheUnion; | ||
| 72 | |||
| 73 | public: | 106 | public: |
| 74 | // Parsing function defines the conversion from raw file to NCA. If there are other steps | 107 | // Parsing function defines the conversion from raw file to NCA. If there are other steps |
| 75 | // besides creating the NCA from the file (e.g. NAX0 on SD Card), that should go in a custom | 108 | // besides creating the NCA from the file (e.g. NAX0 on SD Card), that should go in a custom |
| 76 | // parsing function. | 109 | // parsing function. |
| 77 | explicit RegisteredCache(VirtualDir dir, | 110 | explicit RegisteredCache(VirtualDir dir, |
| 78 | RegisteredCacheParsingFunction parsing_function = | 111 | ContentProviderParsingFunction parsing_function = |
| 79 | [](const VirtualFile& file, const NcaID& id) { return file; }); | 112 | [](const VirtualFile& file, const NcaID& id) { return file; }); |
| 80 | ~RegisteredCache(); | 113 | ~RegisteredCache() override; |
| 81 | 114 | ||
| 82 | void Refresh(); | 115 | void Refresh() override; |
| 83 | 116 | ||
| 84 | bool HasEntry(u64 title_id, ContentRecordType type) const; | 117 | bool HasEntry(u64 title_id, ContentRecordType type) const override; |
| 85 | bool HasEntry(RegisteredCacheEntry entry) const; | ||
| 86 | 118 | ||
| 87 | std::optional<u32> GetEntryVersion(u64 title_id) const; | 119 | std::optional<u32> GetEntryVersion(u64 title_id) const override; |
| 88 | 120 | ||
| 89 | VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const; | 121 | VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const override; |
| 90 | VirtualFile GetEntryUnparsed(RegisteredCacheEntry entry) const; | ||
| 91 | 122 | ||
| 92 | VirtualFile GetEntryRaw(u64 title_id, ContentRecordType type) const; | 123 | VirtualFile GetEntryRaw(u64 title_id, ContentRecordType type) const override; |
| 93 | VirtualFile GetEntryRaw(RegisteredCacheEntry entry) const; | ||
| 94 | 124 | ||
| 95 | std::unique_ptr<NCA> GetEntry(u64 title_id, ContentRecordType type) const; | 125 | std::unique_ptr<NCA> GetEntry(u64 title_id, ContentRecordType type) const override; |
| 96 | std::unique_ptr<NCA> GetEntry(RegisteredCacheEntry entry) const; | ||
| 97 | 126 | ||
| 98 | std::vector<RegisteredCacheEntry> ListEntries() const; | ||
| 99 | // If a parameter is not std::nullopt, it will be filtered for from all entries. | 127 | // If a parameter is not std::nullopt, it will be filtered for from all entries. |
| 100 | std::vector<RegisteredCacheEntry> ListEntriesFilter( | 128 | std::vector<ContentProviderEntry> ListEntriesFilter( |
| 101 | std::optional<TitleType> title_type = {}, std::optional<ContentRecordType> record_type = {}, | 129 | std::optional<TitleType> title_type = {}, std::optional<ContentRecordType> record_type = {}, |
| 102 | std::optional<u64> title_id = {}) const; | 130 | std::optional<u64> title_id = {}) const override; |
| 103 | 131 | ||
| 104 | // Raw copies all the ncas from the xci/nsp to the csache. Does some quick checks to make sure | 132 | // Raw copies all the ncas from the xci/nsp to the csache. Does some quick checks to make sure |
| 105 | // there is a meta NCA and all of them are accessible. | 133 | // there is a meta NCA and all of them are accessible. |
| @@ -131,46 +159,70 @@ private: | |||
| 131 | bool RawInstallYuzuMeta(const CNMT& cnmt); | 159 | bool RawInstallYuzuMeta(const CNMT& cnmt); |
| 132 | 160 | ||
| 133 | VirtualDir dir; | 161 | VirtualDir dir; |
| 134 | RegisteredCacheParsingFunction parser; | 162 | ContentProviderParsingFunction parser; |
| 135 | Core::Crypto::KeyManager keys; | ||
| 136 | 163 | ||
| 137 | // maps tid -> NcaID of meta | 164 | // maps tid -> NcaID of meta |
| 138 | boost::container::flat_map<u64, NcaID> meta_id; | 165 | std::map<u64, NcaID> meta_id; |
| 139 | // maps tid -> meta | 166 | // maps tid -> meta |
| 140 | boost::container::flat_map<u64, CNMT> meta; | 167 | std::map<u64, CNMT> meta; |
| 141 | // maps tid -> meta for CNMT in yuzu_meta | 168 | // maps tid -> meta for CNMT in yuzu_meta |
| 142 | boost::container::flat_map<u64, CNMT> yuzu_meta; | 169 | std::map<u64, CNMT> yuzu_meta; |
| 143 | }; | 170 | }; |
| 144 | 171 | ||
| 145 | // Combines multiple RegisteredCaches (i.e. SysNAND, UserNAND, SDMC) into one interface. | 172 | enum class ContentProviderUnionSlot { |
| 146 | class RegisteredCacheUnion { | 173 | SysNAND, ///< System NAND |
| 147 | public: | 174 | UserNAND, ///< User NAND |
| 148 | explicit RegisteredCacheUnion(std::vector<RegisteredCache*> caches); | 175 | SDMC, ///< SD Card |
| 149 | 176 | FrontendManual, ///< Frontend-defined game list or similar | |
| 150 | void Refresh(); | 177 | }; |
| 151 | |||
| 152 | bool HasEntry(u64 title_id, ContentRecordType type) const; | ||
| 153 | bool HasEntry(RegisteredCacheEntry entry) const; | ||
| 154 | |||
| 155 | std::optional<u32> GetEntryVersion(u64 title_id) const; | ||
| 156 | |||
| 157 | VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const; | ||
| 158 | VirtualFile GetEntryUnparsed(RegisteredCacheEntry entry) const; | ||
| 159 | |||
| 160 | VirtualFile GetEntryRaw(u64 title_id, ContentRecordType type) const; | ||
| 161 | VirtualFile GetEntryRaw(RegisteredCacheEntry entry) const; | ||
| 162 | |||
| 163 | std::unique_ptr<NCA> GetEntry(u64 title_id, ContentRecordType type) const; | ||
| 164 | std::unique_ptr<NCA> GetEntry(RegisteredCacheEntry entry) const; | ||
| 165 | 178 | ||
| 166 | std::vector<RegisteredCacheEntry> ListEntries() const; | 179 | // Combines multiple ContentProvider(s) (i.e. SysNAND, UserNAND, SDMC) into one interface. |
| 167 | // If a parameter is not std::nullopt, it will be filtered for from all entries. | 180 | class ContentProviderUnion : public ContentProvider { |
| 168 | std::vector<RegisteredCacheEntry> ListEntriesFilter( | 181 | public: |
| 182 | ~ContentProviderUnion() override; | ||
| 183 | |||
| 184 | void SetSlot(ContentProviderUnionSlot slot, ContentProvider* provider); | ||
| 185 | void ClearSlot(ContentProviderUnionSlot slot); | ||
| 186 | |||
| 187 | void Refresh() override; | ||
| 188 | bool HasEntry(u64 title_id, ContentRecordType type) const override; | ||
| 189 | std::optional<u32> GetEntryVersion(u64 title_id) const override; | ||
| 190 | VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const override; | ||
| 191 | VirtualFile GetEntryRaw(u64 title_id, ContentRecordType type) const override; | ||
| 192 | std::unique_ptr<NCA> GetEntry(u64 title_id, ContentRecordType type) const override; | ||
| 193 | std::vector<ContentProviderEntry> ListEntriesFilter( | ||
| 194 | std::optional<TitleType> title_type, std::optional<ContentRecordType> record_type, | ||
| 195 | std::optional<u64> title_id) const override; | ||
| 196 | |||
| 197 | std::vector<std::pair<ContentProviderUnionSlot, ContentProviderEntry>> ListEntriesFilterOrigin( | ||
| 198 | std::optional<ContentProviderUnionSlot> origin = {}, | ||
| 169 | std::optional<TitleType> title_type = {}, std::optional<ContentRecordType> record_type = {}, | 199 | std::optional<TitleType> title_type = {}, std::optional<ContentRecordType> record_type = {}, |
| 170 | std::optional<u64> title_id = {}) const; | 200 | std::optional<u64> title_id = {}) const; |
| 171 | 201 | ||
| 172 | private: | 202 | private: |
| 173 | std::vector<RegisteredCache*> caches; | 203 | std::map<ContentProviderUnionSlot, ContentProvider*> providers; |
| 204 | }; | ||
| 205 | |||
| 206 | class ManualContentProvider : public ContentProvider { | ||
| 207 | public: | ||
| 208 | ~ManualContentProvider() override; | ||
| 209 | |||
| 210 | void AddEntry(TitleType title_type, ContentRecordType content_type, u64 title_id, | ||
| 211 | VirtualFile file); | ||
| 212 | void ClearAllEntries(); | ||
| 213 | |||
| 214 | void Refresh() override; | ||
| 215 | bool HasEntry(u64 title_id, ContentRecordType type) const override; | ||
| 216 | std::optional<u32> GetEntryVersion(u64 title_id) const override; | ||
| 217 | VirtualFile GetEntryUnparsed(u64 title_id, ContentRecordType type) const override; | ||
| 218 | VirtualFile GetEntryRaw(u64 title_id, ContentRecordType type) const override; | ||
| 219 | std::unique_ptr<NCA> GetEntry(u64 title_id, ContentRecordType type) const override; | ||
| 220 | std::vector<ContentProviderEntry> ListEntriesFilter( | ||
| 221 | std::optional<TitleType> title_type, std::optional<ContentRecordType> record_type, | ||
| 222 | std::optional<u64> title_id) const override; | ||
| 223 | |||
| 224 | private: | ||
| 225 | std::map<std::tuple<TitleType, ContentRecordType, u64>, VirtualFile> entries; | ||
| 174 | }; | 226 | }; |
| 175 | 227 | ||
| 176 | } // namespace FileSys | 228 | } // namespace FileSys |
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 | ||
| 146 | std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> NSP::GetNCAs() const { | 146 | std::map<u64, std::map<std::pair<TitleType, ContentRecordType>, std::shared_ptr<NCA>>> |
| 147 | NSP::GetNCAs() const { | ||
| 147 | return ncas; | 148 | return ncas; |
| 148 | } | 149 | } |
| 149 | 150 | ||
| 150 | std::shared_ptr<NCA> NSP::GetNCA(u64 title_id, ContentRecordType type) const { | 151 | std::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 | ||
| 165 | VirtualFile NSP::GetNCAFile(u64 title_id, ContentRecordType type) const { | 166 | VirtualFile 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/am/applets/web_browser.cpp b/src/core/hle/service/am/applets/web_browser.cpp index 9b0aa7f5f..7e17df98a 100644 --- a/src/core/hle/service/am/applets/web_browser.cpp +++ b/src/core/hle/service/am/applets/web_browser.cpp | |||
| @@ -86,7 +86,7 @@ static FileSys::VirtualFile GetManualRomFS() { | |||
| 86 | if (loader.ReadManualRomFS(out) == Loader::ResultStatus::Success) | 86 | if (loader.ReadManualRomFS(out) == Loader::ResultStatus::Success) |
| 87 | return out; | 87 | return out; |
| 88 | 88 | ||
| 89 | const auto& installed{FileSystem::GetUnionContents()}; | 89 | const auto& installed{Core::System::GetInstance().GetContentProvider()}; |
| 90 | const auto res = installed.GetEntry(Core::System::GetInstance().CurrentProcess()->GetTitleID(), | 90 | const auto res = installed.GetEntry(Core::System::GetInstance().CurrentProcess()->GetTitleID(), |
| 91 | FileSys::ContentRecordType::Manual); | 91 | FileSys::ContentRecordType::Manual); |
| 92 | 92 | ||
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 | ||
| 34 | static std::vector<u64> AccumulateAOCTitleIDs() { | 34 | static 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 4c2b371c3..1ebfeb4bf 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -391,11 +391,6 @@ void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id, | |||
| 391 | save_data_factory->WriteSaveDataSize(type, title_id, user_id, new_value); | 391 | save_data_factory->WriteSaveDataSize(type, title_id, user_id, new_value); |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | FileSys::RegisteredCacheUnion GetUnionContents() { | ||
| 395 | return FileSys::RegisteredCacheUnion{ | ||
| 396 | {GetSystemNANDContents(), GetUserNANDContents(), GetSDMCContents()}}; | ||
| 397 | } | ||
| 398 | |||
| 399 | FileSys::RegisteredCache* GetSystemNANDContents() { | 394 | FileSys::RegisteredCache* GetSystemNANDContents() { |
| 400 | LOG_TRACE(Service_FS, "Opening System NAND Contents"); | 395 | LOG_TRACE(Service_FS, "Opening System NAND Contents"); |
| 401 | 396 | ||
| @@ -460,6 +455,10 @@ void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) { | |||
| 460 | if (bis_factory == nullptr) { | 455 | if (bis_factory == nullptr) { |
| 461 | bis_factory = | 456 | bis_factory = |
| 462 | std::make_unique<FileSys::BISFactory>(nand_directory, load_directory, dump_directory); | 457 | std::make_unique<FileSys::BISFactory>(nand_directory, load_directory, dump_directory); |
| 458 | Core::System::GetInstance().RegisterContentProvider( | ||
| 459 | FileSys::ContentProviderUnionSlot::SysNAND, bis_factory->GetSystemNANDContents()); | ||
| 460 | Core::System::GetInstance().RegisterContentProvider( | ||
| 461 | FileSys::ContentProviderUnionSlot::UserNAND, bis_factory->GetUserNANDContents()); | ||
| 463 | } | 462 | } |
| 464 | 463 | ||
| 465 | if (save_data_factory == nullptr) { | 464 | if (save_data_factory == nullptr) { |
| @@ -468,6 +467,8 @@ void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) { | |||
| 468 | 467 | ||
| 469 | if (sdmc_factory == nullptr) { | 468 | if (sdmc_factory == nullptr) { |
| 470 | sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory)); | 469 | sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory)); |
| 470 | Core::System::GetInstance().RegisterContentProvider(FileSys::ContentProviderUnionSlot::SDMC, | ||
| 471 | sdmc_factory->GetSDMCContents()); | ||
| 471 | } | 472 | } |
| 472 | } | 473 | } |
| 473 | 474 | ||
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index 7cfc0d902..6481f237c 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, | |||
| 54 | void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id, | 54 | void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id, |
| 55 | FileSys::SaveDataSize new_value); | 55 | FileSys::SaveDataSize new_value); |
| 56 | 56 | ||
| 57 | FileSys::RegisteredCacheUnion GetUnionContents(); | ||
| 58 | |||
| 59 | FileSys::RegisteredCache* GetSystemNANDContents(); | 57 | FileSys::RegisteredCache* GetSystemNANDContents(); |
| 60 | FileSys::RegisteredCache* GetUserNANDContents(); | 58 | FileSys::RegisteredCache* GetUserNANDContents(); |
| 61 | FileSys::RegisteredCache* GetSDMCContents(); | 59 | FileSys::RegisteredCache* GetSDMCContents(); |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index ffe2eea8a..d7c47c197 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -21,6 +21,8 @@ | |||
| 21 | #include "core/memory.h" | 21 | #include "core/memory.h" |
| 22 | #include "core/settings.h" | 22 | #include "core/settings.h" |
| 23 | 23 | ||
| 24 | #pragma optimize("", off) | ||
| 25 | |||
| 24 | namespace Loader { | 26 | namespace Loader { |
| 25 | namespace { | 27 | namespace { |
| 26 | struct MODHeader { | 28 | struct MODHeader { |
| @@ -136,13 +138,13 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, | |||
| 136 | 138 | ||
| 137 | // Apply patches if necessary | 139 | // Apply patches if necessary |
| 138 | if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { | 140 | if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { |
| 139 | std::vector<u8> pi_header(sizeof(NSOHeader) + program_image.size()); | 141 | std::vector<u8> pi_header; |
| 140 | pi_header.insert(pi_header.begin(), reinterpret_cast<u8*>(&nso_header), | 142 | pi_header.insert(pi_header.begin(), reinterpret_cast<u8*>(&nso_header), |
| 141 | reinterpret_cast<u8*>(&nso_header) + sizeof(NSOHeader)); | 143 | reinterpret_cast<u8*>(&nso_header) + sizeof(NSOHeader)); |
| 142 | pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.begin(), | 144 | pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.begin(), |
| 143 | program_image.end()); | 145 | program_image.end()); |
| 144 | 146 | ||
| 145 | pi_header = pm->PatchNSO(pi_header); | 147 | pi_header = pm->PatchNSO(pi_header, file.GetName()); |
| 146 | 148 | ||
| 147 | std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.begin()); | 149 | std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.begin()); |
| 148 | } | 150 | } |