mrcrowbar.lib.containers.patch module¶
File format classes for binary patches.
Sources: IPS https://zerosoft.zophar.net/ips.php
UPS http://individual.utoronto.ca/dmeunier/ups-spec.pdf
-
class
mrcrowbar.lib.containers.patch.IPS(source_data=None, *, parent=None, preload_attrs=None, endian=None, cache_bytes=False, path_hint=None, strict=False)[source]¶ Bases:
mrcrowbar.blocks.BlockBase class for Blocks.
- source_data
- Source data to construct Block with. Can be a byte string, dictionary of attribute: value pairs, or another Block object.
- parent
- Parent Block object where this Block is defined. Used for e.g. evaluating Refs.
- preload_attrs
- Attributes on the Block to set before importing the data. Used for linking in dependencies before loading.
- endian
- Platform endianness to use when interpreting the Block data. Useful for Blocks which have the same data layout but different endianness for stored numbers. Has no effect on fields with an predefined endianness.
- cache_bytes
- Cache the bytes equivalent of the Block. Useful for debugging the loading procedure. Defaults to False.
- path_hint
- Cache a string containing the path of the current Block, relative to the root.
- strict
- Throw an exception if parsing a BlockField fails, instead of logging a warning and returning an Unknown. Defaults to False.
-
magic= <Bytes: offset=0x0, length=5>¶
-
records= <BlockField: 0x00007f13d2b778d0>¶
-
repr¶ Plaintext summary of the Block.
-
class
mrcrowbar.lib.containers.patch.IPSRecord(source_data=None, *, parent=None, preload_attrs=None, endian=None, cache_bytes=False, path_hint=None, strict=False)[source]¶ Bases:
mrcrowbar.blocks.BlockBase class for Blocks.
- source_data
- Source data to construct Block with. Can be a byte string, dictionary of attribute: value pairs, or another Block object.
- parent
- Parent Block object where this Block is defined. Used for e.g. evaluating Refs.
- preload_attrs
- Attributes on the Block to set before importing the data. Used for linking in dependencies before loading.
- endian
- Platform endianness to use when interpreting the Block data. Useful for Blocks which have the same data layout but different endianness for stored numbers. Has no effect on fields with an predefined endianness.
- cache_bytes
- Cache the bytes equivalent of the Block. Useful for debugging the loading procedure. Defaults to False.
- path_hint
- Cache a string containing the path of the current Block, relative to the root.
- strict
- Throw an exception if parsing a BlockField fails, instead of logging a warning and returning an Unknown. Defaults to False.
-
data= <Bytes: offset=0x5, length=<Ref: size (rw)>>¶
-
offset¶
-
offset_maj= <UInt8: offset=0x0>¶
-
offset_min= <UInt16_BE: offset=0x1>¶
-
repr¶ Plaintext summary of the Block.
-
size= <UInt16_BE: offset=0x3>¶
-
class
mrcrowbar.lib.containers.patch.UIntVLV(offset, default=0, **kwargs)[source]¶ Bases:
mrcrowbar.fields.Field-
get_from_buffer(buffer, parent=None)[source]¶ Create a Python object from a byte string, using the field definition.
- buffer
- Input byte string to process.
- parent
- Parent block object where this Field is defined. Used for e.g. evaluating Refs.
-
get_size(value, parent=None, index=None)[source]¶ Return the size of the Field’s data (in bytes).
- value
- Input Python object to process.
- parent
- Parent block object where this Field is defined. Used for e.g. evaluating Refs.
- index
- Index of the Python object to measure from. Used if the Field takes a list of objects.
-
get_start_offset(value, parent=None, index=None)[source]¶ Return the start offset of where the Field’s data is to be stored in the Block.
- value
- Input Python object to process.
- parent
- Parent block object where this Field is defined. Used for e.g. evaluating Refs.
- index
- Index of the Python object to measure from. Used if the Field takes a list of objects.
-
update_buffer_with_value(value, buffer, parent=None)[source]¶ Write a Python object into a byte array, using the field definition.
- value
- Input Python object to process.
- buffer
- Output byte array to encode value into.
- parent
- Parent block object where this Field is defined. Used for e.g. evaluating Refs.
-
-
class
mrcrowbar.lib.containers.patch.UPS(source_data=None, *, parent=None, preload_attrs=None, endian=None, cache_bytes=False, path_hint=None, strict=False)[source]¶ Bases:
mrcrowbar.blocks.BlockBase class for Blocks.
- source_data
- Source data to construct Block with. Can be a byte string, dictionary of attribute: value pairs, or another Block object.
- parent
- Parent Block object where this Block is defined. Used for e.g. evaluating Refs.
- preload_attrs
- Attributes on the Block to set before importing the data. Used for linking in dependencies before loading.
- endian
- Platform endianness to use when interpreting the Block data. Useful for Blocks which have the same data layout but different endianness for stored numbers. Has no effect on fields with an predefined endianness.
- cache_bytes
- Cache the bytes equivalent of the Block. Useful for debugging the loading procedure. Defaults to False.
- path_hint
- Cache a string containing the path of the current Block, relative to the root.
- strict
- Throw an exception if parsing a BlockField fails, instead of logging a warning and returning an Unknown. Defaults to False.
-
STOP_CHECK(pointer)¶
-
blocks= <BlockField: 0x00007f13d303d090>¶
-
input_crc32= <UInt32_LE: offset=<EndOffset: blocks (rw)>>¶
-
input_size= <UIntVLV: 0x00007f13d3037ed0>¶
-
magic= <Bytes: offset=0x0, length=4>¶
-
output_crc32= <UInt32_LE: offset=<EndOffset: input_crc32 (rw)>>¶
-
output_size= <UIntVLV: 0x00007f13d3037f90>¶
-
patch_crc32= <UInt32_LE: offset=<EndOffset: output_crc32 (rw)>>¶
-
class
mrcrowbar.lib.containers.patch.UPSBlock(source_data=None, *, parent=None, preload_attrs=None, endian=None, cache_bytes=False, path_hint=None, strict=False)[source]¶ Bases:
mrcrowbar.blocks.BlockBase class for Blocks.
- source_data
- Source data to construct Block with. Can be a byte string, dictionary of attribute: value pairs, or another Block object.
- parent
- Parent Block object where this Block is defined. Used for e.g. evaluating Refs.
- preload_attrs
- Attributes on the Block to set before importing the data. Used for linking in dependencies before loading.
- endian
- Platform endianness to use when interpreting the Block data. Useful for Blocks which have the same data layout but different endianness for stored numbers. Has no effect on fields with an predefined endianness.
- cache_bytes
- Cache the bytes equivalent of the Block. Useful for debugging the loading procedure. Defaults to False.
- path_hint
- Cache a string containing the path of the current Block, relative to the root.
- strict
- Throw an exception if parsing a BlockField fails, instead of logging a warning and returning an Unknown. Defaults to False.
-
rel_offset= <UIntVLV: 0x00007f13d3037c10>¶
-
repr¶ Plaintext summary of the Block.
-
xor_data= <XORData: offset=<EndOffset: rel_offset (rw)>>¶
-
class
mrcrowbar.lib.containers.patch.XORData(offset, *args, **kwargs)[source]¶ Bases:
mrcrowbar.fields.Bytes