From ee8e1bea3e7c4209e4bded9e8046907675bb6fdf Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 19 Jan 2015 03:45:56 +0200 Subject: [PATCH] plugin: detect one more align type --- plugin/saveasm.cpp | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/plugin/saveasm.cpp b/plugin/saveasm.cpp index 26ba2f9..bfe7e36 100644 --- a/plugin/saveasm.cpp +++ b/plugin/saveasm.cpp @@ -193,10 +193,27 @@ static void my_rename(ea_t ea, char *name) rebuild_name_cache(); } +static void make_align(ea_t ea) +{ + ea_t tmp_ea; + int n; + + tmp_ea = next_head(ea, inf.maxEA); + if ((tmp_ea & 0x03) == 0) { + n = calc_max_align(tmp_ea); + if (n > 4) // masm doesn't like more.. + n = 4; + msg("%x: align %d\n", ea, 1 << n); + do_unknown(ea, DOUNK_SIMPLE); + doAlign(ea, tmp_ea - ea, n); + } +} + static void idaapi run(int /*arg*/) { // isEnabled(ea) // address belongs to disassembly // ea_t ea = get_screen_ea(); + // extern foo; // foo = DecodeInstruction(ScreenEA()); FILE *fout = NULL; int fout_line = 0; @@ -344,15 +361,8 @@ static void idaapi run(int /*arg*/) && cmd.Operands[1].type == o_displ && cmd.Operands[1].addr == 0) { - tmp_ea = next_head(ea, inf.maxEA); - if ((tmp_ea & 0x03) == 0) { - n = calc_max_align(tmp_ea); - if (n > 4) // masm doesn't like more.. - n = 4; - msg("%x: align %d\n", ea, 1 << n); - do_unknown(ea, DOUNK_SIMPLE); - doAlign(ea, tmp_ea - ea, n); - } + // lea eax, [eax+0] + make_align(ea); } else if (!isDefArg1(ea_flags) && cmd.Operands[1].type == o_mem // why o_mem? @@ -373,6 +383,15 @@ static void idaapi run(int /*arg*/) } } } + else if (cmd.itype == NN_mov && cmd.segpref == 0x1e // 2e? + && cmd.Operands[0].type == o_reg + && cmd.Operands[1].type == o_reg + && cmd.Operands[0].dtyp == cmd.Operands[1].dtyp + && cmd.Operands[0].reg == cmd.Operands[1].reg) + { + // db 2Eh; mov eax, eax + make_align(ea); + } // find non-local branches if (is_insn_jmp(cmd.itype) && cmd.Operands[0].type == o_near) -- 2.39.2