summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Snyder <ryan@vector35.com>2019-09-13 21:08:25 -0400
committerRyan Snyder <ryan@vector35.com>2019-09-24 10:42:26 -0400
commitca2d870a3aac0b2154b06f3ab075ca22bd0a0596 (patch)
treef2e56d17914d4412737f788959ab1ecc6531bfd9
parentc5bd94376017e9d9d98a4dba2fac6b49572cda6d (diff)
typelibrary: more consistent naming, type exports
-rw-r--r--binaryninjacore.h13
-rw-r--r--python/architecture.py3
-rw-r--r--python/binaryview.py28
-rw-r--r--python/platform.py2
4 files changed, 33 insertions, 13 deletions
diff --git a/binaryninjacore.h b/binaryninjacore.h
index af26a67b..1e0ba256 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -3451,12 +3451,15 @@ extern "C"
BINARYNINJACOREAPI void BNWriteTypeLibraryToFile(BNTypeLibrary* lib, const char* path);
- BINARYNINJACOREAPI void BNBinaryViewAddTypeLibrary(BNBinaryView* view, BNTypeLibrary* lib);
- BINARYNINJACOREAPI BNTypeLibrary* BNBinaryViewGetTypeLibrary(BNBinaryView* view, const char* name);
- BINARYNINJACOREAPI BNTypeLibrary** BNBinaryViewGetTypeLibraries(BNBinaryView* view, size_t* count);
+ BINARYNINJACOREAPI void BNAddBinaryViewTypeLibrary(BNBinaryView* view, BNTypeLibrary* lib);
+ BINARYNINJACOREAPI BNTypeLibrary* BNGetBinaryViewTypeLibrary(BNBinaryView* view, const char* name);
+ BINARYNINJACOREAPI BNTypeLibrary** BNGetBinaryViewTypeLibraries(BNBinaryView* view, size_t* count);
- BINARYNINJACOREAPI BNType* BNBinaryViewImportLibraryType(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name);
- BINARYNINJACOREAPI BNType* BNBinaryViewImportLibraryObject(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name);
+ BINARYNINJACOREAPI BNType* BNBinaryViewImportTypeLibraryType(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name);
+ BINARYNINJACOREAPI BNType* BNBinaryViewImportTypeLibraryObject(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name);
+
+ BINARYNINJACOREAPI void BNBinaryViewExportTypeToTypeLibrary(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name, BNType* type);
+ BINARYNINJACOREAPI void BNBinaryViewExportObjectToTypeLibrary(BNBinaryView* view, BNTypeLibrary* lib, BNQualifiedName* name, BNType* type);
// Types
BINARYNINJACOREAPI bool BNTypesEqual(BNType* a, BNType* b);
diff --git a/python/architecture.py b/python/architecture.py
index 296bdab9..8498951d 100644
--- a/python/architecture.py
+++ b/python/architecture.py
@@ -31,7 +31,6 @@ import binaryninja
from binaryninja import log
from binaryninja import lowlevelil
from binaryninja import types
-from binaryninja import typelibrary
from binaryninja import databuffer
from binaryninja import platform
from binaryninja import callingconvention
@@ -438,7 +437,7 @@ class Architecture(with_metaclass(_ArchitectureMetaClass, object)):
result = []
handles = core.BNGetArchitectureTypeLibraries(self.handle, count)
for i in range(0, count.value):
- result.append(typelibrary.TypeLibrary(core.BNNewTypeLibraryReference(handles[i])))
+ result.append(binaryninja.typelibrary.TypeLibrary(core.BNNewTypeLibraryReference(handles[i])))
core.BNFreeTypeLibraryList(handles, count.value)
return result
diff --git a/python/binaryview.py b/python/binaryview.py
index fe3d7dbe..251e96dd 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -1621,7 +1621,7 @@ class BinaryView(object):
def type_libraries(self):
"""List of imported type libraries (read-only)"""
count = ctypes.c_ulonglong(0)
- libraries = core.BNBinaryViewGetTypeLibraries(self.handle, count)
+ libraries = core.BNGetBinaryViewTypeLibraries(self.handle, count)
result = []
for i in range(0, count.value):
result.append(typelibrary.TypeLibrary(core.BNNewTypeLibraryReference(libraries[i])))
@@ -4500,7 +4500,7 @@ class BinaryView(object):
"""
if not isinstance(lib, typelibrary.TypeLibrary):
raise ValueError("must pass in a TypeLibrary object")
- core.BNBinaryViewAddTypeLibrary(self.handle, lib.handle)
+ core.BNAddBinaryViewTypeLibrary(self.handle, lib.handle)
def get_type_library(self, name):
"""
@@ -4512,7 +4512,7 @@ class BinaryView(object):
:Example:
"""
- handle = core.BNBinaryViewGetTypeLibrary(self.handle, name)
+ handle = core.BNGetBinaryViewTypeLibrary(self.handle, name)
if handle is None:
return None
return typelibrary.TypeLibrary(handle)
@@ -4640,7 +4640,7 @@ class BinaryView(object):
def import_library_type(self, name, lib = None):
if not isinstance(name, types.QualifiedName):
name = types.QualifiedName(name)
- handle = core.BNBinaryViewImportLibraryType(self.handle, None if lib is None else lib.handle, name._get_core_struct())
+ handle = core.BNBinaryViewImportTypeLibraryType(self.handle, None if lib is None else lib.handle, name._get_core_struct())
if handle is None:
return None
return types.Type(handle, platform = self.platform)
@@ -4648,11 +4648,29 @@ class BinaryView(object):
def import_library_object(self, name, lib = None):
if not isinstance(name, types.QualifiedName):
name = types.QualifiedName(name)
- handle = core.BNBinaryViewImportLibraryObject(self.handle, None if lib is None else lib.handle, name._get_core_struct())
+ handle = core.BNBinaryViewImportTypeLibraryObject(self.handle, None if lib is None else lib.handle, name._get_core_struct())
if handle is None:
return None
return types.Type(handle, platform = self.platform)
+ def export_type_to_library(self, lib, name, type_obj):
+ if not isinstance(name, types.QualifiedName):
+ name = types.QualifiedName(name)
+ if not isinstance(lib, typelibrary.TypeLibrary):
+ raise ValueError("lib must be a TypeLibrary object")
+ if not isinstance(type_obj, types.Type):
+ raise ValueError("type_obj must be a Type object")
+ core.BNBinaryViewExportTypeToTypeLibrary(self.handle, lib.handle, name._get_core_struct(), type_obj.handle)
+
+ def export_object_to_library(self, lib, name, type_obj):
+ if not isinstance(name, types.QualifiedName):
+ name = types.QualifiedName(name)
+ if not isinstance(lib, typelibrary.TypeLibrary):
+ raise ValueError("lib must be a TypeLibrary object")
+ if not isinstance(type_obj, types.Type):
+ raise ValueError("type_obj must be a Type object")
+ core.BNBinaryViewExportObjectToTypeLibrary(self.handle, lib.handle, name._get_core_struct(), type_obj.handle)
+
def register_platform_types(self, platform):
"""
``register_platform_types`` ensures that the platform-specific types for a :py:Class:`Platform` are available
diff --git a/python/platform.py b/python/platform.py
index 2d061172..2091e1d1 100644
--- a/python/platform.py
+++ b/python/platform.py
@@ -296,7 +296,7 @@ class Platform(with_metaclass(_PlatformMetaClass, object)):
core.BNFreeTypeLibraryList(libs, count.value)
return result
- def type_libraries_by_name(self, name):
+ def get_type_libraries_by_name(self, name):
count = ctypes.c_ulonglong(0)
libs = core.BNGetPlatformTypeLibrariesByName(self.handle, name, count)
result = []