23

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.

Steven
  • 166,672
  • 24
  • 332
  • 435
user900492
  • 301
  • 2
  • 3
  • 5
  • As far as I'm aware there are easier ways to get hold of the dot net framework libraries source code. See this article by Scott Gu: http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx – Jamie Dixon Sep 12 '11 at 13:55
  • Are you trying to get the source code of the .Net Framework assemblies, or some other .Net dll? – Polyfun Sep 12 '11 at 14:06
  • 1
    Why do you want to do this? Why don't you have the source code? – Jeremy E Sep 12 '11 at 14:21
  • hi the code is combination of c# and middle level language it contains pointers and many address symbols like @@@ its giving the errors. i am trying to convert my private dll – user900492 Sep 13 '11 at 06:11
  • Similar question and some different solutions: [Modify Compiled .Net Exe](https://stackoverflow.com/q/18437031/772981) – Jarekczek Apr 09 '18 at 16:00

2 Answers2

10

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).

Jarekczek
  • 7,456
  • 3
  • 46
  • 66
8

I've had limited success in recompiling DLLs. A better way of going about it is to using Reflector and the Reflexil plugin. You need to have a bit better knowledge of the IL code that makes up .NET assemblies but Reflexil does a great job of describing the OP codes. I have a little walk through on my blog about how I used to modify the PowerShell Cmdlet Help Editor: http://csharpening.net/?p=348

Adam Driscoll
  • 9,395
  • 9
  • 61
  • 104