Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows PE目录的名称_Windows_Winapi_Executable_Portable Executable_Coff - Fatal编程技术网

Windows PE目录的名称

Windows PE目录的名称,windows,winapi,executable,portable-executable,coff,Windows,Winapi,Executable,Portable Executable,Coff,我在做一个PE解剖仪,发现了一些不寻常的东西。PE格式中目录的名称和顺序似乎因您查看的位置而异: 发件人: In(已更正为0-base): 在: 发件人: 这是一张桌子: +------+-------------------+-------------------+-------------------+-------------------+ | Dir# | WINE's winnt.h | PEReader | PEInfo | CFF Ex

我在做一个PE解剖仪,发现了一些不寻常的东西。PE格式中目录的名称和顺序似乎因您查看的位置而异:

发件人:

In(已更正为0-base):

在:

发件人:

这是一张桌子:

+------+-------------------+-------------------+-------------------+-------------------+
| Dir# | WINE's winnt.h    | PEReader          | PEInfo            | CFF Explorer      |
+------+-------------------+-------------------+-------------------+-------------------+
| 0    | Export            | Export            | Export            | Export            |
| 1    | Import            | Import            | Import            | Import            |
| 2    | Resource          | Resource          | Resource          | Resource          |
| 3    | Exception         | Exception         | Exception         | Exception         |
| 4    | Security          | Security          | Security          | Security          |
| 5    | Relocation        | Relocation        | Relocation        | Relocation        |
| 6    | Debug             | Debug             | Debug             | Debug             |
| 7    | Copyright         | Architecture      | Copyright         | Architecture      |
| 8    | Global Ptr        | Global Ptr        | Global Ptr        | (reserved)        |
| 9    | TLS               | TLS               | TLS               | TLS               |
| 10   | Load Config       | Load Config       | Load Config       | Load Config       |
| 11   | Bound Import      | Bound Import      | Bound Import      | Bound Import      |
| 12   | IAT               | IAT               | IAT               | IAT               |
| 13   | Delay Import      | Delay Import      | COM               | Delay Import      |
| 14   | COM Descriptor    | COM Descriptor    | Delay Import      | .NET MetaData     |
| 15   | -                 | -                 | (reserved)        | -                 |
+------+-------------------+-------------------+-------------------+-------------------+
这些文件的编号和顺序似乎不匹配。在PEReader和winnt.h中,条目14都是COM描述符,但在CFF Explorer中,它显示为.NET元数据。COM和Delay导入条目似乎也在切换


奇怪的是,这些工具中有几个会出错。哪一个是正确的?我是否缺少一个更新的定义?

PE规范由MS记录,您最好的选择是它们在pecoff.doc中提供的信息:

最后一个条目被描述为CLR Runtime Header,如果我没记错的话,它过去有不同的含义(这就是为什么有些人称之为COM描述符),但现在用来指向CLR元数据


最后三个的顺序是IAT、DelayImport、CLR。其他任何东西都是错误的,目录显然不会神奇地移动。

您不必使用任何未记录的东西。在随附的WinNT.h文件中可以找到正确的文件(安装后,在我的计算机上,它位于C:\Program Files(x86)\Microsoft SDK\Windows\v7.0A\Include):

WINE&PEReader的定义(我相信是正确的)借用了这个.h文件


这里还提到:

事实上,目录顺序是固定的,正如winnt.h中定义的那样。
甚至COM、Delay Import和.NET元数据在目录表中也有固定的位置!一些工具用自己的名称和顺序显示目录。表示的方式与PE规范无关。

在2001年之前,.NET最初被称为“COM+运行时”(或COM2或NGWS…),因此您可以在各种.H文件中看到COR前缀,以及名称“COM运行时描述符”。
0   Export
1   Import
2   Resource
3   Exception
4   Security
5   Base Reloc
6   Debug
7   Copyright
8   Global Ptr
9   TLS
10  Load Config
11  Bound Import
12  IAT
13  COM
14  Delay Import
15  (reserved)
0   Export
1   Import
2   Resource
3   Exception
4   Security
5   Relocation
6   Debug
7   Architecture
8   (reserved)
9   TLS
10  Configuration
11  Bound Import
12  IAT
13  Delay Import
14  .NET MetaData
#define IMAGE_DIRECTORY_ENTRY_EXPORT            0
#define IMAGE_DIRECTORY_ENTRY_IMPORT            1
#define IMAGE_DIRECTORY_ENTRY_RESOURCE          2
#define IMAGE_DIRECTORY_ENTRY_EXCEPTION         3
#define IMAGE_DIRECTORY_ENTRY_SECURITY          4
#define IMAGE_DIRECTORY_ENTRY_BASERELOC         5
#define IMAGE_DIRECTORY_ENTRY_DEBUG             6
#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT         7
#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR         8   /* (MIPS GP) */
#define IMAGE_DIRECTORY_ENTRY_TLS               9
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG       10
#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT      11
#define IMAGE_DIRECTORY_ENTRY_IAT               12  /* Import Address Table */
#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT      13
#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR    14
+------+-------------------+-------------------+-------------------+-------------------+
| Dir# | WINE's winnt.h    | PEReader          | PEInfo            | CFF Explorer      |
+------+-------------------+-------------------+-------------------+-------------------+
| 0    | Export            | Export            | Export            | Export            |
| 1    | Import            | Import            | Import            | Import            |
| 2    | Resource          | Resource          | Resource          | Resource          |
| 3    | Exception         | Exception         | Exception         | Exception         |
| 4    | Security          | Security          | Security          | Security          |
| 5    | Relocation        | Relocation        | Relocation        | Relocation        |
| 6    | Debug             | Debug             | Debug             | Debug             |
| 7    | Copyright         | Architecture      | Copyright         | Architecture      |
| 8    | Global Ptr        | Global Ptr        | Global Ptr        | (reserved)        |
| 9    | TLS               | TLS               | TLS               | TLS               |
| 10   | Load Config       | Load Config       | Load Config       | Load Config       |
| 11   | Bound Import      | Bound Import      | Bound Import      | Bound Import      |
| 12   | IAT               | IAT               | IAT               | IAT               |
| 13   | Delay Import      | Delay Import      | COM               | Delay Import      |
| 14   | COM Descriptor    | COM Descriptor    | Delay Import      | .NET MetaData     |
| 15   | -                 | -                 | (reserved)        | -                 |
+------+-------------------+-------------------+-------------------+-------------------+
// Directory Entries

#define IMAGE_DIRECTORY_ENTRY_EXPORT          0   // Export Directory
#define IMAGE_DIRECTORY_ENTRY_IMPORT          1   // Import Directory
#define IMAGE_DIRECTORY_ENTRY_RESOURCE        2   // Resource Directory
#define IMAGE_DIRECTORY_ENTRY_EXCEPTION       3   // Exception Directory
#define IMAGE_DIRECTORY_ENTRY_SECURITY        4   // Security Directory
#define IMAGE_DIRECTORY_ENTRY_BASERELOC       5   // Base Relocation Table
#define IMAGE_DIRECTORY_ENTRY_DEBUG           6   // Debug Directory
//      IMAGE_DIRECTORY_ENTRY_COPYRIGHT       7   // (X86 usage)
#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE    7   // Architecture Specific Data
#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR       8   // RVA of GP
#define IMAGE_DIRECTORY_ENTRY_TLS             9   // TLS Directory
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG    10   // Load Configuration Directory
#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT   11   // Bound Import Directory in headers
#define IMAGE_DIRECTORY_ENTRY_IAT            12   // Import Address Table
#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT   13   // Delay Load Import Descriptors
#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14   // COM Runtime descriptor