I need to patch an arm7 program by replacing this fopen function by another function.

.text:00018D68 52 D7 FF EB                       BL              fopen


.plt:0000EAB8 ; FILE *fopen(const char *filename, const char *modes)

Do you know how to calculate the 24 bits that I need to write after EB? The documentation is not very clear. I tried to find a Branch offset calculator but not found.



you can use https://www.keystone-engine.org/showcase/ assembler

from keystone import *
target = 0xDEADBEEF
current = 0x18D68
bytes(ks.asm("bl {}".format(hex(target)), current)[0]).hex()
| improve this answer | |
  • It's working!! Thank you – john Jul 7 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.