0

在使用具有 4 个字节的文件对齐和节对齐的压缩 PE(Windows 控制台 EXE)时,我注意到如果节的虚拟大小和原始大小匹配,则程序加载,但如果数据节的虚拟大小,最后一部分不匹配,则 Windows 拒绝加载它,即使按照规范,您应该能够拥有大于原始大小的虚拟大小。

这是对压缩 PE 的某种隐藏约束吗?

我在下面粘贴了一个 exe 的垃圾箱/标题:

Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file ba42x.exe

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
             14C machine (x86)
               2 number of sections
        50AABC14 time date stamp Mon Nov 19 18:09:08 2012
               0 file pointer to symbol table
               0 number of symbols
              60 size of optional header
             10F characteristics
                   Relocations stripped
                   Executable
                   Line numbers stripped
                   Symbols stripped
                   32 bit word machine

OPTIONAL HEADER VALUES
             10B magic # (PE32)
            2.03 linker version
             BD0 size of code
            5000 size of initialized data
               0 size of uninitialized data
              CC entry point (004000CC)
              CC base of code
             C9C base of data
          400000 image base (00400000 to 00403FFF)
               4 section alignment
               4 file alignment
            4.00 operating system version
            0.00 image version
            4.00 subsystem version
               0 Win32 version
            4000 size of image
              CC size of headers
               0 checksum
               3 subsystem (Windows CUI)
               0 DLL characteristics
           10000 size of stack reserve
            1000 size of stack commit
               0 size of heap reserve
               0 size of heap commit
               0 loader flags
               0 number of directories


SECTION HEADER #1
   .text name
     BD0 virtual size
      CC virtual address (004000CC to 00400C9B)
     BD0 size of raw data
      CC file pointer to raw data (000000CC to 00000C9B)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
E0000020 flags
         Code
         Execute Read Write

SECTION HEADER #2
   .data name
    3102 virtual size
     C9C virtual address (00400C9C to 00403D9D)
    3102 size of raw data
     C9C file pointer to raw data (00000C9C to 00003D9D)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0000040 flags
         Initialized Data
         Read Write

  Summary

        3104 .data
         BD0 .text

例如,如果您将上述 .data 部分的虚拟大小更改为 3106,则程序将不会加载,即使初始化数据 (0x5000) 的大小足以容纳额外的内存。

4

1 回答 1

1

不,没有与压缩图像相关的特殊限制,因为只要您的图像符合 PE,加载程序就不会关心压缩。压缩由存根处理,而不是加载程序。

您能否提供您的图像以供进一步分析?

只看dumpbin的输出,图像看起来很不寻常。。根本没有目录,很奇怪。看起来加载器的问题与对齐没有直接关系,而是图像文件的格式错误。您是否尝试使用其他 PE 工具(例如 PeStudio、CFF Explorer ..)查看您的图像文件?

于 2012-12-06T08:06:23.073 回答