使用Visual Studio自帶工具dumpbin解析PE文件


如果想查看PE文件或庫包含了哪些函數以及相關的信息(符號清單),可以通過VS自帶的dumpbin工具來完成。

介紹

dumpbin.exe爲Microsoft COFF二進制文件轉換器,它顯示有關通用對象文件格式(COFF)二進制文件的信息。可以使用dumpbin檢查COFF對象文件、標準COFF對象庫、可執行文件和動態鏈接庫等。

使用方法

在“開始”中找到“Visual Studio 2019”文件夾,打開後找到“x86 Native Tools Command Prompt for VS 2019”,雙擊打開

打開後,直接輸入dumpbin,然後回車,即可得到幫助信息

翻譯如下:

   /ALL    顯示除代碼反彙編外的所有可用信息
   /ARCHIVEMEMBERS  顯示有關庫成員對象的最少信息
   /CLRHEADER  顯示有關在任何託管程序中使用的 .NET 頭的信息
   /DEPENDENTS    轉儲映像從中導入函數的 DLL 的名稱
   /DIRECTIVES  轉儲映像中由編譯器生成的 .directive 節
   /DISASM[:{BYTES|NOBYTES}]      顯示代碼段的反彙編,如果出現在文件中則使用符號
   /ERRORREPORT:{NONE|PROMPT|QUEUE|SEND}
   /EXPORTS  顯示從可執行文件或 DLL 導出的所有定義
   /FPO  顯示框架指針優化 (FPO) 記錄
   /HEADERS  顯示文件頭和每節的頭。當用於庫時,顯示每個成員對象的頭
   /IMPORTS[:文件名]  顯示導入到可執行文件或 DLL 的 DLL 列表(靜態鏈接的和延遲加載 )和上述每個 DLL 的各個導入
   /LINENUMBERS  顯示 COFF 行號
   /LINKERMEMBER[:{1|2}] 顯示庫中定義的公共符號。指定參數 1 將按對象順序顯示符號及其偏移量。指定參數 2 將顯示
   對象的偏移量和索引號,然後按字母順序列出這些符號及每個符號的對象索引
   /LOADCONFIG 轉儲 IMAGE_LOAD_CONFIG_DIRECTORY 結構,此結構是由 Windows NT 加載程序使用並在 WINNT.H 中定義的可選結構。
   /NOLOGO
   /OUT:filename
   /PDATA  僅用於 RISC 處理器。此選項從映像或對象轉儲異常表 (.pdata)
   /PDBPATH[:VERBOSE]  將沿調試器搜索 .pdb 文件的同一路徑搜索計算機,並將報告哪些 .pdb 文件(若有)和 filename 中指定的文件相對應
   /RANGE:vaMin[,vaMax]
   /RAWDATA[:{NONE|1|2|4|8}[,#]]   此選項顯示文件中每節的原始內容
   /RELOCATIONS  此選項顯示對象或映像中的任何重定位

使用格式爲:dumpbin 選項 文件名
格式說明:
多個選項間用空格分開,多個文件名間也用空格分開,文件名可以爲後綴爲.obj、.lib、.dll、.exe,如 dumpbin /ALL/RAWDATA:NONE /OUT:1.txt text.obj (dmpbin /ALL /RAWDATA:NONE test.obj >1.txt)。如果沒有給dumpbin指定任何選項,它將等同於使用了/SUMMARY參數。如果沒有指定任何輸入文件,它將列出所有的選項。
選項說明:參數的使用可以用”-”或者”/”(如-ALL等於/ALL)後面跟選項名。有些選項可以在選項名後接”:”。使用空格或製表符(Tab)分割命令選項。選項名,關鍵字和文件名是不區分大小寫的。大多數的參數可以應用於所有的二進制文件,有少部分參數只能用於特定的文件。

示例

比如,我當前有個名爲“main.exe”的可執行文件,想查看文件頭的信息
命令如下:
dumpbin /HEADERS E:\娛樂\網易雲音樂\crack\ncmdump\main.exe
運行結果爲:

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
            8664 machine (x64)
               4 number of sections
               0 time date stamp
          216C00 file pointer to symbol table
               0 number of symbols
              F0 size of optional header
             223 characteristics
                   Relocations stripped
                   Executable
                   Application can handle large (>2GB) addresses
                   Debug information stripped

OPTIONAL HEADER VALUES
             20B magic # (PE32+)
            3.00 linker version
          1E8600 size of code
           2DC00 size of initialized data
               0 size of uninitialized data
           51360 entry point (0000000000451360)
            1000 base of code
          400000 image base (0000000000400000 to 0000000000638FFF)
            1000 section alignment
             200 file alignment
            4.00 operating system version
            1.00 image version
            4.00 subsystem version
               0 Win32 version
          239000 size of image
             600 size of headers
               0 checksum
               3 subsystem (Windows CUI)
               0 DLL characteristics
          200000 size of stack reserve
            1000 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
          237000 [     3FE] 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
          1EA000 [     118] 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
   .text name
  1E8482 virtual size
    1000 virtual address (0000000000401000 to 00000000005E9481)
  1E8600 size of raw data
     600 file pointer to raw data (00000600 to 001E8BFF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60000060 flags
         Code
         Initialized Data
         Execute Read

SECTION HEADER #2
   .data name
   4C0D8 virtual size
  1EA000 virtual address (00000000005EA000 to 00000000006360D7)
   2DC00 size of raw data
  1E8C00 file pointer to raw data (001E8C00 to 002167FF)
       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

SECTION HEADER #3
  .idata name
     3FE virtual size
  237000 virtual address (0000000000637000 to 00000000006373FD)
     400 size of raw data
  216800 file pointer to raw data (00216800 to 00216BFF)
       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

SECTION HEADER #4
 .symtab name
       4 virtual size
  238000 virtual address (0000000000638000 to 0000000000638003)
     200 size of raw data
  216C00 file pointer to raw data (00216C00 to 00216DFF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
42000000 flags
         Discardable
         Read Only

  Summary

       4D000 .data
        1000 .idata
        1000 .symtab
      1E9000 .text
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章