mrcrowbar.checks module¶
-
class
mrcrowbar.checks.Check(raise_exception: bool = False)[source]¶ Bases:
objectBase 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_start_offset(parent: Block | None = None)[source]¶ Return the start offset of where the Check inspects the Block.
-
repr= None¶
-
class
mrcrowbar.checks.Const(field: Field, target: Any | Ref[Any], raise_exception: bool = False)[source]¶ Bases:
mrcrowbar.checks.CheckCheck 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_start_offset(parent=None)[source]¶ Return the start offset of where the Check inspects the Block.
-
repr¶
-
class
mrcrowbar.checks.Pointer(field, target, *args, **kwargs)[source]¶ Bases:
mrcrowbar.checks.CheckCheck 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_start_offset(parent=None)[source]¶ Return the start offset of where the Check inspects the Block.
-
repr¶