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

Method get_string_at

python/binaryview.py:7229–7253  ·  view source on GitHub ↗

``get_string_at`` returns the string that falls on given virtual address. .. note:: This returns discovered strings and is therefore governed by `analysis.limits.minStringLength` and other settings. For an alternative API that simply returns any potential c-string at a given location, use :py:

(self, addr: int, partial: bool = False)

Source from the content-addressed store, hash-verified

7227 core.BNFreeStringReferenceList(strings)
7228
7229 def get_string_at(self, addr: int, partial: bool = False) -> Optional['StringReference']:
7230 """
7231 ``get_string_at`` returns the string that falls on given virtual address.
7232
7233 .. note:: This returns discovered strings and is therefore governed by `analysis.limits.minStringLength` and other settings. For an alternative API that simply returns any potential c-string at a given location, use :py:func:`get_ascii_string_at`.
7234
7235 :param int addr: virtual address to get the string from
7236 :param bool partial: whether to return a partial string reference or not
7237 :return: returns the StringReference at the given virtual address, otherwise None.
7238 :rtype: StringReference
7239 :Example:
7240
7241 >>> bv.get_string_at(0x40302f)
7242 <StringType.AsciiString: 0x403028, len 0x12>
7243
7244 """
7245 str_ref = core.BNStringReference()
7246 if not core.BNGetStringAtAddress(self.handle, addr, str_ref):
7247 return None
7248 if partial and (addr != str_ref.start) and (str_ref.type != StringType.AsciiString):
7249 partial = False
7250 log_warn("Partial string not supported at {}".format(hex(addr)))
7251 start = addr if partial else str_ref.start
7252 length = str_ref.length - (addr - str_ref.start) if partial else str_ref.length
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']:

Callers

nothing calls this directly

Calls 3

log_warnFunction · 0.85
StringReferenceClass · 0.85
formatMethod · 0.45

Tested by

no test coverage detected