B2R2


ByteArray Module

It is sometimes convenient to consider a binary chunk as a byte array. This module provides several useful functions to deal with byte arrays.

Functions and values

Function or value Description

extractCString arg1 arg2

Full Usage: extractCString arg1 arg2

Parameters:
    arg0 : byte[]
    arg1 : int

Returns: string

Extract a C-string (string that ends with a NULL char) from a byte array.

arg0 : byte[]
arg1 : int
Returns: string

extractCStringFromSpan arg1 arg2

Full Usage: extractCStringFromSpan arg1 arg2

Parameters:
Returns: string

Extract a C-string (string that ends with a NULL char) from a byte array.

arg0 : ReadOnlySpan<byte>
arg1 : int
Returns: string

findIdxs offset pattern buf

Full Usage: findIdxs offset pattern buf

Parameters:
    offset : uint64
    pattern : byte[]
    buf : byte[]

Returns: uint64 list

Find and return the offsets of all the matching byte positions. The final byte positions are adjusted by the given offset.

offset : uint64
pattern : byte[]
buf : byte[]
Returns: uint64 list

ofHexString arg1

Full Usage: ofHexString arg1

Parameters:
    arg0 : string

Returns: byte[]

Convert a hex string to a byte array.

arg0 : string
Returns: byte[]

readInt32 arg1 offset

Full Usage: readInt32 arg1 offset

Parameters:
    arg0 : byte[]
    offset : int

Returns: Result<int, ErrorCase>

Read int32 from the given byte array at the given offset.

arg0 : byte[]
offset : int
Returns: Result<int, ErrorCase>

toReadOnlySpan arg1

Full Usage: toReadOnlySpan arg1

Parameters:
    arg0 : byte[]

Returns: ReadOnlySpan<byte>

Convert a byte array into a read-only span.

arg0 : byte[]
Returns: ReadOnlySpan<byte>

toUInt32Arr arg1

Full Usage: toUInt32Arr arg1

Parameters:
    arg0 : byte[]

Returns: uint32[]

Convert a byte array into a uint32 array.

arg0 : byte[]
Returns: uint32[]

tryFindIdx arg1 arg2 arg3

Full Usage: tryFindIdx arg1 arg2 arg3

Parameters:
    arg0 : uint64
    arg1 : byte[]
    arg2 : byte[]

Returns: uint64 option

Find a matching byte position. If there is no match, this function will return None.

arg0 : uint64
arg1 : byte[]
arg2 : byte[]
Returns: uint64 option