应用程序清单和程序集清单之间的区别
应用程序清单和程序集清单有什么区别?每一项都用在哪里?在 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简而言之,这两个是完全不同的概念,但不幸的是名称相似。
应用程序清单是一个嵌入 PE 二进制文件(托管或本机)或与 PE 二进制文件一起分发的 XML 文件,向操作系统加载程序提供有关 SxS 程序集依赖性、所需提升、操作系统版本等信息的说明兼容性等。
程序集清单是 CLI 程序集中的一个部分,说明托管程序集的依赖项、构成程序集的文件、程序集的公钥、类型导出、CLR 标志等。您可以使用 ILDASM.exe 或大多数 .NET 反编译器检查程序集的清单。
ECMA 335(CLI 规范)第 I.9.6 节的相关摘录:
请注意:
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:
Note that:
看来我必须同时遵循:
(信息可在此处找到)。因此,可执行文件似乎具有嵌入在资源中的应用程序清单,而库 (DLL) 具有程序集清单。由于它们都是 PE(可移植可执行文件),因此我需要解析这两种类型。
It seems that i will have to follow both:
(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.
应用程序清单通常嵌入在 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.