Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet dll decompile and change the code

Tags:

I need to change the code of the .NET DLL. I am able to see the code by compilable the DLL with .NET reflector, but I am not able to change the code of the DLL. With .NET Reflector, I decompile the code and saved in to my hard disk, but when i am able to recompile the code its giving errors.

Few code is decompiled in binary format few code is decompiled with c#. Is there any tool to change and recompile the DLL?

Here are the tools I used for trying to decompile the DLL:

  • ILSpy
  • DisSharp
  • Reflector7.1 With the Reflexil plugin
  • Spices.Net.Suite.5.8
  • Deploy .NET 1.0.0
  • devextras.codereflect
  • dotPeek-1.0.0.2545
  • intellilock
  • JustDecompile_BETA_2011.1.728.1

Unfortunately, none of the tools giving perfect source code to recompile the DLL code.

like image 495
user900492 Avatar asked Sep 12 '11 13:09

user900492


People also ask

How do I decompile a DLL file to get source code back?

Press Ctrl + O and select your DLL File. Dll will be shown in left pane. Right click on Dll and select Export Source Code.

Can you edit code in dotPeek?

However, dotPeek can't be used to edit disassembled code. This feature could be implemented in future. You can watch and/or vote for the corresponding feature request: In-place assembly editing: http://youtrack.jetbrains.com/issue/DOTP-533.

Is it possible to decompile DLL?

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. Then, as stated, if it's Visual Basic, research p-code decompilers.

How do I decompile a DLL in Visual Studio code?

To do this, go to the Modules window and from the context menu of a . NET assembly, and then select the Decompile source code command. Visual Studio generates a symbol file for the assembly and then embeds the source into the symbol file. In a later step, you can extract the embedded source code.


1 Answers

The following code is working:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\ildasm.exe" original.dll /out=code.asm echo Here changes to code.asm should be done. C:\Windows\Microsoft.NET\Framework\v4.0.30319\ilasm.exe /dll code.asm 

So if the change in code is to be small, it's doable by making the changes in assembly code directly. One can compile and disassemble simple methods to see how the assembly code should look like. Putting additional methods inside the assembly file should not be too hard too.

Of course code analyzis should be done using ilspy-like tools, displaying the source code rather than assembly code.

Tools employed here come from Windows SDK (ildasm) and from .net framework (ilasm).

like image 151
Jarekczek Avatar answered Sep 17 '22 16:09

Jarekczek