mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 03:33:56 +00:00
Replace constructor function with actual constructor call
This commit is contained in:
@@ -58,15 +58,9 @@ namespace utils
|
||||
{
|
||||
};
|
||||
|
||||
template <typename, typename = void>
|
||||
struct has_construct_function : std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct has_construct_function<T, std::void_t<decltype(T::construct(
|
||||
std::declval<buffer_deserializer&>()))>>
|
||||
: std::bool_constant<std::is_same_v<decltype(T::construct(std::declval<buffer_deserializer&>())), T>>
|
||||
struct has_deserializer_constructor
|
||||
: std::bool_constant<std::is_constructible_v<T, buffer_deserializer&>>
|
||||
{
|
||||
};
|
||||
}
|
||||
@@ -303,9 +297,9 @@ namespace utils
|
||||
template <typename T>
|
||||
T construct_object()
|
||||
{
|
||||
if constexpr (detail::has_construct_function<T>::value)
|
||||
if constexpr (detail::has_deserializer_constructor<T>::value)
|
||||
{
|
||||
return T::construct(*this);
|
||||
return T(*this);
|
||||
}
|
||||
else if constexpr (std::is_default_constructible_v<T>)
|
||||
{
|
||||
|
||||
@@ -22,12 +22,14 @@ struct io_device_context
|
||||
emulator_pointer output_buffer{};
|
||||
ULONG output_buffer_length{};
|
||||
|
||||
static io_device_context construct(utils::buffer_deserializer& buffer)
|
||||
io_device_context(x64_emulator& emu)
|
||||
: io_status_block(emu)
|
||||
{
|
||||
}
|
||||
|
||||
io_device_context(utils::buffer_deserializer& buffer)
|
||||
: io_device_context(buffer.read<x64_emulator_wrapper>().get())
|
||||
{
|
||||
const auto wrapper = buffer.read<x64_emulator_wrapper>();
|
||||
return io_device_context{
|
||||
.io_status_block = wrapper.get(),
|
||||
};
|
||||
}
|
||||
|
||||
void serialize(utils::buffer_serializer& buffer) const
|
||||
@@ -129,7 +131,7 @@ struct stateless_device : io_device
|
||||
}
|
||||
};
|
||||
|
||||
std::unique_ptr<io_device> create_device(const std::wstring_view device);
|
||||
std::unique_ptr<io_device> create_device(std::wstring_view device);
|
||||
|
||||
class io_device_container : public io_device
|
||||
{
|
||||
|
||||
@@ -188,6 +188,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
emulator_thread(utils::buffer_deserializer& buffer)
|
||||
: emulator_thread(buffer.read<x64_emulator_wrapper>().get())
|
||||
{
|
||||
}
|
||||
|
||||
emulator_thread(x64_emulator& emu, const process_context& context, uint64_t start_address, uint64_t argument,
|
||||
uint64_t stack_size, uint32_t id);
|
||||
|
||||
@@ -202,12 +207,6 @@ public:
|
||||
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{};
|
||||
|
||||
@@ -1677,17 +1677,16 @@ namespace
|
||||
return STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
const io_device_context context{
|
||||
.event = event,
|
||||
.apc_routine = apc_routine,
|
||||
.apc_context = apc_context,
|
||||
.io_status_block = io_status_block,
|
||||
.io_control_code = io_control_code,
|
||||
.input_buffer = input_buffer,
|
||||
.input_buffer_length = input_buffer_length,
|
||||
.output_buffer = output_buffer,
|
||||
.output_buffer_length = output_buffer_length,
|
||||
};
|
||||
io_device_context context{c.emu};
|
||||
context.event = event;
|
||||
context.apc_routine = apc_routine;
|
||||
context.apc_context = apc_context;
|
||||
context.io_status_block = io_status_block;
|
||||
context.io_control_code = io_control_code;
|
||||
context.input_buffer = input_buffer;
|
||||
context.input_buffer_length = input_buffer_length;
|
||||
context.output_buffer = output_buffer;
|
||||
context.output_buffer_length = output_buffer_length;
|
||||
|
||||
return device->execute_ioctl(c.win_emu, context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user