summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2024-02-13 13:10:11 -0500
committerJosh Ferrell <josh@vector35.com>2024-02-13 13:45:51 -0500
commit3607e3a8a94c1f1e16caa099bd81eaba6e182cb7 (patch)
tree4a4573da7d5c9246edaeec471fbdff9365089190
parentd1915bec3ee94c978f096a824a6eee73e5c6be26 (diff)
Rename ExternalLocation APIs to be more clear, add ExternalLocation and ExternalLibrary API documentation
-rw-r--r--binaryninjaapi.h20
-rw-r--r--binaryninjacore.h24
-rw-r--r--binaryview.cpp16
-rw-r--r--externallibrary.cpp36
-rw-r--r--python/binaryview.py72
-rw-r--r--python/exceptions.py4
-rw-r--r--python/externallibrary.py112
-rw-r--r--ui/externallocationdialog.h6
8 files changed, 209 insertions, 81 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index d412464d..55fd672c 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -2417,16 +2417,16 @@ namespace BinaryNinja {
public:
ExternalLocation(BNExternalLocation* loc);
- Ref<Symbol> GetInternalSymbol();
- std::optional<uint64_t> GetAddress();
- std::optional<std::string> GetSymbol();
+ Ref<Symbol> GetSourceSymbol();
+ std::optional<uint64_t> GetTargetAddress();
+ std::optional<std::string> GetTargetSymbol();
Ref<ExternalLibrary> GetExternalLibrary();
- bool HasAddress();
- bool HasSymbol();
+ bool HasTargetAddress();
+ bool HasTargetSymbol();
- void SetAddress(std::optional<uint64_t> address);
- void SetSymbol(std::optional<std::string> symbol);
+ bool SetTargetAddress(std::optional<uint64_t> address);
+ bool SetTargetSymbol(std::optional<std::string> symbol);
void SetExternalLibrary(Ref<ExternalLibrary> library);
};
@@ -6510,9 +6510,9 @@ namespace BinaryNinja {
Ref<ExternalLibrary> GetExternalLibrary(const std::string& name);
std::vector<Ref<ExternalLibrary>> GetExternalLibraries();
- Ref<ExternalLocation> AddExternalLocation(Ref<Symbol> internalSymbol, Ref<ExternalLibrary> library, std::optional<std::string> externalSymbol, std::optional<uint64_t> externalAddress, bool isAuto = false);
- void RemoveExternalLocation(Ref<Symbol> internalSymbol);
- Ref<ExternalLocation> GetExternalLocation(Ref<Symbol> internalSymbol);
+ Ref<ExternalLocation> AddExternalLocation(Ref<Symbol> sourceSymbol, Ref<ExternalLibrary> library, std::optional<std::string> targetSymbol, std::optional<uint64_t> targetAddress, bool isAuto = false);
+ void RemoveExternalLocation(Ref<Symbol> sourceSymbol);
+ Ref<ExternalLocation> GetExternalLocation(Ref<Symbol> sourceSymbol);
std::vector<Ref<ExternalLocation>> GetExternalLocations();
};
diff --git a/binaryninjacore.h b/binaryninjacore.h
index f78eed47..2c010328 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -37,14 +37,14 @@
// Current ABI version for linking to the core. This is incremented any time
// there are changes to the API that affect linking, including new functions,
// new types, or modifications to existing functions or types.
-#define BN_CURRENT_CORE_ABI_VERSION 51
+#define BN_CURRENT_CORE_ABI_VERSION 52
// Minimum ABI version that is supported for loading of plugins. Plugins that
// are linked to an ABI version less than this will not be able to load and
// will require rebuilding. The minimum version is increased when there are
// incompatible changes that break binary compatibility, such as changes to
// existing types or functions.
-#define BN_MINIMUM_CORE_ABI_VERSION 51
+#define BN_MINIMUM_CORE_ABI_VERSION 52
#ifdef __GNUC__
#ifdef BINARYNINJACORE_LIBRARY
@@ -3465,14 +3465,14 @@ extern "C"
BINARYNINJACOREAPI BNExternalLocation* BNNewExternalLocationReference(BNExternalLocation*loc);
BINARYNINJACOREAPI void BNFreeExternalLocation(BNExternalLocation*loc);
BINARYNINJACOREAPI void BNFreeExternalLocationList(BNExternalLocation**locs, size_t count);
- BINARYNINJACOREAPI BNSymbol* BNExternalLocationGetInternalSymbol(BNExternalLocation* loc);
- BINARYNINJACOREAPI uint64_t BNExternalLocationGetAddress(BNExternalLocation* loc);
- BINARYNINJACOREAPI char* BNExternalLocationGetSymbol(BNExternalLocation* loc);
+ BINARYNINJACOREAPI BNSymbol* BNExternalLocationGetSourceSymbol(BNExternalLocation* loc);
+ BINARYNINJACOREAPI uint64_t BNExternalLocationGetTargetAddress(BNExternalLocation* loc);
+ BINARYNINJACOREAPI char* BNExternalLocationGetTargetSymbol(BNExternalLocation* loc);
BINARYNINJACOREAPI BNExternalLibrary* BNExternalLocationGetExternalLibrary(BNExternalLocation* loc);
- BINARYNINJACOREAPI bool BNExternalLocationHasAddress(BNExternalLocation* loc);
- BINARYNINJACOREAPI bool BNExternalLocationHasSymbol(BNExternalLocation* loc);
- BINARYNINJACOREAPI void BNExternalLocationSetAddress(BNExternalLocation* loc, uint64_t* address);
- BINARYNINJACOREAPI void BNExternalLocationSetSymbol(BNExternalLocation* loc, const char* symbol);
+ BINARYNINJACOREAPI bool BNExternalLocationHasTargetAddress(BNExternalLocation* loc);
+ BINARYNINJACOREAPI bool BNExternalLocationHasTargetSymbol(BNExternalLocation* loc);
+ BINARYNINJACOREAPI bool BNExternalLocationSetTargetAddress(BNExternalLocation* loc, uint64_t* address);
+ BINARYNINJACOREAPI bool BNExternalLocationSetTargetSymbol(BNExternalLocation* loc, const char* symbol);
BINARYNINJACOREAPI void BNExternalLocationSetExternalLibrary(BNExternalLocation* loc, BNExternalLibrary* library);
// Database object
@@ -5936,9 +5936,9 @@ extern "C"
BINARYNINJACOREAPI void BNBinaryViewRemoveExternalLibrary(BNBinaryView* view, const char* name);
BINARYNINJACOREAPI BNExternalLibrary* BNBinaryViewGetExternalLibrary(BNBinaryView* view, const char* name);
BINARYNINJACOREAPI BNExternalLibrary** BNBinaryViewGetExternalLibraries(BNBinaryView* view, size_t* count);
- BINARYNINJACOREAPI BNExternalLocation* BNBinaryViewAddExternalLocation(BNBinaryView* view, BNSymbol* internalSymbol, BNExternalLibrary* library, const char* externalSymbol, uint64_t* externalAddress, bool isAuto);
- BINARYNINJACOREAPI void BNBinaryViewRemoveExternalLocation(BNBinaryView* view, BNSymbol* internalSymbol);
- BINARYNINJACOREAPI BNExternalLocation* BNBinaryViewGetExternalLocation(BNBinaryView* view, BNSymbol* internalSymbol);
+ BINARYNINJACOREAPI BNExternalLocation* BNBinaryViewAddExternalLocation(BNBinaryView* view, BNSymbol* sourceSymbol, BNExternalLibrary* library, const char* targetSymbol, uint64_t* targetAddress, bool isAuto);
+ BINARYNINJACOREAPI void BNBinaryViewRemoveExternalLocation(BNBinaryView* view, BNSymbol* sourceSymbol);
+ BINARYNINJACOREAPI BNExternalLocation* BNBinaryViewGetExternalLocation(BNBinaryView* view, BNSymbol* sourceSymbol);
BINARYNINJACOREAPI BNExternalLocation** BNBinaryViewGetExternalLocations(BNBinaryView* view, size_t* count);
// Source code processing
diff --git a/binaryview.cpp b/binaryview.cpp
index 057c0954..0dd6d8f8 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -5139,13 +5139,13 @@ std::vector<Ref<ExternalLibrary>> BinaryView::GetExternalLibraries()
}
-Ref<ExternalLocation> BinaryView::AddExternalLocation(Ref<Symbol> internalSymbol, Ref<ExternalLibrary> library, std::optional<std::string> externalSymbol, std::optional<uint64_t> externalAddress, bool isAuto)
+Ref<ExternalLocation> BinaryView::AddExternalLocation(Ref<Symbol> sourceSymbol, Ref<ExternalLibrary> library, std::optional<std::string> targetSymbol, std::optional<uint64_t> targetAddress, bool isAuto)
{
BNExternalLocation* loc = BNBinaryViewAddExternalLocation(m_object,
- internalSymbol->GetObject(),
+ sourceSymbol->GetObject(),
library ? library->m_object : nullptr,
- externalSymbol.has_value() ? externalSymbol.value().c_str() : nullptr,
- externalAddress.has_value() ? &externalAddress.value() : nullptr,
+ targetSymbol.has_value() ? targetSymbol.value().c_str() : nullptr,
+ targetAddress.has_value() ? &targetAddress.value() : nullptr,
isAuto
);
@@ -5155,15 +5155,15 @@ Ref<ExternalLocation> BinaryView::AddExternalLocation(Ref<Symbol> internalSymbol
}
-void BinaryView::RemoveExternalLocation(Ref<Symbol> internalSymbol)
+void BinaryView::RemoveExternalLocation(Ref<Symbol> sourceSymbol)
{
- BNBinaryViewRemoveExternalLocation(m_object, internalSymbol->GetObject());
+ BNBinaryViewRemoveExternalLocation(m_object, sourceSymbol->GetObject());
}
-Ref<ExternalLocation> BinaryView::GetExternalLocation(Ref<Symbol> internalSymbol)
+Ref<ExternalLocation> BinaryView::GetExternalLocation(Ref<Symbol> sourceSymbol)
{
- BNExternalLocation* loc = BNBinaryViewGetExternalLocation(m_object, internalSymbol->GetObject());
+ BNExternalLocation* loc = BNBinaryViewGetExternalLocation(m_object, sourceSymbol->GetObject());
if (!loc)
return nullptr;
return new ExternalLocation(BNNewExternalLocationReference(loc));
diff --git a/externallibrary.cpp b/externallibrary.cpp
index 77b9cabc..2da8f6df 100644
--- a/externallibrary.cpp
+++ b/externallibrary.cpp
@@ -60,28 +60,28 @@ ExternalLocation::ExternalLocation(BNExternalLocation* loc)
}
-Ref<Symbol> ExternalLocation::GetInternalSymbol()
+Ref<Symbol> ExternalLocation::GetSourceSymbol()
{
- BNSymbol* sym = BNExternalLocationGetInternalSymbol(m_object);
+ BNSymbol* sym = BNExternalLocationGetSourceSymbol(m_object);
return new Symbol(sym);
}
-std::optional<uint64_t> ExternalLocation::GetAddress()
+std::optional<uint64_t> ExternalLocation::GetTargetAddress()
{
- if (BNExternalLocationHasAddress(m_object))
+ if (BNExternalLocationHasTargetAddress(m_object))
{
- return BNExternalLocationGetAddress(m_object);
+ return BNExternalLocationGetTargetAddress(m_object);
}
return {};
}
-std::optional<std::string> ExternalLocation::GetSymbol()
+std::optional<std::string> ExternalLocation::GetTargetSymbol()
{
- if (BNExternalLocationHasSymbol(m_object))
+ if (BNExternalLocationHasTargetSymbol(m_object))
{
- return BNExternalLocationGetSymbol(m_object);
+ return BNExternalLocationGetTargetSymbol(m_object);
}
return {};
}
@@ -96,42 +96,42 @@ Ref<ExternalLibrary> ExternalLocation::GetExternalLibrary()
}
-bool ExternalLocation::HasAddress()
+bool ExternalLocation::HasTargetAddress()
{
- return BNExternalLocationHasAddress(m_object);
+ return BNExternalLocationHasTargetAddress(m_object);
}
-bool ExternalLocation::HasSymbol()
+bool ExternalLocation::HasTargetSymbol()
{
- return BNExternalLocationHasSymbol(m_object);
+ return BNExternalLocationHasTargetSymbol(m_object);
}
-void ExternalLocation::SetAddress(std::optional<uint64_t> address)
+bool ExternalLocation::SetTargetAddress(std::optional<uint64_t> address)
{
if (address.has_value())
{
uint64_t addr = address.value();
- BNExternalLocationSetAddress(m_object, &addr);
+ return BNExternalLocationSetTargetAddress(m_object, &addr);
}
else
{
- BNExternalLocationSetAddress(m_object, nullptr);
+ return BNExternalLocationSetTargetAddress(m_object, nullptr);
}
}
-void ExternalLocation::SetSymbol(std::optional<std::string> symbol)
+bool ExternalLocation::SetTargetSymbol(std::optional<std::string> symbol)
{
if (symbol.has_value())
{
std::string sym = symbol.value();
- BNExternalLocationSetSymbol(m_object, sym.c_str());
+ return BNExternalLocationSetTargetSymbol(m_object, sym.c_str());
}
else
{
- BNExternalLocationSetSymbol(m_object, nullptr);
+ return BNExternalLocationSetTargetSymbol(m_object, nullptr);
}
}
diff --git a/python/binaryview.py b/python/binaryview.py
index 74f6c2ff..cfce2c96 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -45,7 +45,7 @@ from .enums import (
AnalysisState, SymbolType, Endianness, ModificationStatus, StringType, SegmentFlag, SectionSemantics, FindFlag,
TypeClass, BinaryViewEventType, FunctionGraphType, TagReferenceType, TagTypeType, RegisterValueType, DisassemblyOption
)
-from .exceptions import RelocationWriteException, ILException
+from .exceptions import RelocationWriteException, ILException, ExternalLinkException
from . import associateddatastore # required for _BinaryViewAssociatedDataStore
from .log import log_warn, log_error, Logger
@@ -9143,6 +9143,14 @@ class BinaryView:
return Logger(self.file.session_id, logger_name)
def add_external_library(self, name: str, backing_file: Optional['project.ProjectFile'] = None, auto: bool = False) -> externallibrary.ExternalLibrary:
+ """
+ Add an ExternalLibrary to this BinaryView
+
+ :param name: Name of the external library
+ :param backing_file: Optional ProjectFile that backs the external library
+ :param auto: Whether or not this action is the result of automated analysis
+ :return: The created ExternalLibrary
+ """
file_handle = None
if backing_file is not None:
file_handle = backing_file._handle
@@ -9151,15 +9159,32 @@ class BinaryView:
return externallibrary.ExternalLibrary(handle)
def remove_external_library(self, name: str):
+ """
+ Remove an ExternalLibrary from this BinaryView by name.
+ Any associated ExternalLocations will be unassociated from the ExternalLibrary
+
+ :param name: Name of the external library to remove
+ """
core.BNBinaryViewRemoveExternalLibrary(self.handle, name)
def get_external_library(self, name: str) -> Optional[externallibrary.ExternalLibrary]:
+ """
+ Get an ExternalLibrary in this BinaryView by name
+
+ :param name: Name of the external library
+ :return: An ExternalLibrary with the given name, or None
+ """
handle = core.BNBinaryViewGetExternalLibrary(self.handle, name)
if handle is None:
return None
return externallibrary.ExternalLibrary(handle)
def get_external_libraries(self) -> List[externallibrary.ExternalLibrary]:
+ """
+ Get a list of all ExternalLibrary in this BinaryView
+
+ :return: A list of ExternalLibraries in this BinaryView
+ """
count = ctypes.c_ulonglong(0)
handles = core.BNBinaryViewGetExternalLibraries(self.handle, count)
assert handles is not None, "core.BNBinaryViewGetExternalLibraries returned None"
@@ -9173,25 +9198,54 @@ class BinaryView:
finally:
core.BNFreeExternalLibraryList(handles, count.value)
- def add_external_location(self, symbol: '_types.CoreSymbol', library: Optional[externallibrary.ExternalLibrary], external_symbol: Optional[str], external_address: Optional[int], auto: bool = False) -> externallibrary.ExternalLocation:
+ def add_external_location(self, source_symbol: '_types.CoreSymbol', library: Optional[externallibrary.ExternalLibrary], target_symbol: Optional[str], target_address: Optional[int], auto: bool = False) -> externallibrary.ExternalLocation:
+ """
+ Add an ExternalLocation with its source in this BinaryView.
+ ExternalLocations must have a target address and/or symbol.
+
+ :param source_symbol: Symbol that the association is from
+ :param library: Library that the ExternalLocation belongs to
+ :param target_symbol: Symbol that the ExternalLocation points to
+ :param target_address: Address that the ExternalLocation points to
+ :param auto: Whether or not this action is the result of automated analysis
+ :return: The created ExternalLocation
+ """
c_addr = None
- if external_address is not None:
- c_addr = ctypes.c_ulonglong(external_address)
+ if target_address is not None:
+ c_addr = ctypes.c_ulonglong(target_address)
+ elif target_symbol is None:
+ raise ExternalLinkException("External locations must have a target address and/or symbol")
- handle = core.BNBinaryViewAddExternalLocation(self.handle, symbol.handle, library._handle if library else None, external_symbol, c_addr, auto)
+ handle = core.BNBinaryViewAddExternalLocation(self.handle, source_symbol.handle, library._handle if library else None, target_symbol, c_addr, auto)
assert handle is not None, "core.BNBinaryViewAddExternalLocation returned None"
return externallibrary.ExternalLocation(handle)
- def remove_external_location(self, symbol: '_types.CoreSymbol'):
- core.BNBinaryViewRemoveExternalLocation(self.handle, symbol._handle)
+ def remove_external_location(self, source_symbol: '_types.CoreSymbol'):
+ """
+ Remove the ExternalLocation with the given source symbol from this BinaryView
+
+ :param source_symbol: Source symbol that will be used to determine the ExternalLocation to remove
+ """
+ core.BNBinaryViewRemoveExternalLocation(self.handle, source_symbol._handle)
+
+ def get_external_location(self, source_symbol: '_types.CoreSymbol') -> Optional[externallibrary.ExternalLocation]:
+ """
+ Get the ExternalLocation with the given source symbol in this BinaryView
- def get_external_location(self, symbol: '_types.CoreSymbol') -> Optional[externallibrary.ExternalLocation]:
- handle = core.BNBinaryViewGetExternalLocation(self.handle, symbol.handle)
+ :param source_symbol: The source symbol of the ExternalLocation
+ :return: An ExternalLocation with the given source symbol, or None
+ """
+ handle = core.BNBinaryViewGetExternalLocation(self.handle, source_symbol.handle)
if handle is None:
return None
return externallibrary.ExternalLocation(handle)
def get_external_locations(self) -> List[externallibrary.ExternalLocation]:
+ """
+ Get a list of ExternalLocations in this BinaryView
+
+ :return: A list of ExternalLocations in this BinaryView
+ """
count = ctypes.c_ulonglong(0)
handles = core.BNBinaryViewGetExternalLocations(self.handle, count)
assert handles is not None, "core.BNBinaryViewGetExternalLocations returned None"
diff --git a/python/exceptions.py b/python/exceptions.py
index a2ba197a..a9b4b5aa 100644
--- a/python/exceptions.py
+++ b/python/exceptions.py
@@ -9,3 +9,7 @@ class ILException(Exception):
class ProjectException(Exception):
""" Exception raised when project operations fail """
pass
+
+class ExternalLinkException(Exception):
+ """ Exception raised when external library/location operations fail """
+ pass
diff --git a/python/externallibrary.py b/python/externallibrary.py
index 8164465a..c4aa0528 100644
--- a/python/externallibrary.py
+++ b/python/externallibrary.py
@@ -29,6 +29,9 @@ from . import types
class ExternalLibrary:
+ """
+ An ExternalLibrary is an abstraction for a library that is optionally backed by a ProjectFile.
+ """
def __init__(self, handle: core.BNExternalLibrary):
self._handle = handle
@@ -44,10 +47,20 @@ class ExternalLibrary:
@property
def name(self) -> str:
+ """
+ Get the name of this external library
+
+ :return: The name of this external library
+ """
return core.BNExternalLibraryGetName(self._handle) # type: ignore
@property
def backing_file(self) -> Optional[project.ProjectFile]:
+ """
+ Get the file backing this external library
+
+ :return: The file backing this external library or None
+ """
handle = core.BNExternalLibraryGetBackingFile(self._handle)
if handle is None:
return None
@@ -55,6 +68,11 @@ class ExternalLibrary:
@backing_file.setter
def backing_file(self, new_file: Optional[project.ProjectFile]):
+ """
+ Set the file backing this external library
+
+ :param new_file: The file that will back this external library
+ """
new_file_handle = None
if new_file is not None:
new_file_handle = new_file._handle
@@ -62,6 +80,9 @@ class ExternalLibrary:
class ExternalLocation:
+ """
+ An ExternalLocation is an association from a source symbol in a binary view to a target symbol and/or address in an ExternalLibrary.
+ """
def __init__(self, handle: core.BNExternalLocation):
self._handle = handle
@@ -70,50 +91,94 @@ class ExternalLocation:
core.BNFreeExternalLocation(self._handle)
def __repr__(self) -> str:
- return f'<ExternalLocation: {self.internal_symbol}>'
+ return f'<ExternalLocation: {self.source_symbol}>'
def __str__(self) -> str:
- return f'<ExternalLocation: {self.internal_symbol}>'
+ return f'<ExternalLocation: {self.source_symbol}>'
@property
- def internal_symbol(self) -> 'types.CoreSymbol':
- sym = core.BNExternalLocationGetInternalSymbol(self._handle)
- assert sym is not None, "core.BNExternalLocationGetInternalSymbol returned None"
+ def source_symbol(self) -> 'types.CoreSymbol':
+ """
+ Get the source symbol for this ExternalLocation
+
+ :return: The source symbol for this ExternalLocation
+ """
+ sym = core.BNExternalLocationGetSourceSymbol(self._handle)
+ assert sym is not None, "core.BNExternalLocationGetSourceSymbol returned None"
return types.CoreSymbol(sym)
@property
- def has_address(self) -> bool:
- return core.BNExternalLocationHasAddress(self._handle)
+ def has_target_address(self) -> bool:
+ """
+ Check if this ExternalLocation has a target address
+
+ :return: True is this ExternalLocation has a target address, False otherwise
+ """
+ return core.BNExternalLocationHasTargetAddress(self._handle)
@property
- def has_symbol(self) -> bool:
- return core.BNExternalLocationHasSymbol(self._handle)
+ def has_target_symbol(self) -> bool:
+ """
+ Check if this ExternalLocation has a target symbol
+
+ :return: True is this ExternalLocation has a target symbol, False otherwise
+ """
+ return core.BNExternalLocationHasTargetSymbol(self._handle)
@property
- def address(self) -> Optional[int]:
- if not self.has_address:
+ def target_address(self) -> Optional[int]:
+ """
+ Get the address pointed to by this ExternalLocation
+
+ :return: The address pointed to by this ExternalLocation if one exists, None otherwise
+ """
+ if not self.has_target_address:
return None
- return core.BNExternalLocationGetAddress(self._handle)
+ return core.BNExternalLocationGetTargetAddress(self._handle)
+
+ @target_address.setter
+ def target_address(self, new_address: Optional[int]) -> bool:
+ """
+ Set the address pointed to by this ExternalLocation.
+ ExternalLocations must have a valid target address and/or symbol set.
- @address.setter
- def address(self, new_address: Optional[int]):
+ :param new_address: The address that this ExternalLocation will point to
+ :return: True if the address was set, False otherwise
+ """
c_addr = None
if new_address is not None:
c_addr = ctypes.c_ulonglong(new_address)
- return core.BNExternalLocationSetAddress(self._handle, c_addr)
+ return core.BNExternalLocationSetTargetAddress(self._handle, c_addr)
@property
- def symbol(self) -> Optional[str]:
- if not self.has_symbol:
+ def target_symbol(self) -> Optional[str]:
+ """
+ Get the symbol pointed to by this ExternalLocation
+
+ :return: The symbol pointed to by this ExternalLocation if one exists, None otherwise
+ """
+ if not self.has_target_symbol:
return None
- return core.BNExternalLocationGetSymbol(self._handle)
+ return core.BNExternalLocationGetTargetSymbol(self._handle)
- @symbol.setter
- def symbol(self, new_symbol: Optional[str]):
- return core.BNExternalLocationSetSymbol(self._handle, new_symbol)
+ @target_symbol.setter
+ def target_symbol(self, new_symbol: Optional[str]) -> bool:
+ """
+ Set the symbol pointed to by this ExternalLocation.
+ ExternalLocations must have a valid target address and/or symbol set.
+
+ :param new_symbol: The raw symbol that this ExternalLocation will point to
+ :return: True if the symbol was set, False otherwise
+ """
+ return core.BNExternalLocationSetTargetSymbol(self._handle, new_symbol)
@property
def library(self) -> Optional[ExternalLibrary]:
+ """
+ Get the ExternalLibrary that this ExternalLocation targets
+
+ :return: The ExternalLibrary pointed in to by this ExternalLocation if one exists, None otherwise
+ """
handle = core.BNExternalLocationGetExternalLibrary(self._handle)
if handle is None:
return None
@@ -121,5 +186,10 @@ class ExternalLocation:
@library.setter
def library(self, new_library: Optional[ExternalLibrary]):
+ """
+ Set the ExternalLibrary that this ExternalLocation targets
+
+ :param new_library: The ExternalLibrary that this ExternalLocation will pointed in to
+ """
lib_handle = new_library._handle if new_library is not None else None
return core.BNExternalLocationSetExternalLibrary(self._handle, lib_handle)
diff --git a/ui/externallocationdialog.h b/ui/externallocationdialog.h
index c86eea70..13a8d2ad 100644
--- a/ui/externallocationdialog.h
+++ b/ui/externallocationdialog.h
@@ -12,10 +12,10 @@ class BINARYNINJAUIAPI ExternalLocationDialog : public QDialog
QPushButton* m_acceptButton;
QPushButton* m_cancelButton;
- QLineEdit* m_internalSymbolField;
+ QLineEdit* m_sourceSymbolField;
QComboBox* m_libraryField;
- QLineEdit* m_externalSymbolField;
- QLineEdit* m_addressField;
+ QLineEdit* m_targetSymbolField;
+ QLineEdit* m_targetaddressField;
BinaryViewRef m_data;
ExternalLocationRef m_location;