Skip to content

Commit

Permalink
idapython: add print_insn_mnem, print_operand, get_operand_type,
Browse files Browse the repository at this point in the history
   find_func_end but mantain previous name for API compatibility
idapython: add old API name get_long
  • Loading branch information
invano authored and imbillow committed Aug 20, 2020
1 parent b3e2f00 commit 5b7a300
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions idb/idapython.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,12 @@ def __init__(self, db, api):
else:
raise RuntimeError("unexpected wordsize")

## Mantain API compatibility for API < 7
self.GetMnem = self.print_insn_mnem
self.GetOpnd = self.print_operand
self.GetOpType = self.get_operand_type
self.FindFuncEnd = self.find_func_end

def ScreenEA(self):
return self.api.ScreenEA

Expand Down Expand Up @@ -1012,15 +1018,15 @@ def _disassemble(self, ea):
else:
return op

def GetMnem(self, ea):
def print_insn_mnem(self, ea):
op = self._disassemble(ea)
return op.mnemonic

def GetDisasm(self, ea):
op = self._disassemble(ea)
return "%s\t%s" % (op.mnemonic, op.op_str)

def GetOpnd(self, ea, n):
def print_operand(self, ea, n):
op = self._disassemble(ea)
opnds = op.op_str.split(", ")
n_opnds = len(opnds)
Expand All @@ -1030,7 +1036,7 @@ def GetOpnd(self, ea, n):
else:
return ""

def GetOpType(self, ea, n):
def get_operand_type(self, ea, n):
from capstone import CS_OP_INVALID, CS_OP_REG, CS_OP_MEM, CS_OP_IMM

op = self._disassemble(ea)
Expand Down Expand Up @@ -1132,7 +1138,7 @@ def GetFunctionAttr(self, ea, attr):
def GetFunctionName(self, ea):
return self.api.ida_funcs.get_func_name(ea)

def FindFuncEnd(self, ea):
def find_func_end(self, ea):
func = self.api.ida_funcs.get_func(ea)
if not func:
return self.BADADDR
Expand Down Expand Up @@ -1316,6 +1322,9 @@ def __init__(self, db, api):
self.idb = db
self.api = api

## Mantain API compatibility for API < 7
self.get_long = self.get_dword

def get_cmt(self, ea, repeatable):
flags = self.api.idc.GetFlags(ea)
if not self.has_cmt(flags):
Expand Down

0 comments on commit 5b7a300

Please sign in to comment.