ofrak icon indicating copy to clipboard operation
ofrak copied to clipboard

Invalidate FreeSpaceAnalyzer when FreeSpace is created

Open rbs-afflitto opened this issue 8 months ago • 0 comments

What is the use case for the feature?

Currently, if FreeSpaceModifier is run on a dataless resource, and FreeSpaceAnalyzer has already ran, the Allocatable view will not have knowledge of the new FreeSpace unless FreeSpaceAnalyzer is removed and re-ran on the resource.

The following snippet shows how I would expect this to work, and a workaround at the end:

resource = get_resource() # This is a resource which already has free space
allocatable = await resource.view_as(Allocatable)
print(allocatable.free_space_ranges[MemoryPermissions.RX]) # this prints existing free space ranges

# Create new dataless free space
child = await resource.create_child_from_view(
  MemoryRegion(0x8000, 0x100)
)
await child.run(
  FreeSpaceModifier,
  FreeSpaceModifierConfig(
    permissions=MemoryPermissions.RW
  )
)

# Attempt to find new free space in Allocatable
allocatable = await resource.view_as(Allocatable)
print(allocatable.dataless_free_space_ranges[MemoryPermissions.RW]) # New child is not printed

# Workaround
resource.remove_component(FreeSpaceAnalyzer.get_id())
await resource.save()
await resource.run(FreeSpaceAnalyzer)

Does the feature contain any proprietary information about another company's intellectual property?

No

How would you implement this feature?

FreeSpaceModifier should remove FreeSpaceAnalyzer so that the analyzer will be re-run the next time the resource is viewed as Allocatable. Allocatable should always have an up to date list of FreeSpace.

I suspect RemoveFreeSpaceModifier has the same quirk and needs to invalidate FreeSpaceAnalyzer so that Allocatable is up to date when dataless free space is removed.

Are there any (reasonable) alternative approaches?

n/a

Are you interested in implementing it yourself?

Sure

rbs-afflitto avatar Apr 22 '25 14:04 rbs-afflitto