tags:

views:

411

answers:

3

There is a GetILAsByteArray method in MethodBody class which gives body of a method. I am looking for converting this byte array into more understandable IL instructions (into a List or something like that). What resources, open source code or api available are there to help me understand and convert this byte array (or do it for me)?

I found this but it does not work with generics. I am pretty much looking for guidance to convert understand these bytes in all framework versions.

CLI Documentation is also helpful for learning IL instructions but I cannot see how to use it to make these bytes make sense.

+1  A: 

It is a huge undertaking. I wrote the starts of an IL reader and it had a pretty good amount of opcodes implemented: but you will need to finish it.

http://svn.ensemble-os.org/tags/OldOCJ/CIL/

There is also MONO Cecil, which is feature-complete.

Jonathan C Dickinson
+2  A: 

Have a look at the Mono.Cecil library.

Anton Tykhyy
+3  A: 

I just wrote an extension method to get a more understandable list of instructions using GetILAsByteArray. It's quite simple, the API is like:

public static IList<Instruction> GetInstructions (this MethodBase self);

You can read more about the implementation in my blog post. Or you can go take the implementation and start using it.

Jb Evain