我已经问了一个类似的问题, "PE头要求", 但我真的不感到满意的答复。

我建立一个汇编/链接,在Java SE1.6.我读了关于5种不同的单证/技术规格有关的PE/。头和文件格式,但我被困在一个问题:

我产生的文件是无效的,说Windows: "X是不是有效的Win32应用程序。" 我没什么可以错误的;我必须仔细检查每个条目中PE头和PE可选择的标题和一切似乎是正确的。
我有三个部分:

  • code (空中航线管理局 0x1000, 文件 0x400)
  • data (空中航线管理局 0x2000, 文件 0x600)
  • import (空中航线管理局 0x3000, 文件 0x800)

我的入口点值是在 0x1000 (的开始 code)和我imagebase是 0x400000.部分对齐 0x1000 和文件准 0x200.

参见修订的这个问题的看到整个文件。

所以:我抓住了一个有效的PE文件(一个简单的"hello World"信息框中的应用程序),并开始修改,有六编(HxD).我有很多不同的错误消息, "X是不是有效的Win32应用程序。":

我知道我的 code 内容是不是"有效的"代码,但我已经测试出来:无效的代码给出了一个应用程序的崩溃错误。

如果所进口的部分内容是无效的"hello World"PE文件,它给了我错误的过程"指无法发现的[...]",或"应用程序未启动,因为[..]dll是找不到.", 或者一个应用程序的崩溃。这些错误都很有用;他们都给我一些什么线索是错误的。

但我PE文件,与错误"X是不是有效的Win32应用程序。", 让我疯狂: 什么是错的我PE的文件?

Dumpbin输出:

E:\Documenten\CP Language\compiler\Win32Builder>dumpbin /ALL test.exe
Microsoft (R) COFF/PE Dumper Version 10.00.21003.01
Copyright (C) Microsoft Corporation.  All rights reserved.
Dump of file test.exe
PE signature found
File Type: EXECUTABLE IMAGE
FILE HEADER VALUES
         14C machine (x86)
           3 number of sections
    32EB4BF5 time date stamp Sun Jan 26 13:20:05 1997
           0 file pointer to symbol table
           0 number of symbols
          E0 size of optional header
         703 characteristics
               Relocations stripped
               Executable
               32 bit word machine
               Debug information stripped
               CD - run from swapfile

OPTIONAL HEADER VALUES
         10B magic # (PE32)
        8.00 linker version
        1000 size of code
        1000 size of initialized data
           0 size of uninitialized data
        1000 entry point (00401000)
        1000 base of code
        2000 base of data
      400000 image base (00400000 to 0040088F)
        1000 section alignment
         200 file alignment
        4.00 operating system version
       13.37 image version
        4.00 subsystem version
           0 Win32 version
         890 size of image
         400 size of headers
           0 checksum
           2 subsystem (Windows GUI)
           0 DLL characteristics
       40000 size of stack reserve
       11000 size of stack commit
      100000 size of heap reserve
        1000 size of heap commit
           0 loader flags
          10 number of directories
           0 [       0] RVA [size] of Export Directory
        3000 [    1000] RVA [size] of Import Directory
           0 [       0] RVA [size] of Resource Directory
           0 [       0] RVA [size] of Exception Directory
           0 [       0] RVA [size] of Certificates Directory
           0 [       0] RVA [size] of Base Relocation Directory
           0 [       0] RVA [size] of Debug Directory
           0 [       0] RVA [size] of Architecture Directory
           0 [       0] RVA [size] of Global Pointer Directory
           0 [       0] RVA [size] of Thread Storage Directory
           0 [       0] RVA [size] of Load Configuration Directory
           0 [       0] RVA [size] of Bound Import Directory
           0 [       0] RVA [size] of Import Address Table Directory
           0 [       0] RVA [size] of Delay Import Directory
           0 [       0] RVA [size] of COM Descriptor Directory
           0 [       0] RVA [size] of Reserved Directory

SECTION HEADER #1
   .code name
    1000 virtual size
    1000 virtual address (00401000 to 00401FFF)
      23 size of raw data
     400 file pointer to raw data (00000400 to 00000422)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60000020 flags
         Code
         Execute Read    
RAW DATA #1
  00401000: 68 00 00 00 00 68 0D 20 40 00 68 00 20 40 00 68  h....h. @.h. @.h
  00401010: 00 00 00 00 E8 64 30 40 00 68 00 00 00 00 E8 6C  ....èd0@.h....èl
  00401020: 30 40 00                                         0@.

SECTION HEADER #2
   .data name
    1000 virtual size
    2000 virtual address (00402000 to 00402FFF)
      23 size of raw data
     600 file pointer to raw data (00000600 to 00000622)
       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
RAW DATA #2
  00402000: 48 65 6C 6C 6F 20 57 6F 72 6C 64 21 00 48 65 6C  Hello World!.Hel
  00402010: 6C 6F 20 53 74 61 63 6B 20 4F 76 65 72 66 6C 6F  lo Stack Overflo
  00402020: 77 21 00                                         w!.

SECTION HEADER #3
 .import name
    1000 virtual size
    3000 virtual address (00403000 to 00403FFF)
      90 size of raw data
     800 file pointer to raw data (00000800 to 0000088F)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
50000040 flags
         Initialized Data
         Shared
         Read Only
RAW DATA #3
  00403000: 54 30 00 00 00 00 00 00 00 00 00 00 3C 30 00 00  T0..........<0..
  00403010: 64 30 00 00 5C 30 00 00 00 00 00 00 00 00 00 00  d0..\0..........
  00403020: 47 30 00 00 6C 30 00 00 00 00 00 00 00 00 00 00  G0..l0..........
  00403030: 00 00 00 00 00 00 00 00 00 00 00 00 75 73 65 72  ............user
  00403040: 33 32 2E 64 6C 6C 00 6B 65 72 6E 65 6C 33 32 2E  32.dll.kernel32.
  00403050: 64 6C 6C 00 74 30 00 00 00 00 00 00 82 30 00 00  dll.t0.......0..
  00403060: 00 00 00 00 74 30 00 00 00 00 00 00 82 30 00 00  ....t0.......0..
  00403070: 00 00 00 00 00 00 4D 65 73 73 61 67 65 42 6F 78  ......MessageBox
  00403080: 41 00 00 00 45 78 69 74 50 72 6F 63 65 73 73 00  A...ExitProcess.

  Section contains the following imports:

user32.dll
            403064 Import Address Table
            403054 Import Name Table
                 0 time date stamp
                 0 Index of first forwarder reference

                0 MessageBoxA

kernel32.dll
            40306C Import Address Table
            40305C Import Name Table
                 0 time date stamp
                 0 Index of first forwarder reference

                0 ExitProcess

Summary
    1000 .code
    1000 .data
    1000 .import
有帮助吗?

解决方案 3

大小的图像,根据dumpbin 890, 同时它应该是大小的图像存储器,即最新的部分是空中航线管理局,部分是圆形的-大小(例如 0x5000 在这种情况下)。

它的工作。谢谢你anserws,特别是提示 dumpbin!

其他提示

你肯定是解决这一问题从错误的结束。黑客的hex不会得到你想要的东西,PE文件的结构过于复杂。你只需要两件事情。

  • 马特Pietrek的 开创性的文章 是必不可少的阅读理解的结构。不要开始代码,直到你了解的至少75%。
  • 你会需要的Windows软件开发工具包。这包括/winnt.h文件中包含的声明的结构中使用的PE格式。它开始在_IMAGE_DOS_HEADER,第一组块的文件。

编写代码,以创建的结构,从他们的声明,这是唯一的方法来结束了一个有效的执行文件。

PS:你hex垃圾场挂上的浏览器的任何人,试图看看你的问题。

一个快速的谷歌透露:

http://rcecafe.net/?p=26.没有一个在这里是要卑躬屈膝通过你的字节对你来说,好的,你可以期待是指针的工具。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top