《. NET Quest: MSIL authoritative Guide to reading notes

Source: Internet
Author: User
Tags mscorlib

1th Chapter Simple Example (pages 2nd to 20th)

3rd page, the 4th natural segment IL code is "managed" by the CLR. CLR hosting includes at least three main activities: type control, structured exception handling , and garbage collection. type control involves validation and conversion of item types during execution. Managed exception handling is functionally similar to "unmanaged" structured exception handling, but it is performed by the CLR and not by the operating system. garbage collection involves automatic identification and deallocation of objects that are no longer in use.

The red " structured exception handling " in the preceding paragraph should be "managed exception handling." (Please refer to the comments on the 2 floor after I have finished "14th chapter managed Exception Handling")

11th page, 1th natural Section

The type of the calling convention, return type, and method parameter that defines the signature of the METHODDEF.

It seems that the "method name" should be added to form the METHODDEF signature. (See comments on the 2 floor)

11th page, 5th natural section

For example, locale init (int Retval, String tempstr).

This should be: for example locals init (Int32 Retval, String tempstr).

Pages 12th, 14, 15

Odd.or.Even::Check

The check above should be check.

16th page, the 1th Natural section of the penultimate

Obviously, any data can be represented verbatim as ByteArray. For example, instead of using quoted strings in ldstr "Enter a number" , use the ByteArray representation of the string.

The "Enter a number" in the above paragraph should be "odd!".

17th page, the 1th Natural section of the penultimate

The attribute PinvokeImpl ("Msvcrt.dll" cdecl) indicates that this is an unmanaged method that is called using a mechanism called P/inKOke (Platform invocation, platform invoke). This feature also indicates that this method resides in an unmanaged MsbCrt.dll and has a calling convention of Cdecl. This calling convention means that the unmanaged method handles the arguments in the same way as the ANSI C function.

The p/in k oke inthe above paragraph should be p/invoke (there are three more places on page 18th), and Msbcrt.dll should be msvcrt.dll.

2nd Chapter Code Enhancements (pages 21st to 28th)

21st page, the penultimate 1th natural section Let's take a look at this simple example of a slight modification (source file simple.il ), as shown in Listing 2-1. At the moment, the part I'm interested in is the part of the change. I use annotations on where to change change! have been labeled.

The simple.il in the above paragraph should be simple1.il.

22nd page, the last part of the Code //-----------Call the unmanaged method
. Method public static PinvokeImpl ("Msvcrt.dll" cdecl)
vararg int32 sscanf ( string, string) cil managed {}

The last line should be followed by// change! .

23rd page, 5th natural Section my colleague compiles the original program written with Visual C # . NET and Visual Basic.NET in order to find a special method for automated test program generation and makes the resulting executable decompile, then insert the ILASM section that is specific to the test and recompile the modified code to become the new executable ,

The above Visual C #. NET should be Visual C # (the first row of page 24th has another Place ), "decompile" should be "disassembly", "recompile" should be "reassembly", and the last comma should be changed to a full stop.

23rd page, 6th Natural paragraph Note Another change in the example is that the instruction Ldc.i4 1 is replaced by ldc.i4.1. The logic here is the same as using ldloc Retval instead of ldloc.0 , in other words, using a shortcut opcode to avoid using a 4-byte integer argument.

The above " using ldloc Retval instead of ldloc.0" should be "directive Lodloc Retval replaced by ldloc.0".

the 3rd chapter makes the code more simple (pages 29th to 35th)

on page 30th, the 1th natural segment is behind the program header, and I define the class [mscorlib]System.Console 's alias and its method WriteLine (string).

It should be: just behind the program header, I define the alias of the class [mscorlib]System.Console and its method WriteLine (string).

33rd, the 1th natural segment -#include "myheaderfile.il": effectively inserts the contents of the myheader.dl file into the current location.

The above myheader.dl should be myheaderfile.il.

34th page, lower keyword. This represents the current class ( just like the c++/c# keyword this, not an instance of the current class ). This keyword can cause compilation errors when used outside the scope of the class. In this example, the following code is not correct :

The red character of the front parenthesis should be: instead of representing the current instance of the class as in c++/c#, the following " is wrong " should be deleted.

Copyright NOTICE: This article for Bo Master http://www.zuiniusn.com original article, without Bo Master permission not reproduced.

《. NET Quest: MSIL authoritative Guide to reading notes

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.