应用程序清单和程序集清单之间的区别

发布于 2024-09-14 08:47:10 字数 460 浏览 2 评论 0原文

应用程序清单和程序集清单有什么区别?每一项都用在哪里?在 .dll 或 .exe 资源中找到这两者中的哪一个? (或者两者都可以存在?)。

抱歉,如果一次有太多问题,但如果有人可以向我解释这一点,那将非常有帮助。我问这个问题的原因是我希望能够从 PE 文件中嵌入的清单中提取信息。我找到了这些清单描述,但有两个,我不确定该遵循哪一个:

应用程序清单描述
程序集清单描述

编辑:并且没有,我不想使用任何 API 调用。都是我自己写的。

What is the difference between application manifest and assembly manifest? Where is each one used? Which one of the two is found in .dll or .exe resources? (or both can be there? ).

Sorry if its too many questions at once, but if anyone can explain this to me it would be really helpful. The reason i'm asking this is that i want to be able to extract information from manifests embedded in PE files. I found these descriptions of manifests, but there are two and i'm not sure which one to follow:

Application manifest description
Assembly manifest description

EDIT: and no, i do not want to use any API calls. I'm writting it all myself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三生殊途 2024-09-21 08:47:11

简而言之,这两个是完全不同的概念,但不幸的是名称相似。

应用程序清单是一个嵌入 PE 二进制文件(托管或本机)或与 PE 二进制文件一起分发的 XML 文件,向操作系统加载程序提供有关 SxS 程序集依赖性、所需提升、操作系统版本等信息的说明兼容性等。

程序集清单是 CLI 程序集中的一个部分,说明托管程序集的依赖项、构成程序集的文件、程序集的公钥、类型导出、CLR 标志等。您可以使用 ILDASM.exe 或大多数 .NET 反编译器检查程序集的清单。

ECMA 335(CLI 规范)第 I.9.6 节的相关摘录:

清单:每个程序集都有一个清单,用于声明哪些文件
组成程序集,导出什么类型,以及其他什么
需要程序集来解析内部的类型引用
集会。正如 CLI 组件通过元数据进行自我描述一样
CLI 组件,程序集也通过其自描述
体现出来。当单个文件组成一个程序集时,它包含
描述程序集中定义的类型的元数据和
描述程序集本身的元数据。当程序集包含
多个包含元数据的文件,每个文件都描述
文件中定义的类型(如果有)以及这些文件之一
包含描述程序集的元数据(包括名称
其他文件、它们的加密哈希值以及它们导出的类型
装配体外部)。

请注意:

  • 所有托管程序集必须具有程序集清单、可执行文件和库;
  • 所有本机二进制文件、可执行文件和库,可能具有应用程序清单。

In brief, the two are completely separate concepts with unfortunately similar names.

An application manifest is an XML file embedded in, or distributed along with, a PE binary (managed or native), giving instructions to the OS loader about things such as SxS assembly dependencies, required elevation, OS version compatibility, etc.

An assembly manifest is a section in a CLI assembly, stating the managed assembly's dependencies, the files making up the assembly, the assembly's public key, type exports, CLR flags, and so on. You can inspect an assembly's manifest using ILDASM.exe or most .NET decompilers.

A relevant excerpt from ECMA 335 (the CLI specification), section I.9.6:

Manifests: Every assembly has a manifest that declares which files
make up the assembly, what types are exported, and what other
assemblies are required to resolve type references within the
assembly. Just as CLI components are self-describing via metadata in
the CLI component, so are assemblies self-describing via their
manifests. When a single file makes up an assembly it contains both
the metadata describing the types defined in the assembly and the
metadata describing the assembly itself. When an assembly contains
more than one file with metadata, each of the files describes the
types defined in the file, if any, and one of these files also
contains the metadata describing the assembly (including the names of
the other files, their cryptographic hashes, and the types they export
outside of the assembly).

Note that:

  • all managed assemblies must have assembly manifests, executables and libraries alike;
  • all native binaries, executables and libraries, may have application manifests.
≈。彩虹 2024-09-21 08:47:11

看来我必须同时遵循:

作为 DLL 中的资源,程序集
可供私人使用
DLL。程序集清单不能
作为资源包含在 EXE 中。
EXE 文件可能包含应用程序
表现为资源。

(信息可在此处找到)。因此,可执行文件似乎具有嵌入在资源中的应用程序清单,而库 (DLL) 具有程序集清单。由于它们都是 PE(可移植可执行文件),因此我需要解析这两种类型。

It seems that i will have to follow both:

As a resource in a DLL, the assembly
is available for the private use of
the DLL. An assembly manifest cannot
be included as a resource in an EXE.
An EXE file may include an application
manifest as a resource.

(Information found here). So it seems that executables have application manifests embedded in resources and libraries (DLL) have assembly manifests. Since both of them are PE (portable executable), i will need to parse both types.

旧时浪漫 2024-09-21 08:47:11

应用程序清单通常嵌入在 EXE 中,讽刺的是,嵌入在 Dll 中,并指定 EXE 或 DLL 所依赖的程序集。

程序集清单可以嵌入到 DLL 中,或者作为单独的文件位于磁盘上,并为程序集提供标识和资源列表:DLL、免激活 com 对象和窗口类。

如果程序集的名称是 dll 的名称,则同一清单最终将用作应用程序清单以确定 dll 的依赖项,并用作程序集清单以查看程序集导出的内容。对于本机程序集来说,此选项确实看起来很疯狂,通常最好创建一个具有复杂名称的程序集,如 company.product.module,然后只使用一个简单的 module.dll 作为其一个条目。

Application manifests are typically embedded in EXEs and, ironically, Dlls, and specify which assemblies the EXE or DLL is dependent upon.

Assembly manifests can be embedded in DLLs, or be on disk as a separate file, and give an assembly an identity, and a list of resources: being dll's, activation free com objects, and window classes.

If the name of the assembly is the name of a dll, then the same manifest ends up being used as both an application manifest to determine the dependencies of the dll, and an assembly manifest to see what the assembly exports. This option really just seems crazy for native assemblies, its usually better to create an assembly with a complicated name along the lines of company.product.module, and then just have a simple module.dll as its one entry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文