add architecture query (#842)

This commit is contained in:
misson20000 2017-05-20 18:47:02 -07:00 committed by Nguyen Anh Quynh
parent 14222bd5f0
commit 3fdb2d2442
7 changed files with 11 additions and 0 deletions

View file

@ -101,6 +101,7 @@ module Common =
let UC_HOOK_MEM_VALID = 7168
let UC_QUERY_MODE = 1
let UC_QUERY_PAGE_SIZE = 2
let UC_QUERY_ARCH = 3
let UC_PROT_NONE = 0
let UC_PROT_READ = 1

View file

@ -96,6 +96,7 @@ const (
HOOK_MEM_VALID = 7168
QUERY_MODE = 1
QUERY_PAGE_SIZE = 2
QUERY_ARCH = 3
PROT_NONE = 0
PROT_READ = 1

View file

@ -98,6 +98,7 @@ public interface UnicornConst {
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_QUERY_ARCH = 3;
public static final int UC_PROT_NONE = 0;
public static final int UC_PROT_READ = 1;

View file

@ -94,6 +94,7 @@ UC_HOOK_MEM_INVALID = 1008
UC_HOOK_MEM_VALID = 7168
UC_QUERY_MODE = 1
UC_QUERY_PAGE_SIZE = 2
UC_QUERY_ARCH = 3
UC_PROT_NONE = 0
UC_PROT_READ = 1

View file

@ -96,6 +96,7 @@ module Unicorn
UC_HOOK_MEM_VALID = 7168
UC_QUERY_MODE = 1
UC_QUERY_PAGE_SIZE = 2
UC_QUERY_ARCH = 3
UC_PROT_NONE = 0
UC_PROT_READ = 1

View file

@ -305,6 +305,7 @@ typedef enum uc_query_type {
// Dynamically query current hardware mode.
UC_QUERY_MODE = 1,
UC_QUERY_PAGE_SIZE,
UC_QUERY_ARCH,
} uc_query_type;
// Opaque storage for CPU context, used with uc_context_*()

5
uc.c
View file

@ -1155,6 +1155,11 @@ uc_err uc_query(uc_engine *uc, uc_query_type type, size_t *result)
return UC_ERR_OK;
}
if (type == UC_QUERY_ARCH) {
*result = uc->arch;
return UC_ERR_OK;
}
switch(uc->arch) {
#ifdef UNICORN_HAS_ARM
case UC_ARCH_ARM: