diff --git a/tools/winedump/main.c b/tools/winedump/main.c index e0162a276aa..d0453cf10e2 100644 --- a/tools/winedump/main.c +++ b/tools/winedump/main.c @@ -124,6 +124,30 @@ static void do_end (const char *arg) } +static void do_symfile (const char *arg) +{ + FILE *f; + char symstring[256]; /* keep count with "%s" below */ + search_symbol *symbolp,**symbolptail = &globals.search_symbol; + + if (!(f = fopen(arg, "rt"))) + fatal ("Cannot open "); + while (1 == fscanf(f, "%255s", symstring)) /* keep count with [] above */ + { + symstring[sizeof(symstring)-1] = '\0'; + if (!(symbolp = malloc(sizeof(*symbolp) + strlen(symstring)))) + fatal ("Out of memory"); + strcpy(symbolp->symbolname, symstring); + symbolp->found = 0; + symbolp->next = NULL; + *symbolptail = symbolp; + symbolptail = &symbolp->next; + } + if (fclose(f)) + fatal ("Cannot close "); +} + + static void do_verbose (void) { globals.do_verbose = 1; @@ -173,6 +197,7 @@ static const struct option option_table[] = { {"-C", SPEC, 0, do_cdecl, "-C Assume __cdecl calls (default: __stdcall)"}, {"-s", SPEC, 1, do_start, "-s num Start prototype search after symbol 'num'"}, {"-e", SPEC, 1, do_end, "-e num End prototype search after symbol 'num'"}, + {"-S", SPEC, 1, do_symfile, "-S symfile Search only prototype names found in 'symfile'"}, {"-q", SPEC, 0, do_quiet, "-q Don't show progress (quiet)."}, {"-v", SPEC, 0, do_verbose, "-v Show lots of detail while working (verbose)."}, {"dump", DUMP, 0, do_dump, "dump Dumps the content of the module (dll, exe...) named "}, @@ -290,6 +315,54 @@ static void set_module_name(unsigned setUC) OUTPUT_UC_DLL_NAME = (setUC) ? str_toupper( strdup (OUTPUT_DLL_NAME)) : ""; } +/* Marks the symbol as 'found'! */ +/* return: perform-search */ +static int symbol_searched(int count, const char *symbolname) +{ + search_symbol *search_symbol; + + if (!(count >= globals.start_ordinal + && (!globals.end_ordinal || count <= globals.end_ordinal))) + return 0; + if (!globals.search_symbol) + return 1; + for (search_symbol = globals.search_symbol; + search_symbol; + search_symbol = search_symbol->next) + { + if (!strcmp(symbolname, search_symbol->symbolname)) + { + search_symbol->found = 1; + return 1; + } + } + return 0; +} + +/* return: some symbols weren't found */ +static int symbol_finish(void) +{ + const search_symbol *search_symbol; + int started = 0; + + for (search_symbol = globals.search_symbol; + search_symbol; + search_symbol = search_symbol->next) + { + if (search_symbol->found) + continue; + if (!started) + { + /* stderr? not a practice here */ + puts("These requested symbols weren't found:"); + started = 1; + } + printf("\t%s\n",search_symbol->symbolname); + return 1; + } + return started; +} + /******************************************************************* * main */ @@ -344,8 +417,7 @@ int main (int argc, char *argv[]) printf ("Export %3d - '%s' ...%c", count, symbol.symbol, VERBOSE ? '\n' : ' '); - if (globals.do_code && count >= globals.start_ordinal - && (!globals.end_ordinal || count <= globals.end_ordinal)) + if (globals.do_code && symbol_searched(count, symbol.symbol)) { /* Attempt to get information about the symbol */ int result = symbol_demangle (&symbol); @@ -375,6 +447,8 @@ int main (int argc, char *argv[]) if (VERBOSE) puts ("Finished, Cleaning up..."); + if (symbol_finish()) + return 1; break; case NONE: do_usage(); diff --git a/tools/winedump/winedump.h b/tools/winedump/winedump.h index 8d4dce95a97..d3c8795d010 100644 --- a/tools/winedump/winedump.h +++ b/tools/winedump/winedump.h @@ -91,6 +91,14 @@ typedef struct __parsed_symbol char *arg_name [MAX_FUNCTION_ARGS]; } parsed_symbol; +/* FIXME: Replace with some hash such as GHashTable */ +typedef struct __search_symbol +{ + struct __search_symbol *next; + int found; + char symbolname[1]; /* static string, be ANSI C compliant by [1] */ +} search_symbol; + /* All globals */ typedef struct __globals { @@ -117,6 +125,7 @@ typedef struct __globals /* Option arguments: spec mode */ int start_ordinal; /* -s */ int end_ordinal; /* -e */ + search_symbol *search_symbol; /* -S */ const char *directory; /* -I */ const char *forward_dll; /* -f */ const char *dll_name; /* -o */