summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2017-01-09 21:58:55 -0500
committerPeter LaFosse <peter@vector35.com>2017-01-09 21:58:55 -0500
commitaae6c3aecdb04e8a6e33799287737a33a634418d (patch)
treed9812259f3ce96123b3310f9ee332e8dc34ab643 /python
parent9d1cac8ee55553cdb20c36deb3b15c9219b02d9b (diff)
Wrapping some unwrapped enumeration values, and adding il basic block indexing
Diffstat (limited to 'python')
-rw-r--r--python/architecture.py2
-rw-r--r--python/binaryview.py4
-rw-r--r--python/function.py11
-rw-r--r--python/lowlevelil.py12
4 files changed, 19 insertions, 10 deletions
diff --git a/python/architecture.py b/python/architecture.py
index c95c71a0..f1440ca3 100644
--- a/python/architecture.py
+++ b/python/architecture.py
@@ -176,7 +176,7 @@ class Architecture(object):
self._flag_roles = {}
self.__dict__["flag_roles"] = {}
for flag in self.__dict__["flags"]:
- role = core.BNGetArchitectureFlagRole(self.handle, self._flags[flag])
+ role = FlagRole(core.BNGetArchitectureFlagRole(self.handle, self._flags[flag]))
self.__dict__["flag_roles"][flag] = role
self._flag_roles[self._flags[flag]] = role
diff --git a/python/binaryview.py b/python/binaryview.py
index b19ecbd6..3467dcc3 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -708,7 +708,7 @@ class BinaryView(object):
@property
def endianness(self):
"""Endianness of the binary (read-only)"""
- return core.BNGetDefaultEndianness(self.handle)
+ return Endianness(core.BNGetDefaultEndianness(self.handle))
@property
def address_size(self):
@@ -1577,7 +1577,7 @@ class BinaryView(object):
:rtype: ModificationStatus or str
"""
if length is None:
- return core.BNGetModification(self.handle, addr)
+ return ModificationStatus(core.BNGetModification(self.handle, addr))
data = (ModificationStatus * length)()
length = core.BNGetModificationArray(self.handle, addr, data, length)
return data[0:length]
diff --git a/python/function.py b/python/function.py
index e3c79312..1843dd3d 100644
--- a/python/function.py
+++ b/python/function.py
@@ -25,7 +25,8 @@ import ctypes
# Binary Ninja components
import _binaryninjacore as core
from enums import (FunctionGraphType, BranchType, SymbolType, InstructionTextTokenType,
- HighlightStandardColor, RegisterValueType, ImplicitRegisterExtend, DisassemblyOption, IntegerDisplayType)
+ HighlightStandardColor, HighlightColorStyle, RegisterValueType, ImplicitRegisterExtend,
+ DisassemblyOption, IntegerDisplayType)
import architecture
import highlight
import associateddatastore
@@ -47,7 +48,7 @@ class LookupTableEntry(object):
class RegisterValue(object):
def __init__(self, arch, value):
- self.type = value.state
+ self.type = RegisterValueType(value.state)
if value.state == RegisterValueType.EntryValue:
self.reg = arch.get_reg_name(value.reg)
elif value.state == RegisterValueType.OffsetFromEntryValue:
@@ -682,7 +683,7 @@ class Function(object):
def get_int_display_type(self, instr_addr, value, operand, arch=None):
if arch is None:
arch = self.arch
- return core.BNGetIntegerConstantDisplayType(self.handle, arch.handle, instr_addr, value, operand)
+ return IntegerDisplayType(core.BNGetIntegerConstantDisplayType(self.handle, arch.handle, instr_addr, value, operand))
def set_int_display_type(self, instr_addr, value, operand, display_type, arch=None):
"""
@@ -831,7 +832,7 @@ class DisassemblyTextLine(object):
class FunctionGraphEdge:
def __init__(self, branch_type, arch, target, points):
- self.type = branch_type
+ self.type = BranchType(branch_type)
self.arch = arch
self.target = target
self.points = points
@@ -1237,7 +1238,7 @@ class InstructionTextToken(object):
"""
def __init__(self, token_type, text, value = 0, size = 0, operand = 0xffffffff):
- self.type = token_type
+ self.type = InstructionTextTokenType(token_type)
self.text = text
self.value = value
self.size = size
diff --git a/python/lowlevelil.py b/python/lowlevelil.py
index 4564bf13..419e8513 100644
--- a/python/lowlevelil.py
+++ b/python/lowlevelil.py
@@ -118,8 +118,7 @@ class LowLevelILInstruction(object):
self.function = func
self.expr_index = expr_index
self.instr_index = instr_index
- self.operation = instr.operation
- self.operation_name = LowLevelILOperation(instr.operation)
+ self.operation = LowLevelILOperation(instr.operation)
self.size = instr.size
self.address = instr.address
self.source_operand = instr.sourceOperand
@@ -1261,6 +1260,15 @@ class LowLevelILBasicBlock(basicblock.BasicBlock):
for idx in xrange(self.start, self.end):
yield self.il_function[idx]
+ def __getitem__(self, idx):
+ size = self.end - self.start
+ if idx > size or idx < -size:
+ raise IndexError("list index is out of range")
+ if idx >= 0:
+ return self.il_function[idx + self.start]
+ else:
+ return self.il_function[self.end + idx]
+
def LLIL_TEMP(n):
return n | 0x80000000