Commit 7370e15c authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedump: Introduce ability to pass several section names to -j option.

parent 51adaa33
...@@ -169,7 +169,23 @@ static void do_dumphead (const char *arg) ...@@ -169,7 +169,23 @@ static void do_dumphead (const char *arg)
static void do_dumpsect (const char* arg) static void do_dumpsect (const char* arg)
{ {
globals.dumpsect = arg; unsigned count = 2;
char* p;
const char** out;
for (p = (char*)arg; (p = strchr(p, ',')) != NULL; p++, count++);
out = malloc(count * sizeof(char*));
globals.dumpsect = out;
count = 0;
p = strdup(arg);
for (;;)
{
out[count++] = p;
p = strchr(p, ',');
if (!p) break;
*p++ = '\0';
}
out[count] = NULL;
} }
static void do_rawdebug (const char *arg) static void do_rawdebug (const char *arg)
...@@ -182,7 +198,7 @@ static void do_dumpall(const char *arg) ...@@ -182,7 +198,7 @@ static void do_dumpall(const char *arg)
globals.do_dumpheader = TRUE; globals.do_dumpheader = TRUE;
globals.do_dump_rawdata = TRUE; globals.do_dump_rawdata = TRUE;
globals.do_symbol_table = TRUE; globals.do_symbol_table = TRUE;
globals.dumpsect = "ALL"; do_dumpsect ("ALL");
} }
static void do_symtable(const char* arg) static void do_symtable(const char* arg)
...@@ -207,8 +223,10 @@ static const struct my_option option_table[] = { ...@@ -207,8 +223,10 @@ static const struct my_option option_table[] = {
{"-C", DUMP, 0, do_symdmngl, "-C Turn on symbol demangling"}, {"-C", DUMP, 0, do_symdmngl, "-C Turn on symbol demangling"},
{"-f", DUMP, 0, do_dumphead, "-f Dump file header information"}, {"-f", DUMP, 0, do_dumphead, "-f Dump file header information"},
{"-G", DUMP, 0, do_rawdebug, "-G Dump raw debug information"}, {"-G", DUMP, 0, do_rawdebug, "-G Dump raw debug information"},
{"-j", DUMP, 1, do_dumpsect, "-j <sect_name> Dump only the content of section 'sect_name'\n" {"-j", DUMP, 1, do_dumpsect, "-j <sect_name> Dump the content of section 'sect_name'\n"
" (import, export, debug, resource, tls, loadcfg, clr, reloc, except, apiset)"}, " (use '-j sect_name,sect_name2' to dump several sections)\n"
" for NE: export, resource\n"
" for PE: import, export, debug, resource, tls, loadcfg, clr, reloc, except, apiset"},
{"-t", DUMP, 0, do_symtable, "-t Dump symbol table"}, {"-t", DUMP, 0, do_symtable, "-t Dump symbol table"},
{"-x", DUMP, 0, do_dumpall, "-x Dump everything"}, {"-x", DUMP, 0, do_dumpall, "-x Dump everything"},
{"sym", DMGL, 0, do_demangle, "sym <sym> Demangle C++ symbol <sym> and exit"}, {"sym", DMGL, 0, do_demangle, "sym <sym> Demangle C++ symbol <sym> and exit"},
...@@ -370,6 +388,16 @@ static BOOL symbol_finish(void) ...@@ -370,6 +388,16 @@ static BOOL symbol_finish(void)
return started; return started;
} }
BOOL globals_dump_sect(const char* s)
{
const char** sect;
if (!s || !globals.dumpsect) return FALSE;
for (sect = globals.dumpsect; *sect; sect++)
if (!strcmp(*sect, s) || !strcmp(*sect, "ALL")) return TRUE;
return FALSE;
}
/******************************************************************* /*******************************************************************
* main * main
*/ */
......
...@@ -429,15 +429,11 @@ void ne_dump( void ) ...@@ -429,15 +429,11 @@ void ne_dump( void )
dump_ne_header( ne ); dump_ne_header( ne );
if (globals.do_dumpheader) if (globals.do_dumpheader)
dump_ne_names( ne ); dump_ne_names( ne );
if (globals.dumpsect)
{
BOOL all = strcmp(globals.dumpsect, "ALL") == 0;
if (all || !strcmp(globals.dumpsect, "resource")) if (globals_dump_sect("resource"))
dump_ne_resources( ne ); dump_ne_resources( ne );
if (all || !strcmp(globals.dumpsect, "export")) if (globals_dump_sect("export"))
dump_ne_exports( ne ); dump_ne_exports( ne );
}
if (globals.do_dumpheader) if (globals.do_dumpheader)
for (i = 1; i <= ne->ne_cseg; i++) dump_ne_segment( ne, i ); for (i = 1; i <= ne->ne_cseg; i++) dump_ne_segment( ne, i );
} }
...@@ -2525,8 +2525,6 @@ enum FileSig get_kind_exec(void) ...@@ -2525,8 +2525,6 @@ enum FileSig get_kind_exec(void)
void pe_dump(void) void pe_dump(void)
{ {
int all = (globals.dumpsect != NULL) && strcmp(globals.dumpsect, "ALL") == 0;
PE_nt_headers = get_nt_header(); PE_nt_headers = get_nt_header();
print_fake_dll(); print_fake_dll();
...@@ -2543,32 +2541,30 @@ void pe_dump(void) ...@@ -2543,32 +2541,30 @@ void pe_dump(void)
dump_pe_header(); dump_pe_header();
} }
if (globals.dumpsect) if (globals_dump_sect("import"))
{ {
if (all || !strcmp(globals.dumpsect, "import")) dump_dir_imported_functions();
{ dump_dir_delay_imported_functions();
dump_dir_imported_functions(); }
dump_dir_delay_imported_functions(); if (globals_dump_sect("export"))
} dump_dir_exported_functions();
if (all || !strcmp(globals.dumpsect, "export")) if (globals_dump_sect("debug"))
dump_dir_exported_functions(); dump_dir_debug();
if (all || !strcmp(globals.dumpsect, "debug")) if (globals_dump_sect("resource"))
dump_dir_debug(); dump_dir_resource();
if (all || !strcmp(globals.dumpsect, "resource")) if (globals_dump_sect("tls"))
dump_dir_resource(); dump_dir_tls();
if (all || !strcmp(globals.dumpsect, "tls")) if (globals_dump_sect("loadcfg"))
dump_dir_tls(); dump_dir_loadconfig();
if (all || !strcmp(globals.dumpsect, "loadcfg")) if (globals_dump_sect("clr"))
dump_dir_loadconfig(); dump_dir_clr_header();
if (all || !strcmp(globals.dumpsect, "clr")) if (globals_dump_sect("reloc"))
dump_dir_clr_header(); dump_dir_reloc();
if (all || !strcmp(globals.dumpsect, "reloc")) if (globals_dump_sect("except"))
dump_dir_reloc(); dump_dir_exceptions();
if (all || !strcmp(globals.dumpsect, "except")) if (globals_dump_sect("apiset"))
dump_dir_exceptions(); dump_section_apiset();
if (all || !strcmp(globals.dumpsect, "apiset"))
dump_section_apiset();
}
if (globals.do_symbol_table) if (globals.do_symbol_table)
dump_symbol_table(); dump_symbol_table();
if (globals.do_debug) if (globals.do_debug)
......
...@@ -135,13 +135,15 @@ typedef struct __globals ...@@ -135,13 +135,15 @@ typedef struct __globals
const char *uc_dll_name; /* -o */ const char *uc_dll_name; /* -o */
/* Option arguments: dump mode */ /* Option arguments: dump mode */
const char *dumpsect; /* -j */ const char **dumpsect; /* -j */
} _globals; } _globals;
extern _globals globals; extern _globals globals;
extern void *dump_base; extern void *dump_base;
extern size_t dump_total_len; extern size_t dump_total_len;
BOOL globals_dump_sect(const char*);
/* Names to use for output DLL */ /* Names to use for output DLL */
#define OUTPUT_DLL_NAME \ #define OUTPUT_DLL_NAME \
(globals.dll_name ? globals.dll_name : (globals.input_module ? globals.input_module : globals.input_name)) (globals.dll_name ? globals.dll_name : (globals.input_module ? globals.input_module : globals.input_name))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment