From 77d4a1d8b11b17d580e489cd6136c0fa44f0995f Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Sat, 13 May 2023 00:56:07 -0700 Subject: [PATCH] Fix definition of uc_version --- bindings/java/unicorn/Unicorn.java | 6 +++--- include/unicorn/unicorn.h | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/bindings/java/unicorn/Unicorn.java b/bindings/java/unicorn/Unicorn.java index f1f1cb8f..f2840cce 100644 --- a/bindings/java/unicorn/Unicorn.java +++ b/bindings/java/unicorn/Unicorn.java @@ -161,9 +161,9 @@ public class Unicorn /** * Return combined API version & major and minor version numbers. * - * @return version number as {@code (major << 8 | minor)}, which encodes - * both major & minor versions. - * For example, Unicorn version 1.2 would yield 0x0102. + * @return version number as {@code (major << 24 | minor << 16 | + * patch << 8 | extra)}. + * For example, Unicorn version 2.0.1 final would be 0x020001ff. */ public static int version() { return _version(); diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index 3814b8e0..c170029b 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -86,7 +86,7 @@ typedef size_t uc_hook; Macro to create combined version which can be compared to result of uc_version() API. */ -#define UC_MAKE_VERSION(major, minor) ((major << 8) + minor) +#define UC_MAKE_VERSION(major, minor) (((major) << 24) + ((minor) << 16)) // Scales to calculate timeout on microsecond unit // 1 second = 1000,000 microseconds @@ -673,13 +673,11 @@ typedef struct uc_context uc_context; @major: major number of API version @minor: minor number of API version - @return hexical number as (major << 8 | minor), which encodes both - major & minor versions. + @return hexadecimal number as (major << 24 | minor << 16 | patch << 8 | extra). NOTE: This returned value can be compared with version number made with macro UC_MAKE_VERSION - For example, second API version would return 1 in @major, and 1 in @minor - The return value would be 0x0101 + For example, Unicorn version 2.0.1 final would be 0x020001ff. NOTE: if you only care about returned value, but not major and minor values, set both @major & @minor arguments to NULL.