diff --git a/bindings/dotnet/UnicornManaged/Const/Common.fs b/bindings/dotnet/UnicornManaged/Const/Common.fs index d5f9b986..e09cb41f 100644 --- a/bindings/dotnet/UnicornManaged/Const/Common.fs +++ b/bindings/dotnet/UnicornManaged/Const/Common.fs @@ -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 diff --git a/bindings/go/unicorn/unicorn_const.go b/bindings/go/unicorn/unicorn_const.go index f0214809..91c706d5 100644 --- a/bindings/go/unicorn/unicorn_const.go +++ b/bindings/go/unicorn/unicorn_const.go @@ -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 diff --git a/bindings/java/unicorn/UnicornConst.java b/bindings/java/unicorn/UnicornConst.java index c83ac9d8..fe399839 100644 --- a/bindings/java/unicorn/UnicornConst.java +++ b/bindings/java/unicorn/UnicornConst.java @@ -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; diff --git a/bindings/python/unicorn/unicorn_const.py b/bindings/python/unicorn/unicorn_const.py index 35d0a5ef..1e7134b1 100644 --- a/bindings/python/unicorn/unicorn_const.py +++ b/bindings/python/unicorn/unicorn_const.py @@ -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 diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb index 2d5d77a0..e8f37908 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb @@ -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 diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index 9dde3378..36b1b263 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -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_*() diff --git a/uc.c b/uc.c index 192b67d0..40466940 100644 --- a/uc.c +++ b/uc.c @@ -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: