How to decompile dll

How to decompile dll

Decompiling code (language independent) [closed]

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

10 Answers 10

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

If it’s an unmanaged DLL (native), you’re out of luck. The best you can do is load a disassembler. Which leads you nearly nowhere unless you know exactly where you want to go.

It’s not possible(1) to decompile object code to source code. Inspecting an interface is another matter altogether; there are tools that exist but I don’t know of any offhand.

The only readable code you’ll get is assembly language (there are many programs for this). There are some languages that can be decompiled to original (or close to) source code, such as Visual Basic 3. But who writes programs in VB3 nowadays? Nobody. As far as seeing the imports/exports of the DLL, you can use the Dependency walker program from: http://www.dependencywalker.com/

For some languages, for example Visual Basic or C#, you can get readable source-code if you use a good decompiler and the code is not obfuscated (which it most of the time isn’t)

Decompilation of C# code made easy with Visual Studio

We have recently released a new decompilation and symbol creation experience in the latest preview of Visual Studio 2019 version 16.5 that will aid debugging in situations where you might be missing symbol files or source code. As we launch this feature, we want to ensure that we are creating the most intuitive workflows so please provide feedback.

Decompilation and PDB generation with ILSpy

Decompilation is the process used to produce source code from compiled code. In order to accomplish this we are partnering with ILSpy, a popular open source project, which provides first class, cross platform symbol generation and decompliation. Our engineering team is working to integrate ILSpy technology into valuable debugging scenarios.

What are symbol files? Why do you need them?

Debuggers are able to use the information in the symbol file to determine the source file and line number that should be displayed, and the location in the executable to stop at when you set a breakpoint. Debugging without a symbol file would make it difficult to set breakpoints on a specific line of code or even step through code.

By integrating decompilation directly into your debugging experiences we hope to provide developers with the most direct route to troubleshooting issues in 3 rd party managed code. We are initially integrating the decompilation experiences into the Module Window, No Symbols Loaded, and Source Not Found page.

No Symbols Loaded/Source Not Found

There are a several ways in which Visual Studio will try to step into code for which it does not have symbols or source files available:

Under these circumstances, the debugger displays the No Symbols Loaded or Source Not Found page and provides an opportunity to load the necessary symbols or source.

In the following example I have opened a crash dump in Visual Studio and have hit an exception in framework code. I do not have the original source code so If I try to switch to the main thread, I see the No Symbols Loaded page. However, it is now possible to decompile the code directly on this page and see the origins of the exception.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Module Window

During debugging the Modules window is a great place to get information related to the assemblies and executables currently in memory. To open the Modules window, select Debug > Windows > Modules.

Once you have identified a module that requires decompilation, you can right-click on the module and select “Decompile Source to Symbol File”. This action creates a symbol file containing decompiled source which in turn permits you to step into 3 rd party code directly from your source code.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Some Considerations

Try it now!

Download the preview and try out decompilation and let us how it works for you! Please reach out and give us feedback over at Developer Community. Finally, we also have a survey for collecting feedback on the new experiences here. We look forward to hearing from you.

How to decompile dll

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Answered by:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Question

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

I have a DLL file which I would like to decompile in order to edit the source code. Does anyone have any idea of how I come go about doing this?

I don not have the original solution (The person who wrote it has left the company)

Answers

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Reply if success,

Thanks & Good luck!

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Thanks for the post,

Reply if success.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

All replies

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Thanks for the post,

Reply if success.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Reply if success,

Thanks & Good luck!

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Thanks a mill. The above was a GREAT Success. 🙂

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Does anyone know if this is because the plugin is not compatible with the beta? Or is it that the plugin does not even work with their newest version, version 7 because when this thread was created I believe they were not using version 7.

Thanks for any help on this

Something else I am wondering:

Seems there is actual error output:

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. (ReflectionTypeLoadException)

LoaderExceptions:
Could not load file or assembly ‘Reflector, Version=5.0.0.0, Culture=neutral, PublicKeyToken=18ca6bb8dd6a03c3’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (FileLoadException)

That error message repeats 7 more times.

couple of hours of searching I found free stable version 6.5

I downloaded it and tried to use the plugin. Seems to be working. I think the problem might be the fact that version 7 is in beta. Hopefully the problem doesn’t exist in final production of version 7.

Generate source code

When you’re debugging and no source code is available, Visual Studio shows the Source Not Found document, or if you don’t have symbols for the assembly, the No Symbols Loaded document. Both documents have a Decompile source code option that generates C# code for the current location. The generated C# code can then be used just like any other source code. You can view the code, inspect variables, set breakpoints, and so on.

No symbols loaded

The following illustration shows the No Symbols Loaded message.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Source not found

The following illustration shows the Source Not Found message.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Generate and embed sources for an assembly

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Extract and view the embedded source code

You can extract source files that are embedded in a symbol file using the Extract Source Code command in the context menu of the Modules window.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

The extracted source files are added to the solution as miscellaneous files. The miscellaneous files feature is off by default in Visual Studio. You can enable this feature from the Tools > Options > Environment > Documents > Show Miscellaneous files in Solution Explorer checkbox. Without enabling this feature, you won’t be able to open the extracted source code.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Extracted source files appear in the miscellaneous files in Solution Explorer.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

SourceLink

Known limitations

Requires break mode

Generating source code using decompilation is only possible when the debugger is in break mode and the application is paused. For example, Visual Studio enters break mode when it hits a breakpoint or an exception. You can easily trigger Visual Studio to break the next time your code runs by using the Break All command (How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll).

Decompilation limitations

Debug optimized or release assemblies

When debugging code that was decompiled from an assembly that was compiled using compiler optimizations, you may come across the following issues:

Decompilation reliability

A relatively small percentage of decompilation attempts may result in failure. This is due to a sequence point null-reference error in ILSpy. We have mitigated the failure by catching these issues and gracefully failing the decompilation attempt.

Limitations with async code

The results from decompiling modules with async/await code patterns may be incomplete or fail entirely. The ILSpy implementation of async/await and yield state-machines is only partially implemented.

More details can be found in the GitHub issue: PDB Generator Status.

Just My Code

The Just My Code (JMC) settings allows Visual Studio to step over system, framework, library, and other non-user calls. During a debugging session, the Modules window shows which code modules the debugger is treating as My Code (user code).

Decompilation of optimized or release modules produces non-user code. If the debugger breaks in your decompiled non-user code, for example, the No Source window appears. To disable Just My Code, navigate to Tools > Options (or Debug > Options) > Debugging > General, and then deselect Enable Just My Code.

Extracted sources

Source code extracted from an assembly has the following limitations:

Generated code is C# only

Decompilation only generates source code files in C#. There is no option to generate files in any other language.

Disclaimer: This article is for educational and training orientation, we are not responsible for the misuse of the techniques and explanations mentioned in this article and/or the use of the tools mentioned/provided, also we do not assume responsibility for the actions carried out with the information of the same. Please use this information for ethical purposes.

All tools and decompilers mentioned are our own recommendations, nothing sponsored.

One day at lunch I told them what we were doing and they didn’t understand anything, it turns out that they had no idea what decompilation is, they didn’t know that with a simple tool they could see, copy or modify their development.

Not in all cases you should worry, but for some of them the core of the business is the development itself and obviously it was not very funny.

In this article I am going to show basic notions about decompilation and reverse engineering, if you are interested in something more complex, do not hesitate to ask us!

You might know that C# is a high level programming language and it uses a combination of static and JIT compilation. This means that the code is compiled down to bytecode.

Decompilation is the reverse of compilation (I’m going to patent this great explanation).

That is, the COMPILATION is basically:

The process will be something like this:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

And is it simple?🙄

I’d say it’s easier than compiling, but let’s see how it’s done.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

To do this, all we have to do is drag it to DnSpy:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Once loaded, the original source code will be shown and we can work on it, we can analyze it, modify it, debug it, etc.

Once our application is decompiled, we can navigate through the source code as if it were our own project:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

This will be useful to understand how it works or to obtain some values in memory.

For example, let’s put a breakpoint before doing a subtraction:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

and then we will run the application:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Here is a simple example:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

This is a function that can be very useful at times, but it can also be dangerous ⚡.

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

We can also do it using IL code, but if we do not know it it will be much more complex.

We change that simple text:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

and we compile again:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Now to save our modified application, we will give:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

We will select the name of the file, its path and we will mark the following options:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

and we will have our modified application:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Ok, these are simple and unimportant examples, I leave to your imagination 💭 everything that could be done with these simple tools.

Decompiling a Blazor Web Application

Now we have created a sample web application with Blazor, this is the application code in visual studio:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Basically it is an application that shows the weather and we have added Dotnetsafer in the middle so that we can see it later in the decompiled application, here is the web application:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Ok, let’s get the code again.

Here will be the file that contains the code of our web application:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Well, we download it and open it again with DnSpy:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Once we have the decompiled file we can do everything that I mentioned in the previous point.

Decompiling a Xamarin Mobile Application

We raised the level of difficulty a little 🧨, but the operation is still the same.

The first thing we will do is unzip the APK, there are tools for this, but it is not necessary, for something so simple we can use winrar, (yes, the program that never expires 🆓):

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

and we will copy all the files in a folder:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Here comes the interesting thing, these files have lz4 compression, which will give us an error if we try to decompile it with DnSpy:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Yes, this sounds very complex, and it seems that you must be an expert:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

But it really is something very simple that we will do in less than a minute.

If you don’t have Python on your machine, install it previously.

Once we have Python (I run it from the VSCode terminal) we proceed:

Install lz4:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Use of the decompression script

The author of this script is Christian Reitter, X41 D-Sec GmbH, thank you for your article at X41 D-Sec GmbH, we have modified it to unzip all the files in the directory.

Decompress the files we need

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

In this case I am only interested in the two files corresponding to my application.

What has not been so difficult?

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Now we have the files ready to open with the DnSpy dll decompiler:

How to decompile dll. Смотреть фото How to decompile dll. Смотреть картинку How to decompile dll. Картинка про How to decompile dll. Фото How to decompile dll

Now again we can do everything I mentioned earlier, the procedure is always the same, only the way in which the files are compiled varies.

Did you like this article?

It has been very simple but I consider it fine for a basic level and learn a little about these topics 😊.

If you have found it interesting, do not hesitate to support it, and tell us below 👇 if you want to know something else, like let’s talk about cracking, injection and other aspects.

Also, if you want to learn more about decompiling and reverse engineering I would recommend you to look for reverse engineering forums (yes, there are such forums).

You have an online C# decompiler at https://decompiler.dotnetsafer.com so that you can comfortably do all the tests in this article without having to download any program.

Thank you for your attention, we hope you have learned a lot!

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *