From 54870cca0ec31c31db3c957dfd471e87b7733a87 Mon Sep 17 00:00:00 2001 From: "Takacs, Philipp" Date: Mon, 8 May 2023 15:32:58 +0200 Subject: [PATCH 1/2] remove unused function cmp_vaddr --- uc.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/uc.c b/uc.c index 0a8626cf..0b464a4d 100644 --- a/uc.c +++ b/uc.c @@ -2384,16 +2384,6 @@ uc_err uc_ctl(uc_engine *uc, uc_control_type control, ...) return err; } -gint cmp_vaddr(gconstpointer a, gconstpointer b, gpointer user_data) -{ - uint64_t va = (uint64_t)a; - uint64_t vb = (uint64_t)b; - if (va == vb) { - return 0; - } - return va < vb ? -1 : 1; -} - #ifdef UNICORN_TRACER uc_tracer *get_tracer() { From 227e578660b1ca1c4158970eecb4cb4376855b32 Mon Sep 17 00:00:00 2001 From: "Takacs, Philipp" Date: Mon, 8 May 2023 15:38:43 +0200 Subject: [PATCH 2/2] move typedef definition of enum uc_mem_type forword references to enum types are forbidden in C. Also C++ will not build if this is used --- include/unicorn/unicorn.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index ed016dc0..feae9eea 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -245,7 +245,19 @@ typedef void (*uc_cb_insn_out_t)(uc_engine *uc, uint32_t port, int size, uint32_t value, void *user_data); typedef struct uc_tlb_entry uc_tlb_entry; -typedef enum uc_mem_type uc_mem_type; +// All type of memory accesses for UC_HOOK_MEM_* +typedef enum uc_mem_type { + UC_MEM_READ = 16, // Memory is read from + UC_MEM_WRITE, // Memory is written to + UC_MEM_FETCH, // Memory is fetched + UC_MEM_READ_UNMAPPED, // Unmapped memory is read from + UC_MEM_WRITE_UNMAPPED, // Unmapped memory is written to + UC_MEM_FETCH_UNMAPPED, // Unmapped memory is fetched + UC_MEM_WRITE_PROT, // Write to write protected, but mapped, memory + UC_MEM_READ_PROT, // Read from read protected, but mapped, memory + UC_MEM_FETCH_PROT, // Fetch from non-executable, but mapped, memory + UC_MEM_READ_AFTER, // Memory is read from (successful access) +} uc_mem_type; /* Callback function for tlb lookups @@ -310,20 +322,6 @@ typedef void (*uc_cb_mmio_write_t)(uc_engine *uc, uint64_t offset, unsigned size, uint64_t value, void *user_data); -// All type of memory accesses for UC_HOOK_MEM_* -enum uc_mem_type { - UC_MEM_READ = 16, // Memory is read from - UC_MEM_WRITE, // Memory is written to - UC_MEM_FETCH, // Memory is fetched - UC_MEM_READ_UNMAPPED, // Unmapped memory is read from - UC_MEM_WRITE_UNMAPPED, // Unmapped memory is written to - UC_MEM_FETCH_UNMAPPED, // Unmapped memory is fetched - UC_MEM_WRITE_PROT, // Write to write protected, but mapped, memory - UC_MEM_READ_PROT, // Read from read protected, but mapped, memory - UC_MEM_FETCH_PROT, // Fetch from non-executable, but mapped, memory - UC_MEM_READ_AFTER, // Memory is read from (successful access) -}; - // These are all op codes we support to hook for UC_HOOK_TCG_OP_CODE. // Be cautious since it may bring much more overhead than UC_HOOK_CODE without // proper flags.