binaryninja.binaryview.BinaryWriter¶
-
class
BinaryWriter(view, endian=None)[source]¶ class BinaryWriteris a convenience class for writing binary data.BinaryWriter can be instantiated as follows and the rest of the document will start from this context
>>> from binaryninja import * >>> bv = BinaryViewType['Mach-O'].open("/bin/ls") >>> br = BinaryReader(bv) >>> bw = BinaryWriter(bv) >>>
Or using the optional endian parameter
>>> from binaryninja import * >>> br = BinaryReader(bv, Endianness.BigEndian) >>> bw = BinaryWriter(bv, Endianness.BigEndian) >>>
Methods
__init__(view[, endian])x.__init__(…) initializes x; see help(type(x)) for signature seek(offset)seekupdate internal offset tooffset.seek_relative(offset)seek_relativeupdates the internal offset byoffset.write(value)writewriteslen(value)bytes to the internal offset, without regard to endianness.write16(value)write16writes the lowest order two bytes from the integervalueto the current offset, using internal endianness.write16be(value)write16bewrites the lowest order two bytes from the big endian integervalueto the current offset.write16le(value)write16lewrites the lowest order two bytes from the little endian integervalueto the current offset.write32(value)write32writes the lowest order four bytes from the integervalueto the current offset, using internal endianness.write32be(value)write32bewrites the lowest order four bytes from the big endian integervalueto the current offset.write32le(value)write32lewrites the lowest order four bytes from the little endian integervalueto the current offset.write64(value)write64writes the lowest order eight bytes from the integervalueto the current offset, using internal endianness.write64be(value)write64bewrites the lowest order eight bytes from the big endian integervalueto the current offset.write64le(value)write64lewrites the lowest order eight bytes from the little endian integervalueto the current offset.write8(value)write8lowest order byte from the integervalueto the current offset.Attributes
endiannessThe Endianness to written data. offsetThe current write offset (read/write).