diff options
| author | Peter LaFosse <peter@vector35.com> | 2021-11-29 09:23:53 -0500 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2021-11-29 11:39:13 -0500 |
| commit | bbf4d616ebdec77538832c1353b8e200a1ad9bbf (patch) | |
| tree | 9e9562c4538841753ad601a359bc8960842a5bfe /python/types.py | |
| parent | 38a232121c233225860fec8fa929ebeb555dad88 (diff) | |
Better handling of symbols whose raw names are obfuscated
Diffstat (limited to 'python/types.py')
| -rw-r--r-- | python/types.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/python/types.py b/python/types.py index 4dbd9174..40a49ba8 100644 --- a/python/types.py +++ b/python/types.py @@ -218,7 +218,10 @@ class CoreSymbol: core.BNFreeSymbol(self._handle) def __repr__(self): - return f"<{self.type.name}: \"{self.full_name}\" @ {self.address:#x}>" + try: + return f"<{self.type.name}: \"{self.full_name}\" @ {self.address:#x}>" + except UnicodeDecodeError: + return f"<{self.type.name}: \"{self.raw_bytes}\" @ {self.address:#x}>" def __eq__(self, other): if not isinstance(other, self.__class__): @@ -272,6 +275,17 @@ class CoreSymbol: return core.BNGetSymbolRawName(self._handle) @property + def raw_bytes(self) -> bytes: + """Bytes of the raw symbol (read-only)""" + count = ctypes.c_ulonglong() + result = core.BNGetSymbolRawBytes(self._handle, count) + assert result is not None, "core.BNGetSymbolRawBytes returned None" + buf = ctypes.create_string_buffer(count.value) + ctypes.memmove(buf, result, count.value) + core.BNFreeSymbolRawBytes(result) + return buf.raw + + @property def address(self) -> int: """Symbol address (read-only)""" return core.BNGetSymbolAddress(self._handle) |
