Merge pull request #450 from nplanel/query-page-size
[query] add UC_QUERY_PAGE_SIZE uc_query helper
This commit is contained in:
commit
ddba377bd8
@ -93,6 +93,7 @@ module Common =
|
||||
let UC_HOOK_MEM_INVALID = 1008
|
||||
let UC_HOOK_MEM_VALID = 7168
|
||||
let UC_QUERY_MODE = 1
|
||||
let UC_QUERY_PAGE_SIZE = 2
|
||||
|
||||
let UC_PROT_NONE = 0
|
||||
let UC_PROT_READ = 1
|
||||
|
@ -88,6 +88,7 @@ const (
|
||||
HOOK_MEM_INVALID = 1008
|
||||
HOOK_MEM_VALID = 7168
|
||||
QUERY_MODE = 1
|
||||
QUERY_PAGE_SIZE = 2
|
||||
|
||||
PROT_NONE = 0
|
||||
PROT_READ = 1
|
||||
|
@ -90,6 +90,7 @@ public interface UnicornConst {
|
||||
public static final int UC_HOOK_MEM_INVALID = 1008;
|
||||
public static final int UC_HOOK_MEM_VALID = 7168;
|
||||
public static final int UC_QUERY_MODE = 1;
|
||||
public static final int UC_QUERY_PAGE_SIZE = 2;
|
||||
|
||||
public static final int UC_PROT_NONE = 0;
|
||||
public static final int UC_PROT_READ = 1;
|
||||
|
@ -86,6 +86,7 @@ UC_HOOK_MEM_FETCH_INVALID = 576
|
||||
UC_HOOK_MEM_INVALID = 1008
|
||||
UC_HOOK_MEM_VALID = 7168
|
||||
UC_QUERY_MODE = 1
|
||||
UC_QUERY_PAGE_SIZE = 2
|
||||
|
||||
UC_PROT_NONE = 0
|
||||
UC_PROT_READ = 1
|
||||
|
@ -262,6 +262,7 @@ typedef struct uc_mem_region {
|
||||
typedef enum uc_query_type {
|
||||
// Dynamically query current hardware mode.
|
||||
UC_QUERY_MODE = 1,
|
||||
UC_QUERY_PAGE_SIZE,
|
||||
} uc_query_type;
|
||||
|
||||
/*
|
||||
|
@ -158,6 +158,15 @@ static void test_strange_map(void **state)
|
||||
uc_mem_unmap(uc, 0x0,0x1000);
|
||||
}
|
||||
|
||||
static void test_query_page_size(void **state)
|
||||
{
|
||||
uc_engine *uc = *state;
|
||||
|
||||
size_t page_size;
|
||||
uc_assert_success(uc_query(uc, UC_QUERY_PAGE_SIZE, &page_size));
|
||||
assert_int_equal(4096, page_size);
|
||||
}
|
||||
|
||||
void write(uc_engine* uc, uint64_t addr, uint64_t len){
|
||||
uint8_t* buff = alloca(len);
|
||||
memset(buff,0,len);
|
||||
@ -220,6 +229,7 @@ int main(void) {
|
||||
test(test_unmap_double_map),
|
||||
test(test_overlap_unmap_double_map),
|
||||
test(test_strange_map),
|
||||
test(test_query_page_size),
|
||||
};
|
||||
#undef test
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
|
5
uc.c
5
uc.c
@ -1094,6 +1094,11 @@ uint32_t uc_mem_regions(uc_engine *uc, uc_mem_region **regions, uint32_t *count)
|
||||
UNICORN_EXPORT
|
||||
uc_err uc_query(uc_engine *uc, uc_query_type type, size_t *result)
|
||||
{
|
||||
if (type == UC_QUERY_PAGE_SIZE) {
|
||||
*result = uc->target_page_size;
|
||||
return UC_ERR_OK;
|
||||
}
|
||||
|
||||
switch(uc->arch) {
|
||||
case UC_ARCH_ARM:
|
||||
return uc->query(uc, type, result);
|
||||
|
Loading…
Reference in New Issue
Block a user