Skip to content

Commit

Permalink
apply_patches: Return status to indicate if patches were successfully…
Browse files Browse the repository at this point in the history
… applied or not
  • Loading branch information
dnivra committed Dec 6, 2023
1 parent 7affb2d commit 82242e3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions patcherex/backends/detourbackends/i386.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, filename, base_address=None, try_reuse_unused_space=False, re
super().__init__(filename, base_address=base_address, replace_note_segment=replace_note_segment, try_without_cfg=try_without_cfg, cfg=cfg)

def apply_patches(self, patches):
success = True
# deal with stackable patches
# add stackable patches to the one with highest priority
insert_code_patches = [p for p in patches if isinstance(p, InsertCodePatch)]
Expand Down Expand Up @@ -301,6 +302,7 @@ def apply_patches(self, patches):
#print map(str,removed)
applied_patches = self.restore_state(applied_patches, removed)
l.warning("One patch failed, rolling back InsertCodePatch patches. Failed patch: %s", str(patch))
success = False
break
# TODO: right now rollback goes back to 0 patches, we may want to go back less
# the solution is to save touched_bytes and ncontent indexed by applied patfch
Expand Down Expand Up @@ -360,6 +362,8 @@ def apply_patches(self, patches):
else:
l.info("no patches, the binary will not be touched")

return success

def check_if_movable(self, instruction, is_thumb=False):
# the idea here is an instruction is movable if and only if
# it has the same string representation when moved at different offsets is "movable"
Expand Down

0 comments on commit 82242e3

Please sign in to comment.