MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / get_ascii_string_at

Method get_ascii_string_at

python/binaryview.py:7255–7299  ·  view source on GitHub ↗

``get_ascii_string_at`` returns an ascii string found at ``addr``. .. note:: This returns an ascii string irrespective of whether the core analysis identified a string at that location. For an alternative API that uses existing identified strings, use :py:func:`get_string_at`. :param int ad

(self, addr: int, min_length: int = 4, max_length: Optional[int] = None,
	                        require_cstring: bool = True)

Source from the content-addressed store, hash-verified

7253 return StringReference(self, StringType(str_ref.type), start, length)
7254
7255 def get_ascii_string_at(self, addr: int, min_length: int = 4, max_length: Optional[int] = None,
7256 require_cstring: bool = True) -> Optional['StringReference']:
7257 """
7258 ``get_ascii_string_at`` returns an ascii string found at ``addr``.
7259
7260 .. note:: This returns an ascii string irrespective of whether the core analysis identified a string at that location. For an alternative API that uses existing identified strings, use :py:func:`get_string_at`.
7261
7262 :param int addr: virtual address to start the string
7263 :param int min_length: minimum length to define a string
7264 :param int max_length: max length string to return
7265 :param bool require_cstring: only return 0x0-terminated strings
7266 :return: the string found at ``addr`` or None if a string does not exist
7267 :rtype: StringReference or None
7268 :Example:
7269
7270 >>> s1 = bv.get_ascii_string_at(0x70d0)
7271 >>> s1
7272 <AsciiString: 0x70d0, len 0xb>
7273 >>> s1.value
7274 'AWAVAUATUSH'
7275 >>> s2 = bv.get_ascii_string_at(0x70d1)
7276 >>> s2
7277 <AsciiString: 0x70d1, len 0xa>
7278 >>> s2.value
7279 'WAVAUATUSH'
7280 """
7281 if not isinstance(addr, int):
7282 raise ValueError("Input address (" + str(addr) + ") is not a number.")
7283 if addr < self.start or addr >= self.end:
7284 return None
7285
7286 br = BinaryReader(self)
7287 br.seek(addr)
7288 length = 0
7289 c = br.read8()
7290 while c is not None and c > 0 and c <= 0x7f:
7291 if length == max_length:
7292 break
7293 length += 1
7294 c = br.read8()
7295 if length < min_length:
7296 return None
7297 if require_cstring and c != 0:
7298 return None
7299 return StringReference(self, StringType.AsciiString, addr, length)
7300
7301 def add_analysis_completion_event(self, callback: Callable[[], None]) -> 'AnalysisCompletionEvent':
7302 """

Callers 1

Calls 4

seekMethod · 0.95
read8Method · 0.95
StringReferenceClass · 0.85
BinaryReaderClass · 0.70

Tested by

no test coverage detected