Several fundamental concepts about .net framework (from cracker’s view)
Recently I’m reading Essential .NET, cause I want to get some common view about .NET framework after I had doing some reversing work on it. This book mainly focus on program design, but the author describe his opinions from very fundamental aspects. So by reading this book, as a crack fan, I hope I can know something new and make clear some confusion in my head. Following notes come out after I read first 2 chapters, some of which are directly refrenced from original book, and some other are my summary.
Assembly: An assembly is a logical collection of one or more modules. Assemblies are logical constructs and are referenced by location-independent names that must be translated to physical paths either in the file system or on the Internet. Those physical paths ultimately point to one or more modules that contain the type definitions, code, and resources that make up the assembly.
For example, mscorlib is assembly, with no ext.
Module: A CLR module is a byte stream, typically stored as a file of the local file system or on a Web server. In contrast to assembly, module is physical and assembly is logic concept.
Take a view of the cmd line of compiler will make this clear.
Csc.exe /t:module md.cs
(create md.netmodule file, which is a module without any manifest info.)
Csc.exe /t:library /addmodule:md.netmodule lib.cs
(explain using a equation: lib.dll+md.netmodule->lib.dll assembly)
Csc.exe /r:lib.dll main.cs
(create main.exe assembly. main.exe reference lib.dll assembly, which contain two modules: md and lib.)
Type: Type is the atom element in .NET framework, you can see that form naming of CTS(Common Type System). Classes, structs, enums, etc are all types. Three fundamental kinds of type members: fields, methods, and nested types. All other type members (e.g., properties, events) are simply methods that have been augmented with additional metadata. At least description here can make you clear about what that lot’s metadata tables in .NET PE files mean.
Interface: Why I get interested in interface is when I’m reading src code of mdbg sample. This sample demonstrate how to write debugger using managed code. There are lot’s of reference to debug interface in the src(ICorDebug, ICorDebugAppdomain, etc). So I’m eager to know the essential explanation about interface, and this book work well. In the CLR, those categories of types are referred to as interfaces. Interfaces are always implicitly “abstract”. A code sample for this.
public interface IEnglishWriter {}
public class Person {}
public class ChineseWriter1 : Person, IEnglishWriter {}
public class ChineseWriter2 : Person {}
class PediyForumEnglishColumn
{
void ReadPost(Person person) {}
void PostNew (IEnglishWriter eperson) {}
}
We can see from the code that, any one, whether he knows English or not, can read in this column. But only who can write English will be allowed to post here.
hidebysig: This term is often seen in ILDasm code. It has no significant relationship with cracking, but it’s better to know what it means rather than don’t know. This term mainly used in class inherit and overidding. Use hidebysig, two methods having same name can be called respectively if their signature are different. (For example, they need different params, int and strings). But using hidebyname, method of base class will be shaowed if the derived class has a same name method.
That’s all for this time. After I read more chaps, I will talk more about .NET concepts, of cause, from a cracker’s view as best as I can.