Exetools  

Go Back   Exetools > General > General Discussion

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 02-27-2019, 16:09
deepzero's Avatar
deepzero deepzero is offline
VIP
 
Join Date: Mar 2010
Location: Germany
Posts: 310
Rept. Given: 115
Rept. Rcvd 64 Times in 42 Posts
Thanks Given: 195
Thanks Rcvd at 224 Times in 95 Posts
deepzero Reputation: 64
First.

Code:
    IL_0000: ldarg.1      // load a
    IL_0001: ldarg.2      // load b (which is a reference)
    IL_0002: ldind.i4      //dereference b (bc it is is reference: int&)
    IL_0003: call         BitConverter::ToUInt() //call and put result on stack
then

Code:
    IL_0008: ldarg.2      // load b on stack for later use
    IL_0009: ldarg.2      // load b
    IL_000a: ldind.i4      //dereference it
    IL_000b: ldc.i4.4      //load interger-constant "4" to stack
    IL_000c: add           //add the values of b and "4" and put the result on the stack
SO now the stack looks like this:


Code:
<value: result of b+4>
<reference: b> (was loaded at IL_0008)
<value: return value of the BitConverter call>

Then the last piece of the puzzle:

Code:
    IL_000d: stind.i4   //store the result of  "b+4" in b
There now is just one entry on the stack:

Code:
<value: return value of the BitConverter call>
and finally return that last entry:

Code:
    IL_000e: ret


So in conclusion the method does two things: 1) b += 4 and 2) return BitConverter(). So reflector is right and the others are wrong. You should file a bug report.


A more literal decompilation would be:


Code:
    private uint e(byte[] a, ref int b)
    {
        uint32 tmp = BitConverter.ToUInt32(a, b);
        b += 4;
        return tmp;
    }
But you can trivially optimize that by eliminating the tmp variable.
Reply With Quote
The Following 2 Users Say Thank You to deepzero For This Useful Post:
tonyweb (03-02-2019), WhoCares (02-27-2019)
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Decompiling the mov compiler chants General Discussion 3 12-08-2016 21:16
VB3 decompiling wasq General Discussion 23 05-23-2005 02:30
decompiling back to C++? Rhodium General Discussion 44 10-11-2004 08:30


All times are GMT +8. The time now is 23:39.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )