diff --git a/src/emulator/serialization.hpp b/src/emulator/serialization.hpp index 83b66c3..ae0b897 100644 --- a/src/emulator/serialization.hpp +++ b/src/emulator/serialization.hpp @@ -9,9 +9,6 @@ #include #include -void serialize(); -void deserialize(); - namespace utils { class buffer_serializer; diff --git a/src/windows-emulator/emulator_utils.hpp b/src/windows-emulator/emulator_utils.hpp index 3ea6c59..ced2ce0 100644 --- a/src/windows-emulator/emulator_utils.hpp +++ b/src/windows-emulator/emulator_utils.hpp @@ -1,19 +1,26 @@ #pragma once #include "memory_utils.hpp" +#include // TODO: Replace with pointer handling structure for future 32 bit support using emulator_pointer = uint64_t; -struct emulator_wrapper +class x64_emulator_wrapper { - emulator* emu; + x64_emulator* emu_; - emulator& get() const +public: + x64_emulator_wrapper(x64_emulator& emu) + : emu_(&emu) + { + } + + x64_emulator& get() const { - return *this->emu; + return *this->emu_; } - operator emulator&() const + operator x64_emulator&() const { return this->get(); } @@ -33,8 +40,8 @@ class emulator_object public: using value_type = T; - emulator_object(const emulator_wrapper& wrapper, const uint64_t address = 0) - : emulator_object(wrapper.emu, address) + emulator_object(const x64_emulator_wrapper& wrapper, const uint64_t address = 0) + : emulator_object(wrapper.get(), address) { } diff --git a/src/windows-emulator/io_device.hpp b/src/windows-emulator/io_device.hpp index 0e6bff7..de7a243 100644 --- a/src/windows-emulator/io_device.hpp +++ b/src/windows-emulator/io_device.hpp @@ -24,7 +24,7 @@ struct io_device_context static io_device_context construct(utils::buffer_deserializer& buffer) { - const auto wrapper = buffer.read(); + const auto wrapper = buffer.read(); return io_device_context{ .io_status_block = wrapper.get(), }; diff --git a/src/windows-emulator/process_context.hpp b/src/windows-emulator/process_context.hpp index 8fca160..8d24df5 100644 --- a/src/windows-emulator/process_context.hpp +++ b/src/windows-emulator/process_context.hpp @@ -202,6 +202,12 @@ class emulator_thread : ref_counted_object this->release(); } + static emulator_thread construct(utils::buffer_deserializer& buffer) + { + const auto wrapper = buffer.read(); + return {wrapper.get()}; + } + moved_marker marker{}; x64_emulator* emu_ptr{}; diff --git a/src/windows-emulator/windows_emulator.cpp b/src/windows-emulator/windows_emulator.cpp index 3d042d2..43e6009 100644 --- a/src/windows-emulator/windows_emulator.cpp +++ b/src/windows-emulator/windows_emulator.cpp @@ -1046,19 +1046,11 @@ void windows_emulator::serialize(utils::buffer_serializer& buffer) const void windows_emulator::deserialize(utils::buffer_deserializer& buffer) { - buffer.register_factory([this] + buffer.register_factory([this] { - return emulator_wrapper{ - .emu = &this->emu(), - }; + return x64_emulator_wrapper{this->emu()}; }); - buffer.register_factory([this] - { - return emulator_thread(this->emu()); - }); - - buffer.read(this->use_relative_time_); this->emu().deserialize(buffer);