From 3b6779479e79c983f1df466c91c38714416a71ac Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Thu, 30 Mar 2017 15:59:13 +0800 Subject: [PATCH 01/14] cleanup uc_priv.h --- include/uc_priv.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/uc_priv.h b/include/uc_priv.h index 4a5311a3..1f87656c 100644 --- a/include/uc_priv.h +++ b/include/uc_priv.h @@ -60,8 +60,6 @@ typedef int (*uc_args_int_uc_t)(struct uc_struct*); typedef bool (*uc_args_tcg_enable_t)(struct uc_struct*); -typedef void (*uc_minit_t)(struct uc_struct*, ram_addr_t); - typedef void (*uc_args_uc_long_t)(struct uc_struct*, unsigned long); typedef void (*uc_args_uc_u64_t)(struct uc_struct *, uint64_t addr); From 4eca426fb6bb67d3fc76e07803390ec69b4707d1 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 30 Mar 2017 22:21:45 -0400 Subject: [PATCH 02/14] unicorn_aarch64: Expose UC_ARM64_REG_NZCV register. (#791) --- qemu/target-arm/unicorn_aarch64.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qemu/target-arm/unicorn_aarch64.c b/qemu/target-arm/unicorn_aarch64.c index 5b9980f1..9d94b64c 100644 --- a/qemu/target-arm/unicorn_aarch64.c +++ b/qemu/target-arm/unicorn_aarch64.c @@ -86,6 +86,9 @@ int arm64_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int co case UC_ARM64_REG_SP: *(int64_t *)value = ARM_CPU(uc, mycpu)->env.xregs[31]; break; + case UC_ARM64_REG_NZCV: + *(int32_t *)value = cpsr_read(&ARM_CPU(uc, mycpu)->env) & CPSR_NZCV; + break; } } } @@ -139,6 +142,9 @@ int arm64_reg_write(struct uc_struct *uc, unsigned int *regs, void* const* vals, case UC_ARM64_REG_SP: ARM_CPU(uc, mycpu)->env.xregs[31] = *(uint64_t *)value; break; + case UC_ARM64_REG_NZCV: + cpsr_write(&ARM_CPU(uc, mycpu)->env, *(uint32_t *) value, CPSR_NZCV); + break; } } } From d10737c9f853d78a9a383c70af2cfd672de2b286 Mon Sep 17 00:00:00 2001 From: Elias Bachaalany Date: Tue, 11 Apr 2017 17:50:02 -0700 Subject: [PATCH 03/14] Added .gitignore for VS 2015 (#794) --- samples/msvc/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 samples/msvc/.gitignore diff --git a/samples/msvc/.gitignore b/samples/msvc/.gitignore new file mode 100644 index 00000000..35015f90 --- /dev/null +++ b/samples/msvc/.gitignore @@ -0,0 +1,2 @@ +*.VC.db +*.VC.opendb \ No newline at end of file From 3315f288d380b6d0106cff6b222b43cd1e9d9c8a Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Wed, 12 Apr 2017 14:01:58 +0800 Subject: [PATCH 04/14] fix an warning in glib_compat.c --- qemu/glib_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu/glib_compat.c b/qemu/glib_compat.c index d800ea25..cea18d7e 100644 --- a/qemu/glib_compat.c +++ b/qemu/glib_compat.c @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #ifndef _WIN64 -#define GPOINTER_TO_UINT(p) ((guint) (p)) +#define GPOINTER_TO_UINT(p) ((guint)(uintptr_t)(p)) #else #define GPOINTER_TO_UINT(p) ((guint) (guint64) (p)) #endif From cb44f77ac3f70369760893aa584dbe4a73c3b302 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Wed, 12 Apr 2017 22:06:26 +0800 Subject: [PATCH 05/14] mips: fix uc_reg_read() for MIPS64 --- qemu/target-mips/unicorn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu/target-mips/unicorn.c b/qemu/target-mips/unicorn.c index 0aa63391..50294d6a 100644 --- a/qemu/target-mips/unicorn.c +++ b/qemu/target-mips/unicorn.c @@ -87,7 +87,7 @@ int mips_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int cou unsigned int regid = regs[i]; void *value = vals[i]; if (regid >= UC_MIPS_REG_0 && regid <= UC_MIPS_REG_31) - *(int32_t *)value = MIPS_CPU(uc, mycpu)->env.active_tc.gpr[regid - UC_MIPS_REG_0]; + *(mipsreg_t *)value = MIPS_CPU(uc, mycpu)->env.active_tc.gpr[regid - UC_MIPS_REG_0]; else { switch(regid) { default: break; From 605400e10ebcf37c6df1a7a3ca504fc1aa7f7e7e Mon Sep 17 00:00:00 2001 From: 0xSeb <0xSeb@users.noreply.github.com> Date: Fri, 14 Apr 2017 18:39:56 +0200 Subject: [PATCH 06/14] =?UTF-8?q?determine=20correct=20Thumb/Thumb2=20inst?= =?UTF-8?q?ruction=20size=20(16/32-bit)=20for=20code=20=E2=80=A6=20(#796)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * determine correct Thumb/Thumb2 instruction size (16/32-bit) for code hook * determine correct Thumb/Thumb2 instruction size (16/32-bit) for code hook * determine correct Thumb/Thumb2 instruction size (16/32-bit) for code hook --- qemu/target-arm/translate.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/qemu/target-arm/translate.c b/qemu/target-arm/translate.c index 2ac5f47d..84bba43c 100644 --- a/qemu/target-arm/translate.c +++ b/qemu/target-arm/translate.c @@ -10405,14 +10405,27 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) // qq } } + insn = arm_lduw_code(env, s->pc, s->bswap_code); + // Unicorn: trace this instruction on request if (HOOK_EXISTS_BOUNDED(s->uc, UC_HOOK_CODE, s->pc)) { - gen_uc_tracecode(tcg_ctx, 2, UC_HOOK_CODE_IDX, s->uc, s->pc); + // determine instruction size (Thumb/Thumb2) + switch(insn & 0xf800) { + // Thumb2: 32-bit + case 0xe800: + case 0xf000: + case 0xf800: + gen_uc_tracecode(tcg_ctx, 4, UC_HOOK_CODE_IDX, s->uc, s->pc); + break; + // Thumb: 16-bit + default: + gen_uc_tracecode(tcg_ctx, 2, UC_HOOK_CODE_IDX, s->uc, s->pc); + break; + } // the callback might want to stop emulation immediately check_exit_request(tcg_ctx); } - insn = arm_lduw_code(env, s->pc, s->bswap_code); s->pc += 2; switch (insn >> 12) { From 0948580acc0d11d49a3f1b223fcf8e64f6a89b04 Mon Sep 17 00:00:00 2001 From: Elias Bachaalany Date: Fri, 14 Apr 2017 18:35:09 -0700 Subject: [PATCH 07/14] Added more clarification to Windows compilation steps (#797) --- docs/COMPILE-WINDOWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/COMPILE-WINDOWS.md b/docs/COMPILE-WINDOWS.md index b5cf9a7d..0e292370 100644 --- a/docs/COMPILE-WINDOWS.md +++ b/docs/COMPILE-WINDOWS.md @@ -81,6 +81,9 @@ For each option, refer to docs/README for more details. [2] Compile from source on Windows - with MinGW (MSYS2) To compile with MinGW, install MSYS2 as instructed in the first section. + +Note: After MSYS2 is installed, you will have 3 shortcuts to open the command prompt: "MSYS2 MSYS", "MSYS2 MingGW-32 bit" and "MSYS2 MinGW 64-bit". Use the MinGW shortcut so that compilation succeeds. + Then, build Unicorn with the next steps: - To compile Windows 32-bit binary with MinGW, run: From d5cf6771a0ddd34dfcf1895fc1bbde91211894a4 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Mon, 17 Apr 2017 15:53:36 +0800 Subject: [PATCH 08/14] bump version to 1.0.1 --- pkgconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgconfig.mk b/pkgconfig.mk index b9680f3e..31ba340a 100644 --- a/pkgconfig.mk +++ b/pkgconfig.mk @@ -7,7 +7,7 @@ PKG_MAJOR = 1 PKG_MINOR = 0 # version bugfix level. Example: PKG_EXTRA = 1 -PKG_EXTRA = 0 +PKG_EXTRA = 1 # version tag. Examples: rc1, b2, post1 PKG_TAG = From 4f07910eae5a9e6198dc5818fc6092991991e184 Mon Sep 17 00:00:00 2001 From: tylerni7 Date: Mon, 17 Apr 2017 16:44:48 -0700 Subject: [PATCH 09/14] handle not having a path (#798) --- bindings/python/unicorn/unicorn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/unicorn/unicorn.py b/bindings/python/unicorn/unicorn.py index fa50ad1f..fd708412 100644 --- a/bindings/python/unicorn/unicorn.py +++ b/bindings/python/unicorn/unicorn.py @@ -82,7 +82,7 @@ _path_list = [pkg_resources.resource_filename(__name__, 'lib'), '', distutils.sysconfig.get_python_lib(), "/usr/local/lib/" if sys.platform == 'darwin' else '/usr/lib64', - os.environ['PATH']] + os.getenv('PATH','')] #print(_path_list) #print("-" * 80) From 7441cfe4e55d1719912e38565ef7e3bca95a1b6b Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 18 Apr 2017 07:46:12 +0800 Subject: [PATCH 10/14] Update unicorn.py space --- bindings/python/unicorn/unicorn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/unicorn/unicorn.py b/bindings/python/unicorn/unicorn.py index fd708412..0a21c15d 100644 --- a/bindings/python/unicorn/unicorn.py +++ b/bindings/python/unicorn/unicorn.py @@ -82,7 +82,7 @@ _path_list = [pkg_resources.resource_filename(__name__, 'lib'), '', distutils.sysconfig.get_python_lib(), "/usr/local/lib/" if sys.platform == 'darwin' else '/usr/lib64', - os.getenv('PATH','')] + os.getenv('PATH', '')] #print(_path_list) #print("-" * 80) From f713021bc0e242a305dcf4c1f018c53e284fd372 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 18 Apr 2017 23:29:51 +0800 Subject: [PATCH 11/14] update Changelog for 1.0.1 --- ChangeLog | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4fba368a..d3d9d04e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ This file details the changelog of Unicorn Engine. +---------------------------------- +[Version 1.0.1]: April, 2017 + +- Properly handle selected-architecture build. +- Fix compilation issues on PPC & S390x. +- Fix a memory leak on uc_mem_protect(). +- Support ARM big-endian. +- ARM: + - Correct instruction size of Thumb/Thumb2 code. + - Support read/write APSR register. +- ARM64: + - Support read/write NEON registers. + - Support read/write NZCV registers. +- Mips: Support read/write Mips64 registers. +- X86: Support read/write MSR. +- Haskell binding: update to the latest API. +- Python: allow not having PATH setup. + ---------------------------------- [Version 1.0]: February 23rd, 2017 From 65a8c88f16820376217b7735c0b90147d5774466 Mon Sep 17 00:00:00 2001 From: Elias Bachaalany Date: Tue, 18 Apr 2017 23:04:52 -0700 Subject: [PATCH 12/14] Fixed minor typo (#799) --- docs/COMPILE-WINDOWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/COMPILE-WINDOWS.md b/docs/COMPILE-WINDOWS.md index 0e292370..6ddfd467 100644 --- a/docs/COMPILE-WINDOWS.md +++ b/docs/COMPILE-WINDOWS.md @@ -82,7 +82,7 @@ For each option, refer to docs/README for more details. To compile with MinGW, install MSYS2 as instructed in the first section. -Note: After MSYS2 is installed, you will have 3 shortcuts to open the command prompt: "MSYS2 MSYS", "MSYS2 MingGW-32 bit" and "MSYS2 MinGW 64-bit". Use the MinGW shortcut so that compilation succeeds. +Note: After MSYS2 is installed, you will have 3 shortcuts to open the command prompt: "MSYS2 MSYS", "MSYS2 MinGW-32 bit" and "MSYS2 MinGW 64-bit". Use the MinGW shortcut so that compilation succeeds. Then, build Unicorn with the next steps: From a709e68dce3b6df1904410cb1eba78e4f6a6f958 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Thu, 20 Apr 2017 13:28:02 +0800 Subject: [PATCH 13/14] update ChangeLog --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3d9d04e..8ff87b51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,13 @@ This file details the changelog of Unicorn Engine. ---------------------------------- -[Version 1.0.1]: April, 2017 +[Version 1.0.1]: April 20th, 2017 - Properly handle selected-architecture build. - Fix compilation issues on PPC & S390x. - Fix a memory leak on uc_mem_protect(). -- Support ARM big-endian. - ARM: + - Support big-endian mode. - Correct instruction size of Thumb/Thumb2 code. - Support read/write APSR register. - ARM64: From 5dbc640b9a2dae735fb663ede90f3900ad43f6d5 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Thu, 20 Apr 2017 14:14:24 +0800 Subject: [PATCH 14/14] bump UC_VERSION_EXTRA to 1 --- bindings/dotnet/UnicornManaged/Const/Common.fs | 3 +-- bindings/go/unicorn/unicorn_const.go | 3 +-- bindings/java/unicorn/UnicornConst.java | 3 +-- bindings/python/unicorn/unicorn_const.py | 3 +-- bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb | 3 +-- include/unicorn/unicorn.h | 2 +- 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/bindings/dotnet/UnicornManaged/Const/Common.fs b/bindings/dotnet/UnicornManaged/Const/Common.fs index 8fbc08c0..67a22e17 100644 --- a/bindings/dotnet/UnicornManaged/Const/Common.fs +++ b/bindings/dotnet/UnicornManaged/Const/Common.fs @@ -12,8 +12,7 @@ module Common = let UC_VERSION_MAJOR = 1 let UC_VERSION_MINOR = 0 - - let UC_VERSION_EXTRA = 0 + let UC_VERSION_EXTRA = 1 let UC_SECOND_SCALE = 1000000 let UC_MILISECOND_SCALE = 1000 let UC_ARCH_ARM = 1 diff --git a/bindings/go/unicorn/unicorn_const.go b/bindings/go/unicorn/unicorn_const.go index 9d782142..c5c2441d 100644 --- a/bindings/go/unicorn/unicorn_const.go +++ b/bindings/go/unicorn/unicorn_const.go @@ -7,8 +7,7 @@ const ( VERSION_MAJOR = 1 VERSION_MINOR = 0 - - VERSION_EXTRA = 0 + VERSION_EXTRA = 1 SECOND_SCALE = 1000000 MILISECOND_SCALE = 1000 ARCH_ARM = 1 diff --git a/bindings/java/unicorn/UnicornConst.java b/bindings/java/unicorn/UnicornConst.java index 9dd4d669..3002281a 100644 --- a/bindings/java/unicorn/UnicornConst.java +++ b/bindings/java/unicorn/UnicornConst.java @@ -9,8 +9,7 @@ public interface UnicornConst { public static final int UC_VERSION_MAJOR = 1; public static final int UC_VERSION_MINOR = 0; - - public static final int UC_VERSION_EXTRA = 0; + public static final int UC_VERSION_EXTRA = 1; public static final int UC_SECOND_SCALE = 1000000; public static final int UC_MILISECOND_SCALE = 1000; public static final int UC_ARCH_ARM = 1; diff --git a/bindings/python/unicorn/unicorn_const.py b/bindings/python/unicorn/unicorn_const.py index 32201f68..7e7ab0e5 100644 --- a/bindings/python/unicorn/unicorn_const.py +++ b/bindings/python/unicorn/unicorn_const.py @@ -5,8 +5,7 @@ UC_API_MINOR = 0 UC_VERSION_MAJOR = 1 UC_VERSION_MINOR = 0 - -UC_VERSION_EXTRA = 0 +UC_VERSION_EXTRA = 1 UC_SECOND_SCALE = 1000000 UC_MILISECOND_SCALE = 1000 UC_ARCH_ARM = 1 diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb index 81068a6e..8848e1d3 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb @@ -7,8 +7,7 @@ module Unicorn UC_VERSION_MAJOR = 1 UC_VERSION_MINOR = 0 - - UC_VERSION_EXTRA = 0 + UC_VERSION_EXTRA = 1 UC_SECOND_SCALE = 1000000 UC_MILISECOND_SCALE = 1000 UC_ARCH_ARM = 1 diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index 40cb9930..04e6a773 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -70,7 +70,7 @@ typedef size_t uc_hook; // Unicorn package version #define UC_VERSION_MAJOR UC_API_MAJOR #define UC_VERSION_MINOR UC_API_MINOR -#define UC_VERSION_EXTRA 0 +#define UC_VERSION_EXTRA 1 /*