TransWikia.com

Change function call to another function call in arm using IDA

Reverse Engineering Asked by Alexandra Urushadze on November 30, 2020

Is it possible to patch arm lib in a way that changes branch instruction calling one function to another function call?

I have instruction

B function_a

and want change it to:

B function_b 

One Answer

See this answer for details on how branch instructions are encoded on ARM. Here's what you should do:

  1. Set Options->General->Number of opcode bytes to 4 (if it was 0 initially)
  2. Find any B instruction.
  3. Just to make sure you understand it, work out the displacement from pc+8 at the B instruction to the destination, and verify that the displacement in the instruction matches what you expect.
  4. Calculate the displacement to the target to which you wish to branch instead.
  5. Use Edit->Patch program->Change byte to modify the current instruction. IDA will update the display, so you can tell whether you've succeeded or not. If you haven't, keep messing with it until you get the bytes you want.
  6. To generate a patch file, you can use File->Produce file->Create .DIF file.

Answered by Rolf Rolles on November 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP