From 37e033c560533b560a1f0ac92ae32bb92a4c282e Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 13 Sep 2026 23:11:25 +0000 Subject: [PATCH] 2026-09-13 23:11:25 Signed-off-by: lizzie --- src/common/uuid.cpp | 4 ++-- src/common/uuid.h | 2 +- .../hle/service/am/service/application_functions.cpp | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/common/uuid.cpp b/src/common/uuid.cpp index 51fe0abaa5..4b992c5df8 100644 --- a/src/common/uuid.cpp +++ b/src/common/uuid.cpp @@ -208,9 +208,9 @@ UUID UUID::MakeRandomRFC4122V4() { return uuid; } -UUID UUID::MakeRFC4122V5(std::span sha1) { +UUID UUID::MakeRFC4122V5(std::span sha1) { UUID uuid{}; - std::memcpy(&uuid.uuid, sha1.data(), sizeof(UUID)); + std::memcpy(&uuid.uuid, sha1.data(), sha1.size()); uuid.uuid[8] = 0x80 | (uuid.uuid[8] & 0x3F); uuid.uuid[6] = 0x50 | (uuid.uuid[6] & 0xF); return uuid; diff --git a/src/common/uuid.h b/src/common/uuid.h index 3aa3212dd7..465b5be58d 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h @@ -104,7 +104,7 @@ struct UUID { /// @returns A random UUID that is RFC 4122 Version 4 compliant. [[nodiscard]] static UUID MakeRandomRFC4122V4(); - [[nodiscard]] static UUID MakeRFC4122V5(std::span sha1); + [[nodiscard]] static UUID MakeRFC4122V5(std::span sha1); friend constexpr bool operator==(const UUID& lhs, const UUID& rhs) = default; }; diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index 215d204098..90d292c4a2 100644 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp @@ -347,21 +347,22 @@ Result IApplicationFunctions::NotifyRunning(Out out_became_running) { Result IApplicationFunctions::GetPseudoDeviceId(Out out_pseudo_device_id) { LOG_WARNING(Service_AM, "(stubbed)"); - R_UNLESS(out_pseudo_device_id, ResultUnknown); + R_UNLESS(out_pseudo_device_id != nullptr, ResultUnknown); // 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]; + R_UNLESS(res.first != nullptr, ResultUnknown); + std::array hash; 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_DigestFinal_ex(ctx, hash.data(), &hash_len); EVP_MD_CTX_free(ctx); - *out_pseudo_device_id = Common::UUID::MakeRFC4122V5(std::span{hash, std::size(hash)}); + *out_pseudo_device_id = Common::UUID::MakeRFC4122V5(std::span{hash.begin(), hash.begin() + 16}); R_SUCCEED(); }