Search this blog

Sunday, April 13, 2008

Intermediate Language (IL)

Can I look at the IL for an assembly?

Yes. MS supply a tool called ILDASM that can be used to view the metadata and IL for an assembly.

Source code be reverse-engineered from IL?

Yes, it is often relatively straightforward to regenerate high-level source from IL. Lutz Roeder's Reflector does a very good job of turning IL into C# or VB.NET.

How can I stop my code being reverse-engineered from IL?

You can buy an IL obfuscation tool. These tools work by 'optimising' the IL in such a way that reverse-engineering becomes much more difficult.

Of course if you are writing web services then reverse-engineering is not a problem as clients do not have access to your IL.

Can I write IL programs directly?

Yes. Peter Drayton posted this simple example to the DOTNET mailing list:

    .assembly MyAssembly {}

.class MyApp {

.method static void Main() {
.entrypoint
ldstr "Hello, IL!"
call void System.Console::WriteLine(class System.Object)
ret
}
}

Just put this into a file called hello.il, and then run ilasm hello.il. An exe assembly will be generated.

Can I do things in IL that I can't do in C#?

Yes. A couple of simple examples are that you can throw exceptions that are not derived from System.Exception, and you can have non-zero-based arrays.


No comments:

Post a Comment