From 9acd336422a0d29d9ee80e93e5f323cfafa87faa Mon Sep 17 00:00:00 2001 From: David Marcec Date: Wed, 29 Apr 2020 22:13:56 +1000 Subject: [PATCH 1/2] am: Properly implement GetDisplayVersion Properly implement IApplicationFunctions::GetDisplayVersion --- src/core/hle/service/am/am.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 5695d2521b..276a3fc0c7 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1343,12 +1343,23 @@ void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) { } void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_AM, "(STUBBED) called"); + LOG_DEBUG(Service_AM, "called"); + + std::array version_string{}; + + FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID()}; + const auto res = pm.GetControlMetadata(); + if (res.first != nullptr) { + const auto& version = res.first->GetVersionString(); + std::copy(version.begin(), version.end(), version_string.begin()); + } else { + const u128 default_version = {1, 0}; + std::memcpy(version_string.data(), default_version.data(), sizeof(u128)); + } IPC::ResponseBuilder rb{ctx, 6}; rb.Push(RESULT_SUCCESS); - rb.Push(1); - rb.Push(0); + rb.PushRaw(version_string); } void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { From c49f51eaf18e76e17385f29215991cc113440ff0 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 2 May 2020 23:35:31 -0400 Subject: [PATCH 2/2] Update src/core/hle/service/am/am.cpp Co-authored-by: Mat M. --- src/core/hle/service/am/am.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 276a3fc0c7..9522f8c4b9 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1353,7 +1353,7 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) { const auto& version = res.first->GetVersionString(); std::copy(version.begin(), version.end(), version_string.begin()); } else { - const u128 default_version = {1, 0}; + constexpr u128 default_version = {1, 0}; std::memcpy(version_string.data(), default_version.data(), sizeof(u128)); }