Eric Pouech : winedump: Dump PE symbols table if any.

Alexandre Julliard julliard at winehq.org
Thu Dec 10 10:00:57 CST 2009


Module: wine
Branch: master
Commit: 2271a8d417fa5ac1c51d554811b5d420d92dfea5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2271a8d417fa5ac1c51d554811b5d420d92dfea5

Author: Eric Pouech <eric.pouech at orange.fr>
Date:   Wed Dec  9 20:55:18 2009 +0100

winedump: Dump PE symbols table if any.

---

 tools/winedump/main.c     |    7 +++++++
 tools/winedump/pe.c       |   20 ++++++++++++++++++++
 tools/winedump/winedump.h |    3 +++
 3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/tools/winedump/main.c b/tools/winedump/main.c
index 3524a1e..d5f39b5 100644
--- a/tools/winedump/main.c
+++ b/tools/winedump/main.c
@@ -187,9 +187,15 @@ static void do_dumpall(const char *arg)
 {
     globals.do_dumpheader = 1;
     globals.do_dump_rawdata = 1;
+    globals.do_symbol_table = 1;
     globals.dumpsect = "ALL";
 }
 
+static void do_symtable(const char* arg)
+{
+    globals.do_symbol_table = 1;
+}
+
 struct my_option
 {
   const char *name;
@@ -222,6 +228,7 @@ static const struct my_option option_table[] = {
   {"-f",    DUMP, 0, do_dumphead, "-f           Dumps file header information"},
   {"-G",    DUMP, 0, do_rawdebug, "-G           Dumps raw debug information"},
   {"-j",    DUMP, 1, do_dumpsect, "-j sect_name Dumps only the content of section sect_name (import, export, debug, resource, tls, clr)"},
+  {"-t",    DUMP, 0, do_symtable, "-t           Dumps symbol table"},
   {"-x",    DUMP, 0, do_dumpall,  "-x           Dumps everything"},
   {NULL,    NONE, 0, NULL,        NULL}
 };
diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c
index 9761215..a79593c 100644
--- a/tools/winedump/pe.c
+++ b/tools/winedump/pe.c
@@ -1399,6 +1399,24 @@ static void dump_debug(void)
         dump_stabs(stabs, szstabs, stabstr, szstr);
 }
 
+static void dump_symbol_table(void)
+{
+    const IMAGE_SYMBOL* sym;
+    int                 numsym;
+    const char*         strtable;
+
+    numsym = PE_nt_headers->FileHeader.NumberOfSymbols;
+    if (!PE_nt_headers->FileHeader.PointerToSymbolTable || !numsym)
+        return;
+    sym = (const IMAGE_SYMBOL*)PRD(PE_nt_headers->FileHeader.PointerToSymbolTable,
+                                   sizeof(*sym) * numsym);
+    if (!sym) return;
+    /* FIXME: no way to get strtable size */
+    strtable = (const char*)&sym[numsym];
+
+    dump_coff_symbol_table(sym, numsym, IMAGE_FIRST_SECTION(PE_nt_headers));
+}
+
 enum FileSig get_kind_exec(void)
 {
     const WORD*                pw;
@@ -1468,6 +1486,8 @@ void pe_dump(void)
 	if (all || !strcmp(globals.dumpsect, "except"))
 	    dump_dir_exceptions();
     }
+    if (globals.do_symbol_table)
+        dump_symbol_table();
     if (globals.do_debug)
         dump_debug();
 }
diff --git a/tools/winedump/winedump.h b/tools/winedump/winedump.h
index 15a8cdb..9ad20a5 100644
--- a/tools/winedump/winedump.h
+++ b/tools/winedump/winedump.h
@@ -123,6 +123,7 @@ typedef struct __globals
   int   do_dumpheader;      /* -f */
   int   do_dump_rawdata;    /* -x */
   int   do_debug;           /* -G == 1, -g == 2 */
+  int   do_symbol_table;    /* -t */
 
   /* Option arguments: spec mode */
   int   start_ordinal;     /* -s */
@@ -263,6 +264,8 @@ void            codeview_dump_linetab2(const char* linetab, DWORD size, const ch
 void            dump_stabs(const void* pv_stabs, unsigned szstabs, const char* stabstr, unsigned szstr);
 void		dump_codeview(unsigned long ptr, unsigned long len);
 void		dump_coff(unsigned long coffbase, unsigned long len, const void* sect_map);
+void            dump_coff_symbol_table(const IMAGE_SYMBOL *coff_symbols, unsigned num_sym,
+                                       const IMAGE_SECTION_HEADER *sectHead);
 void		dump_frame_pointer_omission(unsigned long base, unsigned long len);
 
 FILE *open_file (const char *name, const char *ext, const char *mode);




More information about the wine-cvs mailing list