summaryrefslogtreecommitdiff
path: root/python/interaction.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/interaction.py')
-rw-r--r--python/interaction.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/python/interaction.py b/python/interaction.py
index da6f792a..5b78b278 100644
--- a/python/interaction.py
+++ b/python/interaction.py
@@ -25,6 +25,9 @@ import traceback
from binaryninja import _binaryninjacore as core
from binaryninja.enums import FormInputFieldType, MessageBoxIcon, MessageBoxButtonSet, MessageBoxButtonResult
+# 2-3 compatibility
+from six.moves import range
+
class LabelField(object):
"""
@@ -160,7 +163,7 @@ class ChoiceField(object):
value.type = FormInputFieldType.ChoiceFormField
value.prompt = self.prompt
choice_buf = (ctypes.c_char_p * len(self.choices))()
- for i in xrange(0, len(self.choices)):
+ for i in range(0, len(self.choices)):
choice_buf[i] = str(self.choices[i])
value.choices = choice_buf
value.count = len(self.choices)
@@ -330,7 +333,7 @@ class InteractionHandler(object):
def _get_choice_input(self, ctxt, result, prompt, title, choice_buf, count):
try:
choices = []
- for i in xrange(0, count):
+ for i in range(0, count):
choices.append(choice_buf[i])
value = self.get_choice_input(prompt, title, choices)
if value is None:
@@ -373,7 +376,7 @@ class InteractionHandler(object):
def _get_form_input(self, ctxt, fields, count, title):
try:
field_objs = []
- for i in xrange(0, count):
+ for i in range(0, count):
if fields[i].type == FormInputFieldType.LabelFormField:
field_objs.append(LabelField(fields[i].prompt))
elif fields[i].type == FormInputFieldType.SeparatorFormField:
@@ -391,7 +394,7 @@ class InteractionHandler(object):
field_objs.append(AddressField(fields[i].prompt, view, fields[i].currentAddress))
elif fields[i].type == FormInputFieldType.ChoiceFormField:
choices = []
- for j in xrange(0, fields[i].count):
+ for j in range(0, fields[i].count):
choices.append(fields[i].choices[j])
field_objs.append(ChoiceField(fields[i].prompt, choices))
elif fields[i].type == FormInputFieldType.OpenFileNameFormField:
@@ -404,7 +407,7 @@ class InteractionHandler(object):
field_objs.append(LabelField(fields[i].prompt))
if not self.get_form_input(field_objs, title):
return False
- for i in xrange(0, count):
+ for i in range(0, count):
field_objs[i]._fill_core_result(fields[i])
return True
except:
@@ -613,7 +616,7 @@ def get_choice_input(prompt, title, choices):
0L
"""
choice_buf = (ctypes.c_char_p * len(choices))()
- for i in xrange(0, len(choices)):
+ for i in range(0, len(choices)):
choice_buf[i] = str(choices[i])
value = ctypes.c_ulonglong()
if not core.BNGetChoiceInput(value, prompt, title, choice_buf, len(choices)):
@@ -728,7 +731,7 @@ def get_form_input(fields, title):
Peter 1337 0
"""
value = (core.BNFormInputField * len(fields))()
- for i in xrange(0, len(fields)):
+ for i in range(0, len(fields)):
if isinstance(fields[i], str):
LabelField(fields[i])._fill_core_struct(value[i])
elif fields[i] is None:
@@ -737,7 +740,7 @@ def get_form_input(fields, title):
fields[i]._fill_core_struct(value[i])
if not core.BNGetFormInput(value, len(fields), title):
return False
- for i in xrange(0, len(fields)):
+ for i in range(0, len(fields)):
if not (isinstance(fields[i], str) or (fields[i] is None)):
fields[i]._get_result(value[i])
core.BNFreeFormInputResults(value, len(fields))