diff --git a/src/windows-emulator/emulator_utils.hpp b/src/windows-emulator/emulator_utils.hpp index f8737ff6..c1f992fc 100644 --- a/src/windows-emulator/emulator_utils.hpp +++ b/src/windows-emulator/emulator_utils.hpp @@ -104,6 +104,16 @@ class emulator_object return this->address_ != 0; } + std::optional try_read(const size_t index = 0) const + { + T obj{}; + if (this->memory_->try_read_memory(this->address_ + index * this->size(), &obj, sizeof(obj))) + { + return obj; + } + return std::nullopt; + } + T read(const size_t index = 0) const { T obj{}; @@ -111,6 +121,11 @@ class emulator_object return obj; } + bool try_write(const T& value, const size_t index = 0) const + { + return this->memory_->try_write_memory(this->address_ + index * this->size(), &value, sizeof(value)); + } + void write(const T& value, const size_t index = 0) const { this->memory_->write_memory(this->address_ + index * this->size(), &value, sizeof(value));