什么是.NET的DLL和正常的DLL之间的`exact`区别在哪里?区别、正常、NET、DLL

2023-09-04 22:44:32 作者:半夏的溫柔

我想知道是什么的确切的.NET的DLL和正常的DLL之间的差异。

I want to know what are the exact differences between .NET dll and a normal dll.

第一个问题,什么是正常的DLL叫什么名字?我用这个词正常。但它似乎没有吧?

First question, what is "normal DLL" called? I'm using the word 'normal'. But it doesnt seem right?

由于双方按照PE格式。是的,我同意.NET的DLL有一个额外的部分。除此之外,每一件事情别人是一样的。

Because both follow the PE format. Yeah, I agree that .NET DLL has an extra section. Other than that every thing else is same.

我也知道,在.NET code转换成CIL / MSIL又是什么填充PE文件的.text段? MSIL?因为没有二进制code。但是,如果他们把MSIL在.text段。装载机假设其二进制code,并允许它执行。这不是这种情况。我在想什么?

I also know that in .NET code is converted into CIL/MSIL then what is filled in .text section of PE file? MSIL? because there is no binary code. But if they put MSIL in .text section. Loader assumes that its a binary code and allows it to execute. Which is not the case. What am I missing?

我很惊讶地知道,

即使是DLL文件的扩展名是   人为的。您可以使用的DLL   完全不同的扩展,为   例如.OCX控制和控制   面板小程序(.cpl文件)的动态链接库。

Even the DLL file extension is artificial. You can have DLLs with entirely different extensions—for instance .OCX controls and Control Panel applets (.CPL files) are DLLs.

还有什么是用于DLL文件扩展名?

What else extensions are used for DLL files?

不过,我可以理解为使用不同的扩展名的原因。他们为什么不跟着做同样的事情的情况下.NET的DLL?它们也可以使用一个新的扩展,从正常的DLL分开。他们甚至有一个不同的名称(组装)对于.NET的DLL,但不能更改扩展名。是吧?

But I can understand the reason for using different extensions. Why didn't they follow do the same thing in case of .NET DLLS? they could have used a new extension to differentiate it from the "normal" DLL. They even have a different name (ASSEMBLY) for dlls in .NET but couldn't change the extension. huh?

另外一个完全不同的问题:什么是DLL注册?他们使用regsvr32.exe的吧。对?我注意到,当我安装了Windows XP SP3。在安装和放大器;重新启动Windows之前,我检查启动列表,发现大量的 regsvr32.exe的有很多的DLL项。

Another completely different question: What is DLL registration? they use regsvr32.exe for it. right? I noticed it when I installed Windows XP SP3. After the installation & before restarting windows, I checked startup list and found lot of regsvr32.exe entries with lot of DLLs.

请随时深入到尽可能多的深度,只要你喜欢。我正在学习接头,装载机,二进制格式。我熟悉PE文件格式也。

Please feel free to dive into as much depth as you like. I'm learning about linkers,loaders,binary formats. I'm familiar with PE file format also.

推荐答案

我复制并从的我自己的帖子就可以了:

I've copied and pasted this from my own post on it:

一个.NET的DLL的格式为:

The format of a .NET dll is:

PE头 在CLR头 在CLR元数据 在CLR IL code 本机数据

PE头是便携式可执行文件头,所有的Win32应用程序和库拥有的,指示Windows如何处理文件。随着.NET程序集,加载反过来加载程序集的CLR。

The PE header is the portable executable header that all Win32 applications and libraries have, and instructs Windows what to do with the file. With .NET assemblies this loads the CLR which in turn loads the assembly.

这包含的信息,如.NET版本中的.exe或装配体写的,任何强大的名称签名哈希,文件中的地址(RVA或相对虚拟地址)的资源都可以找到。而且最重要的入口点是一个令牌指向MethodDef元数据表,或其他文件的应用程序。此令牌是0的类库。

This contains information such as the .NET version the .exe or assembly was written with, any strong name signature hash, the address (RVA or relative virtual address) in the file that the resources can be found. And most importantly the entry point for the application which is a token pointing to the MethodDef metadata table, or another file. This token is 0 for class libraries.

这是关于存储内多种不同类型的流的模块信息。这些流通常是COM pressed,除#〜可以是pssed进行编辑,并继续uncom $ P $。这些流有两种形式,这只是用于存储堆和表格。

This is information about the module that is stored inside several different types of "streams". These streams are typically compressed, with the exception of #~ which can be uncompressed for edit and continue. The streams come in two forms, a heap which is just used for storage, and tables.

您的DLL /组件的各个部分都存储在基于他们所做的事情不同的表 - 例如所有类型的存储在 TypeRef 表,在所有方法方法表。每个表的引用一个父表

The various parts of your DLL/assembly are stored in different tables based on what they do - for example all types are stored in the TypeRef table, all methods in the Method table. Each of the tables references a parent table.

表的起点是含有仅仅是名称和GUID模块作为一个单一的行的模块表。在这之后是ModuleRef表,其中包含有关通过该模块(来自同一个程序集)中引用的所有模块的信息。在VS.NET的情况及其使用csc.exe的还有在组装而不是多个文件,只需一个模块。

The start point of the tables is the Module table which contains just the name and guid of the module as a single row. After this is the ModuleRef table which contains information about all modules that are referenced by this module (from the same assembly). In the case of VS.NET and its use of csc.exe there aren't multiple files in the assembly, just one module.

在这其中包含6列抱着类型的名称,命名空间,它的父(0接口和对象),开始行其在FieldDef表中的字段类型定义表,开始行其在MethodDef表方法。

After this is the TypeDef table which contains 6 columns holding the type's name, namespace, its parent (0 for interfaces and Object), the start row for its fields in the FieldDef table, start row for its methods in the MethodDef table.

该应用程序本身。

借助本书中的Microsoft .NET IL汇编 - 塞尔Lidin 进入了很多如果你有兴趣的细节。

The book Inside Microsoft .NET IL Assembler - Serge Lidin goes into a lot more detail if you're interested.