diff options
Diffstat (limited to 'src/frontend_common')
| -rw-r--r-- | src/frontend_common/content_manager.h | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/src/frontend_common/content_manager.h b/src/frontend_common/content_manager.h index 0b0fee73e..f3efe3465 100644 --- a/src/frontend_common/content_manager.h +++ b/src/frontend_common/content_manager.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/file_sys/common_funcs.h" | 10 | #include "core/file_sys/common_funcs.h" |
| 11 | #include "core/file_sys/content_archive.h" | 11 | #include "core/file_sys/content_archive.h" |
| 12 | #include "core/file_sys/mode.h" | 12 | #include "core/file_sys/fs_filesystem.h" |
| 13 | #include "core/file_sys/nca_metadata.h" | 13 | #include "core/file_sys/nca_metadata.h" |
| 14 | #include "core/file_sys/patch_manager.h" | 14 | #include "core/file_sys/patch_manager.h" |
| 15 | #include "core/file_sys/registered_cache.h" | 15 | #include "core/file_sys/registered_cache.h" |
| @@ -47,14 +47,14 @@ inline bool RemoveDLC(const Service::FileSystem::FileSystemController& fs_contro | |||
| 47 | 47 | ||
| 48 | /** | 48 | /** |
| 49 | * \brief Removes all DLC for a game | 49 | * \brief Removes all DLC for a game |
| 50 | * \param system Raw pointer to the system instance | 50 | * \param system Reference to the system instance |
| 51 | * \param program_id Program ID for the game that will have all of its DLC removed | 51 | * \param program_id Program ID for the game that will have all of its DLC removed |
| 52 | * \return Number of DLC removed | 52 | * \return Number of DLC removed |
| 53 | */ | 53 | */ |
| 54 | inline size_t RemoveAllDLC(Core::System* system, const u64 program_id) { | 54 | inline size_t RemoveAllDLC(Core::System& system, const u64 program_id) { |
| 55 | size_t count{}; | 55 | size_t count{}; |
| 56 | const auto& fs_controller = system->GetFileSystemController(); | 56 | const auto& fs_controller = system.GetFileSystemController(); |
| 57 | const auto dlc_entries = system->GetContentProvider().ListEntriesFilter( | 57 | const auto dlc_entries = system.GetContentProvider().ListEntriesFilter( |
| 58 | FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); | 58 | FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); |
| 59 | std::vector<u64> program_dlc_entries; | 59 | std::vector<u64> program_dlc_entries; |
| 60 | 60 | ||
| @@ -124,15 +124,15 @@ inline bool RemoveMod(const Service::FileSystem::FileSystemController& fs_contro | |||
| 124 | 124 | ||
| 125 | /** | 125 | /** |
| 126 | * \brief Installs an NSP | 126 | * \brief Installs an NSP |
| 127 | * \param system Raw pointer to the system instance | 127 | * \param system Reference to the system instance |
| 128 | * \param vfs Raw pointer to the VfsFilesystem instance in Core::System | 128 | * \param vfs Reference to the VfsFilesystem instance in Core::System |
| 129 | * \param filename Path to the NSP file | 129 | * \param filename Path to the NSP file |
| 130 | * \param callback Callback to report the progress of the installation. The first size_t | 130 | * \param callback Callback to report the progress of the installation. The first size_t |
| 131 | * parameter is the total size of the virtual file and the second is the current progress. If you | 131 | * parameter is the total size of the virtual file and the second is the current progress. If you |
| 132 | * return true to the callback, it will cancel the installation as soon as possible. | 132 | * return true to the callback, it will cancel the installation as soon as possible. |
| 133 | * \return [InstallResult] representing how the installation finished | 133 | * \return [InstallResult] representing how the installation finished |
| 134 | */ | 134 | */ |
| 135 | inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vfs, | 135 | inline InstallResult InstallNSP(Core::System& system, FileSys::VfsFilesystem& vfs, |
| 136 | const std::string& filename, | 136 | const std::string& filename, |
| 137 | const std::function<bool(size_t, size_t)>& callback) { | 137 | const std::function<bool(size_t, size_t)>& callback) { |
| 138 | const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest, | 138 | const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest, |
| @@ -159,7 +159,7 @@ inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vf | |||
| 159 | }; | 159 | }; |
| 160 | 160 | ||
| 161 | std::shared_ptr<FileSys::NSP> nsp; | 161 | std::shared_ptr<FileSys::NSP> nsp; |
| 162 | FileSys::VirtualFile file = vfs->OpenFile(filename, FileSys::Mode::Read); | 162 | FileSys::VirtualFile file = vfs.OpenFile(filename, FileSys::OpenMode::Read); |
| 163 | if (boost::to_lower_copy(file->GetName()).ends_with(std::string("nsp"))) { | 163 | if (boost::to_lower_copy(file->GetName()).ends_with(std::string("nsp"))) { |
| 164 | nsp = std::make_shared<FileSys::NSP>(file); | 164 | nsp = std::make_shared<FileSys::NSP>(file); |
| 165 | if (nsp->IsExtractedType()) { | 165 | if (nsp->IsExtractedType()) { |
| @@ -173,7 +173,7 @@ inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vf | |||
| 173 | return InstallResult::Failure; | 173 | return InstallResult::Failure; |
| 174 | } | 174 | } |
| 175 | const auto res = | 175 | const auto res = |
| 176 | system->GetFileSystemController().GetUserNANDContents()->InstallEntry(*nsp, true, copy); | 176 | system.GetFileSystemController().GetUserNANDContents()->InstallEntry(*nsp, true, copy); |
| 177 | switch (res) { | 177 | switch (res) { |
| 178 | case FileSys::InstallResult::Success: | 178 | case FileSys::InstallResult::Success: |
| 179 | return InstallResult::Success; | 179 | return InstallResult::Success; |
| @@ -188,17 +188,17 @@ inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vf | |||
| 188 | 188 | ||
| 189 | /** | 189 | /** |
| 190 | * \brief Installs an NCA | 190 | * \brief Installs an NCA |
| 191 | * \param vfs Raw pointer to the VfsFilesystem instance in Core::System | 191 | * \param vfs Reference to the VfsFilesystem instance in Core::System |
| 192 | * \param filename Path to the NCA file | 192 | * \param filename Path to the NCA file |
| 193 | * \param registered_cache Raw pointer to the registered cache that the NCA will be installed to | 193 | * \param registered_cache Reference to the registered cache that the NCA will be installed to |
| 194 | * \param title_type Type of NCA package to install | 194 | * \param title_type Type of NCA package to install |
| 195 | * \param callback Callback to report the progress of the installation. The first size_t | 195 | * \param callback Callback to report the progress of the installation. The first size_t |
| 196 | * parameter is the total size of the virtual file and the second is the current progress. If you | 196 | * parameter is the total size of the virtual file and the second is the current progress. If you |
| 197 | * return true to the callback, it will cancel the installation as soon as possible. | 197 | * return true to the callback, it will cancel the installation as soon as possible. |
| 198 | * \return [InstallResult] representing how the installation finished | 198 | * \return [InstallResult] representing how the installation finished |
| 199 | */ | 199 | */ |
| 200 | inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string& filename, | 200 | inline InstallResult InstallNCA(FileSys::VfsFilesystem& vfs, const std::string& filename, |
| 201 | FileSys::RegisteredCache* registered_cache, | 201 | FileSys::RegisteredCache& registered_cache, |
| 202 | const FileSys::TitleType title_type, | 202 | const FileSys::TitleType title_type, |
| 203 | const std::function<bool(size_t, size_t)>& callback) { | 203 | const std::function<bool(size_t, size_t)>& callback) { |
| 204 | const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest, | 204 | const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest, |
| @@ -224,7 +224,8 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string& | |||
| 224 | return true; | 224 | return true; |
| 225 | }; | 225 | }; |
| 226 | 226 | ||
| 227 | const auto nca = std::make_shared<FileSys::NCA>(vfs->OpenFile(filename, FileSys::Mode::Read)); | 227 | const auto nca = |
| 228 | std::make_shared<FileSys::NCA>(vfs.OpenFile(filename, FileSys::OpenMode::Read)); | ||
| 228 | const auto id = nca->GetStatus(); | 229 | const auto id = nca->GetStatus(); |
| 229 | 230 | ||
| 230 | // Game updates necessary are missing base RomFS | 231 | // Game updates necessary are missing base RomFS |
| @@ -233,7 +234,7 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string& | |||
| 233 | return InstallResult::Failure; | 234 | return InstallResult::Failure; |
| 234 | } | 235 | } |
| 235 | 236 | ||
| 236 | const auto res = registered_cache->InstallEntry(*nca, title_type, true, copy); | 237 | const auto res = registered_cache.InstallEntry(*nca, title_type, true, copy); |
| 237 | if (res == FileSys::InstallResult::Success) { | 238 | if (res == FileSys::InstallResult::Success) { |
| 238 | return InstallResult::Success; | 239 | return InstallResult::Success; |
| 239 | } else if (res == FileSys::InstallResult::OverwriteExisting) { | 240 | } else if (res == FileSys::InstallResult::OverwriteExisting) { |
| @@ -245,19 +246,19 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string& | |||
| 245 | 246 | ||
| 246 | /** | 247 | /** |
| 247 | * \brief Verifies the installed contents for a given ManualContentProvider | 248 | * \brief Verifies the installed contents for a given ManualContentProvider |
| 248 | * \param system Raw pointer to the system instance | 249 | * \param system Reference to the system instance |
| 249 | * \param provider Raw pointer to the content provider that's tracking indexed games | 250 | * \param provider Reference to the content provider that's tracking indexed games |
| 250 | * \param callback Callback to report the progress of the installation. The first size_t | 251 | * \param callback Callback to report the progress of the installation. The first size_t |
| 251 | * parameter is the total size of the installed contents and the second is the current progress. If | 252 | * parameter is the total size of the installed contents and the second is the current progress. If |
| 252 | * you return true to the callback, it will cancel the installation as soon as possible. | 253 | * you return true to the callback, it will cancel the installation as soon as possible. |
| 253 | * \return A list of entries that failed to install. Returns an empty vector if successful. | 254 | * \return A list of entries that failed to install. Returns an empty vector if successful. |
| 254 | */ | 255 | */ |
| 255 | inline std::vector<std::string> VerifyInstalledContents( | 256 | inline std::vector<std::string> VerifyInstalledContents( |
| 256 | Core::System* system, FileSys::ManualContentProvider* provider, | 257 | Core::System& system, FileSys::ManualContentProvider& provider, |
| 257 | const std::function<bool(size_t, size_t)>& callback) { | 258 | const std::function<bool(size_t, size_t)>& callback) { |
| 258 | // Get content registries. | 259 | // Get content registries. |
| 259 | auto bis_contents = system->GetFileSystemController().GetSystemNANDContents(); | 260 | auto bis_contents = system.GetFileSystemController().GetSystemNANDContents(); |
| 260 | auto user_contents = system->GetFileSystemController().GetUserNANDContents(); | 261 | auto user_contents = system.GetFileSystemController().GetUserNANDContents(); |
| 261 | 262 | ||
| 262 | std::vector<FileSys::RegisteredCache*> content_providers; | 263 | std::vector<FileSys::RegisteredCache*> content_providers; |
| 263 | if (bis_contents) { | 264 | if (bis_contents) { |
| @@ -309,11 +310,11 @@ inline std::vector<std::string> VerifyInstalledContents( | |||
| 309 | const auto title_id = nca.GetTitleId(); | 310 | const auto title_id = nca.GetTitleId(); |
| 310 | std::string title_name = "unknown"; | 311 | std::string title_name = "unknown"; |
| 311 | 312 | ||
| 312 | const auto control = provider->GetEntry(FileSys::GetBaseTitleID(title_id), | 313 | const auto control = provider.GetEntry(FileSys::GetBaseTitleID(title_id), |
| 313 | FileSys::ContentRecordType::Control); | 314 | FileSys::ContentRecordType::Control); |
| 314 | if (control && control->GetStatus() == Loader::ResultStatus::Success) { | 315 | if (control && control->GetStatus() == Loader::ResultStatus::Success) { |
| 315 | const FileSys::PatchManager pm{title_id, system->GetFileSystemController(), | 316 | const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), |
| 316 | *provider}; | 317 | provider}; |
| 317 | const auto [nacp, logo] = pm.ParseControlNCA(*control); | 318 | const auto [nacp, logo] = pm.ParseControlNCA(*control); |
| 318 | if (nacp) { | 319 | if (nacp) { |
| 319 | title_name = nacp->GetApplicationName(); | 320 | title_name = nacp->GetApplicationName(); |
| @@ -335,7 +336,7 @@ inline std::vector<std::string> VerifyInstalledContents( | |||
| 335 | 336 | ||
| 336 | /** | 337 | /** |
| 337 | * \brief Verifies the contents of a given game | 338 | * \brief Verifies the contents of a given game |
| 338 | * \param system Raw pointer to the system instance | 339 | * \param system Reference to the system instance |
| 339 | * \param game_path Patch to the game file | 340 | * \param game_path Patch to the game file |
| 340 | * \param callback Callback to report the progress of the installation. The first size_t | 341 | * \param callback Callback to report the progress of the installation. The first size_t |
| 341 | * parameter is the total size of the installed contents and the second is the current progress. If | 342 | * parameter is the total size of the installed contents and the second is the current progress. If |
| @@ -343,10 +344,10 @@ inline std::vector<std::string> VerifyInstalledContents( | |||
| 343 | * \return GameVerificationResult representing how the verification process finished | 344 | * \return GameVerificationResult representing how the verification process finished |
| 344 | */ | 345 | */ |
| 345 | inline GameVerificationResult VerifyGameContents( | 346 | inline GameVerificationResult VerifyGameContents( |
| 346 | Core::System* system, const std::string& game_path, | 347 | Core::System& system, const std::string& game_path, |
| 347 | const std::function<bool(size_t, size_t)>& callback) { | 348 | const std::function<bool(size_t, size_t)>& callback) { |
| 348 | const auto loader = Loader::GetLoader( | 349 | const auto loader = Loader::GetLoader( |
| 349 | *system, system->GetFilesystem()->OpenFile(game_path, FileSys::Mode::Read)); | 350 | system, system.GetFilesystem()->OpenFile(game_path, FileSys::OpenMode::Read)); |
| 350 | if (loader == nullptr) { | 351 | if (loader == nullptr) { |
| 351 | return GameVerificationResult::NotImplemented; | 352 | return GameVerificationResult::NotImplemented; |
| 352 | } | 353 | } |
| @@ -368,4 +369,11 @@ inline GameVerificationResult VerifyGameContents( | |||
| 368 | return GameVerificationResult::Success; | 369 | return GameVerificationResult::Success; |
| 369 | } | 370 | } |
| 370 | 371 | ||
| 372 | /** | ||
| 373 | * Checks if the keys required for decrypting firmware and games are available | ||
| 374 | */ | ||
| 375 | inline bool AreKeysPresent() { | ||
| 376 | return !Core::Crypto::KeyManager::Instance().BaseDeriveNecessary(); | ||
| 377 | } | ||
| 378 | |||
| 371 | } // namespace ContentManager | 379 | } // namespace ContentManager |