x86: handle outs instruction in 16bit mode
This commit is contained in:
parent
4d85f29e08
commit
a01d1546d6
|
@ -734,7 +734,7 @@ static void printVectorList(MCInst *MI, unsigned OpNum,
|
|||
#define PRINT_ALIAS_INSTR
|
||||
#include "AArch64GenAsmWriter.inc"
|
||||
|
||||
void AArch64_post_printer(unsigned int insn, cs_insn *pub_insn, const char *insn_asm)
|
||||
void AArch64_post_printer(cs_insn *pub_insn, char *insn_asm)
|
||||
{
|
||||
// check if this insn requests write-back
|
||||
if (strrchr(insn_asm, '!') != NULL)
|
||||
|
|
|
@ -23,6 +23,6 @@
|
|||
|
||||
void AArch64_printInst(MCInst *MI, SStream *O, void *);
|
||||
|
||||
void AArch64_post_printer(unsigned int insn, cs_insn *pub_insn, const char *insn_asm);
|
||||
void AArch64_post_printer(cs_insn *pub_insn, char *insn_asm);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -219,7 +219,7 @@ static name_map insn_update_flgs[] = {
|
|||
{ ARM_INS_UMULL, "umulls" },
|
||||
};
|
||||
|
||||
void ARM_post_printer(unsigned int insn, cs_insn *pub_insn, const char *insn_asm)
|
||||
void ARM_post_printer(cs_insn *pub_insn, char *insn_asm)
|
||||
{
|
||||
// check if this insn requests write-back
|
||||
if (strrchr(insn_asm, '!') != NULL) {
|
||||
|
@ -232,7 +232,7 @@ void ARM_post_printer(unsigned int insn, cs_insn *pub_insn, const char *insn_asm
|
|||
int i;
|
||||
|
||||
for (i = 0; i < ARR_SIZE(insn_update_flgs); i++) {
|
||||
if (insn == insn_update_flgs[i].id &&
|
||||
if (pub_insn->id == insn_update_flgs[i].id &&
|
||||
!strncmp(insn_asm, insn_update_flgs[i].name,
|
||||
strlen(insn_update_flgs[i].name))) {
|
||||
pub_insn->arm.update_flags = true;
|
||||
|
|
|
@ -22,6 +22,6 @@
|
|||
#include "../../SStream.h"
|
||||
|
||||
void ARM_printInst(MCInst *MI, SStream *O, void *Info);
|
||||
void ARM_post_printer(unsigned int insn, cs_insn *pub_insn, const char *mnem);
|
||||
void ARM_post_printer(cs_insn *pub_insn, char *mnem);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -208,10 +208,6 @@ static bool printAliasInstr(MCInst *MI, SStream *OS);
|
|||
static void printInstruction(MCInst *MI, SStream *O);
|
||||
void X86_Intel_printInst(MCInst *MI, SStream *O, void *Info)
|
||||
{
|
||||
//const MCInstrDesc &Desc = MII.get(MI->getOpcode());
|
||||
// FIXME: target-specified flags need to be handled here
|
||||
//uint64_t TSFlags = Desc.TSFlags;
|
||||
|
||||
//if (TSFlags & X86II::LOCK)
|
||||
// O << "\tlock\n";
|
||||
|
||||
|
|
|
@ -6590,6 +6590,21 @@ static insn_map insns[] = {
|
|||
{ X86_XTEST, X86_INS_XTEST, { 0 }, { X86_REG_EFLAGS, 0 }, { 0 }, 0, 0 },
|
||||
};
|
||||
|
||||
// post printer for X86. put all the hacky stuff here
|
||||
void X86_post_printer(cs_insn *insn, char *insn_asm)
|
||||
{
|
||||
// FIXME: hack to fix some broken decoding here. TODO
|
||||
if (insn->id == X86_INS_OUTSD) {
|
||||
if (insn->x86.op_size == 2) {
|
||||
// modify insn id
|
||||
insn->id = X86_INS_OUTSW;
|
||||
// modify instruction buffer, too
|
||||
memcpy(insn_asm, "outsw", strlen("outsw"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// given internal insn id, return public instruction info
|
||||
void X86_get_insn_id(cs_insn *insn, unsigned int id)
|
||||
{
|
||||
int i = insn_find(insns, ARR_SIZE(insns), id);
|
||||
|
|
|
@ -34,4 +34,7 @@ x86_reg X86_map_insn(const char *mnem);
|
|||
// given public insn id, return internal insn id
|
||||
unsigned int X86_get_insn_id2(unsigned int insn_id);
|
||||
|
||||
// post printer for X86.
|
||||
void X86_post_printer(cs_insn *pub_insn, char *insn_asm);
|
||||
|
||||
#endif
|
||||
|
|
4
cs.c
4
cs.c
|
@ -74,6 +74,7 @@ cs_err cs_open(cs_arch arch, cs_mode mode, csh *handle)
|
|||
ud->reg_name = X86_reg_name;
|
||||
ud->insn_id = X86_get_insn_id;
|
||||
ud->insn_name = X86_insn_name;
|
||||
ud->post_printer = X86_post_printer;
|
||||
break;
|
||||
case CS_ARCH_ARM: {
|
||||
MCRegisterInfo *mri = malloc(sizeof(*mri));
|
||||
|
@ -177,7 +178,7 @@ static void fill_insn(cs_struct *handle, cs_insn *insn, char *buffer, MCInst *mc
|
|||
insn->id = MCInst_getOpcodePub(mci);
|
||||
|
||||
if (printer)
|
||||
printer(insn->id, insn, buffer);
|
||||
printer(insn, buffer);
|
||||
|
||||
// fill in mnemonic & operands
|
||||
// find first space or tab
|
||||
|
@ -192,7 +193,6 @@ static void fill_insn(cs_struct *handle, cs_insn *insn, char *buffer, MCInst *mc
|
|||
for (; ((*sp == ' ') || (*sp == '\t')); sp++);
|
||||
strncpy(insn->op_str, sp, sizeof(insn->op_str) - 1);
|
||||
insn->op_str[sizeof(insn->op_str) - 1] = '\0';
|
||||
printf(">>>> |%s|\n", insn->op_str);
|
||||
} else
|
||||
insn->op_str[0] = '\0';
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef void (*Printer_t)(MCInst *MI, SStream *OS, void *info);
|
|||
|
||||
// function to be called after Printer_t
|
||||
// this is the best time to gather insn's characteristics
|
||||
typedef void (*PostPrinter_t)(unsigned int insn, cs_insn *, const char *mnem);
|
||||
typedef void (*PostPrinter_t)(cs_insn *, char *mnem);
|
||||
|
||||
typedef bool (*Disasm_t)(csh handle, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info);
|
||||
|
||||
|
|
Loading…
Reference in New Issue