views:

623

answers:

5

Hi,

Just to ask if anyone knows of an open source alternative to RedGate's Reflector? I'm interested in checking out how a tool similar to Reflector actually works.

Thanks, MagicAndi.

A: 

Well, Reflector itself is a .NET assembly so you can open Reflector.exe in Reflector to check out how it's built.

Andrew Hare
No, you can't. Reflector is obfuscated.
Jeff Yates
Andrew, -1. Reflector has been obfuscated for a number of years, possibly since it's initial release.
MagicAndi
You can't open Reflector in Reflector? I just did it - obfuscation simply hurts the readability of the IL since identifiers and type names are mangled but that doesn't mean that you cant dissasemble it.
Andrew Hare
Andrew - when in a hole, stop digging...
MagicAndi
Well, I think most of us don't speak IL currently... and you can't see the equivalent C# code, it says "// This item is obfuscated and can not be translated."
Thomas Levesque
Hmm... I have version 5.1.6.0 and I can see the source just fine - only the identifier names are obfuscated. Not perfect yes, but I am looking at the C# source of Reflector right now. :)
Andrew Hare
Andrew, no one is disputing the fact that you can open the Reflector assembly using the Reflector tool. What everyone, apart from yourself, agrees on is that it is unreadable when you do so.
MagicAndi
@MagicAndi - I am not trying to be argumentative, I am just trying to help you by providing a solution to your problem (even though it may not be ideal).
Andrew Hare
@Andrew Hare: If you try to look at method implementations via reflector in reflector you will see "This is obfuscated" and it won't show it so no, you can't use Reflector. Besides, being pedantic about what the OP wants with the OP is a losing battle.
Jeff Yates
+2  A: 

The Reflector tool uses Reflection.

You asked for two things - code that shows what reflector does, and also an alternative to reflector.

Here's an example, much simplified from what Reflector does, but it shows the technique of reflection: TypeView.cs

I don't have a suggestion for an open-source Reflector replacement.

Cheeso
Uhm, if with "Reflection" you refer to "System.Reflection" of the .NET framework, I would very much doubt that.
Christian.K
Not for the decompilation, but yes, for the type interrogation, I would guess Reflector does in fact use Reflection. Of course I have no way to know.
Cheeso
+2  A: 

2 options I know of.

  • CCI
  • Mono Cecil

These wont give you C# though.

leppie
Leppie, thanks. I'm accepting this as the answer, even though it was a tough choice between your answer and Jason Haley's.
MagicAndi
+1  A: 

Update

Check out the new open source tool, Kaliro, for exploring .Net applications using reflection.

Also, there is a open source disassembler tool:

If anyone has used the tool, I would appreciate it if you would add a comment below letting me know what your thoughts are on the tool.

MagicAndi
I used dile a few years ago - it is a great disassembler AND debugger - I highly recommended it back when I was using it. I haven't used it for awhile though.
Jason Haley
+1  A: 

Actually, I'm pretty sure Reflector is considered a disassembler with some decompiler functionality. Disassembler because it reads the bytes out of an assembly's file and converts it to an assembly language (ILasm in this case). The Decompiler functionality it provides by parsing the IL into well known patterns (like expressions and statements) which then get translated into higher level languages like C#, VB.Net, etc. The addin api for Reflector allows you to write your own language translator if you wish ... however the magic of how it parses the IL into the expression trees is a closely guarded secret.

I would recommend looking at any of the three things mentioned above if you want to understand how IL disassemblers work: Dile, CCI and Mono are all good sources for this stuff.

Some other resources that are valuable are listed on a page I put together a few years ago: http://jasonhaley.com/reversing/

I also highly recommend getting the Ecma 335 spec and Serge Lidin's book too.

Jason Haley
Jason, thanks for the advice and for listing a few resources. +1
MagicAndi