4 Kasım 2019 Pazartesi

MSVS dumpbin komutu

Giriş
binary dosyadaki bilgilere erişmek içindir.

/exports seçeneği
Açıklaması şöyle.
The MSVC linker can link together object files (.obj) and object libraries (.lib) to produce an .EXE or a .DLL.

To link with a DLL, the process in MSVC is to use a so-called import library (.LIB) that acts as a glue between the C function names and the DLL's export table (in a DLL a function can be exported by name or by ordinal - the latter was often used for undocumented APIs).

However, in most cases the DLL export table has all the function names and thus the import library (.LIB) contains largely redundant information ("import function ABC -> exported function ABC", etc).
It is even possible to generate a .LIB from an existing .DLL.
Örnek
Şöyle yaparız
dumpbin /EXPORTS yourfile.dll > yourfile.exports
Daha sonra şöyle yaparız. Çıktı olarak yourfile.lib ve yourfile.exp dosyalarını alırız.
vcvars32.bat

 lib /def:yourfile.def /out:yourfile.lib
64 bit için şöyle yaparız.
lib /def:yourfile.def /machine:x64 /out:yourfile64.lib
/section seçeneği
Şöyle yaparız
dumpbin /section:.debug$T /rawdata foo.obj > foo.txt
Dosyanın için şöyledir.
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file ./rc2_cbc.obj

File Type: COFF OBJECT

SECTION HEADER #9
.debug$T name
       0 physical address
       0 virtual address
      5C size of raw data
    1D53 file pointer to raw data (00001D53 to 00001DAE)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
42100040 flags
         Initialized Data
         Discardable
         1 byte align
         Read Only

RAW DATA #9
  00000000: 04 00 00 00 56 00 15 15 03 7A 47 A3 3D 4A 8C 4B  ....V....zGú=J.K
  00000010: A2 A5 26 D3 D6 57 15 46 3A 00 00 00 73 3A 5C 73  óÑ&ËÍW.F:...s:\s
  00000020: 63 61 6C 65 78 2E 6E 65 77 5C 63 65 6E 74 72 6F  caler.new\center
  00000030: 5C 6F 70 65 6E 73 73 6C 5C 62 75 69 6C 64 5C 6F  \openssl\build\o
  00000040: 70 65 6E 73 73 6C 2D 31 2E 30 2E 30 62 5C 74 6D  penssl-1.0.0b\tm
  00000050: 70 33 32 5C 6C 69 62 2E 70 64 62 00              p32\lib.pdb.

  Summary

          5C .debug$T

Hiç yorum yok:

Yorum Gönder