[You must know. NET] The 24th time: Understanding metadata and IL (ON)

Source: Internet
Author: User

Say, before the opening,

Very early to say metadata (metadata) and IL (intermediate language) ideas, has been in this beginning to be counted on the ground to these two class brothers cast some fine care, although there is no "first time: enmity: IS and as" so fast, But metadata and IL are absolutely heavyweight content that deserves our attention at any time, and this is the beginning.

1 Introduction

Have you ever thought about what our C # code is after compiling? Have you ever known what the trajectory of our executable program is when we run it? So, this paper begins with the understanding of metadata (metadata) and Il (Intermediate Language, intermediate language) to give the answer gradually. On this path of discovery, metadata, IL, assemblies, program fields, JIT, virtual dispatch, Method table, and managed heap these various mystery guests will encounter at some point, as you must know. NET As part of the Series 2.0, this article starts with the two heavyweight players who know the metadata and IL, and the other guests will soon be on the stage.

2 Initial Contact

In fact, the compiled CS code is organized into two basic elements: Meta data (Metadata) and IL. The simplest way to understand the secrets of metadata and IL contained in an assembly (*.dll) or executable (*.exe) is that we often say decompile, open the ILDASM, and load the assembly where the implementation is prepared, and we can see the contents of the managed PE file:

Detailed structure information and IL Code Analysis can be found in [you must know. NET] in the 3rd chapter, "Everything Starts with Il" Introduction, this does not do too much analysis. In addition, we can perform "view/metainfo/show!" or ctrl+m shortcut keys to get a list of the metadata information used by the assembly:

The metadata used by the assembly is mainly: Module, TypeRef, TypeDef, method, Param, MemberRef, Costomattribute, Assembly, AssemblyRef, etc. Strings, #GUID, #Blob, #US堆等.

Of course, there are a lot of fun ways to use the ILDASM tool to satisfy our curiosity to explore IL code, for example:

ILDASM anytao.insidenet.metadatail.exe/output:my.il, export the decompile result to the IL code format, generating a my.il containing all the IL code and a my.res containing all the resource files.

ILDASM Anytao.insidenet.metadatail.exe/text, outputs the decompile result as a console.

Of course, we recommend the GUI form to view the IL details, well-organized Class View:

ILDASM Anytao.Insidenet.MetadataIL.exe

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.