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

Method serialize

python/binaryview.py:1417–1450  ·  view source on GitHub ↗

Serialize segment parameters into a JSON string. This is useful for generating a properly formatted segment description as options when using `load`. :param int image_base: The base address of the image. :param int start: The start address of the segment. :param int length: The length of t

(cls, image_base: int, start: int, length: int, data_offset: int=0, data_length: int=0, flags: 'SegmentFlag'=SegmentFlag.SegmentReadable, auto_defined=True, segments: str="[]")

Source from the content-addressed store, hash-verified

1415 @classmethod
1416 @deprecation.deprecated(deprecated_in="4.3.6653", details="Use `SegmentDescriptorList` instead.")
1417 def serialize(cls, image_base: int, start: int, length: int, data_offset: int=0, data_length: int=0, flags: 'SegmentFlag'=SegmentFlag.SegmentReadable, auto_defined=True, segments: str="[]"):
1418 """
1419 Serialize segment parameters into a JSON string. This is useful for generating a properly formatted segment description as options when using `load`.
1420
1421 :param int image_base: The base address of the image.
1422 :param int start: The start address of the segment.
1423 :param int length: The length of the segment.
1424 :param int data_offset: The offset of the data within the segment.
1425 :param int data_length: The length of the data within the segment.
1426 :param SegmentFlag flags: The flags of the segment.
1427 :param bool auto_defined: Whether the segment is auto-defined.
1428 :param str segments: An optional, existing array of segments to append to.
1429 :return: A JSON string representing the segment.
1430 :rtype: str
1431
1432 :Example::
1433 >>> base = 0x400000
1434 >>> rom_base = 0xffff0000
1435 >>> segments = SegmentDescriptorList(base)
1436 >>> segments.append(start=base, length=0x1000, data_offset=0, data_length=0x1000, flags=SegmentFlag.SegmentReadable|SegmentFlag.SegmentExecutable)
1437 >>> segments.append(start=rom_base, length=0x1000, flags=SegmentFlag.SegmentReadable)
1438 >>> view = load(bytes.fromhex('5054ebfe'), options={'loader.imageBase': base, 'loader.platform': 'x86', 'loader.segments': json.dumps(segments)})
1439 """
1440 segments_list = json.loads(segments)
1441 segment_info = {
1442 "auto_defined": auto_defined,
1443 "data_length": data_length,
1444 "data_offset": data_offset,
1445 "flags": flags,
1446 "length": length,
1447 "start": start - image_base
1448 }
1449 segments_list.append(segment_info)
1450 return json.dumps(segments_list)
1451
1452 @property
1453 def length(self):

Callers

nothing calls this directly

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected