Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net-core: Equivalent of ILDASM / ILASM

Is there the equivalent of ILDASM / ILASM for the .net-core?

Specifically, I'm looking for something that runs on Linux (Hence why the .net-core).

like image 819
Doug Avatar asked Oct 11 '16 14:10

Doug


People also ask

What is Ilasm in C#?

In this article, I am going to discuss Intermediate Language (ILDASM & ILASM) Code in C# with Examples. Please read our previous article, where we discussed the . NET Program Execution Process Flow in detail. ILDASM stands for Intermediate Language disassembler and ILASM stands for Intermediate language assembler.

What does Ilasm exe do?

The IL Assembler helps tool vendors design and implement IL generators. Using Ilasm.exe, tool and compiler developers can concentrate on IL and metadata generation without being concerned with emitting IL in the PE file format.

Where can I find Ildasm exe?

I've found online that ildasm.exe is supposed to be located at C:\Program Files (x86)\Microsoft SDKs\Windows\v10. 0A\bin\NETFX 4.6.


2 Answers

Both the ildasm and ilasm tools are built with CoreCLR from this repo: https://github.com/dotnet/coreclr. They include similar functionality as the versions shipped with Windows (sans GUI, etc.).

There are nuget packages shipped that include them as well (https://www.nuget.org/packages?q=ildasm), but they are platform-specific and also require a matching version of CoreCLR to use, so they are not straightforward to consume via nuget. The easiest way to run these on your platform is to just build them from source from the coreclr repo.

like image 61
Eric Mellino Avatar answered Oct 15 '22 00:10

Eric Mellino


It does not appear there is a native Microsoft tool that serves these functions on Linux and it is not currently built into the dot-net-core.

However, Mono allows the assembly and disassembly of IL code:

Installation Instructions can be found here.

What you are looking for is:

ilasm - For assembling
monodis - For disassembling

These are found in the package mono-utils:

e.g. On Debian 8 I did the following:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian jessie" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
apt-get install mono-devel mono-utils

However, FYI, for those trying to create exports, Mono does not appear to handle the x64 export syntax.

like image 24
Doug Avatar answered Oct 14 '22 22:10

Doug