.NET dll和普通dll之间的“精确”差异是甚么? [英] What are the `exact` differences between .NET dll and a normal dll?

查看:285
本文介绍了.NET dll和普通dll之间的“精确”差异是甚么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道.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代码中转换为CIL / MSIL,那么什么是PE文件的.text部分? MSIL?因为没有二进制代码。但是如果他们把MSIL放在.text文件中。 Loader假定它是一个二进制代码并允许它执行。不是这样的。我缺少什么?

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文件扩展名是
人工。您可以使用
完全不同的扩展名,
实例.OCX控件和控件
面板小程序(.CPL文件)是DLL。

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 DLLS的情况下做同样的事情?他们可以使用一个新的扩展来区分它与正常DLL。他们甚至在.NET中使用与dll不同的名称( ASSEMBLY ),但无法更改扩展名。嗯?

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时,我注意到了。安装后在重新启动窗口之前,我检查了启动列表,发现很多DLL的许多 regsvr32.exe 条目。

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.

推荐答案

我已经复制并将其从我自己的帖子

.NET dll的格式是:

The format of a .NET dll is:


  • PE头

  • CLR标题

  • CLR元数据

  • CLR IL代码

  • 本地数据

  • PE header
  • CLR header
  • CLR metadata
  • CLR IL code
  • Native data

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.

这是有关内部存储的模块的信息几种不同类型的流。这些流通常被压缩,除了#〜可以被解压缩以进行编辑并继续。这些流有两种形式,一种仅用于存储的堆和表。

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 表中, Method 表中的所有方法。每个表都引用一个父表。

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.

之后是TypeDef表,包含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如果您有兴趣,汇编程序 - Serge Lidin 将进入更多细节。

这篇关于.NET dll和普通dll之间的“精确”差异是甚么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆