diff options
| author | Brian Potchik <brian@vector35.com> | 2019-04-11 17:36:24 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2019-04-11 17:36:24 -0400 |
| commit | 1eee7293d9a171ba6c2e1e3d33be6d693ac66aee (patch) | |
| tree | a5e258b62c5e3abb4eeeafac9fc5fdcc3dae7181 /python/binaryview.py | |
| parent | 5e03e100bd0dcf5033476be3c3ab3ccad86532e6 (diff) | |
Add partial support to get_string_at.
Diffstat (limited to 'python/binaryview.py')
| -rw-r--r-- | python/binaryview.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index ca780fc4..22ecfa9a 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -3134,11 +3134,12 @@ class BinaryView(object): core.BNFreeStringReferenceList(strings) return result - def get_string_at(self, addr): + def get_string_at(self, addr, partial=False): """ ``get_string_at`` returns the string that falls on given virtual address. :param int addr: virtual address to get the string from + :param bool partial: whether to return a partial string reference or not :return: returns the StringReference at the given virtual address, otherwise None. :rtype: StringReference :Example: @@ -3150,7 +3151,12 @@ class BinaryView(object): str_ref = core.BNStringReference() if not core.BNGetStringAtAddress(self.handle, addr, str_ref): return None - return StringReference(self, StringType(str_ref.type), str_ref.start, str_ref.length) + if str_ref.type != StringType.AsciiString: + partial = False + log.log_warn("Partial string not supported at 0x{}".format(hex(addr))) + start = addr if partial else str_ref.start + length = str_ref.length - (addr - str_ref.start) if partial else str_ref.length + return StringReference(self, StringType(str_ref.type), start, length) def get_ascii_string_at(self, addr, min_length=4, max_length=None, require_cstring=True): """ |
