IDAPython for IDA 8.0

This commit is contained in:
Arnaud Diederen
2022-08-22 10:14:08 +02:00
parent 1e0b352e00
commit 023c5ba53c
108 changed files with 38145 additions and 32850 deletions
+10 -29
View File
@@ -35,18 +35,6 @@ import types
import os
import sys
# TO_REFACTOR_ON_PY2_REMOVAL
# this internal function can be dropped
def refs(ea, funcfirst, funcnext):
"""
Generic reference collector - INTERNAL USE ONLY.
"""
ref = funcfirst(ea)
while ref != ida_idaapi.BADADDR:
yield ref
ref = funcnext(ea, ref)
def CodeRefsTo(ea, flow):
"""
Get a list of code references to 'ea'
@@ -62,17 +50,11 @@ def CodeRefsTo(ea, flow):
for ref in CodeRefsTo(get_screen_ea(), 1):
print(ref)
"""
# TO_REFACTOR_ON_PY2_REMOVAL
# we can use the new generators
# xref = ida_xref.xrefblk_t()
# if flow == 1:
# yield from xref.crefs_to(ea)
# else:
# yield from xref.fcrefs_to(ea)
xref = ida_xref.xrefblk_t()
if flow == 1:
return refs(ea, ida_xref.get_first_cref_to, ida_xref.get_next_cref_to)
yield from xref.crefs_to(ea)
else:
return refs(ea, ida_xref.get_first_fcref_to, ida_xref.get_next_fcref_to)
yield from xref.fcrefs_to(ea)
def CodeRefsFrom(ea, flow):
@@ -90,12 +72,11 @@ def CodeRefsFrom(ea, flow):
for ref in CodeRefsFrom(get_screen_ea(), 1):
print(ref)
"""
# TO_REFACTOR_ON_PY2_REMOVAL
xref = ida_xref.xrefblk_t()
if flow == 1:
return refs(ea, ida_xref.get_first_cref_from, ida_xref.get_next_cref_from)
yield from xref.crefs_from(ea)
else:
return refs(ea, ida_xref.get_first_fcref_from, ida_xref.get_next_fcref_from)
yield from xref.fcrefs_from(ea)
def DataRefsTo(ea):
"""
@@ -110,8 +91,8 @@ def DataRefsTo(ea):
for ref in DataRefsTo(get_screen_ea()):
print(ref)
"""
# TO_REFACTOR_ON_PY2_REMOVAL
return refs(ea, ida_xref.get_first_dref_to, ida_xref.get_next_dref_to)
xref = ida_xref.xrefblk_t()
yield from xref.drefs_to(ea)
def DataRefsFrom(ea):
@@ -127,8 +108,8 @@ def DataRefsFrom(ea):
for ref in DataRefsFrom(get_screen_ea()):
print(ref)
"""
# TO_REFACTOR_ON_PY2_REMOVAL
return refs(ea, ida_xref.get_first_dref_from, ida_xref.get_next_dref_from)
xref = ida_xref.xrefblk_t()
yield from xref.drefs_from(ea)
# Xref type names table
+9 -7
View File
@@ -363,6 +363,7 @@ def rotate_left(value, count, nbits, offset):
"""
assert offset >= 0, "offset must be >= 0"
assert nbits > 0, "nbits must be > 0"
count %= nbits # no need to spin the wheel more than 1 rotation
mask = 2**(offset+nbits) - 2**offset
tmp = value & mask
@@ -554,11 +555,11 @@ def set_name(ea, name, flags=ida_name.SN_CHECK):
"""
return ida_name.set_name(ea, name, flags)
SN_CHECK = ida_name.SN_CHECK
SN_CHECK = ida_name.SN_CHECK # Fail if the name contains invalid characters.
SN_NOCHECK = ida_name.SN_NOCHECK # Don't fail if the name contains invalid characters.
# If this bit is clear, all invalid chars
# (those !is_ident_cp()) will be replaced
# by SUBSTCHAR (usually '_').
# If this bit is set, all invalid chars
# (not in NameChars or MangleChars) will be replaced
# by '_'.
# List of valid characters is defined in ida.cfg
SN_PUBLIC = ida_name.SN_PUBLIC # if set, make name public
SN_NON_PUBLIC = ida_name.SN_NON_PUBLIC # if set, make name non-public
@@ -2970,6 +2971,8 @@ FUNC_PURGED_OK = _scope.FUNC_PURGED_OK # 'argsize' field has been valida
FUNC_TAIL = _scope.FUNC_TAIL # This is a function tail.
# Other bits must be clear
# (except FUNC_HIDDEN)
FUNC_LUMINA = _scope.FUNC_LUMINA # Function info is provided by Lumina.
FUNC_OUTLINE = _scope.FUNC_OUTLINE # Outlined code, not a real function.
def set_func_flags(ea, flags):
@@ -5351,9 +5354,8 @@ get_process_state = ida_dbg.get_process_state
DSTATE_SUSP = -1 # process is suspended
DSTATE_NOTASK = 0 # no process is currently debugged
DSTATE_RUN = 1 # process is running
DSTATE_RUN_WAIT_ATTACH = 2 # process is running, waiting for process properly attached
DSTATE_RUN_WAIT_END = 3 # process is running, but the user asked to kill/detach the process
# remark: in this case, most events are ignored
DSTATE_RUN_WAIT_ATTACH = 2 # deprecated
DSTATE_RUN_WAIT_END = 3 # deprecated
"""
Get various information about the current debug event