I'm having a hard time trying to (Dis)assemble a dll using the Visual Studio command prompt, don't look that simple as I see in the microsoft page.
I'm using the ildasm for these way:
ildasm myLibrary.dll output:MyLibrary.il
And I get: Unable to open 'MyLibrary.il' for output.
I also tried the full path:
ildasm directory\myLibrary.dll output:directory\MyLibrary.il
And I get: MULTIPLE INPUT FILES SPECIFIED
Using the ildasm GUI actually works, but when I use the ilasm:
ilasm myLibrary.il /dll
I get: Could not open 'myLibrary.il', when I use the full path I get the same error.
What's wrong here?
To use the GUI, type ildasm at the command line without supplying the PEfilename argument or any options. From the File menu, you can navigate to the PE file that you want to load into Ildasm.exe. To save the metadata and disassembled code displayed for the selected PE, select the Dump command from the File menu.
You can use Ilasm.exe in conjunction with its companion tool, Ildasm.exe. Ildasm.exe takes a PE file that contains IL code and creates a text file suitable as input to Ilasm.exe. This is useful, for example, when compiling code in a programming language that does not support all the runtime metadata attributes.
ildasm.exe is installed with the Windows SDK tools, located in C:\Program Files (x86)\Microsoft SDKs\Windows\v10.
simple, let's take this line of code:
using System;
public class sample
{
static void Main(string[] args)
{
Console.WriteLine("Inside main ...");
}
}
Let us compile App.cs
to App.exe
. This executable now prints Inside main … when we run it.
Now let us attempt to change the output of this executable without touching its source files.
You run ildasm App.exe /out:App.il
to generate the IL code corresponding to the executable. You can now edit this il code in notepad and change the ldstr
from “Inside main …” to “Inside main changed …” as shown below:
IL_0000: nop
IL_0001: ldstr "Inside main ..."
IL_0006: call void [mscorlib]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ret
To
IL_0000: nop
IL_0001: ldstr "Inside main changed ..."
IL_0006: call void [mscorlib]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ret
Now let us rebuild the executable from this il file by running ilasm App.il.
This generates a new App.exe. If you run App.exe you will get the following output “Inside main changed …”
There are useful posts in social.msdn and in c-sharpcorner as well guiding through the use of ILDASM and ILASM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With