From f9b9dfbce99fbc7e2f260180302dd3a4fb03e3d3 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Mon, 24 Aug 2015 00:52:00 +0800 Subject: [PATCH] fix issue #9 --- include/unicorn/unicorn.h | 1 + uc.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index 68b20e67..474c6afe 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -392,6 +392,7 @@ uc_err uc_hook_del(uch handle, uch *h2); @handle: handle returned by uc_open() @address: starting address of the new memory region to be mapped in. + This address will be round down to 8KB boundary @size: size of the new memory region to be mapped in. This will be round up to the next 8KB boundary. diff --git a/uc.c b/uc.c index 9cfbeb32..c9043750 100644 --- a/uc.c +++ b/uc.c @@ -553,7 +553,7 @@ uc_err uc_mem_map(uch handle, uint64_t address, size_t size) return UC_ERR_UCH; // align to 8KB boundary - map_begin[map_count] = address & (~ (8*1024)); + map_begin[map_count] = address & (~ (8*1024 - 1)); s = (size + 8*1024 - 1) & (~ (8*1024)); map_end[map_count] = s + map_begin[map_count]; uc->memory_map(uc, map_begin[map_count], s);