Skip to content

Commit

Permalink
easier for user to add unused funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
DennyDai committed Jan 10, 2024
1 parent 7a6adab commit 9b6403f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ def add_block(self, block):
self.blocks[type(block)].sort()
self.coalesce(self.blocks[type(block)])

def add_free_space(self, addr, size, flag="RX"):
_flag = 0
if "r" in flag.lower():
_flag |= MemoryFlag.R
if "w" in flag.lower():
_flag |= MemoryFlag.W
if "x" in flag.lower():
_flag |= MemoryFlag.X
block = MappedBlock(
self.p.binary_analyzer.mem_addr_to_file_offset(addr),
addr,
size,
is_free=True,
flag=_flag,
)
self.p.allocation_manager.add_block(block)

def _find_in_mapped_blocks(self, size, flag=MemoryFlag.RWX, align=0x1):
best_fit = None
for block in self.blocks[MappedBlock]:
Expand Down
2 changes: 1 addition & 1 deletion src/patcherex2/targets/elf_leon3_bare.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _init_memory_analysis(self):
func["addr"],
func["size"],
is_free=True,
flag=MemoryFlag.RWX,
flag=MemoryFlag.RX,
)
self.p.allocation_manager.add_block(block)

Expand Down

0 comments on commit 9b6403f

Please sign in to comment.