new API uc_mem_regions() to retrieve the list of memory regions mapped by uc_mem_map_*()
This commit is contained in:
28
uc.c
28
uc.c
@ -1138,3 +1138,31 @@ uc_err uc_hook_del(uc_engine *uc, uc_hook hh)
|
||||
{
|
||||
return hook_del(uc, hh);
|
||||
}
|
||||
|
||||
UNICORN_EXPORT
|
||||
uint32_t uc_mem_regions(uc_engine *uc, uc_mem_region **regions, uint32_t *count)
|
||||
{
|
||||
uint32_t i;
|
||||
uc_mem_region *r = NULL;
|
||||
|
||||
*count = uc->mapped_block_count;
|
||||
|
||||
if (*count) {
|
||||
r = malloc(*count * sizeof(uc_mem_region));
|
||||
if (r == NULL) {
|
||||
// out of memory
|
||||
return UC_ERR_NOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < *count; i++) {
|
||||
r[i].begin = uc->mapped_blocks[i]->addr;
|
||||
r[i].end = uc->mapped_blocks[i]->end - 1;
|
||||
r[i].perms = uc->mapped_blocks[i]->perms;
|
||||
}
|
||||
|
||||
*regions = r;
|
||||
|
||||
return UC_ERR_OK;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user