a blog for those who code

Monday 21 December 2015

Metadata Information of C# Executable File

In this post we will be discussing about metadata information of C# executable file (i.e. .exe). In our previous post Building Types into a Module using C# Compiler we have created an executable file (Example.exe), in this post we will discuss about what this exactly is. It is a managed Program Executable file.

It mainly has four parts : Program Executable Header, CLR Header, Metadata and IL. The Program Executable header is a standard information that windows expects. CLR Header contains information that is specific to modules which requires CLR. It contains information like major and minor version of CLR used to built module, module's entry point and a digital signature.

The metadata is a block of binary data that consists of several table categorized into definition tables, reference tables and manifest table. Some of the definition tables are ModuleDef, TypeDef, MethodDef, FieldDef, ParamDef, PropertyDef and EventDef. Some of the reference tables are AssemblyRef, ModuleRef, TypeRef and MemberRef. Some of the manifest tables are AssemblyDef, FileDef, ManifestResourceDef and ExportedTypesDef.

How to examine the metadata of Program Executable File

There are various tools which allow you ti examine the metadata within a managed Program Executable File. We will be using ILDasm.exe (IL Disassembler). To see the metadata tables we will execute the following command line :

ILDasm Example.exe

It will open up a window as shown below :


Press Ctrl + M to see it in a nice, human-readable form as shown below :


You do not have to fully understand it. The important thing is that you have a TypDefName as Example whose flags are Public, Class etc and it is derived from System.Object. Then you have a method name Main() with void return type and takes no argument.

You can check more about MetaInfo and Statistics in this GitHub Repository. Please Like and Share CodingDefined.com Blog, if you find it interesting and helpful.

No comments:

Post a Comment