2001-09-07 18:04:38 +02:00
|
|
|
/*
|
|
|
|
* Option processing and main()
|
|
|
|
*
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-09-07 18:04:38 +02:00
|
|
|
*/
|
|
|
|
|
2002-08-26 23:47:41 +02:00
|
|
|
#include "config.h"
|
2005-08-03 23:25:10 +02:00
|
|
|
#include "wine/port.h"
|
2002-08-26 23:47:41 +02:00
|
|
|
|
|
|
|
#include "winedump.h"
|
2001-09-07 18:04:38 +02:00
|
|
|
|
|
|
|
_globals globals; /* All global variables */
|
|
|
|
|
|
|
|
|
|
|
|
static void do_include (const char *arg)
|
|
|
|
{
|
2004-12-20 17:52:26 +01:00
|
|
|
char *newIncludes;
|
|
|
|
|
|
|
|
if (!globals.directory)
|
|
|
|
globals.directory = strdup(arg);
|
|
|
|
else {
|
|
|
|
newIncludes = str_create (3,globals.directory," ",arg);
|
|
|
|
free(globals.directory);
|
|
|
|
globals.directory = newIncludes;
|
|
|
|
}
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_code = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline const char* strip_ext (const char *str)
|
|
|
|
{
|
2004-12-20 17:52:26 +01:00
|
|
|
int len = strlen(str);
|
|
|
|
if (len>4 && strcmp(str+len-4,".dll") == 0)
|
|
|
|
return str_substring (str, str+len-4);
|
2001-09-07 18:04:38 +02:00
|
|
|
else
|
|
|
|
return strdup (str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_name (const char *arg)
|
|
|
|
{
|
|
|
|
globals.dll_name = strip_ext (arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_spec (const char *arg)
|
|
|
|
{
|
|
|
|
if (globals.mode != NONE) fatal("Only one mode can be specified\n");
|
|
|
|
globals.mode = SPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_demangle (const char *arg)
|
|
|
|
{
|
|
|
|
if (globals.mode != NONE) fatal("Only one mode can be specified\n");
|
|
|
|
globals.mode = DMGL;
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_code = TRUE;
|
|
|
|
globals.do_demangle = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_dump (const char *arg)
|
|
|
|
{
|
|
|
|
if (globals.mode != NONE) fatal("Only one mode can be specified\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
globals.mode = DUMP;
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_code = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_code (const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_code = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_trace (const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_trace = TRUE;
|
|
|
|
globals.do_code = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_forward (const char *arg)
|
|
|
|
{
|
|
|
|
globals.forward_dll = arg;
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_trace = TRUE;
|
|
|
|
globals.do_code = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_document (const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_documentation = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_cdecl (const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_cdecl = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_quiet (const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_quiet = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_start (const char *arg)
|
|
|
|
{
|
|
|
|
globals.start_ordinal = atoi (arg);
|
|
|
|
if (!globals.start_ordinal)
|
|
|
|
fatal ("Invalid -s option (must be numeric)");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_end (const char *arg)
|
|
|
|
{
|
|
|
|
globals.end_ordinal = atoi (arg);
|
|
|
|
if (!globals.end_ordinal)
|
|
|
|
fatal ("Invalid -e option (must be numeric)");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-17 01:59:53 +02:00
|
|
|
static void do_symfile (const char *arg)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char symstring[256]; /* keep count with "%<width>s" below */
|
|
|
|
search_symbol *symbolp,**symbolptail = &globals.search_symbol;
|
|
|
|
|
|
|
|
if (!(f = fopen(arg, "rt")))
|
|
|
|
fatal ("Cannot open <symfile>");
|
|
|
|
while (1 == fscanf(f, "%255s", symstring)) /* keep count with [<width>] above */
|
|
|
|
{
|
|
|
|
symstring[sizeof(symstring)-1] = '\0';
|
|
|
|
if (!(symbolp = malloc(sizeof(*symbolp) + strlen(symstring))))
|
|
|
|
fatal ("Out of memory");
|
|
|
|
strcpy(symbolp->symbolname, symstring);
|
2013-12-05 00:58:10 +01:00
|
|
|
symbolp->found = FALSE;
|
2002-09-17 01:59:53 +02:00
|
|
|
symbolp->next = NULL;
|
|
|
|
*symbolptail = symbolp;
|
|
|
|
symbolptail = &symbolp->next;
|
|
|
|
}
|
|
|
|
if (fclose(f))
|
|
|
|
fatal ("Cannot close <symfile>");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_verbose (const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_verbose = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_symdmngl (const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_demangle = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_dumphead (const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_dumpheader = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_dumpsect (const char* arg)
|
|
|
|
{
|
|
|
|
globals.dumpsect = arg;
|
|
|
|
}
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_rawdebug (const char *arg)
|
2006-08-27 08:50:46 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_debug = TRUE;
|
2006-08-27 08:50:46 +02:00
|
|
|
}
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
static void do_dumpall(const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_dumpheader = TRUE;
|
|
|
|
globals.do_dump_rawdata = TRUE;
|
|
|
|
globals.do_symbol_table = TRUE;
|
2001-09-07 18:04:38 +02:00
|
|
|
globals.dumpsect = "ALL";
|
|
|
|
}
|
|
|
|
|
2009-12-09 20:55:18 +01:00
|
|
|
static void do_symtable(const char* arg)
|
|
|
|
{
|
2013-12-03 23:36:09 +01:00
|
|
|
globals.do_symbol_table = TRUE;
|
2009-12-09 20:55:18 +01:00
|
|
|
}
|
|
|
|
|
2005-10-11 21:55:11 +02:00
|
|
|
struct my_option
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
Mode mode;
|
|
|
|
int has_arg;
|
2009-10-02 14:52:17 +02:00
|
|
|
void (*func)(const char *arg);
|
2001-09-07 18:04:38 +02:00
|
|
|
const char *usage;
|
|
|
|
};
|
|
|
|
|
2005-10-11 21:55:11 +02:00
|
|
|
static const struct my_option option_table[] = {
|
2013-12-03 23:36:08 +01:00
|
|
|
{"--help",NONE, 0, do_usage, "--help Display this help message"},
|
|
|
|
{"-h", NONE, 0, do_usage, "-h Synonym for --help"},
|
|
|
|
{"-?", NONE, 0, do_usage, "-? Synonym for --help"},
|
|
|
|
{"sym", DMGL, 0, do_demangle, "sym <sym> Demangle C++ symbol <sym> and exit"},
|
|
|
|
{"spec", SPEC, 0, do_spec, "spec <dll> Use 'dll' for input file and generate implementation code"},
|
|
|
|
{"-I", SPEC, 1, do_include, "-I <dir> Look for prototypes in 'dir' (implies -c)"},
|
|
|
|
{"-c", SPEC, 0, do_code, "-c Generate skeleton code (requires -I)"},
|
|
|
|
{"-t", SPEC, 0, do_trace, "-t TRACE arguments (implies -c)"},
|
|
|
|
{"-f", SPEC, 1, do_forward, "-f <dll> Forward calls to 'dll' (implies -t)"},
|
|
|
|
{"-D", SPEC, 0, do_document, "-D Generate documentation"},
|
|
|
|
{"-o", SPEC, 1, do_name, "-o <name> Set the output dll name (default: dll). Note: strips .dll extensions"},
|
|
|
|
{"-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 <file> Dump the contents of 'file' (dll, exe, lib...)"},
|
|
|
|
{"-C", DUMP, 0, do_symdmngl, "-C Turn on symbol demangling"},
|
|
|
|
{"-f", DUMP, 0, do_dumphead, "-f Dump file header information"},
|
|
|
|
{"-G", DUMP, 0, do_rawdebug, "-G Dump raw debug information"},
|
2015-07-21 23:19:31 +02:00
|
|
|
{"-j", DUMP, 1, do_dumpsect, "-j <sect_name> Dump only the content of section 'sect_name' (import, export, debug, resource, tls, loadcfg, clr, reloc, except)"},
|
2013-12-03 23:36:08 +01:00
|
|
|
{"-t", DUMP, 0, do_symtable, "-t Dump symbol table"},
|
|
|
|
{"-x", DUMP, 0, do_dumpall, "-x Dump everything"},
|
2001-09-07 18:04:38 +02:00
|
|
|
{NULL, NONE, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2009-10-02 14:52:17 +02:00
|
|
|
void do_usage (const char *arg)
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
2005-10-11 21:55:11 +02:00
|
|
|
const struct my_option *opt;
|
2006-11-29 21:40:21 +01:00
|
|
|
printf ("Usage: winedump [-h | sym <sym> | spec <dll> | dump <file>]\n");
|
2002-05-12 00:58:57 +02:00
|
|
|
printf ("Mode options (can be put as the mode (sym/spec/dump...) is declared):\n");
|
2005-04-15 18:11:13 +02:00
|
|
|
printf ("\tWhen used in --help mode\n");
|
2001-09-07 18:04:38 +02:00
|
|
|
for (opt = option_table; opt->name; opt++)
|
|
|
|
if (opt->mode == NONE)
|
2002-05-12 00:58:57 +02:00
|
|
|
printf ("\t %s\n", opt->usage);
|
|
|
|
printf ("\tWhen used in sym mode\n");
|
2001-09-07 18:04:38 +02:00
|
|
|
for (opt = option_table; opt->name; opt++)
|
|
|
|
if (opt->mode == DMGL)
|
2002-05-12 00:58:57 +02:00
|
|
|
printf ("\t %s\n", opt->usage);
|
|
|
|
printf ("\tWhen used in spec mode\n");
|
2001-09-07 18:04:38 +02:00
|
|
|
for (opt = option_table; opt->name; opt++)
|
|
|
|
if (opt->mode == SPEC)
|
2002-05-12 00:58:57 +02:00
|
|
|
printf ("\t %s\n", opt->usage);
|
|
|
|
printf ("\tWhen used in dump mode\n");
|
2001-09-07 18:04:38 +02:00
|
|
|
for (opt = option_table; opt->name; opt++)
|
|
|
|
if (opt->mode == DUMP)
|
2002-05-12 00:58:57 +02:00
|
|
|
printf ("\t %s\n", opt->usage);
|
2001-09-07 18:04:38 +02:00
|
|
|
|
2005-04-15 18:11:13 +02:00
|
|
|
puts ("");
|
2001-09-07 18:04:38 +02:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* parse_options
|
|
|
|
*
|
|
|
|
* Parse options from the argv array
|
|
|
|
*/
|
|
|
|
static void parse_options (char *argv[])
|
|
|
|
{
|
2005-10-11 21:55:11 +02:00
|
|
|
const struct my_option *opt;
|
2001-09-07 18:04:38 +02:00
|
|
|
char *const *ptr;
|
|
|
|
const char *arg = NULL;
|
|
|
|
|
|
|
|
ptr = argv + 1;
|
|
|
|
|
|
|
|
while (*ptr != NULL)
|
|
|
|
{
|
|
|
|
for (opt = option_table; opt->name; opt++)
|
|
|
|
{
|
|
|
|
if (globals.mode != NONE && opt->mode != NONE && globals.mode != opt->mode)
|
|
|
|
continue;
|
|
|
|
if (((opt->has_arg == 1) && !strncmp (*ptr, opt->name, strlen (opt->name))) ||
|
|
|
|
((opt->has_arg == 2) && !strcmp (*ptr, opt->name)))
|
|
|
|
{
|
|
|
|
arg = *ptr + strlen (opt->name);
|
|
|
|
if (*arg == '\0') arg = *++ptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!strcmp (*ptr, opt->name))
|
|
|
|
{
|
|
|
|
arg = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!opt->name)
|
2002-05-12 00:58:57 +02:00
|
|
|
{
|
|
|
|
if ((*ptr)[0] == '-')
|
|
|
|
fatal ("Unrecognized option");
|
|
|
|
if (globals.input_name != NULL)
|
|
|
|
fatal ("Only one file can be treated at once");
|
|
|
|
globals.input_name = *ptr;
|
|
|
|
}
|
|
|
|
else if (opt->has_arg && arg != NULL)
|
2001-09-07 18:04:38 +02:00
|
|
|
opt->func (arg);
|
|
|
|
else
|
|
|
|
opt->func ("");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-09-07 18:04:38 +02:00
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (globals.mode == SPEC && globals.do_code && !globals.directory)
|
|
|
|
fatal ("-I must be used if generating code");
|
|
|
|
|
|
|
|
if (VERBOSE && QUIET)
|
|
|
|
fatal ("Options -v and -q are mutually exclusive");
|
2006-11-29 21:40:26 +01:00
|
|
|
|
|
|
|
if (globals.mode == NONE)
|
|
|
|
do_dump("");
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
|
2013-12-05 00:58:10 +01:00
|
|
|
static void set_module_name(BOOL setUC)
|
2001-11-06 00:54:11 +01:00
|
|
|
{
|
|
|
|
const char* ptr;
|
|
|
|
char* buf;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* FIXME: we shouldn't assume all module extensions are .dll in winedump
|
|
|
|
* in some cases, we could have some .drv for example
|
|
|
|
*/
|
|
|
|
/* get module name from name */
|
|
|
|
if ((ptr = strrchr (globals.input_name, '/')))
|
|
|
|
ptr++;
|
|
|
|
else
|
|
|
|
ptr = globals.input_name;
|
|
|
|
len = strlen(ptr);
|
|
|
|
if (len > 4 && strcmp(ptr + len - 4, ".dll") == 0)
|
|
|
|
len -= 4;
|
|
|
|
buf = malloc(len + 1);
|
2004-12-06 21:43:55 +01:00
|
|
|
memcpy(buf, (const void*)ptr, len);
|
2001-11-06 00:54:11 +01:00
|
|
|
buf[len] = 0;
|
|
|
|
globals.input_module = buf;
|
|
|
|
OUTPUT_UC_DLL_NAME = (setUC) ? str_toupper( strdup (OUTPUT_DLL_NAME)) : "";
|
|
|
|
}
|
2001-09-07 18:04:38 +02:00
|
|
|
|
2002-09-17 01:59:53 +02:00
|
|
|
/* Marks the symbol as 'found'! */
|
|
|
|
/* return: perform-search */
|
2013-12-03 23:36:09 +01:00
|
|
|
static BOOL symbol_searched(int count, const char *symbolname)
|
2002-09-17 01:59:53 +02:00
|
|
|
{
|
|
|
|
search_symbol *search_symbol;
|
|
|
|
|
|
|
|
if (!(count >= globals.start_ordinal
|
|
|
|
&& (!globals.end_ordinal || count <= globals.end_ordinal)))
|
2013-12-03 23:36:09 +01:00
|
|
|
return FALSE;
|
2002-09-17 01:59:53 +02:00
|
|
|
if (!globals.search_symbol)
|
2013-12-03 23:36:09 +01:00
|
|
|
return TRUE;
|
2002-09-17 01:59:53 +02:00
|
|
|
for (search_symbol = globals.search_symbol;
|
|
|
|
search_symbol;
|
|
|
|
search_symbol = search_symbol->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(symbolname, search_symbol->symbolname))
|
|
|
|
{
|
2013-12-05 00:58:10 +01:00
|
|
|
search_symbol->found = TRUE;
|
2013-12-03 23:36:09 +01:00
|
|
|
return TRUE;
|
2002-09-17 01:59:53 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-03 23:36:09 +01:00
|
|
|
return FALSE;
|
2002-09-17 01:59:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return: some symbols weren't found */
|
2013-12-03 23:36:09 +01:00
|
|
|
static BOOL symbol_finish(void)
|
2002-09-17 01:59:53 +02:00
|
|
|
{
|
|
|
|
const search_symbol *search_symbol;
|
2013-12-03 23:36:09 +01:00
|
|
|
BOOL started = FALSE;
|
2002-09-17 01:59:53 +02:00
|
|
|
|
|
|
|
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 <symfile> symbols weren't found:");
|
2013-12-03 23:36:09 +01:00
|
|
|
started = TRUE;
|
2002-09-17 01:59:53 +02:00
|
|
|
}
|
|
|
|
printf("\t%s\n",search_symbol->symbolname);
|
|
|
|
}
|
|
|
|
return started;
|
|
|
|
}
|
|
|
|
|
2001-09-07 18:04:38 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* main
|
|
|
|
*/
|
|
|
|
#ifdef __GNUC__
|
|
|
|
int main (int argc __attribute__((unused)), char *argv[])
|
|
|
|
#else
|
|
|
|
int main (int argc, char *argv[])
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
parsed_symbol symbol;
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
globals.mode = NONE;
|
2001-10-16 23:46:58 +02:00
|
|
|
globals.forward_dll = NULL;
|
2002-05-12 00:58:57 +02:00
|
|
|
globals.input_name = NULL;
|
2007-01-05 21:42:26 +01:00
|
|
|
globals.dumpsect = NULL;
|
2001-09-07 18:04:38 +02:00
|
|
|
|
|
|
|
parse_options (argv);
|
|
|
|
|
|
|
|
memset (&symbol, 0, sizeof (parsed_symbol));
|
|
|
|
|
|
|
|
switch (globals.mode)
|
|
|
|
{
|
|
|
|
case DMGL:
|
2013-12-03 23:36:09 +01:00
|
|
|
VERBOSE = TRUE;
|
2001-09-17 22:26:27 +02:00
|
|
|
|
2007-02-10 09:10:07 +01:00
|
|
|
if (globals.input_name == NULL)
|
|
|
|
fatal("No symbol name has been given\n");
|
|
|
|
printf("%s\n", get_symbol_str(globals.input_name));
|
2001-09-07 18:04:38 +02:00
|
|
|
break;
|
2001-09-17 22:26:27 +02:00
|
|
|
|
2001-09-07 18:04:38 +02:00
|
|
|
case SPEC:
|
2002-10-07 20:22:09 +02:00
|
|
|
if (globals.input_name == NULL)
|
|
|
|
fatal("No file name has been given\n");
|
2013-12-05 00:58:10 +01:00
|
|
|
set_module_name(TRUE);
|
2004-01-15 02:47:46 +01:00
|
|
|
if (!dll_open (globals.input_name))
|
|
|
|
break;
|
2001-09-07 18:04:38 +02:00
|
|
|
|
|
|
|
output_spec_preamble ();
|
|
|
|
output_header_preamble ();
|
|
|
|
output_c_preamble ();
|
|
|
|
|
2014-01-02 02:16:51 +01:00
|
|
|
while (dll_next_symbol (&symbol))
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
|
|
|
count++;
|
|
|
|
|
|
|
|
if (NORMAL)
|
|
|
|
printf ("Export %3d - '%s' ...%c", count, symbol.symbol,
|
|
|
|
VERBOSE ? '\n' : ' ');
|
|
|
|
|
2002-09-17 01:59:53 +02:00
|
|
|
if (globals.do_code && symbol_searched(count, symbol.symbol))
|
2001-09-07 18:04:38 +02:00
|
|
|
{
|
|
|
|
/* Attempt to get information about the symbol */
|
2014-01-13 21:44:00 +01:00
|
|
|
BOOL result = symbol_demangle (&symbol) || symbol_search(&symbol);
|
2001-09-07 18:04:38 +02:00
|
|
|
|
2014-01-13 21:44:00 +01:00
|
|
|
if (result && symbol.function_name)
|
2001-09-07 18:04:38 +02:00
|
|
|
/* Clean up the prototype */
|
|
|
|
symbol_clean_string (symbol.function_name);
|
|
|
|
|
|
|
|
if (NORMAL)
|
2014-01-13 21:44:00 +01:00
|
|
|
puts (result ? "[OK]" : "[Not Found]");
|
2001-09-07 18:04:38 +02:00
|
|
|
}
|
|
|
|
else if (NORMAL)
|
|
|
|
puts ("[Ignoring]");
|
|
|
|
|
|
|
|
output_spec_symbol (&symbol);
|
|
|
|
output_header_symbol (&symbol);
|
|
|
|
output_c_symbol (&symbol);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-09-07 18:04:38 +02:00
|
|
|
symbol_clear (&symbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
output_makefile ();
|
|
|
|
|
|
|
|
if (VERBOSE)
|
|
|
|
puts ("Finished, Cleaning up...");
|
2002-09-17 01:59:53 +02:00
|
|
|
if (symbol_finish())
|
|
|
|
return 1;
|
2001-09-07 18:04:38 +02:00
|
|
|
break;
|
|
|
|
case NONE:
|
2009-10-02 14:52:17 +02:00
|
|
|
do_usage(0);
|
2001-09-07 18:04:38 +02:00
|
|
|
break;
|
|
|
|
case DUMP:
|
2002-10-07 20:22:09 +02:00
|
|
|
if (globals.input_name == NULL)
|
|
|
|
fatal("No file name has been given\n");
|
2013-12-05 00:58:10 +01:00
|
|
|
set_module_name(FALSE);
|
2001-09-07 18:04:38 +02:00
|
|
|
dump_file(globals.input_name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|