1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-22 20:06:40 +00:00

sf: fix ipc serialization bug (out object id offsets)

This commit is contained in:
Michael Scire 2023-11-28 12:54:00 -07:00
parent 812b2aeb4c
commit 742fd16080
3 changed files with 20 additions and 15 deletions

View file

@ -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. */
@ -81,7 +81,7 @@ namespace ams::sf::cmif {
return ServerMessageRuntimeMetadata {
.in_data_size = static_cast<u16>(runtime_metadata.GetInDataSize() + runtime_metadata.GetInObjectCount() * sizeof(DomainObjectId)),
.out_data_size = static_cast<u16>(runtime_metadata.GetOutDataSize() + runtime_metadata.GetOutObjectCount() * sizeof(DomainObjectId)),
.unaligned_out_data_size = static_cast<u16>(runtime_metadata.GetOutDataSize() + runtime_metadata.GetOutObjectCount() * sizeof(DomainObjectId)),
.in_headers_size = static_cast<u8>(runtime_metadata.GetInHeadersSize() + sizeof(CmifDomainInHeader)),
.out_headers_size = static_cast<u8>(runtime_metadata.GetOutHeadersSize() + sizeof(CmifDomainOutHeader)),
.in_object_count = 0,

View file

@ -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<size_t>(this->out_data_size);
return static_cast<size_t>(util::AlignUp(this->unaligned_out_data_size, sizeof(u32)));
}
constexpr size_t GetUnalignedOutDataSize() const {
return static_cast<size_t>(this->unaligned_out_data_size);
}
constexpr size_t GetInHeadersSize() const {

View file

@ -472,6 +472,7 @@ namespace ams::sf::impl {
static constexpr size_t InDataSize = util::AlignUp(InDataOffsets[NumInDatas], alignof(u16));
static constexpr std::array<size_t, NumOutDatas+1> OutDataOffsets = RawDataOffsetCalculator<OutDatas>::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<OutDatas>::value) {
@ -493,7 +494,7 @@ 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,
.unaligned_out_data_size = UnalignedOutDataSize,
.in_headers_size = sizeof(CmifInHeader),
.out_headers_size = sizeof(CmifOutHeader),
.in_object_count = NumInObjects,