mrcrowbar.checks module

class mrcrowbar.checks.Check(raise_exception: bool = False)[source]

Bases: object

Base class for Checks.

raise_exception
Whether to raise an exception if the check fails.
check_buffer(buffer: common.BytesReadType, parent: Block | None = None)[source]

Check if the import buffer passes the check.

Throws CheckException if raise_exception = True and the buffer doesn’t match.

get_end_offset(parent: Block | None = None)[source]

Return the end offset of where the Check inspects the Block.

get_fields()[source]

Return None, a single field, or a dictionary of Fields embedded within the Check.

get_size(parent: Block | None = None)[source]

Return the size of the checked data (in bytes).

get_start_offset(parent: Block | None = None)[source]

Return the start offset of where the Check inspects the Block.

repr = None
update_deps(parent: Block | None = None)[source]

Update all dependent variables derived from this Check.

exception mrcrowbar.checks.CheckException[source]

Bases: Exception

class mrcrowbar.checks.Const(field: Field, target: Any | Ref[Any], raise_exception: bool = False)[source]

Bases: mrcrowbar.checks.Check

Check for ensuring a Field matches a particular constant.

On import, the value is tested. On export, the value is copied from the target.

field
Field instance to wrap.
target
Target to copy from on export.
raise_exception
Whether to raise an exception if the check fails.
check_buffer(buffer, parent=None)[source]

Check if the import buffer passes the check.

Throws CheckException if raise_exception = True and the buffer doesn’t match.

get_fields() → Field[source]

Return None, a single field, or a dictionary of Fields embedded within the Check.

get_size(parent=None)[source]

Return the size of the checked data (in bytes).

get_start_offset(parent=None)[source]

Return the start offset of where the Check inspects the Block.

repr
update_deps(parent=None)[source]

Update all dependent variables derived from this Check.

class mrcrowbar.checks.Pointer(field, target, *args, **kwargs)[source]

Bases: mrcrowbar.checks.Check

Check for loading an offset-type pointer into a Field.

On import, the value is returned as-is. On export, the value is copied from the target; in most cases you’d use an EndOffset for another Field in the Block class. This allows for expansion and contraction of data.

field
Field instance to wrap.
target
Target to copy from on export.
get_fields()[source]

Return None, a single field, or a dictionary of Fields embedded within the Check.

get_size(parent=None)[source]

Return the size of the checked data (in bytes).

get_start_offset(parent=None)[source]

Return the start offset of where the Check inspects the Block.

repr
update_deps(parent=None)[source]

Update all dependent variables derived from this Check.

class mrcrowbar.checks.Updater(source, target, *args, **kwargs)[source]

Bases: mrcrowbar.checks.Check

repr
update_buffer(buffer, parent=None)[source]