mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-26 23:11:01 +00:00
Small optimizations
This commit is contained in:
@@ -10,7 +10,7 @@ struct emulator_hook;
|
||||
|
||||
using memory_operation = memory_permission;
|
||||
|
||||
using instruction_hook_callback = std::function<void(uint64_t address)>;
|
||||
using hook_callback = std::function<void()>;
|
||||
|
||||
using simple_memory_hook_callback = std::function<void(uint64_t address, size_t size)>;
|
||||
using complex_memory_hook_callback = std::function<void(uint64_t address, size_t size, memory_operation operation)>;
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
virtual emulator_hook* hook_memory_access(uint64_t address, size_t size, memory_operation filter,
|
||||
complex_memory_hook_callback callback) = 0;
|
||||
virtual emulator_hook* hook_instruction(int instruction_type, instruction_hook_callback callback) = 0;
|
||||
virtual emulator_hook* hook_instruction(int instruction_type, hook_callback callback) = 0;
|
||||
|
||||
virtual void delete_hook(emulator_hook* hook) = 0;
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include "emulator.hpp"
|
||||
|
||||
using simple_instruction_hook_callback = std::function<void()>;
|
||||
|
||||
template <typename PointerType, typename Register, Register InstructionPointer, Register
|
||||
StackPointer, typename HookableInstructions>
|
||||
class typed_emulator : public emulator
|
||||
@@ -62,23 +60,13 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
emulator_hook* hook_instruction(hookable_instructions instruction_type, instruction_hook_callback callback)
|
||||
emulator_hook* hook_instruction(hookable_instructions instruction_type, hook_callback callback)
|
||||
{
|
||||
return this->hook_instruction(instruction_type, [this, c = std::move(callback)]
|
||||
{
|
||||
const auto ip = static_cast<uint64_t>(this->read_instruction_pointer());
|
||||
c(ip);
|
||||
});
|
||||
return this->hook_instruction(static_cast<int>(instruction_type), std::move(callback));
|
||||
}
|
||||
|
||||
virtual emulator_hook* hook_instruction(hookable_instructions instruction_type,
|
||||
simple_instruction_hook_callback callback) = 0;
|
||||
|
||||
private:
|
||||
emulator_hook* hook_instruction(int instruction_type, instruction_hook_callback callback) override
|
||||
{
|
||||
return this->hook_instruction(static_cast<hookable_instructions>(instruction_type), std::move(callback));
|
||||
}
|
||||
emulator_hook* hook_instruction(int instruction_type, hook_callback callback) override = 0;
|
||||
|
||||
void read_raw_register(int reg, void* value, size_t size) override = 0;
|
||||
void write_raw_register(int reg, const void* value, size_t size) override = 0;
|
||||
|
||||
Reference in New Issue
Block a user