Skip to content
Cecil is a library to generate and inspect programs and libraries in the ECMA CIL form.
C#
Pull request Compare This branch is 18 commits ahead, 99 commits behind jbevain:master.
Latest commit cd2ff63 Feb 2, 2016 @radekdoulik radekdoulik allow invalid out-of-range opcode targets
 - fix writting of assemblies with out of range targets in
   instructions with InlineBrTarget and ShortInlineBrTarget operand
   types

 - example broken code:

      ...
      IL_00f6:  leave      IL_0118

    }  // end .try
    finally
    {
      ...
      IL_0117:  throw
    }  // end handler
  } // end of method

 - without the fix we end up with

    System.ArgumentException: Value does not fall within the expected range.
    at Mono.Cecil.Cil.CodeWriter.WriteOperand(Instruction instruction)
    at Mono.Cecil.Cil.CodeWriter.WriteInstructions()
    at Mono.Cecil.Cil.CodeWriter.WriteResolvedMethodBody(MethodDefinition method)
    at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method)
    at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
    at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
    at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
    at Mono.Cecil.MetadataBuilder.AddTypeDefs()
    at Mono.Cecil.MetadataBuilder.BuildTypes()
    at Mono.Cecil.MetadataBuilder.BuildModule()
    at Mono.Cecil.MetadataBuilder.BuildMetadata()
    at Mono.Cecil.ModuleWriter.m__0(MetadataBuilder builder, MetadataReader _)
    at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
    at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
    at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
    at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
    at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)

README.md

Cecil

Mono.Cecil is a library to generate and inspect programs and libraries in the ECMA CIL form.

To put it simply, you can use Cecil to:

  • Analyze .NET binaries using a simple and powerful object model, without having to load assemblies to use Reflection.
  • Modify .NET binaries, add new metadata structures and alter the IL code.

Cecil has been around since 2004 and is widely used in the .NET community.

The best way to learn how to use Cecil is to dive into the Cecil.Samples repository. It's a growing collection of samples with the goal of showing how to get things done using Cecil, as IL manipulation can sometime get tricky.

Cecil is a project under the benevolent umbrella of the .NET Foundation.

To discuss Cecil, the best place is the mono-cecil google group.

Build status

Something went wrong with that request. Please try again.