From 7cad7bc51d86fb5c1062b45583b6ec2678536f95 Mon Sep 17 00:00:00 2001 From: Rot127 Date: Tue, 23 Apr 2024 17:49:51 -0500 Subject: [PATCH] Fix #2244: The offset for pseudo-instr. IDs was incorrectly applied for vcmp. --- cs.c | 2 +- suite/cstest/issues.cs | 4 ++++ suite/cstest/src/x86_detail.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cs.c b/cs.c index 65f89b8e5b..fc74d7ccfd 100644 --- a/cs.c +++ b/cs.c @@ -1209,7 +1209,7 @@ size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64 fill_insn(handle, insn_cache, ss.buffer, &mci, handle->post_printer, buffer); // adjust for pseudo opcode (X86) - if (handle->arch == CS_ARCH_X86) + if (handle->arch == CS_ARCH_X86 && insn_cache->id != X86_INS_VCMP) insn_cache->id += mci.popcode_adjust; next_offset = insn_size; diff --git a/suite/cstest/issues.cs b/suite/cstest/issues.cs index 614470c958..d5da72c21e 100644 --- a/suite/cstest/issues.cs +++ b/suite/cstest/issues.cs @@ -1074,3 +1074,7 @@ !# issue 2079 !# CS_ARCH_X86, CS_MODE_32, CS_OPT_DETAIL 0x0: 0xd1,0x10 == rcl dword ptr [eax] ; operands[1].type: IMM = 0x1 + +!# issue 2244 +!# CS_ARCH_X86, CS_MODE_64, CS_OPT_DETAIL +0x0: 0xc5,0xfb,0xc2,0xda,0x06 == vcmpnlesd xmm3, xmm0, xmm2 ; ID: 797 diff --git a/suite/cstest/src/x86_detail.c b/suite/cstest/src/x86_detail.c index f5456877c2..9d02bf7cc1 100644 --- a/suite/cstest/src/x86_detail.c +++ b/suite/cstest/src/x86_detail.c @@ -203,6 +203,7 @@ char *get_detail_x86(csh *ud, cs_mode mode, cs_insn *ins) x86 = &(ins->detail->x86); + add_str(&result, " ; ID: %" PRIu32 , ins->id); print_string_hex(&result, " ; Prefix:", x86->prefix, 4); print_string_hex(&result, " ; Opcode:", x86->opcode, 4); add_str(&result, " ; rex: 0x%x", x86->rex);