TheSwamp

Code Red => .NET => Topic started by: TheMaster on March 28, 2012, 03:23:43 PM

Title: Is anyone using ILSpy?
Post by: TheMaster on March 28, 2012, 03:23:43 PM
The beta of version 2.0 has been online for a few months and
after playing with it, I'm ready to say 'adios Reflector'.

There's even a version that runs on Metro (http://jcooney.net/post/2011/11/09/Metro-style-for-ILSpy.aspx).

Best of all, its open sourced and you can hack on it to your heart's content.

http://build.sharpdevelop.net/BuildArtefacts/#ILSpyMaster
Title: Re: Is anyone using ILSpy?
Post by: Kerry on March 28, 2012, 03:42:36 PM

Thanks for the heads up Tony - an alternative is handy.
I've had a look at dotPeek from JetBrains ... good, but not up to Reflector yet.
Title: Re: Is anyone using ILSpy?
Post by: TheMaster on March 28, 2012, 08:50:05 PM

Thanks for the heads up Tony - an alternative is handy.
I've had a look at dotPeek from JetBrains ... good, but not up to Reflector yet.

Speaking of Reflector, here's some interesting observations:

 http://community.sharpdevelop.net/blogs/dsrbecky/archive/2011/02/19/ilspy-ensuring-correctness.aspx

Title: Re: Is anyone using ILSpy?
Post by: exmachina on March 28, 2012, 08:59:02 PM
Red Gate Reflector some times do not show code ofuscated with Red gate Smartassembly. Why?  :lmao:

 The best free "decompiler" is Telerick JustDecompile
Title: Re: Is anyone using ILSpy?
Post by: Jeff H on March 28, 2012, 10:02:06 PM
The best free "decompiler" is Telerick JustDecompile
Especially when looking at acdbmgd.dll & acmgd.dll
 
JustDecompile is hands down the best at decompiling the code to this 
(http://i1221.photobucket.com/albums/dd473/Jeffrey_H/Justdecompile.png)
 
 
 
Thanks for that link!!
Wish I would of known about this before I paid for Reflector.
Title: Re: Is anyone using ILSpy?
Post by: exmachina on March 28, 2012, 10:53:57 PM
The best free "decompiler" is Telerick JustDecompile
Especially when looking at acdbmgd.dll & acmgd.dll
 
JustDecompile is hands down the best at decompiling the code to this 

Thanks for that link!!
Wish I would of known about this before I paid for Reflector.
Sorry. I do not understand, perhaps because I do not speak English : Il & C#

(http://i.imgur.com/Ir4D4.png)
Title: Re: Is anyone using ILSpy?
Post by: exmachina on March 28, 2012, 11:07:35 PM
 :oops: :oops: :oops: Ok. You're right

(http://i.imgur.com/irURw.png)
Title: Re: Is anyone using ILSpy?
Post by: TheMaster on March 29, 2012, 04:16:45 AM

Red Gate Reflector some times do not show code ofuscated with Red gate Smartassembly. Why?  :lmao:


Refector is only accurate with IL produced by the Microsoft C# compiler.

IL produced via any other means (e.g., another language) may not
be accurately decompiled.

Quote

  The best free "decompiler" is Telerick JustDecompile


Hate to disagree :grin:

Can you debug managed code with JustDecompile ?

ILSpy 2.0 (beta) is a debugger as well as a decompiler.

You can set breakpoints, launch an executable or attach
to a running process, and step through any code in any
assembly that's loaded, regardless of whether it is your
code, the .NET framework, or AutoCAD's managed runtime.

When a breakpoint is hit, you can examine the call stack,
see the values of  arguments, etc. (no locals/watch window
yet, but that's planned).

Also, it looks like Telerik still has some work to do.

JustDecompile showing the source for System.Linq.Enumerable.ZipIterator:

Code - C#: [Select]
  1.  
  2. Current member / type: System.Collections.Generic.IEnumerable`1<TResult> System.Linq.Enumerable::ZipIterator(System.Collections.Generic.IEnumerable`1<TFirst>,System.Collections.Generic.IEnumerable`1<TSecond>,System.Func`3<TFirst,TSecond,TResult>)
  3. File path: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Core.dll
  4. Product version: 2012.1.214.2
  5. Multiple invocations of finally method
  6.    at ˆ..ˆ(€ handlerInfo, Queue`1 bfsQueue, ILogicalConstruct currentNode)
  7.    at ˆ..‡(€ handlerInfo)
  8.    at ˆ..ƒ(BlockLogicalConstruct theBlock)
  9.    at ˆ.Ž–.‰()
  10.    at ˆ.Ž–.Process(DecompilationContext context, BlockStatement body)
  11.    at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language)
  12.    at Telerik.JustDecompiler.Decompiler.Extensions.DecompileYieldStateMachine(MethodBody body, ILanguage language, YieldFieldsInformation& fieldsInformation)
  13.    at .‹.()
  14.    at .‹.Match(StatementCollection statements)
  15.    at .‹.Process(DecompilationContext context, BlockStatement body)
  16.    at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language)
  17.    at Telerik.JustDecompiler.Decompiler.Extensions.(DecompilationPipeline pipeline, ILanguage language, MethodBody body, DecompilationContext& context)
  18.    at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context)
  19.    at Telerik.JustDecompiler.Languages.BaseImperativeLanguageWriter.Write(MethodDefinition method)
  20.    at Telerik.JustDecompiler.Languages.BaseLanguageWriter.Write(IMemberDefinition member, Boolean showCompilerGeneratedMembers)
  21.    at JustDecompile.CodeViewer.CodeWriter.Write() in c:\Builds\126\Behemoth\JustDecompile Production Build\Sources\UI\JustDecompile.CodeViewer\Writers\CodeWriter.cs:line 32
  22.    at JustDecompile.CodeViewer.ViewModels.CodeViewerViewModel.(AssemblyMemberNode member, CancellationToken cancellationToken) in c:\Builds\126\Behemoth\JustDecompile Production Build\Sources\UI\JustDecompile.CodeViewer\ViewModels\CodeViewerViewModel.cs:line 170
  23.  
  24. mailto: JustDecompilePublicFeedback@telerik.com
  25.  
  26.  

ILSpy showing the same method:

Code - C#: [Select]
  1.  
  2. // System.Linq.Enumerable
  3. private static IEnumerable<TResult> ZipIterator<TFirst, TSecond, TResult>(IEnumerable<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
  4. {
  5.         using (IEnumerator<TFirst> enumerator = first.GetEnumerator())
  6.         {
  7.                 using (IEnumerator<TSecond> enumerator2 = second.GetEnumerator())
  8.                 {
  9.                         while (enumerator.MoveNext() && enumerator2.MoveNext())
  10.                         {
  11.                                 yield return resultSelector(enumerator.Current, enumerator2.Current);
  12.                         }
  13.                 }
  14.         }
  15.         yield break;
  16. }
  17.  
  18.  
Title: Re: Is anyone using ILSpy?
Post by: TheMaster on March 29, 2012, 04:21:22 AM
The best free "decompiler" is Telerick JustDecompile
Especially when looking at acdbmgd.dll & acmgd.dll
 
JustDecompile is hands down the best at decompiling the code to this 
 
Thanks for that link!!
Wish I would of known about this before I paid for Reflector.

Were you using the assemblies from the SDK or the production
assemblies in the AutoCAD folder?
Title: Re: Is anyone using ILSpy?
Post by: exmachina on March 29, 2012, 05:26:48 AM
@ TheMaster
"Red Gate Reflector some times do not show code ofuscated with Red gate Smartassembly. Why?":
Easy :SmartassemblyAttribute

ILSpy
http://wiki.sharpdevelop.net/ILSpy.ashx
Debug? where you see that?.
Why anyone needs debug 3rth party assemblies?: only for hacking or cracking.  And read carefully at ILSpy - Further Down the Road:
Assembly editing capabilities (similar to Reflexil <- This is an Hackers Tool
Title: Re: Is anyone using ILSpy?
Post by: kaefer on March 29, 2012, 06:31:58 AM
ILSpy
http://wiki.sharpdevelop.net/ILSpy.ashx
Debug? where you see that?.

Version 2.0 Beta 1 (ILSpy 2.0.0.1564) (http://sourceforge.net/projects/sharpdevelop/files/ILSpy/2.0/ILSpy_Master_2.0.0.1564_Beta_Binaries.zip/download)
Title: Re: Is anyone using ILSpy?
Post by: exmachina on March 29, 2012, 07:09:00 AM
@ kaefer
Thanks, i proves it.
Title: Re: Is anyone using ILSpy?
Post by: Jeff H on March 29, 2012, 09:34:08 AM
The best free "decompiler" is Telerick JustDecompile
Especially when looking at acdbmgd.dll & acmgd.dll
 
JustDecompile is hands down the best at decompiling the code to this 
 
Thanks for that link!!
Wish I would of known about this before I paid for Reflector.

Were you using the assemblies from the SDK or the production
assemblies in the AutoCAD folder?

The ones located in same location as acad.exe not the sdk's or ones that are just the signatures.
Title: Re: Is anyone using ILSpy?
Post by: Draftek on March 29, 2012, 09:44:50 AM
Thanks Tony.
Title: Re: Is anyone using ILSpy?
Post by: TheMaster on March 29, 2012, 02:09:44 PM
Why anyone needs debug 3rth party assemblies?: only for hacking or cracking. 

Why does anyone need to debug 3rd party assemblies?

Why does Visual Studio allow you to debug .NET framework code?
Title: Re: Is anyone using ILSpy?
Post by: exmachina on April 02, 2012, 11:29:35 AM
Why does Visual Studio allow you to debug .NET framework code?

I do not know. If someone has an (real life) example , please send it.
Thanks.
Title: Re: Is anyone using ILSpy?
Post by: TheMaster on April 02, 2012, 03:21:11 PM
Why does Visual Studio allow you to debug .NET framework code?

I do not know. If someone has an (real life) example , please send it.
Thanks.

Microsoft made the source available for debugging so that if you need to know what the framework is doing when you call one of its APIs, you can step into the source code to find out.
Title: Re: Is anyone using ILSpy?
Post by: exmachina on April 02, 2012, 05:11:37 PM
What about pdb files and others files like this?. In any case, i respect your opinion but i do not understand what may be the purpose of debugging that:
Debugging System.Drawing.Graphics.DrawString
(http://i.imgur.com/MKIq0.png)
Title: Re: Is anyone using ILSpy?
Post by: Jeff H on April 02, 2012, 07:34:32 PM
Many reasons and on one hand you have people checking and testing your code for free.
 
Using your example lets say you keep getting a exception that your brush is null and you use a decompiler to look at code.
Code - C#: [Select]
  1.         public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
  2.         {
  3.             if (brush == null)
  4.             {
  5.                 throw new ArgumentNullException("brush");
  6.             }
  7.             if ((s != null) && (s.Length != 0))
  8.             {
  9.                 if (font == null)
  10.                 {
  11.                     throw new ArgumentNullException("brush");
  12.                 }
  13.                 GPRECTF layoutRect = new GPRECTF(layoutRectangle);
  14.                 IntPtr handle = (format == null) ? IntPtr.Zero : format.nativeFormat;
  15.                 int status = SafeNativeMethods.Gdip.GdipDrawString(new HandleRef(this, this.NativeGraphics), s, s.Length, new HandleRef(font, font.NativeFont), ref layoutRect, new HandleRef(format, handle), new HandleRef(brush, brush.NativeBrush));
  16.                 this.CheckErrorStatus(status);
  17.             }
  18.         }
  19.  

You tell microsoft and they can't reproduce it and you send them your code for creating a brush and they can't reproduce it.
 
I do not know if you caught it but I changed the exception for font null check (easily could happen by copying pasting and forgetting to change brush to font)
 
If you debug it you would have noticed that it really was your font that was null. I do not see how people can really say they know what there code is doing without debugging it.
Title: Re: Is anyone using ILSpy?
Post by: exmachina on April 02, 2012, 08:17:31 PM
Maybe I have not understood well (sorry, always i have the same problem because i don't speack...etc), In my opinion:

1- I do not work for Microsoft, much less free. So i have no reason to find/debug their mistakes
2- 33 + 33 = 66. Otherwise the problem is the compiler or languaje implementation=>Look@point 1
3- At this level anyone can be distinguish what is his own fault/bug or that of others, so=>Look@point 1
Title: Re: Is anyone using ILSpy?
Post by: Jeff H on August 21, 2012, 05:24:16 PM
I have not spent much time with it but at least looks cool, a visualizer plug-in for ILSpy.
 
ILSpy Plug-Ins (http://wiki.sharpdevelop.net/ILSpy%20Plugins.ashx)
 
 
(http://i1221.photobucket.com/albums/dd473/Jeffrey_H/IlSpy.png)
Title: Re: Is anyone using ILSpy?
Post by: BlackBox on August 21, 2012, 06:22:59 PM
I have not spent much time with it but at least looks cool, a visualizer plug-in for ILSpy.
 
ILSpy Plug-Ins (http://wiki.sharpdevelop.net/ILSpy%20Plugins.ashx)

... That's pretty neat; I'm sure the Assembly Visualizer will come in handy as I progress with .NET development. :beer:
Title: Re: Is anyone using ILSpy?
Post by: irneb on August 20, 2013, 02:03:24 AM
Sorry for opening a oldish thread, but there's just been another release of such "free" inspector/decompiler:
dotPeek: http://www.jetbrains.com/decompiler/