gpt4 book ai didi

c - IMAGE_OPTIONAL_HEADER.DataDirectory 的大小是固定的还是可变的?

转载 作者:太空宇宙 更新时间:2023-11-04 04:24:17 24 4
gpt4 key购买 nike

我对 IMAGE_OPTIONAL_HEADER.DataDirectory 有点困惑。作为PE/COFF Specification说,

Header part: Data Directories

Size: Variable

Description: Address/size pairs for special tables that are found in the image file and are used by the operating system (for example, the import table and the export table).

还有

NumberOfRvaAndSizes: The number of data-directory entries in the remainder of the optional header. Each describes a location and size.

最后,

3.4.3. Optional Header Data Directories (Image Only)

Note that the number of directories is not fixed. Before looking for a specific directory, check the NumberOfRvaAndSizes field in the optional header.

Also, do not assume that the RVAs in this table point to the beginning of a section or that the sections that contain specific tables have specific names.

最后一段引用了下表:

enter image description here

正如我从上面了解到的,DataDirectory 不必具有固定大小的 IMAGE_NUMBEROF_DIRECTORY_ENTRIES。它应该包含 NumberOfRvaAndSizes 条目。实际上这与上面的目录条目表相矛盾,其中每种类型在表中都有自己的偏移量,并且会造成混淆。

因此,我的问题是:是否允许在 DataDirectory 中包含小于 IMAGE_NUMBEROF_DIRECTORY_ENTRIES 的内容,还是必须始终为该大小?

在这种情况下如何正确计算 NumberOfRvaAndSizes?例如,我只有导入目录。那么 NumberOfRvaAndSizes 应该是 1。但是我在 DataDirectory 中仍然有 16 个条目并在索引 1 处导入条目?

对于一些误导性标签,我们深表歉意。我添加它们是为了引起一些注意,因为指定 portable-executable only 可能会导致熟悉格式的人可能会错过问题

最佳答案

is it allowed to include less than IMAGE_NUMBEROF_DIRECTORY_ENTRIES in DataDirectory or it must always be that size?

是的,它允许。 NumberOfRvaAndSizes 可以是任何值,包括 0

How to properly compute NumberOfRvaAndSizes in that case?

奇怪的问题。只需阅读并使用它 - 它对 DataDirectory 数组中的有效条目进行计数。

For example, I have only import directory. Then NumberOfRvaAndSizes should be 1.

NumberOfRvaAndSizes 必须大于您使用的最大索引。因为 IMAGE_DIRECTORY_ENTRY_IMPORT == 1 - NumberOfRvaAndSizes 必须 > 1 - 最小值 2。

并寻找source更多理解的代码

关于c - IMAGE_OPTIONAL_HEADER.DataDirectory 的大小是固定的还是可变的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43306896/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com