The Common Intermediate Language (CIL) Disassembler is a companion tool to the CIL Assembler. The CIL Disassembler takes a portable executable (PE) file that contains CIL code and creates a text file suitable as input to Ilasm.
The Shared Source CLI (SSCLI) version of The CIL Disassembler does not have a GUI and outputs only to the console or a file.
The application file for the CIL disassembler is named ildasm.exe in the Shared Source CLI (SSCLI) on Microsoft® Windows®.
Because the SSCLI implementation of CIL Disassembler is console-only, the following features in the .NET Framework Microsoft Intermediate Language Disassembler implementation are not supported in the SSCLI:
ildasm [options] [PEfilename] [options]
The following options are available for working with .exe and .dll files that contain CIL.
Options can be specified using either a dash (-) or a slash (/).
Option | Description | |
---|---|---|
/all | Specifies a combination of the /header, /bytes, and /tokens options. | |
/bytes | Shows actual bytes, in hexadecimal format, as instruction comments. | |
/classlist | Includes a list of classes defined in the module. | |
/header | Includes file header information in the output. | |
/item:class[.method [(sig)]] | Disassembles the following depending on the argument supplied:
|
|
/linenum | Includes references to original source lines. | |
/metadata[=specifier] | Shows metadata. This is commonly used with the
/noil option to view a text dump of the assembly metadata. Specifier can be: |
|
mdheader | Shows metadata header information and sizes. | |
hex | Shows more things in hexadecimal as well as words. | |
csv | Shows the header sizes in Comma Separated format. | |
unrex | Shows unresolved externals. | |
schema | Shows the metadata schema information. | |
raw | Shows the raw metadata tables. | |
heaps | Shows the raw heaps. | |
validate | Validate the consistency of the metadata. | |
/noil | Suppresses CIL assembly code output. | |
/output:filename | Creates an output file with the specified filename | |
/pretty | Pretty-prints CIL as pseudo-C code in comments | |
/pubonly | Disassembles only public types and members. Equivalent to /visibility:PUB. | |
/quoteallnames | Includes all names in single quotes. | |
/raweh | Shows exception handling clauses in raw form. | |
/stats | Includes statistics on the image. | |
/source | Shows original source lines as comments. | |
/tokens | Shows metadata tokens of classes and members. | |
/unicode | Uses Unicode encoding for the output. | |
/utf8 | Uses UTF-8 encoding for the output. ANSI is the default. | |
/visibility:vis [+vis ...] | Disassembles only types or members with the specified visibility.
The following are valid values for vis. |
|
PUB | Public | |
PRI | Private | |
FAM | Family | |
ASM | Assembly | |
FAA | Family and Assembly | |
FOA | Family or Assembly | |
PSC | Private Scope | |
/? | Displays the command syntax and options for the tool. |
Note All options for the CIL Disassembler are case-insensitive and recognized by the first three letters. For example, /quo is equivalent to /quoteallnames. Options that specify arguments accept either a colon (:) or an equal sign (=) as the separator between the option and the argument. For example, /output:filename is equivalent to /output=filename.
The text file produced by the CIL Disassembler can be used as input to the CIL Assembler. This is useful, for example, when compiling code in a programming language that does not support all the runtime metadata attributes. After compiling the code and running its output through Ildasm.exe, the resulting CIL text file can be hand-edited to add the missing attributes. You can then run this text file through the CIL Assembler to produce a final executable file.
Note: Currently, you cannot use this technique with PE files that contain embedded native code (for example, PE files produced by Microsoft® Visual C++® .NET).
If you provide Ildasm.exe with a PEfilename argument that contains embedded resources, the tool produces multiple output files: a text file that contains CIL code and, for each embedded managed resource, a .resources file produced using the resource's name from metadata.
In the SSCLI implementation, if an unmanaged resource is embedded in PEfilename, a .res file is produced using the filename specified for CIL output by the /output option.
Note: The CIL Disassembler shows only metadata descriptions for .obj and .lib input files. CIL code for these file types is not disassembled.
You can run Ildasm.exe over an.exe or .dll file to determine whether the file is managed. If the file is not managed, the tool displays a message stating that the file has no valid common language runtime header and cannot be disassembled. If the file is managed, the tool runs successfully.
The following command causes the metadata and disassembled code for the PE file MyHello.exe
to display in he CIL Disassembler default GUI.
ildasm myHello.exe
The following command disassembles the file MyFile.exe
and stores the resulting
CIL Assembler text in the file MyFile.il
.
ildasm MyFile.exe /output:MyFile.il
The following command disassembles the file MyFile.exe
and displays the resulting
CIL Assembler text to the console window.
ildasm MyFile.exe /text
If the file MyApp.exe
contains embedded managed and unmanaged resources, the following command produces four files: MyApp.il
, MyApp.res
, Icons.resources,
and Message.resources
.
ildasm MyApp.exe /output:MyApp.il
The following command disassembles the method MyMethod
within the class MyClass
in MyFile.exe
and displays the output to the console window.
ildasm /item:MyClass::MyMethod MyFile.exe /text
In the previous example, there could be several MyMethod
methods with different signatures. The following command disassembles the method MyMethod
with the return type of void and the parameters
int32 and System.String.
ildasm /item:"MyClass::MyMethod(void(int32,class System.String))" MyFile.exe /text
Tools Index | CIL Assembler (ilasm.exe)
Copyright (c) 2006 Microsoft Corporation. All rights reserved.