diff options
| author | nofiv <41523109+nofiv@users.noreply.github.com> | 2020-04-15 16:15:04 +0200 |
|---|---|---|
| committer | nofiv <41523109+nofiv@users.noreply.github.com> | 2020-04-16 00:47:24 +0200 |
| commit | ce517ae68975e6f39c11e3b62d68548bc85b6f6b (patch) | |
| tree | 1a37e191af67d3f4659be99d92a90aecda3c5f4a /example | |
| parent | 6b79e8c5ab820222e440d4b96d73dd1258630eb8 (diff) | |
| download | focaccia-miasm-ce517ae68975e6f39c11e3b62d68548bc85b6f6b.tar.gz focaccia-miasm-ce517ae68975e6f39c11e3b62d68548bc85b6f6b.zip | |
IDAPython 7.4 porting
Diffstat (limited to 'example')
| -rw-r--r-- | example/ida/ctype_propagation.py | 16 | ||||
| -rw-r--r-- | example/ida/depgraph.py | 24 | ||||
| -rw-r--r-- | example/ida/graph_ir.py | 6 | ||||
| -rw-r--r-- | example/ida/symbol_exec.py | 8 | ||||
| -rw-r--r-- | example/ida/utils.py | 2 |
5 files changed, 28 insertions, 28 deletions
diff --git a/example/ida/ctype_propagation.py b/example/ida/ctype_propagation.py index f333d69a..35cd53bb 100644 --- a/example/ida/ctype_propagation.py +++ b/example/ida/ctype_propagation.py @@ -27,13 +27,13 @@ class TypePropagationForm(ida_kernwin.Form): default_types_info = r"""ExprId("RDX", 64): char *""" archs = ["AMD64_unk", "X86_32_unk", "msp430_unk"] - func = ida_funcs.get_func(idc.ScreenEA()) - func_addr = func.startEA + func = ida_funcs.get_func(idc.get_screen_ea()) + func_addr = func.start_ea - start_addr = idc.SelStart() + start_addr = idc.read_selection_start() if start_addr == idc.BADADDR: - start_addr = idc.ScreenEA() - end_addr = idc.SelEnd() + start_addr = idc.get_screen_ea() + end_addr = idc.read_selection_end() ida_kernwin.Form.__init__(self, r"""BUTTON YES* Launch @@ -205,7 +205,7 @@ class SymbExecCTypeFix(SymbExecCType): ) self.eval_updt_assignblk(assignblk) for offset, value in viewitems(offset2cmt): - idc.MakeComm(offset, '\n'.join(value)) + idc.set_cmt(offset, '\n'.join(value), 0) print("%x\n" % offset, '\n'.join(value)) return self.eval_expr(self.ir_arch.IRDst) @@ -227,8 +227,8 @@ def get_ira_call_fixer(ira): def call_effects(self, ad, instr): print(hex(instr.offset), instr) - stk_before = idc.GetSpd(instr.offset) - stk_after = idc.GetSpd(instr.offset + instr.l) + stk_before = idc.get_spd(instr.offset) + stk_after = idc.get_spd(instr.offset + instr.l) stk_diff = stk_after - stk_before print(hex(stk_diff)) call_assignblk = AssignBlock( diff --git a/example/ida/depgraph.py b/example/ida/depgraph.py index 9e45ffa9..d607fe96 100644 --- a/example/ida/depgraph.py +++ b/example/ida/depgraph.py @@ -33,7 +33,7 @@ class depGraphSettingsForm(ida_kernwin.Form): self.stk_args = {'ARG%d' % i:i for i in range(10)} self.stk_unalias_force = False - self.address = idc.ScreenEA() + self.address = idc.get_screen_ea() cur_block = None for loc_key in ircfg.getby_offset(self.address): block = ircfg.get_block(loc_key) @@ -54,7 +54,7 @@ class depGraphSettingsForm(ida_kernwin.Form): regs += list(self.stk_args) reg_default = regs[0] for i in range(10): - opnd = idc.GetOpnd(self.address, i).upper() + opnd = idc.print_operand(self.address, i).upper() if opnd in regs: reg_default = opnd break @@ -128,7 +128,7 @@ Method to use: if value in self.stk_args: line = self.ircfg.blocks[self.loc_key][self.line_nb].instr arg_num = self.stk_args[value] - stk_high = m2_expr.ExprInt(idc.GetSpd(line.offset), ir_arch.sp.size) + stk_high = m2_expr.ExprInt(idc.get_spd(line.offset), ir_arch.sp.size) stk_off = m2_expr.ExprInt(self.ira.sp.size // 8 * arg_num, ir_arch.sp.size) element = m2_expr.ExprMem(self.mn.regs.regs_init[ir_arch.sp] + stk_high + stk_off, self.ira.sp.size) element = expr_simp(element) @@ -161,8 +161,8 @@ def clean_lines(): "Remove previous comments" global comments for offset in comments: - idc.SetColor(offset, idc.CIC_ITEM, 0xffffff) - idc.MakeComm(offset, "") + idc.set_color(offset, idc.CIC_ITEM, 0xffffff) + idc.set_cmt(offset, "", 0) comments = {} def treat_element(): @@ -189,7 +189,7 @@ def treat_element(): print("Unable to highlight %s" % node) continue comments[offset] = comments.get(offset, []) + [node.element] - idc.SetColor(offset, idc.CIC_ITEM, settings.color) + idc.set_color(offset, idc.CIC_ITEM, settings.color) if graph.has_loop: print('Graph has dependency loop: symbolic execution is inexact') @@ -197,7 +197,7 @@ def treat_element(): print("Possible value: %s" % next(iter(viewvalues(graph.emul(ir_arch))))) for offset, elements in viewitems(comments): - idc.MakeComm(offset, ", ".join(map(str, elements))) + idc.set_cmt(offset, ", ".join(map(str, elements)), 0) def next_element(): "Display the next element" @@ -208,11 +208,11 @@ def next_element(): def launch_depgraph(): global graphs, comments, sol_nb, settings, addr, ir_arch, ircfg # Get the current function - addr = idc.ScreenEA() + addr = idc.get_screen_ea() func = ida_funcs.get_func(addr) # Init - machine = guess_machine(addr=func.startEA) + machine = guess_machine(addr=func.start_ea) mn, dis_engine, ira = machine.mn, machine.dis_engine, machine.ira bs = bin_stream_ida() @@ -225,7 +225,7 @@ def launch_depgraph(): continue mdis.loc_db.add_location(name, ad) - asmcfg = mdis.dis_multiblock(func.startEA) + asmcfg = mdis.dis_multiblock(func.start_ea) # Generate IR ircfg = ir_arch.new_ircfg_from_asmcfg(asmcfg) @@ -242,7 +242,7 @@ def launch_depgraph(): fix_stack = offset is not None and settings.unalias_stack for assignblk in irb: if fix_stack: - stk_high = m2_expr.ExprInt(idc.GetSpd(assignblk.instr.offset), ir_arch.sp.size) + stk_high = m2_expr.ExprInt(idc.get_spd(assignblk.instr.offset), ir_arch.sp.size) fix_dct = {ir_arch.sp: mn.regs.regs_init[ir_arch.sp] + stk_high} new_assignblk = {} @@ -259,7 +259,7 @@ def launch_depgraph(): # Get dependency graphs dg = settings.depgraph graphs = dg.get(loc_key, elements, line_nb, - set([ir_arch.loc_db.get_offset_location(func.startEA)])) + set([ir_arch.loc_db.get_offset_location(func.start_ea)])) # Display the result comments = {} diff --git a/example/ida/graph_ir.py b/example/ida/graph_ir.py index 082fabd7..7e8c616f 100644 --- a/example/ida/graph_ir.py +++ b/example/ida/graph_ir.py @@ -196,7 +196,7 @@ def build_graph(start_addr, type_graph, simplify=False, dontmodstack=True, loadi if verbose: print("Arch", dis_engine) - fname = idc.GetInputFile() + fname = idc.get_root_filename() if verbose: print(fname) @@ -330,8 +330,8 @@ def function_graph_ir(): if not ret: return - func = ida_funcs.get_func(idc.ScreenEA()) - func_addr = func.startEA + func = ida_funcs.get_func(idc.get_screen_ea()) + func_addr = func.start_ea build_graph( func_addr, diff --git a/example/ida/symbol_exec.py b/example/ida/symbol_exec.py index c0ed89f3..d1141119 100644 --- a/example/ida/symbol_exec.py +++ b/example/ida/symbol_exec.py @@ -124,7 +124,7 @@ def get_focused_view(): class Hooks(idaapi.UI_Hooks): - def finish_populating_tform_popup(self, form, popup): + def finish_populating_widget_popup(self, form, popup): idaapi.attach_action_to_popup(form, popup, 'my:expand', None) idaapi.attach_action_to_popup(form, popup, 'my:translate', None) @@ -135,7 +135,7 @@ def symbolic_exec(): from utils import guess_machine - start, end = idc.SelStart(), idc.SelEnd() + start, end = idc.read_selection_start(), idc.read_selection_end() bs = bin_stream_ida() machine = guess_machine(addr=start) @@ -143,7 +143,7 @@ def symbolic_exec(): mdis = machine.dis_engine(bs) if start == idc.BADADDR and end == idc.BADADDR: - start = idc.ScreenEA() + start = idc.get_screen_ea() end = idc.next_head(start) # Get next instruction address mdis.dont_dis = [end] @@ -197,7 +197,7 @@ idaapi.register_action(action_translate) if __name__ == '__main__': idaapi.CompileLine('static key_F3() { RunPythonStatement("symbolic_exec()"); }') - idc.AddHotkey("F3", "key_F3") + idc.add_idc_hotkey("F3", "key_F3") print("=" * 50) print("""Available commands: diff --git a/example/ida/utils.py b/example/ida/utils.py index cb4ef4d8..245dd541 100644 --- a/example/ida/utils.py +++ b/example/ida/utils.py @@ -10,7 +10,7 @@ import miasm.expression.expression as m2_expr def guess_machine(addr=None): "Return an instance of Machine corresponding to the IDA guessed processor" - processor_name = GetLongPrm(INF_PROCNAME) + processor_name = get_inf_attr(INF_PROCNAME) info = idaapi.get_inf_structure() if info.is_64bit(): |