I have very small experience of decompiling/playing with IL ...anywya

I've tried to decompile one .net application and here's the IL code of one of the function:
.method public hidebysig static string 
          _xaacba899487bce8c(string x5e99b576d2530d13,
                             int32 x2710752c36f2d14b) cil managed
  {
    // Code size       301 (0x12d)
    .maxstack  5
    .locals init (uint16 V_0,
             char[] V_1,
             int32 V_2,
             uint16 V_3,
             string V_4,
             bool V_5,
             bool V_6)
    IL_0000:  ldarg.1
    IL_0001:  conv.u2
    IL_0002:  stloc.0
    IL_0003:  ldloc      V_5
    IL_0007:  conv.u4
    IL_0008:  ldloc      V_0
    IL_000c:  conv.u4
    IL_000d:  add
    IL_000e:  ldc.i4.m1
    IL_000f:  cgt.un
    IL_0011:  stloc      V_6
    IL_0015:  ldloc      V_6
    IL_0019:  brfalse    IL_00fc
.....

that gets translate to:
public static string _xaacba899487bce8c(string x5e99b576d2530d13, int x2710752c36f2d14b)
        {
            ushort s1;

            char[] chs;

            int i;

            bool flag1;

            s1 = (ushort)x2710752c36f2d14b;
            bool flag2 = (uint)flag1 + (uint)s1 > uint.MaxValue;
            if (flag2)
            {
                goto IL_0030;
            }
            flag1 = (uint)x2710752c36f2d14b > uint.MaxValue;
            chs = new char[x5e99b576d2530d13.Length / 4];
            i = 0;
             ...

Receiving some errors like:
bool flag2 = (uint)flag1 + (uint)s1 > uint.MaxValue;

Error 1 Cannot convert type 'bool' to 'uint'

I am doing something wrong here or it's the .net decompiler that has a bug in it...

thanks...
abuck
0

Comments

5 comments

  • abuck
    After looking at the CIL instruction, the conversion make sense as we load the variable into the stack and convert it to 32bits...
    based on:
    0x6D conv.u4 Convert to unsigned int32, pushing int32 on stack.

    My question is, the .net decompiler should maybe use the Convert.ToUInt32() instead of the implicit cast...

    bool flag2 = Convert.ToUInt32(flag1) + (uint)s1 > uint.MaxValue;

    that does make any sence ? Is this a known bug ?
    abuck
    0
  • abuck
    any help is really appreciated ! thanks
    abuck
    0
  • Clive Tong
    You are running into bugs in the decompiler.

    Do you know the original language for the assembly that you are decompiling? If it wasn't C#, then the decompiler may have difficulty translating some instruction sequences into C#.
    Clive Tong
    0
  • abuck
    Clive Tong wrote:
    You are running into bugs in the decompiler.

    Do you know the original language for the assembly that you are decompiling? If it wasn't C#, then the decompiler may have difficulty translating some instruction sequences into C#.

    It was originatly coded in vb.net language but I am experiencing the same compilation error...

    where can I report bugs ?

    BTY thanks for your help !
    abuck
    0
  • Clive Tong
    abuck wrote:
    where can I report bugs ?

    This forum is the best place. We can then log them in our bug tracking system.
    Clive Tong
    0

Add comment

Please sign in to leave a comment.