raw.py
ofrak.core.raw
RawExtendConfig (ComponentConfig)
dataclass
RawExtendConfig(content: bytes)
RawExtendModifier (Modifier)
Extend a binary with new data.
modify(self, resource, config)
async
Modify the given resource.
Users should not call this method directly; rather, they should run Resource.run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource |
Resource |
required | |
config |
RawExtendConfig |
Optional config for modification. If an implementation provides a default, this default will always be used when config would otherwise be None. Note that a copy of the default config will be passed, so the default config values cannot be modified persistently by a component run. |
required |
Source code in ofrak/core/raw.py
async def modify(self, resource: Resource, config: RawExtendConfig):
if len(config.content) == 0:
raise ValueError("Content of the extended space not provided")
data = await resource.get_data()
data += config.content
resource.queue_patch(Range(0, await resource.get_data_length()), data)
RawReplaceConfig (ComponentConfig)
dataclass
RawReplaceConfig(content: bytes, offset: int, size: int)
RawReplaceModifier (Modifier)
Replace a binary with new data
modify(self, resource, config)
async
Modify the given resource.
Users should not call this method directly; rather, they should run Resource.run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource |
Resource |
required | |
config |
RawReplaceConfig |
Optional config for modification. If an implementation provides a default, this default will always be used when config would otherwise be None. Note that a copy of the default config will be passed, so the default config values cannot be modified persistently by a component run. |
required |
Source code in ofrak/core/raw.py
async def modify(self, resource: Resource, config: RawReplaceConfig):
resource.queue_patch(Range(config.offset, config.offset + config.size), config.content)