summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/__init__.py31
-rw-r--r--python/examples/angr_plugin.py12
2 files changed, 31 insertions, 12 deletions
diff --git a/python/__init__.py b/python/__init__.py
index af5e0b55..70267678 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -243,7 +243,7 @@ class FileMetadata(object):
del cls._associated_data[handle.value]
@classmethod
- def set_default_data(cls, name, value):
+ def set_default_session_data(cls, name, value):
_FileMetadataAssociatedDataStore.set_default(name, value)
@property
@@ -324,7 +324,7 @@ class FileMetadata(object):
self.nav = value
@property
- def data(self):
+ def session_data(self):
"""Dictionary object where plugins can store arbitrary data associated with the file"""
handle = ctypes.cast(self.handle, ctypes.c_void_p)
if handle.value not in FileMetadata._associated_data:
@@ -1156,7 +1156,7 @@ class BinaryView(object):
del cls._associated_data[handle.value]
@classmethod
- def set_default_data(cls, name, value):
+ def set_default_session_data(cls, name, value):
_BinaryViewAssociatedDataStore.set_default(name, value)
def __del__(self):
@@ -1415,7 +1415,7 @@ class BinaryView(object):
return result
@property
- def data(self):
+ def session_data(self):
"""Dictionary object where plugins can store arbitrary data associated with the view"""
handle = ctypes.cast(self.handle, ctypes.c_void_p)
if handle.value not in BinaryView._associated_data:
@@ -4320,6 +4320,10 @@ class Type(object):
return Type(core.BNCreateUnknownType(unknown_type.handle))
@classmethod
+ def unknown_type(self, s):
+ return Type(core.BNCreateUnknownType(s.handle))
+
+ @classmethod
def enumeration_type(self, arch, e, width = None):
if width is None:
width = arch.default_int_size
@@ -4754,7 +4758,7 @@ class Function(object):
del cls._associated_data[handle.value]
@classmethod
- def set_default_data(cls, name, value):
+ def set_default_session_data(cls, name, value):
_FunctionAssociatedDataStore.set_default(name, value)
@property
@@ -4882,7 +4886,7 @@ class Function(object):
return result
@property
- def data(self):
+ def session_data(self):
"""Dictionary object where plugins can store arbitrary data associated with the function"""
handle = ctypes.cast(self.handle, ctypes.c_void_p)
if handle.value not in Function._associated_data:
@@ -11008,6 +11012,21 @@ def demangle_ms(arch, mangled_name):
names.append(outName[i])
#core.BNFreeDemangledName(outName.value, outSize.value)
return (Type(handle), names)
+ return (None, mangledName)
+
+
+def demangle_gnu3(arch, mangledName):
+ handle = ctypes.POINTER(core.BNType)()
+ outName = ctypes.POINTER(ctypes.c_char_p)()
+ outSize = ctypes.c_ulonglong()
+ names = []
+ if core.BNDemangleGNU3(arch.handle, mangledName, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize)):
+ for i in xrange(outSize.value):
+ names.append(outName[i])
+ #core.BNFreeDemangledName(outName.value, outSize.value)
+ if not handle:
+ return (None, names)
+ return (Type(handle), names)
return (None, mangled_name)
diff --git a/python/examples/angr_plugin.py b/python/examples/angr_plugin.py
index 5d567511..c6e6f87d 100644
--- a/python/examples/angr_plugin.py
+++ b/python/examples/angr_plugin.py
@@ -21,8 +21,8 @@ import os
logging.disable(logging.WARNING)
# Create sets in the BinaryView's data field to store the desired path for each view
-BinaryView.set_default_data("angr_find", set())
-BinaryView.set_default_data("angr_avoid", set())
+BinaryView.set_default_session_data("angr_find", set())
+BinaryView.set_default_session_data("angr_avoid", set())
def escaped_output(str):
return '\n'.join([s.encode("string_escape") for s in str.split('\n')])
@@ -89,7 +89,7 @@ def find_instr(bv, addr):
block.function.set_auto_instr_highlight(block.arch, addr, GreenHighlightColor)
# Add the instruction to the list associated with the current view
- bv.data.angr_find.add(addr)
+ bv.session_data.angr_find.add(addr)
def avoid_instr(bv, addr):
# Highlight the instruction in red
@@ -99,17 +99,17 @@ def avoid_instr(bv, addr):
block.function.set_auto_instr_highlight(block.arch, addr, RedHighlightColor)
# Add the instruction to the list associated with the current view
- bv.data.angr_avoid.add(addr)
+ bv.session_data.angr_avoid.add(addr)
def solve(bv):
- if len(bv.data.angr_find) == 0:
+ if len(bv.session_data.angr_find) == 0:
show_message_box("Angr Solve", "You have not specified a goal instruction.\n\n" +
"Please right click on the goal instruction and select \"Find Path to This Instruction\" to " +
"continue.", OKButtonSet, ErrorIcon)
return
# Start a solver thread for the path associated with the view
- s = Solver(bv.data.angr_find, bv.data.angr_avoid, bv)
+ s = Solver(bv.session_data.angr_find, bv.session_data.angr_avoid, bv)
s.start()
# Register commands for the user to interact with the plugin