“~”中排序的位向量字段的用途是什么? .NET 程序集中的元数据标头?

发布于 2024-08-08 08:58:39 字数 136 浏览 1 评论 0原文

根据 Partition II 元数据,它说有效字段是一个位掩码,用于记录 .NET 可执行文件中存在哪些 CLR 元数据表 - 但我无法弄清楚“已排序”字段的用途 -它的意义是什么?在创建我自己的 .NET 可移植可执行映像时,我应该向该字段发送什么内容?

According to the Partition II metadata, it says that the valid field is a bitmask that notes which CLR metadata tables are present in a .NET executable--but what I can't figure out is what the "sorted" field is for--what is its significance, and what should I emit into this field when creating my own .NET portable executable images?

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

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

发布评论

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

评论(2

雄赳赳气昂昂 2024-08-15 08:58:39

我认为排序字段只是暗示特定元数据表是否已排序(它是一个位字段,就像有效一样)。

这将允许运行时的实现直接从内存映射的数据对表进行二分搜索。

I think the sorted field is just hinting if the specific metadata table is sorted or not (it's a bitfield just like valid).

This would allow an implemenation of a runtime to do a binary search on the table directly from the memmapped data.

我不在是我 2024-08-15 08:58:39

编辑:这不是答案,我误读了这个问题,认为它是关于“有效”字段而不是“排序”字段,但我将其留在这里,以防它与答案相关

“有效”您正在谈论的字段在 第二部分,§24.2.6,相关部分如下:

Valid 字段是一个 64 位的位向量,它为流中存储的每个表设置了特定的位;表到索引的映射在第 22 节开头给出。例如,当逻辑元数据中存在 DeclSecurity 表时,应在有效向量中设置位 0x0e。 Valid中包含不存在的表是无效的,因此0x2c以上的所有位都应为零。

第 22 节从第 22.2 节开始的每个小节都描述一个表,并给出其位索引。例如,§22.2 的标题为“Assembly:0x20”。这意味着,当且仅当您的 PE 中存在第 22.2 节中描述的汇编表时,才必须在 Valid 字段中设置位 0x20。请注意,这NOT并不意味着Valid & 0x20 == 0x20,表示必须设置Valid的第0x20位(即第32位),即Valid & 0x20。 (1 << 0x20) == (1 << 0x20)。

有一段时间我不确定它是 0 索引还是 1 索引,所以我假设 0 索引。但我现在确定它是 0 索引的,因为模块表是表 0x00。

EDIT: This isn't an answer, I misread the question as being about the Valid field rather than the Sorted field, but I am leaving it here in case it is related to the answer

The "Valid" field you are talking about is described in Partition II, §24.2.6, with the relevant part as follows:

The Valid field is a 64-bit bitvector that has a specific bit set for each table that is stored in the stream; the mapping of tables to indexes is given at the start of §22. For example when the DeclSecurity table is present in the logical metadata, bit 0x0e should be set in the Valid vector. It is invalid to include non-existent tables in Valid, so all bits above 0x2c shall be zero.

Each subsection of section 22 starting with §22.2 describes one table, and gives its bit index. For example, §22.2 is titled "Assembly: 0x20". This means that, if and only if the Assembly table described in §22.2 is present in your PE, then bit 0x20 must be set in the Valid field. Note that this does NOT mean that Valid & 0x20 == 0x20, it means that the 0x20th (ie, the 32nd) bit of Valid must be set, which is to say Valid & (1 << 0x20) == (1 << 0x20).

For a while I wasn't sure if it was 0-indexed or 1-indexed, so I assumed 0-indexed. But I now know for sure that it is 0-indexed, because the Module table is table 0x00.

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