Header menu logo B2R2

BinFilePointer Type

Represents a pointer to binary, which is used to exclusively point to a region of a binary that is (1) mapped to both VM and file, (2) mapped to VM only, or (3) mapped to file only. For the other cases, the pointer is considered invalid (null). The pointer internally holds inclusive ranges of the virtual addresses and the file offsets.

Record fields

Record Field Description

Addr

Full Usage: Addr

Field type: Addr

The first (inclusive) virtual address of the pointed region.

Field type: Addr

MaxAddr

Full Usage: MaxAddr

Field type: Addr

The last (inclusive) virtual address of the pointed region.

Field type: Addr

MaxOffset

Full Usage: MaxOffset

Field type: int

The last (inclusive) file offset corresponding to MaxAddr. For a virtual (VM-only) region this is less than Offset, and it is -1 for a null pointer.

Field type: int

Offset

Full Usage: Offset

Field type: int

The first (inclusive) file offset corresponding to Addr. This is -1 for a null pointer.

Field type: int

Instance members

Instance member Description

this.Advance

Full Usage: this.Advance

Parameters:
    amount : uint32

Returns: BinFilePointer

Advances the pointer forward by the given amount of bytes. See the int overload for the offset-clamping and validity semantics.

amount : uint32
Returns: BinFilePointer

this.Advance

Full Usage: this.Advance

Parameters:
    amount : int

Returns: BinFilePointer

Advances the pointer forward by the given (non-negative) amount of bytes. The address moves forward unconditionally, while the file offset is clamped to one past the max offset, marking the pointer as virtual once it leaves the file-backed region. The amount is assumed to be non-negative and small enough not to overflow the address; callers must check whether the result can read file bytes before dereferencing.

amount : int
Returns: BinFilePointer

this.CanRead

Full Usage: this.CanRead

Parameters:
    size : int

Returns: bool
Modifiers: inline

Checks if the pointer can read the given number of bytes within its virtual address range. The check is purely address-based (it does not consider the file offset), so a virtual pointer can still report true. Returns false for a non-positive size.

size : int
Returns: bool

this.CanReadFileBytes

Full Usage: this.CanReadFileBytes

Returns: bool
Modifiers: inline

Checks if the pointer currently points to file-backed bytes.

Returns: bool

this.IsNull

Full Usage: this.IsNull

Returns: bool
Modifiers: inline

Checks if the pointer is null.

Returns: bool

this.IsVirtual

Full Usage: this.IsVirtual

Returns: bool
Modifiers: inline

Checks if the pointer is virtual, meaning that it currently points to a region that is mapped to VM but not to the file.

Returns: bool

this.ReadableAmount

Full Usage: this.ReadableAmount

Returns: int
Modifiers: inline

Returns the number of file bytes available from the current offset up to (and including) the max offset. This is zero or negative when the pointer is virtual (i.e., not backed by the file), so callers should guard with IsVirtual before using this to slice file contents.

Returns: int

Static members

Static member Description

BinFilePointer.Advance(p, amount)

Full Usage: BinFilePointer.Advance(p, amount)

Parameters:
Returns: BinFilePointer

Advances the given pointer forward by the given amount of bytes. This is a static counterpart of the instance `Advance` method, provided for piping and interop convenience.

p : BinFilePointer
amount : int
Returns: BinFilePointer

BinFilePointer.CreateFileBacked(addr, maxAddr, offset, maxOffset)

Full Usage: BinFilePointer.CreateFileBacked(addr, maxAddr, offset, maxOffset)

Parameters:
    addr : Addr
    maxAddr : Addr
    offset : int
    maxOffset : int

Returns: BinFilePointer

Creates a pointer to a region backed by file bytes. Both address and file offset ranges are inclusive, and the two ranges are expected to have the same length.

addr : Addr
maxAddr : Addr
offset : int
maxOffset : int
Returns: BinFilePointer
InvalidAddrRangeException Raised when addr is greater than maxAddr.
ArgumentException Raised when offset is negative or greater than maxOffset.

BinFilePointer.CreateVirtual(addr, maxAddr)

Full Usage: BinFilePointer.CreateVirtual(addr, maxAddr)

Parameters:
Returns: BinFilePointer

Creates a pointer to a virtual-memory region that is not backed by file bytes. The resulting pointer has no readable file offset range.

addr : Addr
maxAddr : Addr
Returns: BinFilePointer
InvalidAddrRangeException Raised when addr is greater than maxAddr.

BinFilePointer.Null

Full Usage: BinFilePointer.Null

Returns: BinFilePointer

Returns a null pointer.

Returns: BinFilePointer

Type something to start searching.