Skip to content

Commit

Permalink
expose binary content to user
Browse files Browse the repository at this point in the history
  • Loading branch information
DennyDai committed Dec 14, 2023
1 parent 38a88d9 commit cfe3952
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/patcherex2/binfmt_tools/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,16 @@ def update_binary_content(self, offset, new_content):
if offset + len(new_content) > self.file_size:
self.file_size = offset + len(new_content)

def get_binary_content(self, offset, size):
# check if it's in file_updates
for update in self.file_updates:
if offset >= update["offset"] and offset + size <= update["offset"] + len(
update["content"]
):
return update["content"][offset - update["offset"] :]
# otherwise return from original binary
return self.original_binary_content[offset : offset + size]

def append_to_binary_content(self, new_content):
self.file_updates.append({"offset": self.file_size, "content": new_content})
self.file_size += len(new_content)

0 comments on commit cfe3952

Please sign in to comment.