From d45a12826c94f7f0da62d1df05245fcae38784e7 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 18 Feb 2024 18:40:37 -0500 Subject: ns: address review comments --- .../service/ns/application_manager_interface.cpp | 13 +++---- src/core/hle/service/ns/ns_types.h | 41 +++++++++++++--------- ...ead_only_application_control_data_interface.cpp | 6 ++-- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/core/hle/service/ns/application_manager_interface.cpp b/src/core/hle/service/ns/application_manager_interface.cpp index 9c7975b77..2e3a44c0d 100644 --- a/src/core/hle/service/ns/application_manager_interface.cpp +++ b/src/core/hle/service/ns/application_manager_interface.cpp @@ -441,12 +441,13 @@ Result IApplicationManagerInterface::GetApplicationRightsOnClient( flags, application_id, account_id.FormattedString()); if (!out_rights.empty()) { - out_rights[0] = { - .application_id = application_id, - .uid = account_id, - .flags = 0, - .flags2 = 0, - }; + ApplicationRightsOnClient rights{}; + rights.application_id = application_id; + rights.uid = account_id; + rights.flags = 0; + rights.flags2 = 0; + + out_rights[0] = rights; *out_count = 1; } else { *out_count = 0; diff --git a/src/core/hle/service/ns/ns_types.h b/src/core/hle/service/ns/ns_types.h index 37ff078bd..38421b0f4 100644 --- a/src/core/hle/service/ns/ns_types.h +++ b/src/core/hle/service/ns/ns_types.h @@ -13,8 +13,8 @@ enum class ApplicationRecordType : u8 { Installing = 2, Installed = 3, GameCardNotInserted = 5, - Archived = 0xB, - GameCard = 0x10, + Archived = 11, + GameCard = 16, }; enum class ApplicationControlSource : u8 { @@ -37,31 +37,34 @@ struct ApplicationRecord { u8 unknown2; INSERT_PADDING_BYTES_NOINIT(0x7); }; -static_assert(sizeof(ApplicationRecord) == 0x18, "ApplicationRecord is an invalid size"); +static_assert(sizeof(ApplicationRecord) == 0x18, "ApplicationRecord has incorrect size."); /// ApplicationView struct ApplicationView { - u64 application_id; ///< ApplicationId. - u32 unk; ///< Unknown. - u32 flags; ///< Flags. - u8 unk_x10[0x10]; ///< Unknown. - u32 unk_x20; ///< Unknown. - u16 unk_x24; ///< Unknown. - u8 unk_x26[0x2]; ///< Unknown. - u8 unk_x28[0x8]; ///< Unknown. - u8 unk_x30[0x10]; ///< Unknown. - u32 unk_x40; ///< Unknown. - u8 unk_x44; ///< Unknown. - u8 unk_x45[0xb]; ///< Unknown. + u64 application_id; ///< ApplicationId. + u32 unk; ///< Unknown. + u32 flags; ///< Flags. + std::array unk_x10; ///< Unknown. + u32 unk_x20; ///< Unknown. + u16 unk_x24; ///< Unknown. + std::array unk_x26; ///< Unknown. + std::array unk_x28; ///< Unknown. + std::array unk_x30; ///< Unknown. + u32 unk_x40; ///< Unknown. + u8 unk_x44; ///< Unknown. + std::array unk_x45; ///< Unknown. }; +static_assert(sizeof(ApplicationView) == 0x50, "ApplicationView has incorrect size."); struct ApplicationRightsOnClient { u64 application_id; Common::UUID uid; u8 flags; u8 flags2; - INSERT_PADDING_BYTES(0x6); + INSERT_PADDING_BYTES_NOINIT(0x6); }; +static_assert(sizeof(ApplicationRightsOnClient) == 0x20, + "ApplicationRightsOnClient has incorrect size."); /// NsPromotionInfo struct PromotionInfo { @@ -74,12 +77,15 @@ struct PromotionInfo { ///< remaining_time is set. INSERT_PADDING_BYTES_NOINIT(0x3); }; +static_assert(sizeof(PromotionInfo) == 0x20, "PromotionInfo has incorrect size."); /// NsApplicationViewWithPromotionInfo struct ApplicationViewWithPromotionInfo { ApplicationView view; ///< \ref NsApplicationView PromotionInfo promotion; ///< \ref NsPromotionInfo }; +static_assert(sizeof(ApplicationViewWithPromotionInfo) == 0x70, + "ApplicationViewWithPromotionInfo has incorrect size."); struct ApplicationOccupiedSizeEntity { FileSys::StorageId storage_id; @@ -93,10 +99,13 @@ static_assert(sizeof(ApplicationOccupiedSizeEntity) == 0x20, struct ApplicationOccupiedSize { std::array entities; }; +static_assert(sizeof(ApplicationOccupiedSize) == 0x80, + "ApplicationOccupiedSize has incorrect size."); struct ContentPath { u8 file_system_proxy_type; u64 program_id; }; +static_assert(sizeof(ContentPath) == 0x10, "ContentPath has incorrect size."); } // namespace Service::NS diff --git a/src/core/hle/service/ns/read_only_application_control_data_interface.cpp b/src/core/hle/service/ns/read_only_application_control_data_interface.cpp index 1587aed44..9b2ca94a4 100644 --- a/src/core/hle/service/ns/read_only_application_control_data_interface.cpp +++ b/src/core/hle/service/ns/read_only_application_control_data_interface.cpp @@ -43,7 +43,7 @@ Result IReadOnlyApplicationControlDataInterface::GetApplicationControlData( const auto size = out_buffer.size(); const auto icon_size = control.second ? control.second->GetSize() : 0; - const auto total_size = 0x4000 + icon_size; + const auto total_size = sizeof(FileSys::RawNACP) + icon_size; if (size < total_size) { LOG_ERROR(Service_NS, "output buffer is too small! (actual={:016X}, expected_min=0x4000)", @@ -57,11 +57,11 @@ Result IReadOnlyApplicationControlDataInterface::GetApplicationControlData( } else { LOG_WARNING(Service_NS, "missing NACP data for application_id={:016X}, defaulting to zero", application_id); - std::memset(out_buffer.data(), 0, 0x4000); + std::memset(out_buffer.data(), 0, sizeof(FileSys::RawNACP)); } if (control.second != nullptr) { - control.second->Read(out_buffer.data() + 0x4000, icon_size); + control.second->Read(out_buffer.data() + sizeof(FileSys::RawNACP), icon_size); } else { LOG_WARNING(Service_NS, "missing icon data for application_id={:016X}", application_id); } -- cgit v1.2.3