Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename old API names for latest IDA version #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions annotate_lineinfo/annotate_lineinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def compiland_name(compiland):

def dia_enum_iter(enum):
"""Turn an IDiaEnum* object into a python generator"""
for i in xrange(enum.count):
for i in range(enum.count):
yield enum.Next(1)[0]

##================ DIA ================##
Expand Down Expand Up @@ -147,7 +147,7 @@ def ida_anterior_comment(ea, comment):
return
i += 1
# Add the comment
idaapi.add_long_cmt(ea, True, comment)
idaapi.add_extra_cmt(ea, True, comment)

def ida_del_anterior_comment(ea):
"""Remove anterior comment from @ea"""
Expand Down Expand Up @@ -188,11 +188,11 @@ def ida_del_lineinfo_comment_from_range(ea, length):

def ida_add_lineinfo_comment_to_func(dia, ida_func):
length = ida_func.size()+1
ida_add_lineinfo_comment_to_range(dia, ida_func.startEA, length)
ida_add_lineinfo_comment_to_range(dia, ida_func.start_ea, length)

def ida_del_lineinfo_comment_from_func(ida_func):
length = ida_func.size()+1
ida_del_lineinfo_comment_from_range(ida_func.startEA, length)
ida_del_lineinfo_comment_from_range(ida_func.start_ea, length)

def ida_annotate_lineinfo_dia(dia, include_function_name=True):
for func,line in dia.iter_function_lineinfo():
Expand Down
15 changes: 8 additions & 7 deletions annotate_lineinfo_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
MIT License, see LICENSE for details.
"""
import idaapi
import idc
import annotate_lineinfo.annotate_lineinfo as ali

PLUGIN_COMMENT = "Annotate IDA with source and line number information from a PDB"
Expand Down Expand Up @@ -38,7 +39,7 @@ def activate(self, ctx):
cur_sel_from = getattr(ctx.cur_sel, "from")
start,end = (x.at.toea() for x in [cur_sel_from, ctx.cur_sel.to])
except AttributeError:
_,start,end = idaapi.read_selection()
_,start,end = idaapi.read_range_selection(None)
length = end-start
if self._action == ACTION_ADD_ANNOTATION:
ali.ida_add_lineinfo_comment_to_range(ali_plugin.dia, start, length)
Expand Down Expand Up @@ -71,7 +72,7 @@ def activate(self, ctx):
ali.ida_del_lineinfo_comment_from_func(ida_func)
return 1
def update(self, ctx):
return idaapi.AST_ENABLE_FOR_FORM
return idaapi.AST_ENABLE_FOR_WIDGET

class ALI_MENU_AnnotateHandler(idaapi.action_handler_t):
"""Menu action handler. Annotate entire file with line info"""
Expand Down Expand Up @@ -117,12 +118,12 @@ def update(self, ctx):
return idaapi.AST_ENABLE_ALWAYS

class ALI_Hooks(idaapi.UI_Hooks):
def finish_populating_tform_popup(self, form, popup):
tft = idaapi.get_tform_type(form)
def finish_populating_widget_popup(self, form, popup):
tft = idaapi.get_widget_type(form)
if tft == idaapi.BWN_DISASM: # Disassembly view
descs = []
# Choose either selection or function annotation depending on cursor
selection = idaapi.read_selection()
selection = idaapi.read_range_selection(None)
if selection[0] == True:
descs.append(idaapi.action_desc_t(None,
'Annotate selection with line info',
Expand All @@ -131,7 +132,7 @@ def finish_populating_tform_popup(self, form, popup):
'Remove annotations from selection',
ALI_DISASM_SelectionHandler(ACTION_DEL_ANNOTATION)))
else:
func = idaapi.get_func(ScreenEA())
func = idaapi.get_func(idc.get_screen_ea())
if func is not None:
descs.append(idaapi.action_desc_t(None,
'Annotate function with line info',
Expand Down Expand Up @@ -176,7 +177,7 @@ def init(self):
self.dia = None
self.hooks = None

idaapi.autoWait()
idaapi.auto_wait()

if not self.init_dia():
ALI_MSG("Please specify PDB file path using '{}{}'".format(
Expand Down