diff options
| author | Peter LaFosse <peter@vector35.com> | 2017-05-25 19:51:45 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2017-05-25 19:51:52 -0400 |
| commit | d7cb0b3acc0621aa69061d0d1199ac33c664e58f (patch) | |
| tree | 9a0cda4bd39ca7ba7d88821ba7d2ee17db47c41d | |
| parent | 18c3e2e49ceef496d272f6bcbf81b0d768f29acb (diff) | |
Modify how structures are created in the type system, expose additional structure APIs
| -rw-r--r-- | binaryninjaapi.h | 6 | ||||
| -rw-r--r-- | binaryninjacore.h | 5 | ||||
| -rw-r--r-- | python/types.py | 12 | ||||
| -rw-r--r-- | type.cpp | 14 |
4 files changed, 24 insertions, 13 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index d27ab5fa..5ea6d909 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1723,7 +1723,7 @@ namespace BinaryNinja public: Structure(); Structure(BNStructure* s); - Structure(BNStructureType type, bool isUnion = false, bool packed = false); + Structure(BNStructureType type, bool packed = false); std::vector<StructureMember> GetMembers() const; uint64_t GetWidth() const; @@ -1733,8 +1733,8 @@ namespace BinaryNinja bool IsPacked() const; void SetPacked(bool packed); bool IsUnion() const; - void SetUnion(bool u); - + void SetStructureType(BNStructureType type); + BNStructureType GetStructureType() const; void AddMember(Type* type, const std::string& name); void AddMemberAtOffset(Type* type, const std::string& name, uint64_t offset); void RemoveMember(size_t idx); diff --git a/binaryninjacore.h b/binaryninjacore.h index 23014782..8880747c 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -2496,7 +2496,7 @@ extern "C" BINARYNINJACOREAPI BNNamedTypeReference* BNNewNamedTypeReference(BNNamedTypeReference* nt); BINARYNINJACOREAPI BNStructure* BNCreateStructure(void); - BINARYNINJACOREAPI BNStructure* BNCreateStructureWithOptions(BNStructureType type, bool isUnion, bool packed); + BINARYNINJACOREAPI BNStructure* BNCreateStructureWithOptions(BNStructureType type, bool packed); BINARYNINJACOREAPI BNStructure* BNNewStructureReference(BNStructure* s); BINARYNINJACOREAPI void BNFreeStructure(BNStructure* s); @@ -2509,7 +2509,8 @@ extern "C" BINARYNINJACOREAPI bool BNIsStructurePacked(BNStructure* s); BINARYNINJACOREAPI void BNSetStructurePacked(BNStructure* s, bool packed); BINARYNINJACOREAPI bool BNIsStructureUnion(BNStructure* s); - BINARYNINJACOREAPI void BNSetStructureUnion(BNStructure* s, bool u); + BINARYNINJACOREAPI void BNSetStructureType(BNStructure* s, BNStructureType type); + BINARYNINJACOREAPI BNStructureType BNGetStructureType(BNStructure* s); BINARYNINJACOREAPI void BNAddStructureMember(BNStructure* s, BNType* type, const char* name); BINARYNINJACOREAPI void BNAddStructureMemberAtOffset(BNStructure* s, BNType* type, const char* name, uint64_t offset); diff --git a/python/types.py b/python/types.py index 1e566f68..f8e416f4 100644 --- a/python/types.py +++ b/python/types.py @@ -22,7 +22,7 @@ import ctypes # Binary Ninja components import _binaryninjacore as core -from enums import SymbolType, TypeClass, NamedTypeReferenceClass, InstructionTextTokenType +from enums import SymbolType, TypeClass, NamedTypeReferenceClass, InstructionTextTokenType, StructureType import callingconvention import function @@ -646,9 +646,13 @@ class Structure(object): def union(self): return core.BNIsStructureUnion(self.handle) - @union.setter - def union(self, value): - core.BNSetStructureUnion(self.handle, value) + @property + def type(self): + return StructureType(core.BNGetStructureType(self.handle)) + + @type.setter + def type(self, value): + core.BNSetStructureType(self.handle, value) def __setattr__(self, name, value): try: @@ -784,9 +784,9 @@ Structure::Structure() } -Structure::Structure(BNStructureType type, bool isUnion, bool packed) +Structure::Structure(BNStructureType type, bool packed) { - m_object = BNCreateStructureWithOptions(type, isUnion, packed); + m_object = BNCreateStructureWithOptions(type, packed); } @@ -858,9 +858,15 @@ bool Structure::IsUnion() const } -void Structure::SetUnion(bool u) +void Structure::SetStructureType(BNStructureType t) { - BNSetStructureUnion(m_object, u); + BNSetStructureType(m_object, t); +} + + +BNStructureType Structure::GetStructureType() const +{ + return BNGetStructureType(m_object); } |
