winapi - 导入表、导入地址表、导入名称表有什么区别?

标签 winapi reverse-engineering portable-executable disassembly coff

反汇编/转储 exe 时,我在 .idata 导入部分得到三个表:

  • 导入表 (IT)
  • 导入地址表 (IAT)
  • 导入名称表 (INT)

  • 我了解 IAT 和 INT 是什么,但更准确地说 IT 是什么?

    有人可以提供解释,因为各种 PE 教程令人困惑。我不完全理解他们在此特定数据上描述的那些官方结构名称。

    这里的提示/答案会有所帮助

    示例 PE 文件部分
    SECTION .idata  align=4 noexecute                       ; section number 3, data 
    
    Import_table:                                           ; dword 
        db 50H, 30H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403000 _ P0...... 
        db 00H, 00H, 00H, 00H, 0ACH, 30H, 00H, 00H      ; 00403008 _ .....0.. 
        db 68H, 30H, 00H, 00H, 58H, 30H, 00H, 00H       ; 00403010 _ h0..X0.. 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403018 _ ........ 
        db 0C0H, 30H, 00H, 00H, 70H, 30H, 00H, 00H      ; 00403020 _ .0..p0.. 
        db 60H, 30H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403028 _ `0...... 
        db 00H, 00H, 00H, 00H, 0D0H, 30H, 00H, 00H      ; 00403030 _ .....0.. 
        db 78H, 30H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403038 _ x0...... 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403040 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403048 _ ........ 
        db 80H, 30H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403050 _ .0...... 
        db 8EH, 30H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403058 _ .0...... 
        db 98H, 30H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403060 _ .0...... 
    
    Import_address_table:                                   ; dword 
    imp_ExitProcess:                                        ; import from        KERNEL32.dll  
        dd 00003080H, 00000000H                         ; 00403068 _ 12416 0
    
    imp_printf:                                             ; import from  msvcrt.dll 
        dd 0000308EH, 00000000H                         ; 00403070 _ 0000308E 00000000 
    
    imp_MessageBoxA:                                        ; import from USER32.dll 
        dd 00003098H, 00000000H                         ; 00403078 _ 00003098 00000000 
    
    Import_name_table:                                      ; byte 
        db 17H, 01H, 45H, 78H, 69H, 74H, 50H, 72H       ; 00403080 _ ..ExitPr 
        db 6FH, 63H, 65H, 73H, 73H, 00H, 0B1H, 02H      ; 00403088 _ ocess... 
        db 70H, 72H, 69H, 6EH, 74H, 66H, 00H, 00H       ; 00403090 _ printf.. 
        db 0B2H, 01H, 4DH, 65H, 73H, 73H, 61H, 67H      ; 00403098 _ ..Messag 
        db 65H, 42H, 6FH, 78H, 41H, 00H, 00H, 00H       ; 004030A0 _ eBoxA... 
        db 00H, 30H, 00H, 00H, 4BH, 45H, 52H, 4EH       ; 004030A8 _ .0..KERN 
        db 45H, 4CH, 33H, 32H, 2EH, 64H, 6CH, 6CH       ; 004030B0 _ EL32.dll 
        db 00H, 00H, 00H, 00H, 14H, 30H, 00H, 00H       ; 004030B8 _ .....0.. 
        db 6DH, 73H, 76H, 63H, 72H, 74H, 2EH, 64H       ; 004030C0 _ msvcrt.d 
        db 6CH, 6CH, 00H, 00H, 28H, 30H, 00H, 00H       ; 004030C8 _ ll..(0.. 
        db 55H, 53H, 45H, 52H, 33H, 32H, 2EH, 64H       ; 004030D0 _ USER32.d 
        db 6CH, 6CH, 00H, 00H, 00H, 00H, 00H, 00H       ; 004030D8 _ ll...... 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004030E0 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004030E8 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004030F0 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004030F8 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403100 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403108 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403110 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403118 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403120 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403128 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403130 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403138 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403140 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403148 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403150 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403158 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403160 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403168 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403170 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403178 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403180 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403188 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403190 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 00403198 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031A0 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031A8 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031B0 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031B8 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031C0 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031C8 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031D0 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031D8 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031E0 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031E8 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031F0 _ ........ 
        db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H       ; 004031F8 _ ........ 
    

    最佳答案

    导入表

    来自 manual第 6.4.1 节:

    The import information begins with the Import Directory Table, which describes the remainder of the import information. The Import Directory Table contains address information that is used to resolve fix-up references to the entry points within a DLL image.



    每个导入目录表条目都具有以下形式
    Offset    Size    Field
    0         4       Import Lookup Table RVA
    4         4       Time/Date Stamp
    8         4       Forwarder Chain
    12        4       Name RVA
    16        4       Import Address Table RVA
    

    注意:因为 DLL 可以加载到不同的内存位置 RVA代表Relative Virtual Address,它是内容的地址,一旦加载,相对于图像库

    导入查找表

    再次来自文档:

    The collection of these entries describes all imports from the image to a given DLL.



    这些字段包含有关如何处理导入的信息(序数与名称)。如果它指定按序号导入,则表中条目的其余部分包含序号,否则它包含到提示/名称表条目的 RVA。

    提示/名称表

    提示/名称表中的条目采用以下格式:
    Offset    Size    Field    Notes
    0         2       Hint     Index into the Export Name Pointer Table
    2         varies  Name     Null terminated ASCII string
    *         0 or 1  Pad      Each entry must be on an even boundary
    

    导入地址表

    The structure and content of the Import Address Table are identical to that of the Import Lookup Table, until the file is bound. During binding, the entries in the Import Address Table are overwritten with the 32-bit (or 64-bit for PE32+) addresses of the symbols being imported: these addresses are the actual memory addresses of the symbols themselves (although technically, they are still called “virtual addresses”). The processing of binding is typically performed by the loader.



    引用
  • 维基百科条目 Portable Executable
  • Official Documentation
  • Ero Carrera 的 helpful diagrams


  • 以上所有引用和表格均来自引用文献 2 中列出的 Microsoft PE/COFF 手册。

    关于winapi - 导入表、导入地址表、导入名称表有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32841368/

    相关文章:

    delphi - 使用DrawThemeBackground绘图时如何从右到左(RTL)方向绘制元素部分?

    c - 如何使用调试器 (VS 2013) 跟踪 win32 API 程序中的系统调用?

    debugging - 开始可执行文件黑客/反编译/调试

    java - 如何阻止 hibernate 工具实现 Serialized 接口(interface)

    hex - 为什么PE文件中的MZ DOS Header Signature是0x54AD?

    c++ - 如何从 Gdiplus::Bitmap 快速复制数据

    c++ - WriteProcessMemory C++

    c - thread_create_running 导致我的整个计算机在 OSX 10.6 上重新启动

    windows - 什么是图像基础(在 Windows PE 文件中)

    assembly - 如何在 NASM 中编写 'Hello_world' EFI 应用程序?