From ed82bb968a2ec785485345aa202143df57c0f8fe Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 10 Mar 2019 16:51:42 -0400 Subject: [PATCH 1/5] set_sys: Implement GetFirmwareVersion(2) for libnx hosversion Uses the synthesized system archive 9 (SystemVersion) and reports v5.1.0-0.0 --- src/core/CMakeLists.txt | 2 + .../system_archive/system_archive.cpp | 3 +- .../system_archive/system_version.cpp | 48 ++++++++++++++ .../file_sys/system_archive/system_version.h | 13 ++++ src/core/hle/service/set/set_sys.cpp | 63 ++++++++++++++++++- src/core/hle/service/set/set_sys.h | 2 + 6 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 src/core/file_sys/system_archive/system_version.cpp create mode 100644 src/core/file_sys/system_archive/system_version.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8ccb2d5f00..3f855dcb71 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -68,6 +68,8 @@ add_library(core STATIC file_sys/system_archive/ng_word.h file_sys/system_archive/system_archive.cpp file_sys/system_archive/system_archive.h + file_sys/system_archive/system_version.cpp + file_sys/system_archive/system_version.h file_sys/vfs.cpp file_sys/vfs.h file_sys/vfs_concat.cpp diff --git a/src/core/file_sys/system_archive/system_archive.cpp b/src/core/file_sys/system_archive/system_archive.cpp index e3e79f40a1..c9722ed77e 100644 --- a/src/core/file_sys/system_archive/system_archive.cpp +++ b/src/core/file_sys/system_archive/system_archive.cpp @@ -6,6 +6,7 @@ #include "core/file_sys/romfs.h" #include "core/file_sys/system_archive/ng_word.h" #include "core/file_sys/system_archive/system_archive.h" +#include "core/file_sys/system_archive/system_version.h" namespace FileSys::SystemArchive { @@ -30,7 +31,7 @@ constexpr std::array SYSTEM_ARCHI {0x0100000000000806, "NgWord", &NgWord1}, {0x0100000000000807, "SsidList", nullptr}, {0x0100000000000808, "Dictionary", nullptr}, - {0x0100000000000809, "SystemVersion", nullptr}, + {0x0100000000000809, "SystemVersion", &SystemVersion}, {0x010000000000080A, "AvatarImage", nullptr}, {0x010000000000080B, "LocalNews", nullptr}, {0x010000000000080C, "Eula", nullptr}, diff --git a/src/core/file_sys/system_archive/system_version.cpp b/src/core/file_sys/system_archive/system_version.cpp new file mode 100644 index 0000000000..3fc5f95866 --- /dev/null +++ b/src/core/file_sys/system_archive/system_version.cpp @@ -0,0 +1,48 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/file_sys/system_archive/system_version.h" +#include "core/file_sys/vfs_vector.h" + +namespace FileSys::SystemArchive { + +namespace SystemVersionData { + +// This section should reflect the best system version to describe yuzu's HLE api. +// TODO(DarkLordZach): Update when HLE gets better. + +constexpr u8 VERSION_MAJOR = 5; +constexpr u8 VERSION_MINOR = 1; +constexpr u8 VERSION_MICRO = 0; + +constexpr u8 REVISION_MAJOR = 0; +constexpr u8 REVISION_MINOR = 0; + +constexpr char PLATFORM_STRING[] = "YUZU"; +constexpr char VERSION_HASH[] = ""; +constexpr char DISPLAY_VERSION[] = "5.1.0"; +constexpr char DISPLAY_TITLE[] = "YuzuEmulated Firmware for NX 5.1.0-0.0"; + +} // namespace SystemVersionData + +VirtualDir SystemVersion() { + VirtualFile file = std::make_shared(std::vector(0x100), "file"); + file->WriteObject(SystemVersionData::VERSION_MAJOR, 0); + file->WriteObject(SystemVersionData::VERSION_MINOR, 1); + file->WriteObject(SystemVersionData::VERSION_MICRO, 2); + file->WriteObject(SystemVersionData::REVISION_MAJOR, 4); + file->WriteObject(SystemVersionData::REVISION_MINOR, 5); + file->WriteArray(SystemVersionData::PLATFORM_STRING, + std::min(sizeof(SystemVersionData::PLATFORM_STRING), 0x20ull), 0x8); + file->WriteArray(SystemVersionData::VERSION_HASH, + std::min(sizeof(SystemVersionData::VERSION_HASH), 0x40ull), 0x28); + file->WriteArray(SystemVersionData::DISPLAY_VERSION, + std::min(sizeof(SystemVersionData::DISPLAY_VERSION), 0x18ull), 0x68); + file->WriteArray(SystemVersionData::DISPLAY_TITLE, + std::min(sizeof(SystemVersionData::DISPLAY_TITLE), 0x80ull), 0x80); + return std::make_shared(std::vector{file}, + std::vector{}, "data"); +} + +} // namespace FileSys::SystemArchive diff --git a/src/core/file_sys/system_archive/system_version.h b/src/core/file_sys/system_archive/system_version.h new file mode 100644 index 0000000000..9fb794b36d --- /dev/null +++ b/src/core/file_sys/system_archive/system_version.h @@ -0,0 +1,13 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/file_sys/vfs_types.h" + +namespace FileSys::SystemArchive { + +VirtualDir SystemVersion(); + +} // namespace FileSys::SystemArchive diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index c9b4da5b08..ddab0e36fa 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp @@ -3,12 +3,71 @@ // Refer to the license.txt file included. #include "common/logging/log.h" +#include "core/file_sys/system_archive/system_version.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" +#include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/set/set_sys.h" namespace Service::Set { +void SET_SYS::GetFirmwareVersion(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_SET, "called"); + + ASSERT(ctx.GetWriteBufferSize() == 0x100, + "FirmwareVersion output buffer must be 0x100 bytes in size!"); + + // Instead of using the normal procedure of checking for the real system archive and if it + // doesn't exist, synthesizing one, I feel that that would lead to strange bugs because a used + // is using a really old or really new SystemVersion title. The synthesized one ensures + // consistence (currently reports as 5.1.0-0.0) + const auto archive = FileSys::SystemArchive::SystemVersion(); + + const auto early_exit_failure = [&ctx](const std::string& desc) { + LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).", + desc.c_str()); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultCode(-1)); + }; + + if (archive == nullptr) { + early_exit_failure("The system version archive couldn't be synthesized."); + return; + } + + const auto ver_file = archive->GetFile("file"); + if (ver_file == nullptr) { + early_exit_failure("The system version archive didn't contain the file 'file'."); + return; + } + + auto data = ver_file->ReadAllBytes(); + if (data.size() != 0x100) { + early_exit_failure("The system version file 'file' was not the correct size."); + return; + } + + // If the command is GetFirmwareVersion (as opposed to GetFirmwareVersion2), hardware will zero + // out the REVISION_MAJOR and REVISION_MICRO fields, which are u8s at offsets 0x4 and 0x5, + // respectively. This if statement will only execute when the true intended command is + // GetFirmwareVersion, and allows removing duplicate code for the implementation of + // GetFirmwareVersion2. + if (ctx.GetCommand() == 3) { + data[0x4] = 0x0; + data[0x5] = 0x0; + } + + ctx.WriteBuffer(data); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); +} + +void SET_SYS::GetFirmwareVersion2(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_SET, "called - delegating to GetFirmwareVersion"); + GetFirmwareVersion(ctx); +} + void SET_SYS::GetColorSetId(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); @@ -33,8 +92,8 @@ SET_SYS::SET_SYS() : ServiceFramework("set:sys") { {0, nullptr, "SetLanguageCode"}, {1, nullptr, "SetNetworkSettings"}, {2, nullptr, "GetNetworkSettings"}, - {3, nullptr, "GetFirmwareVersion"}, - {4, nullptr, "GetFirmwareVersion2"}, + {3, &SET_SYS::GetFirmwareVersion, "GetFirmwareVersion"}, + {4, &SET_SYS::GetFirmwareVersion2, "GetFirmwareVersion2"}, {5, nullptr, "GetFirmwareVersionDigest"}, {7, nullptr, "GetLockScreenFlag"}, {8, nullptr, "SetLockScreenFlag"}, diff --git a/src/core/hle/service/set/set_sys.h b/src/core/hle/service/set/set_sys.h index f602f3c77e..13ee2cf469 100644 --- a/src/core/hle/service/set/set_sys.h +++ b/src/core/hle/service/set/set_sys.h @@ -20,6 +20,8 @@ private: BasicBlack = 1, }; + void GetFirmwareVersion(Kernel::HLERequestContext& ctx); + void GetFirmwareVersion2(Kernel::HLERequestContext& ctx); void GetColorSetId(Kernel::HLERequestContext& ctx); void SetColorSetId(Kernel::HLERequestContext& ctx); From 597c00698d6d8aff3b09af6f9163fde1432b6fe9 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 10 Mar 2019 19:09:23 -0400 Subject: [PATCH 2/5] set_sys: Use correct error codes in GetFirmwareVersion* --- src/core/hle/service/set/set_sys.cpp | 62 ++++++++++++++++++---------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index ddab0e36fa..225062c0f0 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/assert.h" #include "common/logging/log.h" #include "core/file_sys/system_archive/system_version.h" #include "core/hle/ipc_helpers.h" @@ -11,50 +12,63 @@ namespace Service::Set { -void SET_SYS::GetFirmwareVersion(Kernel::HLERequestContext& ctx) { - LOG_DEBUG(Service_SET, "called"); +constexpr u64 SYSTEM_VERSION_FILE_MINOR_REVISION_OFFSET = 0x05; - ASSERT(ctx.GetWriteBufferSize() == 0x100, - "FirmwareVersion output buffer must be 0x100 bytes in size!"); +constexpr ResultCode ERROR_FAILED_MOUNT_ARCHIVE(ErrorModule::FS, 3223); +constexpr ResultCode ERROR_READ_TOO_LARGE(ErrorModule::FS, 3005); +constexpr ResultCode ERROR_INVALID_NAME(ErrorModule::FS, 6001); + +enum class GetFirmwareVersionType { + Version1, + Version2, +}; + +namespace { +void GetFirmwareVersionImpl(Kernel::HLERequestContext& ctx, GetFirmwareVersionType type) { + LOG_WARNING( + Service_SET, + "called - Using hardcoded firmware version 'YuzuEmulated Firmware for NX 5.1.0-0.0'"); + + ASSERT_MSG(ctx.GetWriteBufferSize() == 0x100, + "FirmwareVersion output buffer must be 0x100 bytes in size!"); // Instead of using the normal procedure of checking for the real system archive and if it - // doesn't exist, synthesizing one, I feel that that would lead to strange bugs because a used - // is using a really old or really new SystemVersion title. The synthesized one ensures + // doesn't exist, synthesizing one, I feel that that would lead to strange bugs because a + // used is using a really old or really new SystemVersion title. The synthesized one ensures // consistence (currently reports as 5.1.0-0.0) const auto archive = FileSys::SystemArchive::SystemVersion(); - const auto early_exit_failure = [&ctx](const std::string& desc) { + const auto early_exit_failure = [&ctx](const std::string& desc, ResultCode code) { LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).", desc.c_str()); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultCode(-1)); + rb.Push(code); }; if (archive == nullptr) { - early_exit_failure("The system version archive couldn't be synthesized."); + early_exit_failure("The system version archive couldn't be synthesized.", + ERROR_FAILED_MOUNT_ARCHIVE); return; } const auto ver_file = archive->GetFile("file"); if (ver_file == nullptr) { - early_exit_failure("The system version archive didn't contain the file 'file'."); + early_exit_failure("The system version archive didn't contain the file 'file'.", + ERROR_INVALID_NAME); return; } auto data = ver_file->ReadAllBytes(); if (data.size() != 0x100) { - early_exit_failure("The system version file 'file' was not the correct size."); + early_exit_failure("The system version file 'file' was not the correct size.", + ERROR_READ_TOO_LARGE); return; } - // If the command is GetFirmwareVersion (as opposed to GetFirmwareVersion2), hardware will zero - // out the REVISION_MAJOR and REVISION_MICRO fields, which are u8s at offsets 0x4 and 0x5, - // respectively. This if statement will only execute when the true intended command is - // GetFirmwareVersion, and allows removing duplicate code for the implementation of - // GetFirmwareVersion2. - if (ctx.GetCommand() == 3) { - data[0x4] = 0x0; - data[0x5] = 0x0; + // If the command is GetFirmwareVersion (as opposed to GetFirmwareVersion2), hardware will + // zero out the REVISION_MINOR field. + if (type == GetFirmwareVersionType::Version1) { + data[SYSTEM_VERSION_FILE_MINOR_REVISION_OFFSET] = 0; } ctx.WriteBuffer(data); @@ -62,10 +76,16 @@ void SET_SYS::GetFirmwareVersion(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } +} // namespace + +void SET_SYS::GetFirmwareVersion(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_SET, "called"); + GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version1); +} void SET_SYS::GetFirmwareVersion2(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "called - delegating to GetFirmwareVersion"); - GetFirmwareVersion(ctx); + LOG_DEBUG(Service_SET, "called"); + GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version2); } void SET_SYS::GetColorSetId(Kernel::HLERequestContext& ctx) { From 73f2ee5484d4b1836cd94becd65af2342b2cdaca Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 10 Mar 2019 19:16:17 -0400 Subject: [PATCH 3/5] system_version: Correct sizes on VectorVfsFile construction --- src/core/file_sys/system_archive/system_version.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/file_sys/system_archive/system_version.cpp b/src/core/file_sys/system_archive/system_version.cpp index 3fc5f95866..52df10f55c 100644 --- a/src/core/file_sys/system_archive/system_version.cpp +++ b/src/core/file_sys/system_archive/system_version.cpp @@ -34,13 +34,13 @@ VirtualDir SystemVersion() { file->WriteObject(SystemVersionData::REVISION_MAJOR, 4); file->WriteObject(SystemVersionData::REVISION_MINOR, 5); file->WriteArray(SystemVersionData::PLATFORM_STRING, - std::min(sizeof(SystemVersionData::PLATFORM_STRING), 0x20ull), 0x8); + std::min(sizeof(SystemVersionData::PLATFORM_STRING), 0x20ull), 0x8); file->WriteArray(SystemVersionData::VERSION_HASH, - std::min(sizeof(SystemVersionData::VERSION_HASH), 0x40ull), 0x28); + std::min(sizeof(SystemVersionData::VERSION_HASH), 0x40ull), 0x28); file->WriteArray(SystemVersionData::DISPLAY_VERSION, - std::min(sizeof(SystemVersionData::DISPLAY_VERSION), 0x18ull), 0x68); + std::min(sizeof(SystemVersionData::DISPLAY_VERSION), 0x18ull), 0x68); file->WriteArray(SystemVersionData::DISPLAY_TITLE, - std::min(sizeof(SystemVersionData::DISPLAY_TITLE), 0x80ull), 0x80); + std::min(sizeof(SystemVersionData::DISPLAY_TITLE), 0x80ull), 0x80); return std::make_shared(std::vector{file}, std::vector{}, "data"); } From debc7442f2904cd11e025b4101ad007561470289 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 10 Mar 2019 19:54:13 -0400 Subject: [PATCH 4/5] set_sys: Use official nintendo version string --- src/core/file_sys/errors.h | 3 +++ .../system_archive/system_version.cpp | 20 +++++++++++-------- .../file_sys/system_archive/system_version.h | 3 +++ src/core/hle/service/set/set_sys.cpp | 18 +++++++---------- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/core/file_sys/errors.h b/src/core/file_sys/errors.h index e4a4ee4ab6..bb4654366f 100644 --- a/src/core/file_sys/errors.h +++ b/src/core/file_sys/errors.h @@ -11,6 +11,9 @@ namespace FileSys { constexpr ResultCode ERROR_PATH_NOT_FOUND{ErrorModule::FS, 1}; constexpr ResultCode ERROR_ENTITY_NOT_FOUND{ErrorModule::FS, 1002}; constexpr ResultCode ERROR_SD_CARD_NOT_FOUND{ErrorModule::FS, 2001}; +constexpr ResultCode ERROR_OUT_OF_BOUNDS{ErrorModule::FS, 3005}; +constexpr ResultCode ERROR_FAILED_MOUNT_ARCHIVE{ErrorModule::FS, 3223}; +constexpr ResultCode ERROR_INVALID_ARGUMENT{ErrorModule::FS, 6001}; constexpr ResultCode ERROR_INVALID_OFFSET{ErrorModule::FS, 6061}; constexpr ResultCode ERROR_INVALID_SIZE{ErrorModule::FS, 6062}; diff --git a/src/core/file_sys/system_archive/system_version.cpp b/src/core/file_sys/system_archive/system_version.cpp index 52df10f55c..6e22f97b04 100644 --- a/src/core/file_sys/system_archive/system_version.cpp +++ b/src/core/file_sys/system_archive/system_version.cpp @@ -16,16 +16,20 @@ constexpr u8 VERSION_MAJOR = 5; constexpr u8 VERSION_MINOR = 1; constexpr u8 VERSION_MICRO = 0; -constexpr u8 REVISION_MAJOR = 0; +constexpr u8 REVISION_MAJOR = 3; constexpr u8 REVISION_MINOR = 0; -constexpr char PLATFORM_STRING[] = "YUZU"; -constexpr char VERSION_HASH[] = ""; +constexpr char PLATFORM_STRING[] = "NX"; +constexpr char VERSION_HASH[] = "23f9df53e25709d756e0c76effcb2473bd3447dd"; constexpr char DISPLAY_VERSION[] = "5.1.0"; -constexpr char DISPLAY_TITLE[] = "YuzuEmulated Firmware for NX 5.1.0-0.0"; +constexpr char DISPLAY_TITLE[] = "NintendoSDK Firmware for NX 5.1.0-3.0"; } // namespace SystemVersionData +std::string GetLongDisplayVersion() { + return SystemVersionData::DISPLAY_TITLE; +} + VirtualDir SystemVersion() { VirtualFile file = std::make_shared(std::vector(0x100), "file"); file->WriteObject(SystemVersionData::VERSION_MAJOR, 0); @@ -34,13 +38,13 @@ VirtualDir SystemVersion() { file->WriteObject(SystemVersionData::REVISION_MAJOR, 4); file->WriteObject(SystemVersionData::REVISION_MINOR, 5); file->WriteArray(SystemVersionData::PLATFORM_STRING, - std::min(sizeof(SystemVersionData::PLATFORM_STRING), 0x20ull), 0x8); + std::min(sizeof(SystemVersionData::PLATFORM_STRING), 0x20ULL), 0x8); file->WriteArray(SystemVersionData::VERSION_HASH, - std::min(sizeof(SystemVersionData::VERSION_HASH), 0x40ull), 0x28); + std::min(sizeof(SystemVersionData::VERSION_HASH), 0x40ULL), 0x28); file->WriteArray(SystemVersionData::DISPLAY_VERSION, - std::min(sizeof(SystemVersionData::DISPLAY_VERSION), 0x18ull), 0x68); + std::min(sizeof(SystemVersionData::DISPLAY_VERSION), 0x18ULL), 0x68); file->WriteArray(SystemVersionData::DISPLAY_TITLE, - std::min(sizeof(SystemVersionData::DISPLAY_TITLE), 0x80ull), 0x80); + std::min(sizeof(SystemVersionData::DISPLAY_TITLE), 0x80ULL), 0x80); return std::make_shared(std::vector{file}, std::vector{}, "data"); } diff --git a/src/core/file_sys/system_archive/system_version.h b/src/core/file_sys/system_archive/system_version.h index 9fb794b36d..deed79b266 100644 --- a/src/core/file_sys/system_archive/system_version.h +++ b/src/core/file_sys/system_archive/system_version.h @@ -4,10 +4,13 @@ #pragma once +#include #include "core/file_sys/vfs_types.h" namespace FileSys::SystemArchive { +std::string GetLongDisplayVersion(); + VirtualDir SystemVersion(); } // namespace FileSys::SystemArchive diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index 225062c0f0..917b4e3a51 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp @@ -4,6 +4,7 @@ #include "common/assert.h" #include "common/logging/log.h" +#include "core/file_sys/errors.h" #include "core/file_sys/system_archive/system_version.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" @@ -14,10 +15,6 @@ namespace Service::Set { constexpr u64 SYSTEM_VERSION_FILE_MINOR_REVISION_OFFSET = 0x05; -constexpr ResultCode ERROR_FAILED_MOUNT_ARCHIVE(ErrorModule::FS, 3223); -constexpr ResultCode ERROR_READ_TOO_LARGE(ErrorModule::FS, 3005); -constexpr ResultCode ERROR_INVALID_NAME(ErrorModule::FS, 6001); - enum class GetFirmwareVersionType { Version1, Version2, @@ -25,9 +22,8 @@ enum class GetFirmwareVersionType { namespace { void GetFirmwareVersionImpl(Kernel::HLERequestContext& ctx, GetFirmwareVersionType type) { - LOG_WARNING( - Service_SET, - "called - Using hardcoded firmware version 'YuzuEmulated Firmware for NX 5.1.0-0.0'"); + LOG_WARNING(Service_SET, "called - Using hardcoded firmware version '{}'", + FileSys::SystemArchive::GetLongDisplayVersion()); ASSERT_MSG(ctx.GetWriteBufferSize() == 0x100, "FirmwareVersion output buffer must be 0x100 bytes in size!"); @@ -47,21 +43,21 @@ void GetFirmwareVersionImpl(Kernel::HLERequestContext& ctx, GetFirmwareVersionTy if (archive == nullptr) { early_exit_failure("The system version archive couldn't be synthesized.", - ERROR_FAILED_MOUNT_ARCHIVE); + FileSys::ERROR_FAILED_MOUNT_ARCHIVE); return; } const auto ver_file = archive->GetFile("file"); if (ver_file == nullptr) { early_exit_failure("The system version archive didn't contain the file 'file'.", - ERROR_INVALID_NAME); + FileSys::ERROR_INVALID_ARGUMENT); return; } auto data = ver_file->ReadAllBytes(); if (data.size() != 0x100) { early_exit_failure("The system version file 'file' was not the correct size.", - ERROR_READ_TOO_LARGE); + FileSys::ERROR_OUT_OF_BOUNDS); return; } @@ -76,7 +72,7 @@ void GetFirmwareVersionImpl(Kernel::HLERequestContext& ctx, GetFirmwareVersionTy IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } -} // namespace +} // Anonymous namespace void SET_SYS::GetFirmwareVersion(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); From cd2921a047db171457fce4e2c19ee7f2beb3d63b Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Mon, 11 Mar 2019 11:16:35 -0400 Subject: [PATCH 5/5] set_sys: Move constants to anonymous namespace --- src/core/hle/service/set/set_sys.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index 917b4e3a51..ecee554bf1 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp @@ -13,6 +13,7 @@ namespace Service::Set { +namespace { constexpr u64 SYSTEM_VERSION_FILE_MINOR_REVISION_OFFSET = 0x05; enum class GetFirmwareVersionType { @@ -20,7 +21,6 @@ enum class GetFirmwareVersionType { Version2, }; -namespace { void GetFirmwareVersionImpl(Kernel::HLERequestContext& ctx, GetFirmwareVersionType type) { LOG_WARNING(Service_SET, "called - Using hardcoded firmware version '{}'", FileSys::SystemArchive::GetLongDisplayVersion());