mirror of
https://github.com/cemu-project/idapython.git
synced 2024-12-28 18:51:53 +01:00
idautils.py: Added FuncItems() and DecodeInstruction(). Thanks to Elias Bachaalany for the patch.
This commit is contained in:
parent
5b0260c301
commit
fb507d9f85
@ -258,6 +258,54 @@ def GetDataList(ea, count, itemsize=1):
|
||||
yield getdata(curea)
|
||||
|
||||
|
||||
def FuncItems(start):
|
||||
"""
|
||||
Get a list of function items
|
||||
|
||||
@param start: address of the function
|
||||
|
||||
@return: ea of each item in the function
|
||||
"""
|
||||
func = idaapi.get_func(start)
|
||||
if not func:
|
||||
return
|
||||
fii = idaapi.func_item_iterator_t()
|
||||
ok = fii.set(func)
|
||||
while ok:
|
||||
yield fii.current()
|
||||
ok = fii.next_code()
|
||||
|
||||
|
||||
def DecodeInstruction(ea):
|
||||
"""
|
||||
Decodes an instruction and returns a insn_t like class
|
||||
|
||||
@param ea: address to decode
|
||||
|
||||
@return: None or an insn_t like structure
|
||||
"""
|
||||
inslen = idaapi.decode_insn(ea)
|
||||
if inslen == 0:
|
||||
return None
|
||||
insn = idaapi.get_current_instruction()
|
||||
if not insn:
|
||||
return None
|
||||
class dup:
|
||||
def __init__(self, op):
|
||||
for x in dir(op):
|
||||
if x.startswith("__") and x.endswith("__"):
|
||||
continue
|
||||
setattr(self, x, getattr(op, x))
|
||||
r = dup(insn)
|
||||
r.Operands = []
|
||||
for n in range(0, idaapi.UA_MAXOP):
|
||||
t = idaapi.get_instruction_operand(insn, n)
|
||||
if t.type == idaapi.o_void:
|
||||
break
|
||||
r.Operands.append(dup(t))
|
||||
return r
|
||||
|
||||
|
||||
def PutDataList(ea, datalist, itemsize=1):
|
||||
"""
|
||||
Put data list - INTERNAL USE ONLY
|
||||
|
Loading…
Reference in New Issue
Block a user