diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-08-04 01:50:54 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-08-04 01:50:54 +0200 |
| commit | 8fe1e6efa2fe21abc9e8e1f83ecbc5a78389e37b (patch) | |
| tree | d09c3210519fda784e30d2754baf21dd4db8324d /src/core | |
| parent | ee197e622216e85753512ed79e9242442a312544 (diff) | |
[core/file_sys] implement IApplicationFunctions::GetPseudoDeviceId; common PatchManager::GetNACP for base|updates (#4159)
a bit of refactoring so there's less code duplication...
probably a good idea to make it a lambda anyways
maybe this is why QLauncher didn't have proper DLCs and updates?
either way "GetPseudoDeviceId" is now implemented (still stubbed) with a proper hash instead of just 0
Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4159
Reviewed-by: Maufeat <sahyno1996@gmail.com>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/file_sys/control_metadata.h | 33 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 10 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/application_functions.cpp | 49 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/library_applet_self_accessor.cpp | 14 |
5 files changed, 49 insertions, 60 deletions
diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index 7b90ba235d..670e8f7389 100644 --- a/src/core/file_sys/control_metadata.h +++ b/src/core/file_sys/control_metadata.h @@ -274,23 +274,22 @@ public: explicit NACP(VirtualFile file); ~NACP(); - const LanguageEntry& GetLanguageEntry() const; - std::string GetApplicationName() const; - std::string GetDeveloperName() const; - u64 GetTitleId() const; - u64 GetDLCBaseTitleId() const; - std::string GetVersionString() const; - u64 GetDefaultNormalSaveSize() const; - u64 GetDefaultJournalSaveSize() const; - u32 GetSupportedLanguages() const; - std::vector<std::string> GetApplicationNames() const; - std::vector<u8> GetRawBytes() const; - bool GetUserAccountSwitchLock() const; - u64 GetDeviceSaveDataSize() const; - u32 GetParentalControlFlag() const; - const std::array<u8, 0x20>& GetRatingAge() const; - -private: + [[nodiscard]] const LanguageEntry& GetLanguageEntry() const; + [[nodiscard]] std::string GetApplicationName() const; + [[nodiscard]] std::string GetDeveloperName() const; + [[nodiscard]] u64 GetTitleId() const; + [[nodiscard]] u64 GetDLCBaseTitleId() const; + [[nodiscard]] std::string GetVersionString() const; + [[nodiscard]] u64 GetDefaultNormalSaveSize() const; + [[nodiscard]] u64 GetDefaultJournalSaveSize() const; + [[nodiscard]] u32 GetSupportedLanguages() const; + [[nodiscard]] std::vector<std::string> GetApplicationNames() const; + [[nodiscard]] std::vector<u8> GetRawBytes() const; + [[nodiscard]] bool GetUserAccountSwitchLock() const; + [[nodiscard]] u64 GetDeviceSaveDataSize() const; + [[nodiscard]] u32 GetParentalControlFlag() const; + [[nodiscard]] const std::array<u8, 0x20>& GetRatingAge() const; + RawNACP raw{}; std::vector<LanguageEntry> language_entries; }; diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 80372ec94e..6ae4679054 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -1156,4 +1156,14 @@ PatchManager::Metadata PatchManager::ParseControlNCA(const NCA& nca) const { return {std::move(nacp), icon_file}; } + +[[nodiscard]] PatchManager::Metadata PatchManager::GetMetadataFromBaseOrUpdate(Core::System& system, u64 application_id) noexcept { + const FileSys::PatchManager pm{application_id, system.GetFileSystemController(), system.GetContentProvider()}; + auto metadata = pm.GetControlMetadata(); + if (metadata.first != nullptr) + return metadata; + const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(application_id), system.GetFileSystemController(), system.GetContentProvider()}; + return pm_update.GetControlMetadata(); +} + } // namespace FileSys diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index 755d924fd4..5d71dbcf20 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h @@ -105,6 +105,9 @@ public: // Version of GetControlMetadata that takes an arbitrary NCA [[nodiscard]] Metadata ParseControlNCA(const NCA& nca) const; + /// @brief Gets NACP metadata (accounting for any patches or updates) + [[nodiscard]] static PatchManager::Metadata GetMetadataFromBaseOrUpdate(Core::System& system, u64 application_id) noexcept; + private: [[nodiscard]] std::vector<VirtualFile> CollectPatches(const std::vector<VirtualDir>& patch_dirs, const std::string& build_id) const; diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index 787c88f52d..25a666233f 100644 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp @@ -4,6 +4,8 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include <openssl/evp.h> + #include "common/settings.h" #include "common/uuid.h" #include "core/file_sys/control_metadata.h" @@ -154,20 +156,7 @@ Result IApplicationFunctions::GetDesiredLanguage(Out<u64> out_language_code) { // Default to 0 (all languages supported) u32 supported_languages = 0; - const auto res = [this] { - const FileSys::PatchManager pm{m_applet->program_id, system.GetFileSystemController(), - system.GetContentProvider()}; - auto metadata = pm.GetControlMetadata(); - if (metadata.first != nullptr) { - return metadata; - } - - const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(m_applet->program_id), - system.GetFileSystemController(), - system.GetContentProvider()}; - return pm_update.GetControlMetadata(); - }(); - + const auto res = FileSys::PatchManager::GetMetadataFromBaseOrUpdate(system, m_applet->program_id); if (res.first != nullptr) { supported_languages = res.first->GetSupportedLanguages(); } @@ -205,20 +194,7 @@ Result IApplicationFunctions::SetTerminateResult(Result terminate_result) { Result IApplicationFunctions::GetDisplayVersion(Out<DisplayVersion> out_display_version) { LOG_DEBUG(Service_AM, "called"); - const auto res = [this] { - const FileSys::PatchManager pm{m_applet->program_id, system.GetFileSystemController(), - system.GetContentProvider()}; - auto metadata = pm.GetControlMetadata(); - if (metadata.first != nullptr) { - return metadata; - } - - const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(m_applet->program_id), - system.GetFileSystemController(), - system.GetContentProvider()}; - return pm_update.GetControlMetadata(); - }(); - + const auto res = FileSys::PatchManager::GetMetadataFromBaseOrUpdate(system, m_applet->program_id); if (res.first != nullptr) { const auto& version = res.first->GetVersionString(); std::memcpy(out_display_version->string.data(), version.data(), @@ -347,8 +323,21 @@ Result IApplicationFunctions::NotifyRunning(Out<bool> out_became_running) { } Result IApplicationFunctions::GetPseudoDeviceId(Out<Common::UUID> out_pseudo_device_id) { - LOG_WARNING(Service_AM, "(STUBBED) called"); - *out_pseudo_device_id = {}; + LOG_WARNING(Service_AM, "(stubbed)"); + + // This should be hashed with the device specific hash + // for now this will do + const auto res = FileSys::PatchManager::GetMetadataFromBaseOrUpdate(system, m_applet->program_id); + u8 hash[EVP_MAX_MD_SIZE]; + unsigned int hash_len = 0; + auto const seed = res.first->raw.seed_for_pseudo_device_id; + EVP_MD_CTX *ctx = EVP_MD_CTX_new(); + auto const algorithm = EVP_sha1(); + EVP_DigestInit_ex(ctx, algorithm, nullptr); + EVP_DigestUpdate(ctx, &seed, sizeof(seed)); + EVP_DigestFinal_ex(ctx, hash, &hash_len); + EVP_MD_CTX_free(ctx); + *out_pseudo_device_id = Common::UUID::MakeRFC4122V5(std::span<u8, 20>{hash, std::size(hash)}); R_SUCCEED(); } diff --git a/src/core/hle/service/am/service/library_applet_self_accessor.cpp b/src/core/hle/service/am/service/library_applet_self_accessor.cpp index b16bf87979..907be49204 100644 --- a/src/core/hle/service/am/service/library_applet_self_accessor.cpp +++ b/src/core/hle/service/am/service/library_applet_self_accessor.cpp @@ -252,19 +252,7 @@ Result ILibraryAppletSelfAccessor::GetMainAppletApplicationDesiredLanguage( // Default to 0 (all languages supported) u32 supported_languages = 0; - const auto res = [this, identity] { - const FileSys::PatchManager pm{identity.application_id, system.GetFileSystemController(), - system.GetContentProvider()}; - auto metadata = pm.GetControlMetadata(); - if (metadata.first != nullptr) { - return metadata; - } - - const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(identity.application_id), - system.GetFileSystemController(), - system.GetContentProvider()}; - return pm_update.GetControlMetadata(); - }(); + const auto res = FileSys::PatchManager::GetMetadataFromBaseOrUpdate(system, identity.application_id); if (res.first != nullptr) { supported_languages = res.first->GetSupportedLanguages(); |
