Telerik blogs

Maybe you have heard the great news that the JustDecompile engine is now open-source and available on Github. The project is licensed under the Apache 2.0 license and you are free to contribute! If your commit is accepted, then your change could land in the official product. The only part that is not open source is the UI, which is shown here.

UI of JustDecompile

There are also a ton of open source plugins that are also available for you to explore.

A Guided Tour to Get Started

Download the .zip file from the Github repo and open the JustDecompileEngine.sln file in Visual Studio. Once you have done that, examine the project structure and set ConsoleRunner as your start-up project as shown below.

Visual Studio Solution Explorer

Upon first run, it will quickly open and close the Command Prompt. Simply add the last line in the snippet below to your App.cs to prevent it from closing:

GeneratorProjectInfo generatorProjectInfo = CommandLineManager.Parse(args);

CmdShell shell = new CmdShell();



Command Prompt

Now you can see what options the executable is expecting upon launch. The interesting thing here is that you have just witnessed the underlying engine of JustDecompile. If you were to navigate to the location that you installed JustDecompile, you can run the same command and see the same screen.

Running the Command Prompt from the Installation Directory

A Quick Change

Say that you wanted to make a quick change to the text that appears on the Command Prompt. Navigate to Tools->JustDecompileCmd->CommandLineManager.cs file and you'll see that this text is coming from a method called, "PrintHelpText". I've included a snippet below of the first two lines of the Command Prompt as shown earlier:



WriteLine("JustDecompile /target: /out: [/lang:] [/vs:] [/net4.0] [/net4.5]");

WriteLine("[/net4.5.1] [/net4.5.2] [/net4.6] [/nodoc] [/norename] [/nohex] [/?]");


You could change any of the text here or if you wanted to dive deeper, you could add or remove arguments that the decompiler is expecting - your options are limitless.

But so far, all we've taken a look at is the Command Line Tools - which is a great introduction into the underlying engine. There are also lots of goodies about how we determine which language you are using, Visual Studio version, etc in the Tools.MSBuildProjectBuilder project. I'd encourage you to go and check that out.

Let's take a look at the Decompiler

Copy over an assembly or application. If you don't have one readily available, then create a simple Console Application and add a few WriteLine and a ReadLine method. Compile the application and place it somewhere that is easy to access. I'm going to place mine in the C:\Temp folder and give it the name Test.exe.

Navigate to the App.cs file found in the ConsoleRunner project. Let's pass several arguments that a user would typically use and see what happens.

string[] testArgs = { @"/target:C:\\Temp\\Test.exe", @"/out", @"c:\\temp" };

GeneratorProjectInfo generatorProjectInfo = CommandLineManager.Parse(testArgs);

CmdShell shell = new CmdShell();


We've added a string array, named it testArgs and provided the path to our executable as well as where we would like the decompiled project to be located. Next, we pass the testArgs variable to the CommandLineManager.Parse method. Go ahead and put a breakpoint on shell.Run(generatorProjectInfo) and run it:

Code Decompiled

If you hover over generateProjectInfo, we can see that the application has detected our arguments as well as determined the Framework Version, Visual Studio Version and more. If we hit F11, we can begin stepping through the project and see a series of checks first, then output directory creation, and finally the code that begins to decompile the assembly or executable.

Code Being Decompiled

If you step through this code, then you can actually see the Visual Studio project creation. The final screen that is shown shows the results:

Console Window

If we look in our Temp Folder, we'll see a Visual Studio solution that contains our decompiled code. It is now ready to open with Visual Studio.

Folder Structure

Tip of the Iceberg

We stand behind our commitment to make JustDecompile free - forever. With this change, we want to allow anyone to understand code decompilation and contribute to the project, if they wish. If you're looking for more info, then I'd encourage you to check out the FAQs or leave feedback on the product. With your help, we can make JustDecompile even better!

About the Author

Michael Crump

is a Microsoft MVP, Pluralsight and MSDN author as well as an international speaker. He works at Telerik with a focus on everything mobile.  You can follow him on Twitter at @mbcrump or keep up with his various blogs by visiting his Telerik Blog or his Personal Blog.


Comments are disabled in preview mode.