Re: Ngen.exe

From: Jonathan Pierce (jpierce_at_nyc.rr.com)
Date: 06/06/04


Date: 5 Jun 2004 23:19:08 -0700

Henning, Rene,

For simple code examples, Reflector 4.0 does a much better job than
the previous version. At first glance, it looks as powerful as the
commercial products being sold, however, there are many examples where
Reflector 4.0 does not generate code that compiles or runs, while
Salamander and Decompiler.NET do a much better job and provide better
support as you might expect from a commercial products. Before you
pass judgement, you may want to try using the tools for more than just
examining code, but instead for generating readable code that compiles
and runs correctly. A good example is the ILReader library written by
Lutz where he provides source code. Reflector 4.0 is unable to
correctly decompile or run this library written by Reflector's author,
while Decompiler.NET decompiles and runs the library correctly.
Another example would be the correct handling of constructs like fixed
statements and unsafe code.

Try the following code example in each of the products and see how
well they handle it both from code readability and runtime behavior.
You will see that Reflectot 4.0 generates code that won't compile or
run correctly. This is just one example of a construct that is
difficult to support and there are many others. I have reported many
of them to each of the other vendors as bugs including Lutz regarding
Reflector 4.0.

unsafe static bool unsafePointer(string s) {
                        char[] c = new char[10];
                        s.CopyTo(0,c,0,10);
                        fixed(char *p=c){
                                *(p+5) = 'x';
                                for (int i = 0; i < 10; i++)
                                if (*(p+i) == 'p')
                                        return true;
                                }
                        return false;
                }

Here's what Reflector generates which will not compile or run
correctly. Notice the assignment to p]10] where it should be p[5]
because the chars are two bytes. Also notice the missing fixed
statement and the incorrect use of the ref keyword and the datatype
mismatch between chars and ints. Here's what Reflector 4.0 produces:

private static bool unsafePointer(string s)
{
int num1;
char[] chArray1 = new char[10];
s.CopyTo(0, chArray1, 0, 10);
pinned ref char local1 = ref chArray1[0];
local1[10] = 120;
for (num1 = 0; (num1 < 10); num1 += 1)
{
 if ((local1 + (num1 * 2)) == 112)
{ return true;
}
 }
local1 = 0;
return false;
}
 
Decompiler.NET however generates even better code than the original by
replacing ptr arithmetic with array references. The generated code
also runs correctly unlike what any of the other decompilers produce
including Salamander. Decompiler.NET is also the only decompiler
product being sold which retains local variable names by reading them
from the symbol file when it is available. It is also priced extremely
low relative to the competitors and includes free support, updates,
and full obfuscation capabilities.

static unsafe bool unsafePointer (string s)
                        
                        {
                                char[] c;
                                c = new char[10];
                                s.CopyTo (0, c, 0, 10);
                                fixed (char* p = c)
                                {
                                        p[5] = 'x';
                                        for (int i = 0; (i < 10); i++)
                                        {
                                                if (p[i] == 'p')
                                                {
                                                        return true;
                                                }
                                        }
                                }
                                return false;
                        }

Jonathan Pierce
President
Jungle Creatures, Inc.
http://www.junglecreatures.com/

"Henning Krause" <newsgroup.no@spam.infinitec.de> wrote in message news:<OH$YGE0SEHA.1168@TK2MSFTNGP11.phx.gbl>...
> Hello,
>
> yes, the Reflecter was the first decompiler I ever used. The current version
> (4.x) has finally an equal high level of decompilation as the Salamander
> Decompiler. The version 3.x left many goto's in the C# code.
>
> From a point of usability, it is by far the best... therefore I fully agree
> with you.
>
> Greetings,
> Henning
>
> --
> Henning Krause
> ==========================
> Visit my website: http://www.infinitec.de
> Try my free Exchange Explorer: Mistaya
> (http://www.infinitec.de/?page=products)
>
>
> "Rene" <renegram@nospam.hotmail.com> wrote in message
> news:Ow2lUxzSEHA.3224@TK2MSFTNGP10.phx.gbl...
> > Have you taken a look at .NET Reflector? It does this already for free and
> > everybody I know is using it.
> >
> > It seems hopeless to me trying to make money on anything like that?
> >
> >
> > "Jonathan Pierce" <jpierce@nyc.rr.com> wrote in message
> > news:3d0f5457.0406011110.1b0cd22c@posting.google.com...
> > > "Henning Krause" <newsgroup.no@spam.infinitec.de> wrote in message
> news:<O3wSgi0REHA.3616@TK2MSFTNGP11.phx.gbl>...
> > > > Hello,
> > > >
> > > > your decompiler is also quite advanced. Add an inline viewer and the
> ability
> > > > to decompile GAC assemblies, and its even more powerfull ;-)
> > >
> > > Henning,
> > >
> > > Thank you for the positive feedback about the product. Also, your
> > > feature suggestions are excellent. Decompiler.NET will decompile
> > > referenced GAC assemblies, but the open file dialog doesn't let you
> > > select one directly. I'll add the feature. I'm also adding a class
> > > browser interface to the next major release of the product as well as
> > > a solution explorer for generated source code.
> > >
> > > I appreciate any technical feedback about code generation accuracy and
> > > additional feature requests as well.
> > >
> > > Jonathan
> >
> >



Relevant Pages

  • Re: Obfuscate
    ... preconfiguration prior to obfuscation, ... Lutz a lot of feedback regarding code generation issues in Reflector ... decompiler which reads symbol files and retains local variable names. ... We also do a much better job with unsafe code and COM Interop and each ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: VB.NET and PRECOMPILES HELP
    ... As Jason said Reflector is the magic word in this case ... I was able to get a copy of the published web site. ... to use a decompiler, such as Reflector: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Decompiler.NET reverse engineers your CLS compliant code
    ... >> Our customers prefer the decompilation capability offered by the real ... >> Our product has many other capabilities that Reflector doesn't include, ... >> Visual Studio and other decompiler tools like Reflector allow. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Ngen.exe
    ... It's simply faster to take a quick look into a .NET Assambly with Reflector. ... but instead for generating readable code that compiles ... > statements and unsafe code. ... the Reflecter was the first decompiler I ever used. ...
    (microsoft.public.dotnet.security)
  • Re: Obfuscate
    ... > preconfiguration prior to obfuscation, ... > our customers have decided to purchase it after having tested both it ... > Lutz a lot of feedback regarding code generation issues in Reflector ... > We also do a much better job with unsafe code and COM Interop and each ...
    (microsoft.public.dotnet.languages.csharp)