I use GDB and want to modify an iOS app. (for example: change score in a game)
So, I set breakpoint, for example:
b *0x0032c870
and that in the breakpoint, I enter
info r
after this, gdb shows
r0 0x92717c0 153556928
r1 0x7d47a0 8210336
r2 0x0 0
And now I know what I need is change r2 to 1
set $r2=1
Now the value changes in the game.
OK, there’s a question, how can I edit in hexeditor to set r2=1 instead using gdb everytime?
Thank you
You can’t: the value of
r2is the value of the register; it doesn’t exist until the program is running.What you need to do is figure out where that value was loaded into the register, and change the code there to make it load
1instead of0.This could be very easy, or tricky depending on how that value is loaded: easy if it’s loaded as a constant (just change the instruction to load a different constant). But chances are it’s loaded as a return value from some function, in which case you’ll have to change that function to return a different value.