-
If you really want to understand C # code, the best way to do that is by understanding the code generated by the C # compiler. This is the focus of this chapter and the following two chapters.
We will use a short C # program to uncover the mystery of IL and interpret the IL code generated by the compiler. In this way, we can "stone": first, we will reveal the mystery of
How to interpret IL code and IL codeHow to interpret IL code
For the IL code, I will unveil it in three ways. What is the IL code? Why should we read the IL code? How can we read the IL
1-
We use C #, VB. NET language will eventually be compiled into an assembly or IL. Therefore, code written with vb.net can be modified in C # and later used in COBOL. Therefore, it is very necessary to understand IL.
Once you are familiar with IL, there is no barrier to understanding. NET technology because all of the. NET languages are compiled to
IL interface and class attributes, IL interface attributes
In the previous article, I learned how to get started with IL. Next, I will use two examples to understand the attributes, constructor, and Interface Usage of the class.
I. class attributes and constructors
1. first take a look at the C # code of the class we want to build and then implement
Understanding IL code (2) and understanding il code
The most basic IL Code mentioned in the previous article should be relatively easy to understand. Therefore, with the foundation of the previous article, this article will be explained in depth.
First, I must introduce some important concepts:
Evaluation Stack: This is caused. net clr automatically manages the m
Read the IL code (4) and read the il code
This is the last article in The IL series, mainly about Process Control in IL. I believe that the above three articles show that the IL code is not a big problem. Okay. If you don't talk much about it, just give it a simple explanati
When I got back to the computer, everyone else went to the Black shop. I did not catch up.What are the other things I'm bored?
Recently, I want to write something to listen to events. After reflecting eventinfo, I need a dynamic constructor,An Opcodes parameter is required. A query of help actually represents a stuff of Il.
Very depressing. So I can see if I can understand it.
Start with the simplest one. This is because the tutorial offered by
Recommended stack and lightning Owin in IL, and IL lightning Owin
In recent days, I had the honor to get guidance from lightning and learn about some commands in EMIT and IL. Although there is a saying that an anti-aircraft gun is used to fight mosquitoes, I believe that 80% of the "20% law" can be used to solve the problem, and 20% of the functions can only be
Ildecompilator --ildasm.exeand reflector.exe:
I. Introduction to ildasm.exe
This is a soft vstool, which has been described in detail in the article "ildasm.exe -- il decompilation utility;
Ii. reflector.exe
So far (10.02.03), the latest version downloaded from the http://www.aisto.com/roeder/dotnet is latest version: 5.1.6.0, here also the classic "Hello world. "Example: When reflector is used. when ext opens an executable file, the ma
The example in study Note 1 can be changed to the following: The function remains unchanged, but the resources occupied during running are smaller. I am in all and Note 1
Code Note the location of the change as follows:
1
//
----------- Program Header
2
. Assembly
Extern
Mscorlib
{}
3
. Assembly oddoreven
{}
4
. Module oddoreven.exe
5
//
----------- Class declaration
6
.
Namespace
Odd. or
{ 7 . Class Public Auto ANSI ev
) {
int i=1;
int j=2;
int k=3;
int answer = I+J+K;
Console.WriteLine ("i+j+k=" +answer);
}
}
After compiling this source code, you can get an EXE program. We can go through ILDASM. EXE (figure 0) to reverse-compile the exe to observe the IL. I set the Il decompile column of Main () as follows, there are 18 il directives, some directives (such
We created an interface III, which has only one function named PQR. Then, the class YYY implements Interface III, but does not implement the function PQR, but instead adds a function called ABC. In the entry point function Vijay, the function PQR is called by Interface III.
We did not get any errors because of the existence of the override directive. This instruction notifies the compiler to redirect any calls to the function PQR of interface III and to the function ABC of the class yyy. The co
-1-
Code written in C # and VB. NET will eventually be compiled into an assembly or IL. Therefore, the code written in VB. NET can be modified in C # And then used in Cobol. Therefore, it is necessary to understand Il.
Once you are familiar with IL, there will be no obstacle to understanding. NET technology, because all. NET languages will compile into
not be aligned with the natural size of the immediately ldind, stind, ldfld, stfld, ldobj, stobj, initblk, or cpblk directives.
Unbox
Converts the boxed representation of a value type to its unboxed form.
Unbox.any
Converts the boxed representation of a specified type in an instruction to an unboxed form.
Volatile
Specifies that the address currently on top of the evaluation stack can be volatile, and that the result of reading that locat
· Il Code Analysis Method
· Il Command Parsing
·. Net learning methodology
1. Introduction
Since the beginning of the "You must know. Net" series, anytao has received a lot of attention and support from everyone, providing great encouragement and motivation. In the past, I found that many garden friends focused on understanding the issue of IL code. For me, this
A prefaceThank you @ Ice Lin Light Wu pointed out the error of the article, has now been correctedFor the IL code does not understand the total feeling is magical, the first day to see completely unintelligible, only listen to the experts said, understand the IL code you can more clearly know how your code is running mutual calls, this is an unknown feeling.Then began to contact
[24th back: Understanding metadata and IL (I)], we have made necessary preparations for the relationship between these concepts and metadata and IL in PE files, assembly, and hosting modules, at the same time, I am familiar with the basic method cognition of decompilation with ildasm tool. Next I will learn about metadata and IL. Let's continue.
I have been talki
Ildasm.exe summary:
I.Preface:
Microsoft's il DecompilationProgram--Ildasm.exe, which extracts il from executable files (ex, exe executable files of the classic console Hello World)CodeAnd provides the namespace and Class View. Before describing how to decompile, it is necessary to look at CLR from the perspective of virtual CPU, which helps you first understand the code execution process from the fr
For deep copies, the usual approach is to serialize the object and then deserialize it into another object. For example, there is a workaround on StackOverflow: https://stackoverflow.com/questions/78536/deep-cloning-objects/78612#78612. This serialized way, for deep copies, is undoubtedly a performance killer.Today we introduce a deep copy of the framework deepcopy, GitHub address: Https://github.com/ReubenBond/DeepCopy, which was adapted from the Orleans Framework, The implementation logic is v
View C # Through IL #
Opening
Address: http://www.cnblogs.com/AndersLiu/archive/2008/11/03/csharp-via-il.html
Author: Anders Liu
Abstract: This is a series of articles that introduce the representation of various language structures in C # after being translated into IL by the compiler, and analyze the principle from the perspective of IL.Origin
Lao Liu is a real fan of. NET technology. However, I have been
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.