mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 11:13:57 +00:00
Simplify violation hook API
This commit is contained in:
@@ -53,8 +53,7 @@ class hook_interface
|
||||
public:
|
||||
virtual ~hook_interface() = default;
|
||||
|
||||
virtual emulator_hook* hook_memory_violation(uint64_t address, size_t size,
|
||||
memory_violation_hook_callback callback) = 0;
|
||||
virtual emulator_hook* hook_memory_violation(memory_violation_hook_callback callback) = 0;
|
||||
|
||||
virtual emulator_hook* hook_memory_access(uint64_t address, size_t size, memory_operation filter,
|
||||
complex_memory_hook_callback callback) = 0;
|
||||
@@ -67,11 +66,6 @@ class hook_interface
|
||||
|
||||
virtual void delete_hook(emulator_hook* hook) = 0;
|
||||
|
||||
emulator_hook* hook_memory_violation(memory_violation_hook_callback callback)
|
||||
{
|
||||
return this->hook_memory_violation(0, std::numeric_limits<size_t>::max(), std::move(callback));
|
||||
}
|
||||
|
||||
emulator_hook* hook_memory_read(const uint64_t address, const size_t size, simple_memory_hook_callback callback)
|
||||
{
|
||||
return this->hook_simple_memory_access(address, size, std::move(callback), memory_operation::read);
|
||||
|
||||
@@ -277,12 +277,8 @@ namespace icicle
|
||||
// throw std::runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
emulator_hook* hook_memory_violation(const uint64_t address, const size_t size,
|
||||
memory_violation_hook_callback callback) override
|
||||
emulator_hook* hook_memory_violation(memory_violation_hook_callback callback) override
|
||||
{
|
||||
(void)address;
|
||||
(void)size;
|
||||
|
||||
auto obj = make_function_object(std::move(callback));
|
||||
auto* ptr = obj.get();
|
||||
auto* wrapper =
|
||||
|
||||
@@ -537,8 +537,7 @@ namespace unicorn
|
||||
return result;
|
||||
}
|
||||
|
||||
emulator_hook* hook_memory_violation(uint64_t address, size_t size,
|
||||
memory_violation_hook_callback callback) override
|
||||
emulator_hook* hook_memory_violation(memory_violation_hook_callback callback) override
|
||||
{
|
||||
function_wrapper<bool, uc_engine*, uc_mem_type, uint64_t, int, int64_t> wrapper(
|
||||
[c = std::move(callback), this](uc_engine*, const uc_mem_type type, const uint64_t address,
|
||||
@@ -573,7 +572,7 @@ namespace unicorn
|
||||
auto container = std::make_unique<hook_container>();
|
||||
|
||||
uce(uc_hook_add(*this, hook.make_reference(), UC_HOOK_MEM_INVALID, wrapper.get_function(),
|
||||
wrapper.get_user_data(), address, size));
|
||||
wrapper.get_user_data(), 0, std::numeric_limits<uint64_t>::max()));
|
||||
|
||||
container->add(std::move(wrapper), std::move(hook));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user