summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2017-07-18 00:20:01 -0400
committerRusty Wagner <rusty@vector35.com>2017-07-18 00:20:01 -0400
commitbf9d72bbae638a42f0b93a9053dffcb1f5e79ff3 (patch)
treed51024630f854d32782a2e24e584fb43557b542c
parent18083837fe452a91e457f02ed8be2abf5fc66877 (diff)
Add instruction for indirect structure access
-rw-r--r--binaryninjaapi.h1
-rw-r--r--binaryninjacore.h5
-rw-r--r--python/mediumlevelil.py4
-rw-r--r--python/types.py5
-rw-r--r--type.cpp6
5 files changed, 21 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 20752370..4f46cd44 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -1842,6 +1842,7 @@ namespace BinaryNinja
void SetTypeName(const QualifiedName& name);
uint64_t GetElementCount() const;
+ uint64_t GetOffset() const;
void SetFunctionCanReturn(const Confidence<bool>& canReturn);
diff --git a/binaryninjacore.h b/binaryninjacore.h
index e601cd1c..2b758a94 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -726,7 +726,9 @@ extern "C"
MLIL_SET_VAR_FIELD, // Not valid in SSA form (see MLIL_SET_VAR_FIELD)
MLIL_SET_VAR_SPLIT, // Not valid in SSA form (see MLIL_SET_VAR_SPLIT_SSA)
MLIL_LOAD, // Not valid in SSA form (see MLIL_LOAD_SSA)
+ MLIL_LOAD_STRUCT, // Not valid in SSA form (see MLIL_LOAD_STRUCT_SSA)
MLIL_STORE, // Not valid in SSA form (see MLIL_STORE_SSA)
+ MLIL_STORE_STRUCT, // Not valid in SSA form (see MLIL_STORE_STRUCT_SSA)
MLIL_VAR, // Not valid in SSA form (see MLIL_VAR_SSA)
MLIL_VAR_FIELD, // Not valid in SSA form (see MLIL_VAR_SSA_FIELD)
MLIL_ADDRESS_OF,
@@ -811,7 +813,9 @@ extern "C"
MLIL_CALL_PARAM_SSA, // Only valid within the MLIL_CALL_SSA, MLIL_SYSCALL_SSA family instructions
MLIL_CALL_OUTPUT_SSA, // Only valid within the MLIL_CALL_SSA or MLIL_SYSCALL_SSA family instructions
MLIL_LOAD_SSA,
+ MLIL_LOAD_STRUCT_SSA,
MLIL_STORE_SSA,
+ MLIL_STORE_STRUCT_SSA,
MLIL_VAR_PHI,
MLIL_MEM_PHI
};
@@ -2534,6 +2538,7 @@ extern "C"
BINARYNINJACOREAPI BNEnumeration* BNGetTypeEnumeration(BNType* type);
BINARYNINJACOREAPI BNNamedTypeReference* BNGetTypeNamedTypeReference(BNType* type);
BINARYNINJACOREAPI uint64_t BNGetTypeElementCount(BNType* type);
+ BINARYNINJACOREAPI uint64_t BNGetTypeOffset(BNType* type);
BINARYNINJACOREAPI void BNSetFunctionCanReturn(BNType* type, BNBoolWithConfidence* canReturn);
BINARYNINJACOREAPI BNMemberScopeWithConfidence BNTypeGetMemberScope(BNType* type);
BINARYNINJACOREAPI void BNTypeSetMemberScope(BNType* type, BNMemberScopeWithConfidence* scope);
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index 8a8d8d0b..ba83f7aa 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -71,7 +71,9 @@ class MediumLevelILInstruction(object):
MediumLevelILOperation.MLIL_SET_VAR_FIELD: [("dest", "var"), ("offset", "int"), ("src", "expr")],
MediumLevelILOperation.MLIL_SET_VAR_SPLIT: [("high", "var"), ("low", "var"), ("src", "expr")],
MediumLevelILOperation.MLIL_LOAD: [("src", "expr")],
+ MediumLevelILOperation.MLIL_LOAD_STRUCT: [("src", "expr"), ("offset", "int")],
MediumLevelILOperation.MLIL_STORE: [("dest", "expr"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_STORE_STRUCT: [("dest", "expr"), ("offset", "int"), ("src", "expr")],
MediumLevelILOperation.MLIL_VAR: [("src", "var")],
MediumLevelILOperation.MLIL_VAR_FIELD: [("src", "var"), ("offset", "int")],
MediumLevelILOperation.MLIL_ADDRESS_OF: [("src", "var")],
@@ -154,7 +156,9 @@ class MediumLevelILInstruction(object):
MediumLevelILOperation.MLIL_CALL_OUTPUT_SSA: [("dest_memory", "int"), ("dest", "var_ssa_list")],
MediumLevelILOperation.MLIL_CALL_PARAM_SSA: [("src_memory", "int"), ("src", "var_ssa_list")],
MediumLevelILOperation.MLIL_LOAD_SSA: [("src", "expr"), ("src_memory", "int")],
+ MediumLevelILOperation.MLIL_LOAD_STRUCT_SSA: [("src", "expr"), ("offset", "int"), ("src_memory", "int")],
MediumLevelILOperation.MLIL_STORE_SSA: [("dest", "expr"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
+ MediumLevelILOperation.MLIL_STORE_STRUCT_SSA: [("dest", "expr"), ("offset", "int"), ("dest_memory", "int"), ("src_memory", "int"), ("src", "expr")],
MediumLevelILOperation.MLIL_VAR_PHI: [("dest", "var_ssa"), ("src", "var_ssa_list")],
MediumLevelILOperation.MLIL_MEM_PHI: [("dest_memory", "int"), ("src_memory", "int_list")]
}
diff --git a/python/types.py b/python/types.py
index 5933661a..ab3fb337 100644
--- a/python/types.py
+++ b/python/types.py
@@ -332,6 +332,11 @@ class Type(object):
"""Type count (read-only)"""
return core.BNGetTypeElementCount(self.handle)
+ @property
+ def offset(self):
+ """Offset into structure (read-only)"""
+ return core.BNGetTypeOffset(self.handle)
+
def __str__(self):
return core.BNGetTypeString(self.handle)
diff --git a/type.cpp b/type.cpp
index 837b212d..19624cdd 100644
--- a/type.cpp
+++ b/type.cpp
@@ -414,6 +414,12 @@ uint64_t Type::GetElementCount() const
}
+uint64_t Type::GetOffset() const
+{
+ return BNGetTypeOffset(m_object);
+}
+
+
string Type::GetString() const
{
char* str = BNGetTypeString(m_object);