Question

I am studding IL.

I like .Net Reflector tool from RedGate (Lutz initially). I already have Serge Lidin’s and Ecma-335 books. It looks like these things are all we have to work with IL (except ILAsm and ILDasm, of course).

My task is to parse assembly binary file and get IL code. It is obvious that the assembly is a binary file; hence, it is just a chain of bytes. To do what I want I need to know the assembly structure: which headers exist, how much bytes they occupy, offsets in bytes to read it byte after byte, etc.

Lidin’s book describes it, but it is not 100% clear for me. Did anyone try to parse DLL as byte stream? To have metadata and IL code as byte streams, then parse the IL byte stream to get IL source? I do not want to use reflection here; I’d want to work just with the binary file, rather.

Does the mono Cecil do the same? Even if so, I’d want to know how to do it.

And yes, I am trying to create another wheel like that of .NET Reflector and I want to know how it's made. Like someone said: “Lutz shouldn't necessarily be the only man in the world who knows how to make it”.

BTW, how does ISDasm work? Was it coded in .net?

Any thoughts, resources, examples?

Thank you.

Was it helpful?

Solution

Mono.Cecil does exactly what you want to do. So, you may want to have a look at the source code.

In fact, there is an on going project named Cecil.Decompiler, from Jb Evain, based on top of Cecil, which is an open source .NET decompiler.

OTHER TIPS

You could use ildasm directly:

ildasm.exe MyFile.dll /output:MyFile.il

It can be automated from within your program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top