Jump to content

Encoding Branch and Link BL sub_x


Go to solution Solved by jayvee,

18 posts in this topic

Recommended Posts

Posted (edited)

The issue I have is encoding the branch and link ARM instruction, since the opcode is pc-relative.
 
All I am trying to do is call a different function that returns a modified item instead of the original.
 
And I am stuck on figuring out the hex for these particular functions. To make it easier, I have here, the old assembly, and what I want to modify the new assembly to be.
 
Old Assembly:

Offset = 0x36C2A6
BL              sub_3C1FC4 // hex=0x55F08DFE
B               loc_36C308 // hex=0x2DE0

Modified Assembly:

Offset = 0x36EE8A
BL              sub_3C5944 // hex=??
B               loc_36EEEC // hex=??

I want it to reference these different functions.

 

If there is any way you can help me figure this out, it would be much appreciated!

 

If I am missing any other piece of information, let me know so I can include it on this post :D

Updated by Javi Tech
Posted

Change to HEX view in IDA to see the changes

Well it's not that, what I am trying to do is change the functions it is referencing, so instead of BL sub_3C1FC4, I am trying to make it to be BL sub_3C5944, but how would I do that? How would I know how to change the hex to make it reference that function?

Posted

I guess the function you mean is

BX       LR

which determines the end of the function.

 

2Byte BX LR : 7047
4Byte BX LR : 1EFF2FE1

Posted

I guess the function you mean is

BX       LR

which determines the end of the function.

 

2Byte BX LR : 7047

4Byte BX LR : 1EFF2FE1

Huh? No, it's not BX LR. I'm trying to link it to another function :o

Posted

Change 

MOV R0,#0

to

MOV R0,#1

at the location

sub_3C1FC4

BL links to the function which holds the value of the boolean. Remember #0 = false; #1= true

Posted

Yeah, he pretty much explains what I already know. I just want to know how to encode BL.W sub_X to hex or if there's a program that can do it for me.

 

BL.W sub_44F08 -> CA F0 43 F5

 

Where the heck does CA F0 43 F5 come from? O.o

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines