C # Assembly series 02, use NotePad to view the Il code of the executable assembly

Source: Internet
Author: User
Tags mscorlib

Continue to the previous article "C # Assembly series 01, write C # And il code in notepad, compile the Assembly with the DOS command, and run the program". There are already several assemblies in the as folder of the F disk. In this article, use NotePad to view the Il code of the executable assembly.

 

→ Open "vs2012 developer command prompt", enter the following command, and press ENTER

Add the 1.txt and 1. res files to the asfile folder.
For example, to open 1.txt


//  Microsoft (R) .NET Framework IL Disassembler.  Version 4.0.30319.18020


// Metadata version: v4.0.30319


.assembly extern mscorlib


{


 .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..


 .ver 4:0:0:0


}


.assembly extern MyClass


{


 .ver 0:0:0:0


}


.assembly MainClass


{


 .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )


 .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx


                                                                                                            63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )       // ceptionThrows.


 .hash algorithm 0x00008004


 .ver 0:0:0:0


}


.module MainClass.exe


// MVID: {73BA142E-F5C9-4C2E-8963-DB7213CB466A}


.imagebase 0x00400000


.file alignment 0x00000200


.stackreserve 0x00100000


.subsystem 0x0003       // WINDOWS_CUI


.corflags 0x00000001    //  ILONLY


// Image base: 0x00560000




// =============== CLASS MEMBERS DECLARATION ===================



.class private auto ansi beforefieldinit MainClass


      extends [mscorlib]System.Object


{


 .method private hidebysig static void  Main() cil managed


 {


   .entrypoint


// Code size 8 (0x8)


   .maxstack  8


   IL_0000:  nop


   IL_0001:  call       void [MyClass]MyClass::PrintSth()


   IL_0006:  nop


   IL_0007:  ret


 } // end of method MainClass::Main



 .method public hidebysig specialname rtspecialname


         instance void  .ctor() cil managed


 {


// Code size 7 (0x7)


   .maxstack  8


   IL_0000:  ldarg.0


   IL_0001:  call       instance void [mscorlib]System.Object::.ctor()


   IL_0006:  ret


 } // end of method MainClass::.ctor



} // end of class MainClass




// =============================================================



***********************


// Warning: the Win32 resource file 1.res is created.




Above,

○. Assembly extern mscorlib indicates that the. Net default Assembly mscorlib needs to be referenced during CLR running.
○. Assembly extern myclass, indicating that the custom Assembly myclass needs to be referenced during CLR operation
○. Assembly mainclass statement block, including the manifest list of the mainclass assembly
○. Module mainclass.exe, mainclassthis program set has a modulenamed mainclass.exe. Of course, an assembly can contain multiple modules

 


C # Assembly series 02, use NotePad to view the Il code of the executable assembly

Related Article

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.