Jump to content

[Tutorial] Simple way to alter/change a function's argument values


4 posts in this topic

Recommended Posts

Posted

I haven't seen any tutorial that has mentioned this so I will share this very simple way to patch/change the value that get passed in as a function argument.


Game Used: Cafeland


A function often has one or more parameters and when that function is called, it requires the caller to pass in those values as arguments.

Example
Function in IDA:
6As3CKI.png

Function in Dump.cs:
PWZy97S.png

So in this case DecreaseCash function has 5 parameters which are (*this,  value, tweenPosition, reasonId, reasonItemId)

The *this parameter will always be the first parameter of a non-static function
You can find more info about this pointer in this tutorial: 

 


In Arm64, the function's arguments is stored in the registers from X0 to X7
Therefore, you can visualize it like this:
sVmWmzY.png

Now, There are many ways you can make this hack work but in this tutorial I want to show you how to alter the value of the argument
In this example I want to change the X1 value to 0 so that this function will decrease 0 cash from my wallet

Normally at the start of the function you will see something like this:
WZNoJx7.png

At the lines with the red arrow, you can see the arguments is getting moved to the respective registers or you can understand it as the function is loading the value of the passed in arguments

Remember which registers correspond to which value in the parameters
Now, Instead of loading the X1's original value, we load int 0 instead so that it decrease 0 amount from our cash
 

MOV        x19, x1
- Change to 
MOV        x19, #0

And It is that simple :D
This is just one of many ways to achieve a certain hack/feature

Thanks for reading ❤️

 

  • Like 5
  • Informative 1

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