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);