CIL/Bytecode Conversion
CIL/Bytecode Conversion Posted on: 02/07/2012 9:56pm
Quote Post
I am a bit confused with converting code into bytecode.

I hacked into a .unity3d and used ILSpy to get this: this.maxForwardSpeed = 10f;
I would like to convert it into: this.maxForwardSpeed = 50f;

However, I have no clue how to do that. I know there is a code for "if", but then do I use wild cards for "maxForwardSpeed" and then what do I use for 10? I really have no clue. I looked at the tutorials for this but it does not help. How should I convert this? I think if I know how to convert this, I can figure out how to convert other lines of code.

Re: CIL/Bytecode Conversion Posted on: 02/17/2012 10:38am
Quote Post
I use .NET reflector for decompiling and there is an option to display the code as "Intermediate Language (IL)" instead of C#. This work much better as you will get something like
    L_0050: ldarg.0
    L_0051: ldc.r4 10f
    L_0056: stfld float32 maxForwardSpeed
which this statement is just this.maxForwardSpeed = 10f in C#
then you can check from wiki
these instructions like ldarg.0, ldc.r4 and stfld
so we have
byte value
50 = 02
51 = 22
52 = ??
53 = ??
54 = ??
55 = ??
56 = 7D
Unluckily, you need way longer search to obtain the only relevant result if you have so many wildcards.