diff options
| author | 2023-09-11 23:50:36 -0400 | |
|---|---|---|
| committer | 2023-09-12 09:20:50 -0400 | |
| commit | f8985d1cc5f7378ab2bca2526a61d6aff778d36e (patch) | |
| tree | e7f492f817486b30549351951163df3ac0b8f20e /src/core | |
| parent | ci: fix msvc when used with LTO (#11459) (diff) | |
| download | yuzu-f8985d1cc5f7378ab2bca2526a61d6aff778d36e.tar.gz yuzu-f8985d1cc5f7378ab2bca2526a61d6aff778d36e.tar.xz yuzu-f8985d1cc5f7378ab2bca2526a61d6aff778d36e.zip | |
qt: add verification for installed contents
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/file_sys/nca_metadata.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/nca_metadata.h | 1 | ||||
| -rw-r--r-- | src/core/file_sys/registered_cache.cpp | 28 | ||||
| -rw-r--r-- | src/core/file_sys/registered_cache.h | 5 |
4 files changed, 37 insertions, 1 deletions
diff --git a/src/core/file_sys/nca_metadata.cpp b/src/core/file_sys/nca_metadata.cpp index 52c78020c..f4a774675 100644 --- a/src/core/file_sys/nca_metadata.cpp +++ b/src/core/file_sys/nca_metadata.cpp | |||
| @@ -45,6 +45,10 @@ CNMT::CNMT(CNMTHeader header_, OptionalHeader opt_header_, | |||
| 45 | 45 | ||
| 46 | CNMT::~CNMT() = default; | 46 | CNMT::~CNMT() = default; |
| 47 | 47 | ||
| 48 | const CNMTHeader& CNMT::GetHeader() const { | ||
| 49 | return header; | ||
| 50 | } | ||
| 51 | |||
| 48 | u64 CNMT::GetTitleID() const { | 52 | u64 CNMT::GetTitleID() const { |
| 49 | return header.title_id; | 53 | return header.title_id; |
| 50 | } | 54 | } |
diff --git a/src/core/file_sys/nca_metadata.h b/src/core/file_sys/nca_metadata.h index c59ece010..68e463b5f 100644 --- a/src/core/file_sys/nca_metadata.h +++ b/src/core/file_sys/nca_metadata.h | |||
| @@ -89,6 +89,7 @@ public: | |||
| 89 | std::vector<ContentRecord> content_records_, std::vector<MetaRecord> meta_records_); | 89 | std::vector<ContentRecord> content_records_, std::vector<MetaRecord> meta_records_); |
| 90 | ~CNMT(); | 90 | ~CNMT(); |
| 91 | 91 | ||
| 92 | const CNMTHeader& GetHeader() const; | ||
| 92 | u64 GetTitleID() const; | 93 | u64 GetTitleID() const; |
| 93 | u32 GetTitleVersion() const; | 94 | u32 GetTitleVersion() const; |
| 94 | TitleType GetType() const; | 95 | TitleType GetType() const; |
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index f70adab82..e33b00d89 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/fs/path_util.h" | 9 | #include "common/fs/path_util.h" |
| 10 | #include "common/hex_util.h" | 10 | #include "common/hex_util.h" |
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "common/scope_exit.h" | ||
| 12 | #include "core/crypto/key_manager.h" | 13 | #include "core/crypto/key_manager.h" |
| 13 | #include "core/file_sys/card_image.h" | 14 | #include "core/file_sys/card_image.h" |
| 14 | #include "core/file_sys/common_funcs.h" | 15 | #include "core/file_sys/common_funcs.h" |
| @@ -625,7 +626,7 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex | |||
| 625 | nca->GetTitleId() != title_id) { | 626 | nca->GetTitleId() != title_id) { |
| 626 | // Create fake cnmt for patch to multiprogram application | 627 | // Create fake cnmt for patch to multiprogram application |
| 627 | const auto sub_nca_result = | 628 | const auto sub_nca_result = |
| 628 | InstallEntry(*nca, TitleType::Update, overwrite_if_exists, copy); | 629 | InstallEntry(*nca, cnmt.GetHeader(), record, overwrite_if_exists, copy); |
| 629 | if (sub_nca_result != InstallResult::Success) { | 630 | if (sub_nca_result != InstallResult::Success) { |
| 630 | return sub_nca_result; | 631 | return sub_nca_result; |
| 631 | } | 632 | } |
| @@ -672,6 +673,31 @@ InstallResult RegisteredCache::InstallEntry(const NCA& nca, TitleType type, | |||
| 672 | return RawInstallNCA(nca, copy, overwrite_if_exists, c_rec.nca_id); | 673 | return RawInstallNCA(nca, copy, overwrite_if_exists, c_rec.nca_id); |
| 673 | } | 674 | } |
| 674 | 675 | ||
| 676 | InstallResult RegisteredCache::InstallEntry(const NCA& nca, const CNMTHeader& base_header, | ||
| 677 | const ContentRecord& base_record, | ||
| 678 | bool overwrite_if_exists, const VfsCopyFunction& copy) { | ||
| 679 | const CNMTHeader header{ | ||
| 680 | .title_id = nca.GetTitleId(), | ||
| 681 | .title_version = base_header.title_version, | ||
| 682 | .type = base_header.type, | ||
| 683 | .reserved = {}, | ||
| 684 | .table_offset = 0x10, | ||
| 685 | .number_content_entries = 1, | ||
| 686 | .number_meta_entries = 0, | ||
| 687 | .attributes = 0, | ||
| 688 | .reserved2 = {}, | ||
| 689 | .is_committed = 0, | ||
| 690 | .required_download_system_version = 0, | ||
| 691 | .reserved3 = {}, | ||
| 692 | }; | ||
| 693 | const OptionalHeader opt_header{0, 0}; | ||
| 694 | const CNMT new_cnmt(header, opt_header, {base_record}, {}); | ||
| 695 | if (!RawInstallYuzuMeta(new_cnmt)) { | ||
| 696 | return InstallResult::ErrorMetaFailed; | ||
| 697 | } | ||
| 698 | return RawInstallNCA(nca, copy, overwrite_if_exists, base_record.nca_id); | ||
| 699 | } | ||
| 700 | |||
| 675 | bool RegisteredCache::RemoveExistingEntry(u64 title_id) const { | 701 | bool RegisteredCache::RemoveExistingEntry(u64 title_id) const { |
| 676 | bool removed_data = false; | 702 | bool removed_data = false; |
| 677 | 703 | ||
diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index bd7f53eaf..64815a845 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h | |||
| @@ -24,6 +24,7 @@ enum class NCAContentType : u8; | |||
| 24 | enum class TitleType : u8; | 24 | enum class TitleType : u8; |
| 25 | 25 | ||
| 26 | struct ContentRecord; | 26 | struct ContentRecord; |
| 27 | struct CNMTHeader; | ||
| 27 | struct MetaRecord; | 28 | struct MetaRecord; |
| 28 | class RegisteredCache; | 29 | class RegisteredCache; |
| 29 | 30 | ||
| @@ -169,6 +170,10 @@ public: | |||
| 169 | InstallResult InstallEntry(const NCA& nca, TitleType type, bool overwrite_if_exists = false, | 170 | InstallResult InstallEntry(const NCA& nca, TitleType type, bool overwrite_if_exists = false, |
| 170 | const VfsCopyFunction& copy = &VfsRawCopy); | 171 | const VfsCopyFunction& copy = &VfsRawCopy); |
| 171 | 172 | ||
| 173 | InstallResult InstallEntry(const NCA& nca, const CNMTHeader& base_header, | ||
| 174 | const ContentRecord& base_record, bool overwrite_if_exists = false, | ||
| 175 | const VfsCopyFunction& copy = &VfsRawCopy); | ||
| 176 | |||
| 172 | // Removes an existing entry based on title id | 177 | // Removes an existing entry based on title id |
| 173 | bool RemoveExistingEntry(u64 title_id) const; | 178 | bool RemoveExistingEntry(u64 title_id) const; |
| 174 | 179 | ||