Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I decompile a batch of .NET DLLs into a Visual Studio project [closed]

I just need to search for bits of text in my C# code.

I already have .NET Reflector and the File Disassembler Add-In, but these just seem to decompile one DLL.

like image 816
John Assymptoth Avatar asked Apr 20 '12 08:04

John Assymptoth


People also ask

How do I decompile DLL in Visual Studio?

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.

Can dlls be decompiled?

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.

Can Visual Studio code open DLL files?

Using Visual Studio, you may edit the code to run the functions that you want. You can also use Visual Studio to read the DLL file without editing the code.

Is it possible to decompile C#?

You can now use Visual Studio to decompile managed code even if you don't have the symbols, allowing you to look at code, inspect variables and set breakpoints.


1 Answers

Actually, none of these answers are right.

Yeah, all the tools can decompile *.dll files into *.csproj file but none of them supports CLI or batch processing. You can save yourself the time with installations.

The best possible solution so far is use dotPeek, put all *.dll files into one folder and use Explore Folder option.

Explore Folder in dotPeek

dotPeek will analyse the given folder and shows a tree of DLLs located inside the folder. You can generate csproj manually for every single dll which is loaded.

DLL tree


If you came across this post because you are looking answer how locate specific instruction in your or 3rd party dlls, specially a use of reflection, you can use this PowerShell script to decompile dlls into IL and look for the instruction (System.Reflection.Assembly::Load(string) for reflection).

Note

It is using Intermediate Language DisASseMbler (ILDASM) from .NET Framework SDK kit. Adjust the path accordingly to your version of SDK.

function Get-LibDump
{
    Param(
# Specifies a path to one or more locations. Wildcards are permitted.
    [Parameter(Mandatory=$true,
            Position=0,
            ParameterSetName="Basic",
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true,
            HelpMessage="Path to one or more locations.")]
    [ValidateNotNullOrEmpty()]
    [SupportsWildcards()]
    [ValidateScript({$_ | Test-Path})]
    [System.IO.FileInfo]
    $Path
    )
    process
    {
        $dumpFileFilePath = $Path.BaseName + '.il'
        $outFile = "C:\LibDump\$dumpFileFilePath"
        Start-Process -FilePath 'c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\ildasm.exe' -ArgumentList "/UNICODE /OUT=`"$outFile`" `"$($Path.FullName)`"" -Wait
        "Dump from:`n$(Resolve-Path -Path $Path.FullName -Relative)" | Out-File -FilePath $outFile -Encoding:unicode -Append
    }
}

# Use
Get-ChildItem -Path $PathToLibFolder -Filter '*.dll' -File -Recurse | Get-LibDump
like image 128
KUTlime Avatar answered Sep 17 '22 15:09

KUTlime