Skip to content

code_region.py

ofrak.core.code_region

CodeRegion (MemoryRegion)

A memory region within a program that contains executable code.

CodeRegionUnpacker (Unpacker, ABC)

Unpack a code region into complex blocks.

unpack(self, resource, config=None) async

Unpack a code region, extracting all of the complex blocks within it.

The bounds of these complex blocks should include any trailing data literals which are considered part of the complex block only if there are only data references to them from within that complex block.

Parameters:

Name Type Description Default
resource Resource

the code region resource

required
config None

Exceptions:

Type Description
ComplexBlockStructureError

if the unpacker tries to define a complex block which did not match our expectations of complex block structure

Source code in ofrak/core/code_region.py
@abstractmethod
async def unpack(self, resource: Resource, config=None):
    """
    Unpack a code region, extracting all of the complex blocks within it.

    The bounds of these complex blocks should include any trailing data literals which are
    considered part of the complex block only if there are only data references to them from
    within that complex block.

    :param resource: the code region resource
    :param config:

    :raises ComplexBlockStructureError: if the unpacker tries to define a complex block which
    did not match our expectations of complex block structure
    """
    raise NotImplementedError()