How to Decompile a .Net Exe into Readable C# Source Code

How do I decompile a .NET EXE into readable C# source code?

Reflector and its add-in FileDisassembler.

Reflector will allow to see the source code. FileDisassembler will allow you to convert it into a VS solution.

Extract/Decompile source files from exe

If you are looking for .Net Reflector plugins only, then you can try ReflectorFileDisassembler:

http://www.denisbauer.com/Home/ReflectorFileDisassembler

One more .Net Reflector plugin is FileGenerator:

http://filegenreflector.codeplex.com/

If you are open for alternatives another option would be JustDecompile by Telerik:

http://www.telerik.com/products/decompiler.aspx

Dotpeek is also an option, as mentioned by other answers.

Decompile VB.NET exe to C# (dotPeek & JustDecompile)

You have a debug build of VB Winform project. The weak reference stuff is used by the debugger and is not emitted for release builds.

VB creates a property for each Dim WithEvents ControlName As ControlType for which there is also a method decorated with Handles ContolName.EventName. The property setter contains the event wiring code that makes the Handles Event stuff work.

For example a button and its click event.

Friend WithEvents Button1 As Button

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'some code
End Sub

Will cause this property to be generated:

Friend Overridable Property Button1 As Button
<CompilerGenerated> _
Get
Return Me._Button1
End Get
<MethodImpl(MethodImplOptions.Synchronized), CompilerGenerated> _
Set(ByVal WithEventsValue As Button)
Dim handler As EventHandler = New EventHandler(AddressOf Me.Button1_Click)
Dim button As Button = Me._Button1
If (Not button Is Nothing) Then
RemoveHandler button.Click, handler
End If
Me._Button1 = WithEventsValue
button = Me._Button1
If (Not button Is Nothing) Then
AddHandler button.Click, handler
End If
End Set
End Property

You will also probably have many classes with a name in the form of My_XYZ that support VB's application framework.

I would suggest that you create a new VB WinForm project with a few controls/event handlers and then de-compile that so that you can see how your de-compiler reproduces the boiler plate stuff from the IL. Once you know the pattern, it will be a lot easier.

How can I get source code from exe files?

You cannot, in general, retrieve source code from an executable as it's a one-way transformation from in this case visual basic to binary machine code. If you compiled your binary with debug information you have more information available. You can of course obtain assembly and there are a class of tools that is called decompilers that ease transformation to a high-level language like C. See for example https://reverseengineering.stackexchange.com/questions/8038/exe-to-c-source-code-decompiler. Sorry.



Related Topics



Leave a reply



Submit