diff --git a/src/patcherex2/components/allocation_managers/allocation_manager.py b/src/patcherex2/components/allocation_managers/allocation_manager.py index 0af5f69..b03cb5f 100644 --- a/src/patcherex2/components/allocation_managers/allocation_manager.py +++ b/src/patcherex2/components/allocation_managers/allocation_manager.py @@ -174,9 +174,9 @@ def _create_new_mapped_block( [segment["p_align"] for segment in self.p.binfmt_tool._segments] + [0] ) - mem_addr = block.addr + (file_addr % max_seg_align) + mem_addr = block.addr + (file_addr - block.addr) % max_seg_align else: - mem_addr = block.addr + (file_addr % 0x1000) + mem_addr = block.addr + (file_addr - block.addr) % 0x1000 block.addr = mem_addr + 0x10000 if file_addr and mem_addr: self.add_block( diff --git a/src/patcherex2/patches/data_patches.py b/src/patcherex2/patches/data_patches.py index 5901316..5b8a07a 100644 --- a/src/patcherex2/patches/data_patches.py +++ b/src/patcherex2/patches/data_patches.py @@ -56,9 +56,7 @@ def apply(self, p: Patcherex) -> None: if self.addr: p.binfmt_tool.update_binary_content(self.addr, self.data) elif self.name: - block = p.allocation_manager.allocate( - len(self.data), flag=MemoryFlag.RWX - ) # FIXME: why RW not work? + block = p.allocation_manager.allocate(len(self.data), flag=MemoryFlag.RW) p.symbols[self.name] = block.mem_addr p.binfmt_tool.update_binary_content(block.file_addr, self.data)