aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRot127 <45763064+Rot127@users.noreply.github.com>2024-04-30 02:35:40 +0000
committerGitHub <noreply@github.com>2024-04-30 10:35:40 +0800
commitb2d5b43ed21dfece72b3e942785efc1af54b7eb2 (patch)
tree46e5f6efb69a25dcdb686b19db53a52d73157877
parenteb4fc2d7612db10379adf7aeb287a7923dcc0fc7 (diff)
downloadcapstone-b2d5b43ed21dfece72b3e942785efc1af54b7eb2.tar.gz
Fix #2079 via the post-printer. (#2330)
-rw-r--r--arch/X86/X86Mapping.c23
-rw-r--r--arch/X86/X86Mapping.h2
-rw-r--r--arch/X86/X86Module.c2
-rw-r--r--suite/cstest/issues.cs4
4 files changed, 30 insertions, 1 deletions
diff --git a/arch/X86/X86Mapping.c b/arch/X86/X86Mapping.c
index d23340d7..a5b87290 100644
--- a/arch/X86/X86Mapping.c
+++ b/arch/X86/X86Mapping.c
@@ -2244,4 +2244,27 @@ unsigned short X86_register_map(unsigned short id)
return 0;
}
+/// The post-printer function. Used to fixup flaws in the disassembly information
+/// of certain instructions.
+void X86_postprinter(csh handle, cs_insn *insn, char *mnem, MCInst *mci) {
+ if (!insn || !insn->detail) {
+ return;
+ }
+ switch (insn->id) {
+ default:
+ break;
+ case X86_INS_RCL:
+ // Addmissing 1 immediate
+ if (insn->detail->x86.op_count > 1) {
+ return;
+ }
+ insn->detail->x86.operands[1].imm = 1;
+ insn->detail->x86.operands[1].type = X86_OP_IMM;
+ insn->detail->x86.operands[1].access = CS_AC_READ;
+ insn->detail->x86.op_count++;
+ break;
+ }
+}
+
+
#endif
diff --git a/arch/X86/X86Mapping.h b/arch/X86/X86Mapping.h
index 89bbfcd8..c6dc4037 100644
--- a/arch/X86/X86Mapping.h
+++ b/arch/X86/X86Mapping.h
@@ -91,4 +91,6 @@ unsigned short X86_register_map(unsigned short id);
unsigned int find_insn(unsigned int id);
+void X86_postprinter(csh handle, cs_insn *insn, char *mnem, MCInst *mci);
+
#endif
diff --git a/arch/X86/X86Module.c b/arch/X86/X86Module.c
index 2ec5625d..ed080a79 100644
--- a/arch/X86/X86Module.c
+++ b/arch/X86/X86Module.c
@@ -26,7 +26,7 @@ cs_err X86_global_init(cs_struct *ud)
ud->insn_id = X86_get_insn_id;
ud->insn_name = X86_insn_name;
ud->group_name = X86_group_name;
- ud->post_printer = NULL;
+ ud->post_printer = X86_postprinter;
#ifndef CAPSTONE_DIET
ud->reg_access = X86_reg_access;
#endif
diff --git a/suite/cstest/issues.cs b/suite/cstest/issues.cs
index 567e6078..614470c9 100644
--- a/suite/cstest/issues.cs
+++ b/suite/cstest/issues.cs
@@ -1070,3 +1070,7 @@
!# issue 2128
!# CS_ARCH_X86, CS_MODE_64, CS_OPT_DETAIL
0x0: 0x4c,0x85,0x7d,0x30 == test qword ptr [rbp + 0x30], r15 ; operands[1].type: REG = r15 ; operands[1].access: READ ; Registers read: rbp r15 ; Registers modified: rflags
+
+!# issue 2079
+!# CS_ARCH_X86, CS_MODE_32, CS_OPT_DETAIL
+0x0: 0xd1,0x10 == rcl dword ptr [eax] ; operands[1].type: IMM = 0x1