Fix hook sizes

This commit is contained in:
momo5502
2025-04-14 18:34:34 +02:00
parent ea336f266f
commit 88d94f7065
3 changed files with 9 additions and 9 deletions

View File

@@ -326,7 +326,7 @@ namespace icicle
return wrap_hook(id); return wrap_hook(id);
} }
emulator_hook* hook_memory_read(const uint64_t address, const size_t size, emulator_hook* hook_memory_read(const uint64_t address, const uint64_t size,
memory_access_hook_callback callback) override memory_access_hook_callback callback) override
{ {
auto obj = make_function_object(std::move(callback)); auto obj = make_function_object(std::move(callback));
@@ -342,7 +342,7 @@ namespace icicle
return wrap_hook(id); return wrap_hook(id);
} }
emulator_hook* hook_memory_write(const uint64_t address, const size_t size, emulator_hook* hook_memory_write(const uint64_t address, const uint64_t size,
memory_access_hook_callback callback) override memory_access_hook_callback callback) override
{ {
auto obj = make_function_object(std::move(callback)); auto obj = make_function_object(std::move(callback));

View File

@@ -556,16 +556,16 @@ namespace unicorn
return this->hook_memory_execution(address, 1, std::move(callback)); return this->hook_memory_execution(address, 1, std::move(callback));
} }
emulator_hook* hook_memory_read(const uint64_t address, const size_t size, emulator_hook* hook_memory_read(const uint64_t address, const uint64_t size,
memory_access_hook_callback callback) override memory_access_hook_callback callback) override
{ {
auto read_wrapper = [c = std::move(callback)](uc_engine*, const uc_mem_type type, auto read_wrapper = [c = std::move(callback)](uc_engine*, const uc_mem_type type,
const uint64_t address, const int size, const uint64_t address, const int length,
const uint64_t value) { const uint64_t value) {
const auto operation = map_memory_operation(type); const auto operation = map_memory_operation(type);
if (operation == memory_operation::read && size > 0) if (operation == memory_operation::read && length > 0)
{ {
c(address, &value, std::min(static_cast<size_t>(size), sizeof(value))); c(address, &value, std::min(static_cast<size_t>(length), sizeof(value)));
} }
}; };
@@ -581,7 +581,7 @@ namespace unicorn
return container->as_opaque_hook(); return container->as_opaque_hook();
} }
emulator_hook* hook_memory_write(const uint64_t address, const size_t size, emulator_hook* hook_memory_write(const uint64_t address, const uint64_t size,
memory_access_hook_callback callback) override memory_access_hook_callback callback) override
{ {
auto write_wrapper = [c = std::move(callback)](uc_engine*, const uc_mem_type type, const uint64_t addr, auto write_wrapper = [c = std::move(callback)](uc_engine*, const uc_mem_type type, const uint64_t addr,

View File

@@ -55,8 +55,8 @@ class hook_interface
virtual emulator_hook* hook_memory_execution(memory_execution_hook_callback callback) = 0; virtual emulator_hook* hook_memory_execution(memory_execution_hook_callback callback) = 0;
virtual emulator_hook* hook_memory_execution(uint64_t address, memory_execution_hook_callback callback) = 0; virtual emulator_hook* hook_memory_execution(uint64_t address, memory_execution_hook_callback callback) = 0;
virtual emulator_hook* hook_memory_read(uint64_t address, size_t size, memory_access_hook_callback callback) = 0; virtual emulator_hook* hook_memory_read(uint64_t address, uint64_t size, memory_access_hook_callback callback) = 0;
virtual emulator_hook* hook_memory_write(uint64_t address, size_t size, memory_access_hook_callback callback) = 0; virtual emulator_hook* hook_memory_write(uint64_t address, uint64_t size, memory_access_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, instruction_hook_callback callback) = 0;