Skip to content

Commit

Permalink
Fix tests and compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
momo5502 committed Nov 17, 2024
1 parent a87bb85 commit 804f517
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
3 changes: 0 additions & 3 deletions src/emulator/serialization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#include <functional>
#include <typeindex>

void serialize();
void deserialize();

namespace utils
{
class buffer_serializer;
Expand Down
21 changes: 14 additions & 7 deletions src/windows-emulator/emulator_utils.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
#pragma once
#include "memory_utils.hpp"
#include <x64_emulator.hpp>

// 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();
}
Expand All @@ -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)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/windows-emulator/io_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct io_device_context

static io_device_context construct(utils::buffer_deserializer& buffer)
{
const auto wrapper = buffer.read<emulator_wrapper>();
const auto wrapper = buffer.read<x64_emulator_wrapper>();
return io_device_context{
.io_status_block = wrapper.get(),
};
Expand Down
6 changes: 6 additions & 0 deletions src/windows-emulator/process_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<x64_emulator_wrapper>();
return {wrapper.get()};
}

moved_marker marker{};

x64_emulator* emu_ptr{};
Expand Down
12 changes: 2 additions & 10 deletions src/windows-emulator/windows_emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,19 +1046,11 @@ void windows_emulator::serialize(utils::buffer_serializer& buffer) const

void windows_emulator::deserialize(utils::buffer_deserializer& buffer)
{
buffer.register_factory<emulator_wrapper>([this]
buffer.register_factory<x64_emulator_wrapper>([this]
{
return emulator_wrapper{
.emu = &this->emu(),
};
return x64_emulator_wrapper{this->emu()};
});

buffer.register_factory<emulator_thread>([this]
{
return emulator_thread(this->emu());
});


buffer.read(this->use_relative_time_);

this->emu().deserialize(buffer);
Expand Down

0 comments on commit 804f517

Please sign in to comment.