Skip to content

Commit

Permalink
Merge pull request #8 from kciredor/master
Browse files Browse the repository at this point in the history
Adds Python 3 compatibility
  • Loading branch information
a1ext authored Jan 10, 2020
2 parents 2380f07 + 5fb7b6c commit f145b9c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions auto_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
from PyQt5.QtWidgets import QTreeView, QVBoxLayout, QLineEdit, QMenu, QInputDialog, QAction, QTabWidget


try:
# Python 2.
xrange
except NameError:
# Python 3.
xrange = range


# enable to allow PyCharm remote debug
RDEBUG = False
# adjust this value to be a full path to a debug egg
Expand Down Expand Up @@ -166,7 +174,7 @@ def OnCreate(self, form):

self._idp_hooks = AutoReIDPHooks(self)
if not self._idp_hooks.hook():
print 'IDP_Hooks.hook() failed'
print('IDP_Hooks.hook() failed')

self.tv = QTreeView()
self.tv.setExpandsOnDoubleClick(False)
Expand Down Expand Up @@ -314,7 +322,7 @@ def on_navigate_to_method_requested(self, index):
idaapi.jumpto(addr)

# def on_filter_text_changed(self, text):
# print 'on_text_changed: %s' % text
# print('on_text_changed: %s' % text)


class auto_re_t(idaapi.plugin_t):
Expand Down Expand Up @@ -366,7 +374,7 @@ def _handle_tags(self, fn, fn_an, known_refs):
tags = dict(fn_an['tags'])
if not tags:
return
print 'fn: %#08x tags: %s' % (self.start_ea_of(fn), tags)
print('fn: %#08x tags: %s' % (self.start_ea_of(fn), tags))
cmt = idaapi.get_func_cmt(fn, True)
if cmt:
cmt += '\n'
Expand Down Expand Up @@ -411,9 +419,9 @@ def _handle_calls(self, fn, fn_an):
if len(fn_an['math']) < self._MIN_MAX_MATH_OPS_TO_ALLOW_RENAME:
force_name(self.start_ea_of(fn), normalized)
# TODO: add an API to the view
print 'fn: %#08x: %d calls, %d math%s possible name: %s, normalized: %s' % (
print('fn: %#08x: %d calls, %d math%s possible name: %s, normalized: %s' % (
self.start_ea_of(fn), len(fn_an['calls']), len(fn_an['math']), 'has bads' if fn_an['has_bads'] else '',
possible_name, normalized)
possible_name, normalized))

# noinspection PyMethodMayBeStatic
def _check_is_jmp_wrapper(self, dis):
Expand Down Expand Up @@ -522,7 +530,7 @@ def run(self, arg):
fn_an = self.analyze_func(fn)

# if fn_an['math']:
# print 'fn: %#08x has math' % self.start_ea_of(fn)
# print('fn: %#08x has math' % self.start_ea_of(fn))

if idaapi.has_dummy_name(self.get_flags_at(self.start_ea_of(fn))):
self._handle_calls(fn, fn_an)
Expand Down Expand Up @@ -607,7 +615,7 @@ def _apply_tag_on_callee(cls, callee_ea, rv, is_call=False):
if not match or name in rv['tags'][tag]:
continue

# print '%#08x: %s, tag: %s' % (dis.ea, name, tag)
# print('%#08x: %s, tag: %s' % (dis.ea, name, tag))
rv['tags'][tag].append(name)
break

Expand Down

0 comments on commit f145b9c

Please sign in to comment.