Editing a Method

Parent Previous Next

In the previous section, we found the Bag Class. The next step is to look at the GetSlots method.


Note: Because De-obfuscation can change the way that each file and method looks, only follow the theory of this work flow, as opposed to hard truths. Such as "this.RU(32)" may not exist for you. It could be something different, like "this.SO(32)".



Double clicking on the GetSlots() in the Assembly Explorer will open up the Method.


The contents:   this.RU(32) is the key. This tells that game how many slots are in the back pack.


The contents look strange. this.RU(32) is such an odd name. That's because we are disassembling the code; and it's not always a clean process. When you see a strange method that has a call to a two letter method, like this.RU(32), it indicates that it will change every build. It will also look different from one computer to the next.


The next step in the instructions is to change the 32 value to whatever you want for a larger back pack. We'll use 48 as our new number.


In the GetSlots() window, right click, and select "Edit Method (C#)".




Highlight 32, and change it to 48.



Then click on the Compile button.



Oops! Identifier expected error pops up. That means something is wrong with our change. In the above example, it's really a really simple change: changing 32 to 48.


Double click on the "CS1001 Identifier expected". You'll be taken to the RU method.



The RU method is actually empty. but the parameter, is not correct. "int = 32" is invalid C# code. What it's trying to do is set a default value, if none are passed.


We can fix this by adding something to the parameter:



Now it says "int size = 32". Press compile, and you'll see that both the RU method, and the GetSlots() call were updated.




Let's look at the method another way to make the change.



In the GetSlots() window, right click, and select "Edit IL Instructions"



A new window will pop up, allowing us to change the code:



Where did the 32 number go? The 0x20 is Hex, for DEC 32. So dnSpy converted the number for us in the "Get Method", but won't allow us to change it.


Using Windows Calculator, we changed from "Standard" to "Programmer". Then we typed in 32. It shows Hex is 20.



So we if want to go with 48, we'll want to put in:




So 48 in hex is 30.


Click on the 0x20 value, and change it so it says 0x30.



Then click on OK.




So that worked. If you are trying to manipulate numbers, it may be easier to "Edit IL instructions", rather than "Edit Method".

Created with the Personal Edition of HelpNDoc: Easy CHM and documentation editor