mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-16 13:22:41 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e7f9d3408 | |||
| 0014ae5f2b |
@@ -208,4 +208,12 @@ UUID UUID::MakeRandomRFC4122V4() {
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UUID UUID::MakeRFC4122V5(std::span<u8, 20> sha1) {
|
||||||
|
UUID uuid{};
|
||||||
|
std::memcpy(&uuid.uuid, sha1.data(), sizeof(UUID));
|
||||||
|
uuid.uuid[8] = 0x80 | (uuid.uuid[8] & 0x3F);
|
||||||
|
uuid.uuid[6] = 0x50 | (uuid.uuid[6] & 0xF);
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|||||||
+16
-20
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -5,6 +8,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
@@ -86,28 +90,20 @@ struct UUID {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @brief Creates a random UUID.
|
||||||
* Creates a random UUID.
|
/// @returns A random UUID.
|
||||||
*
|
[[nodiscard]] static UUID MakeRandom();
|
||||||
* @returns A random UUID.
|
|
||||||
*/
|
|
||||||
static UUID MakeRandom();
|
|
||||||
|
|
||||||
/**
|
/// @brief Creates a random UUID with a seed.
|
||||||
* Creates a random UUID with a seed.
|
/// @param seed A seed to initialize the Mersenne-Twister RNG
|
||||||
*
|
/// @returns A random UUID.
|
||||||
* @param seed A seed to initialize the Mersenne-Twister RNG
|
[[nodiscard]] static UUID MakeRandomWithSeed(u32 seed);
|
||||||
*
|
|
||||||
* @returns A random UUID.
|
|
||||||
*/
|
|
||||||
static UUID MakeRandomWithSeed(u32 seed);
|
|
||||||
|
|
||||||
/**
|
/// @brief Creates a random UUID. The generated UUID is RFC 4122 Version 4 compliant.
|
||||||
* Creates a random UUID. The generated UUID is RFC 4122 Version 4 compliant.
|
/// @returns A random UUID that is RFC 4122 Version 4 compliant.
|
||||||
*
|
[[nodiscard]] static UUID MakeRandomRFC4122V4();
|
||||||
* @returns A random UUID that is RFC 4122 Version 4 compliant.
|
|
||||||
*/
|
[[nodiscard]] static UUID MakeRFC4122V5(std::span<u8, 20> sha1);
|
||||||
static UUID MakeRandomRFC4122V4();
|
|
||||||
|
|
||||||
friend constexpr bool operator==(const UUID& lhs, const UUID& rhs) = default;
|
friend constexpr bool operator==(const UUID& lhs, const UUID& rhs) = default;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -274,23 +274,22 @@ public:
|
|||||||
explicit NACP(VirtualFile file);
|
explicit NACP(VirtualFile file);
|
||||||
~NACP();
|
~NACP();
|
||||||
|
|
||||||
const LanguageEntry& GetLanguageEntry() const;
|
[[nodiscard]] const LanguageEntry& GetLanguageEntry() const;
|
||||||
std::string GetApplicationName() const;
|
[[nodiscard]] std::string GetApplicationName() const;
|
||||||
std::string GetDeveloperName() const;
|
[[nodiscard]] std::string GetDeveloperName() const;
|
||||||
u64 GetTitleId() const;
|
[[nodiscard]] u64 GetTitleId() const;
|
||||||
u64 GetDLCBaseTitleId() const;
|
[[nodiscard]] u64 GetDLCBaseTitleId() const;
|
||||||
std::string GetVersionString() const;
|
[[nodiscard]] std::string GetVersionString() const;
|
||||||
u64 GetDefaultNormalSaveSize() const;
|
[[nodiscard]] u64 GetDefaultNormalSaveSize() const;
|
||||||
u64 GetDefaultJournalSaveSize() const;
|
[[nodiscard]] u64 GetDefaultJournalSaveSize() const;
|
||||||
u32 GetSupportedLanguages() const;
|
[[nodiscard]] u32 GetSupportedLanguages() const;
|
||||||
std::vector<std::string> GetApplicationNames() const;
|
[[nodiscard]] std::vector<std::string> GetApplicationNames() const;
|
||||||
std::vector<u8> GetRawBytes() const;
|
[[nodiscard]] std::vector<u8> GetRawBytes() const;
|
||||||
bool GetUserAccountSwitchLock() const;
|
[[nodiscard]] bool GetUserAccountSwitchLock() const;
|
||||||
u64 GetDeviceSaveDataSize() const;
|
[[nodiscard]] u64 GetDeviceSaveDataSize() const;
|
||||||
u32 GetParentalControlFlag() const;
|
[[nodiscard]] u32 GetParentalControlFlag() const;
|
||||||
const std::array<u8, 0x20>& GetRatingAge() const;
|
[[nodiscard]] const std::array<u8, 0x20>& GetRatingAge() const;
|
||||||
|
|
||||||
private:
|
|
||||||
RawNACP raw{};
|
RawNACP raw{};
|
||||||
std::vector<LanguageEntry> language_entries;
|
std::vector<LanguageEntry> language_entries;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1156,4 +1156,14 @@ PatchManager::Metadata PatchManager::ParseControlNCA(const NCA& nca) const {
|
|||||||
|
|
||||||
return {std::move(nacp), icon_file};
|
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
|
} // namespace FileSys
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ public:
|
|||||||
// Version of GetControlMetadata that takes an arbitrary NCA
|
// Version of GetControlMetadata that takes an arbitrary NCA
|
||||||
[[nodiscard]] Metadata ParseControlNCA(const NCA& nca) const;
|
[[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:
|
private:
|
||||||
[[nodiscard]] std::vector<VirtualFile> CollectPatches(const std::vector<VirtualDir>& patch_dirs,
|
[[nodiscard]] std::vector<VirtualFile> CollectPatches(const std::vector<VirtualDir>& patch_dirs,
|
||||||
const std::string& build_id) const;
|
const std::string& build_id) const;
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "common/uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/file_sys/control_metadata.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)
|
// Default to 0 (all languages supported)
|
||||||
u32 supported_languages = 0;
|
u32 supported_languages = 0;
|
||||||
|
|
||||||
const auto res = [this] {
|
const auto res = FileSys::PatchManager::GetMetadataFromBaseOrUpdate(system, m_applet->program_id);
|
||||||
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();
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (res.first != nullptr) {
|
if (res.first != nullptr) {
|
||||||
supported_languages = res.first->GetSupportedLanguages();
|
supported_languages = res.first->GetSupportedLanguages();
|
||||||
}
|
}
|
||||||
@@ -205,20 +194,7 @@ Result IApplicationFunctions::SetTerminateResult(Result terminate_result) {
|
|||||||
Result IApplicationFunctions::GetDisplayVersion(Out<DisplayVersion> out_display_version) {
|
Result IApplicationFunctions::GetDisplayVersion(Out<DisplayVersion> out_display_version) {
|
||||||
LOG_DEBUG(Service_AM, "called");
|
LOG_DEBUG(Service_AM, "called");
|
||||||
|
|
||||||
const auto res = [this] {
|
const auto res = FileSys::PatchManager::GetMetadataFromBaseOrUpdate(system, m_applet->program_id);
|
||||||
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();
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (res.first != nullptr) {
|
if (res.first != nullptr) {
|
||||||
const auto& version = res.first->GetVersionString();
|
const auto& version = res.first->GetVersionString();
|
||||||
std::memcpy(out_display_version->string.data(), version.data(),
|
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) {
|
Result IApplicationFunctions::GetPseudoDeviceId(Out<Common::UUID> out_pseudo_device_id) {
|
||||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
LOG_WARNING(Service_AM, "(stubbed)");
|
||||||
*out_pseudo_device_id = {};
|
|
||||||
|
// 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();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -252,19 +252,7 @@ Result ILibraryAppletSelfAccessor::GetMainAppletApplicationDesiredLanguage(
|
|||||||
// Default to 0 (all languages supported)
|
// Default to 0 (all languages supported)
|
||||||
u32 supported_languages = 0;
|
u32 supported_languages = 0;
|
||||||
|
|
||||||
const auto res = [this, identity] {
|
const auto res = FileSys::PatchManager::GetMetadataFromBaseOrUpdate(system, identity.application_id);
|
||||||
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();
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (res.first != nullptr) {
|
if (res.first != nullptr) {
|
||||||
supported_languages = res.first->GetSupportedLanguages();
|
supported_languages = res.first->GetSupportedLanguages();
|
||||||
|
|||||||
Reference in New Issue
Block a user