Skip to content

Commit 3eb18b3

Browse files
committed
fix insertfuncpatch when first arg is addr
1 parent 97558a6 commit 3eb18b3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/patcherex2/patches/function_patches.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,17 @@ def apply(self, p) -> None:
117117
self.postfunc = self.postfunc.replace(
118118
"RESTORE_CONTEXT", f"\n{p.archinfo.restore_context_asm}\n"
119119
)
120-
ifp = InsertFunctionPatch(f"__patcherex_{hex(self.addr)}", self.code)
120+
ifp = InsertFunctionPatch(
121+
f"__patcherex_{hex(self.addr)}",
122+
self.code,
123+
is_thumb=self.p.binary_analyzer.is_thumb(self.addr),
124+
)
121125
ifp.apply(p)
122126
instrs = ""
123127
instrs += p.archinfo.save_context_asm if self.save_context else ""
124128
instrs += self.prefunc if self.prefunc else ""
125129
instrs += "\n"
130+
# NOTE: ↓ this is hardcoded to bl, not blx, but it should be fine for this use case
126131
instrs += p.archinfo.call_asm.format(
127132
dst=f"{{__patcherex_{hex(self.addr)}}}"
128133
)

0 commit comments

Comments
 (0)