1

I need to debug a dll at the IL Level, and reading http://blogs.msdn.com/b/jmstall/archive/2004/10/03/237137.aspx I wanted to disassemble/reassemble the DLL with il(d)asm.

The disassembly runs through, but the reassembly fails with

Assembled method Dapper.SqlMapper°UdtTypeHandler::Dapper.SqlMapper.ITypeHandler.SetValue
Assembled method Dapper.SqlMapper°TypeHandler`1::Dapper.SqlMapper.ITypeHandler.SetValue
Assembled method Dapper.SqlMapper°TypeHandler`1::Dapper.SqlMapper.ITypeHandler.Parse
Assembled method Dapper.SqlMapper°TypeHandler`1::.ctor
Assembled method Dapper.SqlMapper°Link`2::TryGet
W:\TimPrecast\ildasm\ppdbcore.il(71204) : error : Undeclared identifier IL_0016
W:\TimPrecast\ildasm\ppdbcore.il(71204) : error : syntax error at token ':' in:       IL_0016:  ldloc.s

***** FAILURE *****

I then openend both the DLL in ILSpy and the generated IL file in notepad:

ILSpy:

    IL_000a: stloc.1
    IL_000b: ldloc.1
    IL_000c: ldarg.1
    IL_000d: ldloca.s found
    IL_000f: call bool class Dapper.SqlMapper/Link`2<!TKey, !TValue>::TryGet(class Dapper.SqlMapper/Link`2<!0, !1>, !0, !1&)
    IL_0014: stloc.s 4
    IL_0016: ldloc.s 4
    IL_0018: brfalse.s IL_0027

    IL_001a: nop
    IL_001b: ldarg.2
    IL_001c: ldloc.2
    IL_001d: stobj !TValue
    IL_0022: ldc.i4.0
    IL_0023: stloc.s 5
    IL_0025: br.s IL_0051

ILDASM (Line 71204 is IL_0016):

  IL_000a:  stloc.1
  IL_000b:  ldloc.1
  IL_000c:  ldarg.1
  IL_000d:  ldloca.s   found
  IL_000f:  call       bool class Dapper.SqlMapper/Link`2<!TKey,!TValue>::TryGet(class Dapper.SqlMapper/Link`2<!0,!1>,
                                                                                 !0,
                                                                                 !1&)
  IL_0014:  stloc.s    
  IL_0016:  ldloc.s    
  IL_0018:  brfalse.s  IL_0027

  IL_001a:  nop
  IL_001b:  ldarg.2
  IL_001c:  ldloc.2
  IL_001d:  stobj      !TValue
  IL_0022:  ldc.i4.0
  IL_0023:  stloc.s    V_5
  IL_0025:  br.s       IL_0051

It looks like the index to stloc.s is missing.

ILDasm Help -> Info shows Version 4.0.30319.0.

Lukas Rieger
  • 676
  • 10
  • 31
  • I could imagine the locals name was replaced with some unprintable characters by some kind of obfuscator. You could compare the ildasm result with the result of an other decompiler like ILSpy. – thehennyy Dec 29 '15 at 10:00
  • @thehennyy the DLL is self-compiled and not obfuscated. The reason that I recompile it is that I wanted IL-Level debugging, not source-level debugging. ILSpy shows the correct output, I was able to recompile it by saving the ILSpy output. – Lukas Rieger Dec 30 '15 at 18:51

0 Answers0