From c66ada8470dae2ed5b8994f6806653052469c6c1 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 21 Aug 2024 20:30:25 +0200 Subject: [PATCH] More cleanup --- src/emulator/typed_emulator.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/emulator/typed_emulator.hpp b/src/emulator/typed_emulator.hpp index af2184fc..38db5a83 100644 --- a/src/emulator/typed_emulator.hpp +++ b/src/emulator/typed_emulator.hpp @@ -42,10 +42,20 @@ public: this->write_register(regid, &value, sizeof(value)); } + pointer_type read_instruction_pointer() + { + return this->reg(instruction_pointer); + } + + pointer_type read_stack_pointer() + { + return this->reg(stack_pointer); + } + pointer_type read_stack(const size_t index) { pointer_type result{}; - const auto sp = this->reg(stack_pointer); + const auto sp = this->read_stack_pointer(); this->read_memory(sp + (index * pointer_size), &result, sizeof(result)); @@ -56,7 +66,7 @@ public: { return this->hook_instruction(instruction_type, [this, c = std::move(callback)] { - const auto ip = static_cast(this->reg(instruction_pointer)); + const auto ip = static_cast(this->read_instruction_pointer()); c(ip); }); }