How do I decompile a .dll file?
Asked Answered
A

7

38

I have a .dll I would like to decompile to make some improvements to the code. What are some tools out there that will allow me to do this?

It's written in VB, I believe.

Ambidexter answered 4/3, 2011 at 17:50 Comment(0)
S
37

The answer depends on what language the DLL was written in.

If it was a .NET language then, as pointed out, you can use .NET Reflector.

If it's the older Visual Basic (pre-.NET), then the DLL is compiled as what's called p-code and there are a few options for doing some variations on decompiling.

Finally, if it's written in a language like C++, there is no direct way to obtain the source code. Such a DLL is compiled to machine language and can only be directly decompiled to assembly language.

So, again, it depends on the language used. And the answer might be that it's just not possible to get anything resembling the original source code.

Scheller answered 4/3, 2011 at 17:58 Comment(6)
Then, as stated, if it's Visual Basic, research p-code decompilers.Scheller
What what I was really looking for was a way to see the source code from a .dll. I don't know if there are free tools for this?Ambidexter
Viewing the source code from a compiled DLL is called decompiling. The source code is not inside a DLL--it has to be reconstructed by decompiling the binary data. There's only so many different ways I can answer your question. I've been very thorough.Scheller
Why is it that the decompiled code is not readable? It doesn't look like vb to me? (Newbie here)Ambidexter
@Ambidexter - this is an old post and I'm sure you've figured it out - but for future newbies the reason is that computers don't run VB code. They run machine code. When we "compile" our programs, what the compiler is doing is translating our programming language to machine code so it can be executed by the computer. When you look at an EXE or a DLL, what you are seeing is this machine code, not the original program. Think of it like having a document in English. Somebody translates to Chinese. And you wonder why when you look at the Chinese document, it's not in English anymore.Equestrian
As to what William said: compiling means transforming source code into another representation. Java compiler compile to a byte code for the JVM, not to machine code. Other system compile to other non-machine-code representations. You can even compile source code of one language into source code of another language (the first compiler for C++ compiled to C).Jaggers
K
20

JetBrain's dotPeek billed as the Free .NET Decompiler and Assembly Browser worked great for me: quick, easy, and of course best of all, free!

Kellda answered 26/10, 2017 at 20:28 Comment(0)
J
2

.NET Reflector!!!

http://www.red-gate.com/products/dotnet-development/reflector/

It is even free, you won't need the pro version to see the dissassembled code.

Jandel answered 4/3, 2011 at 17:51 Comment(3)
That will work if it's VB.NET. If it's VB6 he's out of luck.Overblown
true that, just made the assumption.Jandel
To anyone finding this post now: this utility is no longer free.Olio
E
2

There are many paid tools out there in the market. But I use a free tool and not only just seeing disassembled code, but I am also able to debug the code. For example, let's say there is an exe that was developed in .Net, I am able to debug that compile code using this tool known as DnSpy.

http://xyzcoder.github.io/dll_decompiling/decompiled_dll_debugging/dnspy/2018/06/07/dnSpy-For-DeCompiling,Debugging.html

Embosser answered 7/8, 2020 at 6:14 Comment(0)
T
1

Since this is an older question and a lot has happened since asked I figure I would add a couple links to decompilers out there that may be of use to others looking for a solution.

ILSpy https://github.com/icsharpcode/ILSpy/releases

Completely Free & according to Git README.md as of current:

Decompiler Frontends

Aside from the WPF UI ILSpy (downloadable via Releases, see also plugins), the following other frontends are available:

Visual Studio 2022 ships with decompilation support for F12 enabled by default (using our engine v7.1).
In Visual Studio 2019, you have to manually enable F12 support. Go to Tools / Options / Text Editor / C# / Advanced and check "Enable navigation to decompiled source"
C# for Visual Studio Code ships with decompilation support as well. To enable, activate the setting "Enable Decompilation Support".
Our Visual Studio 2022 extension marketplace
Our Visual Studio 2017/2019 extension marketplace
Our Visual Studio Code Extension repository | marketplace
Our Linux/Mac/Windows ILSpy UI based on Avalonia - check out https://github.com/icsharpcode/AvaloniaILSpy
Our ICSharpCode.Decompiler NuGet for your own projects
Our dotnet tool for Linux/Mac/Windows - check out ILSpyCmd in this repository
Our Linux/Mac/Windows PowerShell cmdlets in this repository

Features

Decompilation to C# (check out the language support status)
Whole-project decompilation (csproj, not sln!)
Search for types/methods/properties (learn about the options)
Hyperlink-based type/method/property navigation
Base/Derived types navigation, history
Assembly metadata explorer (feature walkthrough)
BAML to XAML decompiler
ReadyToRun binary support for .NET Core (see the tutorial)
Extensible via plugins
Additional features in DEBUG builds (for the devs)

Telerik https://www.telerik.com

This one is Free/Trail/Paid Versions with multiple language support.

Tenner answered 22/1, 2023 at 16:49 Comment(1)
ILSpy is very good indeed, simple to use, open source and free.Skippie
S
1

I tried the JetBrains's DotPeek but the result wasn't sufficient enough, (there were some issues with "reference to a compiler-generated field") then I gave a next try to .NET Reflector 11.1 with a little bit better result, but still almost as DotPeek's efficiency. Last I tried Telerik's JustDecompile, with the overall best result.

I recommend the Telerik JustDecompile, if your're looking for a good decompiler, which can save a project file. It is also open source!

Sena answered 26/4, 2023 at 10:22 Comment(0)
G
1

If it's written in 'classic' Visual Basic and not compiled to p-code, you will need a decompiler.

I'm not aware of a VB-specific decompiler, but there is Ghidra, which will decompile native code to C. Ghidra was made available to the public in 2019, long after this question was originally posted.

Gable answered 24/8, 2023 at 0:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.