PDA

View Full Version : What cause reflector to raise exception on this IL


ExeLord
10-05-2009, 03:33 PM
I have target which is obfuscated and all strings are encrypted with simple encryption routine, here is string decryption function:


.method privatescope hidebysig static string ᐁ(string) cil managed
{
.maxstack 4
.locals init (
[0] char[] chArray,
[1] int32 num)
L_0000: ldarg.0
L_0001: call instance char[] [mscorlib]System.String::ToCharArray()
L_0006: dup
L_0007: stloc.0
L_0008: dup
L_0009: ldlen
L_000a: conv.i4
L_000b: dup
L_000c: ldc.i4.0
L_000d: bgt.s L_001b
L_000f: pop
L_0010: newobj instance void [mscorlib]System.String::.ctor(char[])
L_0015: call string [mscorlib]System.String::Intern(string)
L_001a: ret
L_001b: ldc.i4.m1
L_001c: add
L_001d: dup
L_001e: stloc.1
L_001f: ldloc.0
L_0020: ldloc.1
L_0021: ldelem.u2
L_0022: ldc.i4 0x1469
L_0027: sub
L_0028: conv.u2
L_0029: stelem.i2
L_002a: ldloc.0
L_002b: ldloc.1
L_002c: br.s L_000b
}

when I try to decompile it with reflector, it will raise an exception, here is reflector exception info:


Translation failure in 'ᐁ.ᐁ(String) : String' in 'Telligent.Registration, Version=5.0.40702.0, Culture=neutral, PublicKeyToken=null'.

System.InvalidOperationException

InnerException:

Expression stack is empty at offset 001D.

System.InvalidOperationException

at ឺ.ᜀ()
at ឺ.ᜀ(BinaryOperator A_0)
at ឺ.᜘()
at ឺ.ᜊ(Int32 A_0)
at ឺ.ᜋ(Int32 A_0)
at ឺ.ᜂ(Int32 A_0, Int32 A_1)
at ឺ.ᜀ(IMethodDeclaration A_0, IMethodBody A_1)
at ឤ.ᜀ(IMethodDeclaration A_0)
at ឥ.ᜁ(IMethodDeclaration A_0)
at ᝎ.ᜀ(Boolean A_0, Boolean A_1, Boolean A_2)

.NET Reflector 5.1.6.0
.NET Framework 2.0.50727.3074
Microsoft Windows NT 6.0.6001 Service Pack 1
Culture: en-US (en-US)

why it cause reflector decompiler to raise exception ?

I can send target assemlby if needed.

Kurapica
10-05-2009, 03:41 PM
this exception is usually raised when the control-flow of the code is obfuscated.