binaryninja.binaryview.BinaryReader¶
-
class
binaryninja.binaryview.BinaryReader(view, endian=None)[source]¶ class BinaryReaderis a convenience class for reading binary data.BinaryReader 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) >>> hex(br.read32()) '0xfeedfacfL' >>>
Or using the optional endian parameter
>>> from binaryninja import * >>> br = BinaryReader(bv, Endianness.BigEndian) >>> hex(br.read32()) '0xcffaedfeL' >>>
Methods
__init__(view[, endian])read(length)readreturnslengthbytes read from the current offset, addinglengthto offset.read16()read16returns a two byte integer from offet incrementing the offset by two, using specified endianness.read16be()read16bereturns a two byte big endian integer from offet incrementing the offset by two.read16le()read16lereturns a two byte little endian integer from offet incrementing the offset by two.read32()read32returns a four byte integer from offet incrementing the offset by four, using specified endianness.read32be()read32bereturns a four byte big endian integer from offet incrementing the offset by four.read32le()read32lereturns a four byte little endian integer from offet incrementing the offset by four.read64()read64returns an eight byte integer from offet incrementing the offset by eight, using specified endianness.read64be()read64bereturns an eight byte big endian integer from offet incrementing the offset by eight.read64le()read64lereturns an eight byte little endian integer from offet incrementing the offset by eight.read8()read8returns a one byte integer from offet incrementing the offset.seek(offset)seekupdate internal offset tooffset.seek_relative(offset)seek_relativeupdates the internal offset byoffset.Attributes
endiannessThe Endianness to read data. eofIs end of file (read-only) offsetThe current read offset (read/write).