diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp index d13934320..e73a6642c 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp @@ -62,7 +62,7 @@ namespace ams::sf::cmif { } constexpr size_t GetImplOutDataTotalSize() const { - return m_impl_metadata.GetOutDataSize() + m_impl_metadata.GetOutHeadersSize(); + return m_impl_metadata.GetUnalignedOutDataSize() + m_impl_metadata.GetOutHeadersSize(); } public: /* Used to enabled templated message processors. */ @@ -80,12 +80,12 @@ namespace ams::sf::cmif { const auto runtime_metadata = m_impl_processor->GetRuntimeMetadata(); return ServerMessageRuntimeMetadata { - .in_data_size = static_cast(runtime_metadata.GetInDataSize() + runtime_metadata.GetInObjectCount() * sizeof(DomainObjectId)), - .out_data_size = static_cast(runtime_metadata.GetOutDataSize() + runtime_metadata.GetOutObjectCount() * sizeof(DomainObjectId)), - .in_headers_size = static_cast(runtime_metadata.GetInHeadersSize() + sizeof(CmifDomainInHeader)), - .out_headers_size = static_cast(runtime_metadata.GetOutHeadersSize() + sizeof(CmifDomainOutHeader)), - .in_object_count = 0, - .out_object_count = 0, + .in_data_size = static_cast(runtime_metadata.GetInDataSize() + runtime_metadata.GetInObjectCount() * sizeof(DomainObjectId)), + .unaligned_out_data_size = static_cast(runtime_metadata.GetOutDataSize() + runtime_metadata.GetOutObjectCount() * sizeof(DomainObjectId)), + .in_headers_size = static_cast(runtime_metadata.GetInHeadersSize() + sizeof(CmifDomainInHeader)), + .out_headers_size = static_cast(runtime_metadata.GetOutHeadersSize() + sizeof(CmifDomainOutHeader)), + .in_object_count = 0, + .out_object_count = 0, }; } diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp index ca90235e6..ef454e091 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp @@ -28,7 +28,7 @@ namespace ams::sf::cmif { /* This is needed for non-templated domain message processing. */ struct ServerMessageRuntimeMetadata { u16 in_data_size; - u16 out_data_size; + u16 unaligned_out_data_size; u8 in_headers_size; u8 out_headers_size; u8 in_object_count; @@ -39,7 +39,11 @@ namespace ams::sf::cmif { } constexpr size_t GetOutDataSize() const { - return static_cast(this->out_data_size); + return static_cast(util::AlignUp(this->unaligned_out_data_size, sizeof(u32))); + } + + constexpr size_t GetUnalignedOutDataSize() const { + return static_cast(this->unaligned_out_data_size); } constexpr size_t GetInHeadersSize() const { diff --git a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp index 83024df40..c91d4480f 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp @@ -472,6 +472,7 @@ namespace ams::sf::impl { static constexpr size_t InDataSize = util::AlignUp(InDataOffsets[NumInDatas], alignof(u16)); static constexpr std::array OutDataOffsets = RawDataOffsetCalculator::Offsets; + static constexpr size_t UnalignedOutDataSize = OutDataOffsets[NumOutDatas]; static constexpr size_t OutDataSize = util::AlignUp(OutDataOffsets[NumOutDatas], alignof(u32)); static constexpr size_t OutDataAlign = [] { if constexpr (std::tuple_size::value) { @@ -492,12 +493,12 @@ namespace ams::sf::impl { /* Used by server message processor at runtime. */ static constexpr inline const cmif::ServerMessageRuntimeMetadata RuntimeMetadata = cmif::ServerMessageRuntimeMetadata{ - .in_data_size = InDataSize, - .out_data_size = OutDataSize, - .in_headers_size = sizeof(CmifInHeader), - .out_headers_size = sizeof(CmifOutHeader), - .in_object_count = NumInObjects, - .out_object_count = NumOutObjects, + .in_data_size = InDataSize, + .unaligned_out_data_size = UnalignedOutDataSize, + .in_headers_size = sizeof(CmifInHeader), + .out_headers_size = sizeof(CmifOutHeader), + .in_object_count = NumInObjects, + .out_object_count = NumOutObjects, }; /* Construction of argument serialization structs. */