Skip to content

Commit

Permalink
Merge pull request #15 from trail-of-forks/fix-manual-detour
Browse files Browse the repository at this point in the history
Check allocation manager blocks for file_addr when using detour_pos
  • Loading branch information
DennyDai authored Feb 21, 2024
2 parents cbffa34 + dd02a05 commit bd5cb6f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/patcherex2/components/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ def insert_trampoline_code(
file_addr = trampoline_block.file_addr
else:
mem_addr = detour_pos
file_addr = self.p.binary_analyzer.mem_addr_to_file_offset(mem_addr)
for block in self.p.allocation_manager.new_mapped_blocks:
if block.mem_addr == mem_addr:
file_addr = block.file_addr
break
else:
file_addr = self.p.binary_analyzer.mem_addr_to_file_offset(mem_addr)
self.p.sypy_info["patcherex_added_functions"].append(hex(mem_addr))
trampoline_bytes = self.p.assembler.assemble(
trampoline_instrs_with_jump_back,
Expand Down

0 comments on commit bd5cb6f

Please sign in to comment.