binaryninja.binaryview.BinaryWriter

class binaryninja.binaryview.BinaryWriter(view, endian=None)[source]

class BinaryWriter is 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)
>>>
__init__(view, endian=None)[source]

Methods

__init__(view[, endian])
seek(offset) seek update internal offset to offset.
seek_relative(offset) seek_relative updates the internal offset by offset.
write(value) write writes len(value) bytes to the internal offset, without regard to endianness.
write16(value) write16 writes the lowest order two bytes from the integer value to the current offset, using internal endianness.
write16be(value) write16be writes the lowest order two bytes from the big endian integer value to the current offset.
write16le(value) write16le writes the lowest order two bytes from the little endian integer value to the current offset.
write32(value) write32 writes the lowest order four bytes from the integer value to the current offset, using internal endianness.
write32be(value) write32be writes the lowest order four bytes from the big endian integer value to the current offset.
write32le(value) write32le writes the lowest order four bytes from the little endian integer value to the current offset.
write64(value) write64 writes the lowest order eight bytes from the integer value to the current offset, using internal endianness.
write64be(value) write64be writes the lowest order eight bytes from the big endian integer value to the current offset.
write64le(value) write64le writes the lowest order eight bytes from the little endian integer value to the current offset.
write8(value) write8 lowest order byte from the integer value to the current offset.

Attributes

endianness The Endianness to written data.
offset The current write offset (read/write).