From b31bb9638c730b340c535ef3cd07e83f5eb2a3f5 Mon Sep 17 00:00:00 2001 From: Chris Eagle Date: Fri, 28 Aug 2015 00:00:09 -0700 Subject: [PATCH] cleanup for pull request --- {regress => samples}/mem_protect.c | 12 ++++++++---- uc.c | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) rename {regress => samples}/mem_protect.c (98%) diff --git a/regress/mem_protect.c b/samples/mem_protect.c similarity index 98% rename from regress/mem_protect.c rename to samples/mem_protect.c index 183a388c..e4c09201 100755 --- a/regress/mem_protect.c +++ b/samples/mem_protect.c @@ -70,7 +70,8 @@ static int log_num = 1; static uint32_t current_perms = UC_PROT_READ | UC_PROT_WRITE; -static void hexdump(const char *prefix, const uint8_t *bytes, uint32_t len) { +static void hexdump(const char *prefix, const uint8_t *bytes, uint32_t len) +{ uint32_t i; printf("%s", prefix); for (i = 0; i < len; i++) { @@ -80,7 +81,8 @@ static void hexdump(const char *prefix, const uint8_t *bytes, uint32_t len) { } // callback for tracing instruction -static void hook_code(uch handle, uint64_t addr, uint32_t size, void *user_data) { +static void hook_code(uch handle, uint64_t addr, uint32_t size, void *user_data) +{ uint8_t opcode; uint8_t bytes[5]; if (uc_mem_read(handle, addr, &opcode, 1) != UC_ERR_OK) { @@ -130,7 +132,8 @@ static void hook_code(uch handle, uint64_t addr, uint32_t size, void *user_data) // callback for tracing memory access (READ or WRITE) static bool hook_mem_invalid(uch handle, uc_mem_type type, - uint64_t addr, int size, int64_t value, void *user_data) { + uint64_t addr, int size, int64_t value, void *user_data) +{ uint8_t bytes[5]; switch(type) { default: @@ -166,7 +169,8 @@ static bool hook_mem_invalid(uch handle, uc_mem_type type, } } -int main(int argc, char **argv, char **envp) { +int main(int argc, char **argv, char **envp) +{ uch handle, trace1, trace2; uc_err err; uint8_t bytes[8]; diff --git a/uc.c b/uc.c index fdd968a9..d219b7ba 100755 --- a/uc.c +++ b/uc.c @@ -31,6 +31,8 @@ #include "qemu/include/hw/boards.h" +static MemoryRegion *getMemoryBlock(struct uc_struct *uc, uint64_t address); + UNICORN_EXPORT unsigned int uc_version(unsigned int *major, unsigned int *minor) { @@ -353,8 +355,8 @@ uc_err uc_mem_read(uch handle, uint64_t address, uint8_t *bytes, size_t size) return UC_ERR_OK; } -static MemoryRegion *getMemoryBlock(struct uc_struct *uc, uint64_t address); -static MemoryRegion *getMemoryBlock(struct uc_struct *uc, uint64_t address) { +static MemoryRegion *getMemoryBlock(struct uc_struct *uc, uint64_t address) +{ unsigned int i; for(i = 0; i < uc->mapped_block_count; i++) {