Skip to content

Commit

Permalink
Fix #2079 via the post-printer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Apr 23, 2024
1 parent c4d0993 commit 4848082
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions arch/X86/X86Mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions arch/X86/X86Mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion arch/X86/X86Module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4848082

Please sign in to comment.