Skip to content

Commit

Permalink
Fix afd device serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
momo5502 committed Jan 26, 2025
1 parent 59b82a5 commit 454c9a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/emulator/serialization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ namespace utils
{ a.deserialize(deserializer) } -> std::same_as<void>;
};

template <typename T>
struct is_optional : std::false_type
{
};

template <typename T>
struct is_optional<std::optional<T>> : std::true_type
{
};

namespace detail
{
template <typename, typename = void>
Expand Down Expand Up @@ -371,6 +381,7 @@ namespace utils
}

template <typename T>
requires(!is_optional<T>::value)
void write(const T& object)
{
constexpr auto is_trivially_copyable = std::is_trivially_copyable_v<T>;
Expand Down
16 changes: 8 additions & 8 deletions src/windows-emulator/devices/afd_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,20 @@ namespace

void deserialize(utils::buffer_deserializer& buffer) override
{
buffer.read(this->creation_data);
buffer.read_optional(this->creation_data);
this->setup();

buffer.read(this->require_poll_);
buffer.read(this->delayed_ioctl_);
buffer.read(this->timeout_);
buffer.read_optional(this->require_poll_);
buffer.read_optional(this->delayed_ioctl_);
buffer.read_optional(this->timeout_);
}

void serialize(utils::buffer_serializer& buffer) const override
{
buffer.write(this->creation_data);
buffer.write(this->require_poll_);
buffer.write(this->delayed_ioctl_);
buffer.write(this->timeout_);
buffer.write_optional(this->creation_data);
buffer.write_optional(this->require_poll_);
buffer.write_optional(this->delayed_ioctl_);
buffer.write_optional(this->timeout_);
}

NTSTATUS io_control(windows_emulator& win_emu, const io_device_context& c) override
Expand Down

0 comments on commit 454c9a2

Please sign in to comment.