mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
Fixed and globalized some path and module name handling.
Tweaked the demangling of function pointers as function parameters.
This commit is contained in:
parent
2f9eb3b0cb
commit
de6d4e211b
@ -36,7 +36,7 @@ static void do_spec (const char *arg)
|
||||
{
|
||||
if (globals.mode != NONE) fatal("Only one mode can be specified\n");
|
||||
globals.mode = SPEC;
|
||||
globals.input_name = strip_ext (arg);
|
||||
globals.input_name = arg;
|
||||
}
|
||||
|
||||
|
||||
@ -162,7 +162,7 @@ static const struct option option_table[] = {
|
||||
{"-e", SPEC, 1, do_end, "-e num End prototype search after symbol 'num'"},
|
||||
{"-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, 2, do_dump, "dump <dll> Dumps the content of the dll named <dll>"},
|
||||
{"dump", DUMP, 2, do_dump, "dump <mod> Dumps the content of the module (dll, exe...) named <mod>"},
|
||||
{"-C", DUMP, 0, do_symdmngl, "-C Turns on symbol demangling"},
|
||||
{"-f", DUMP, 0, do_dumphead, "-f Dumps file header information"},
|
||||
{"-j", DUMP, 1, do_dumpsect, "-j sect_name Dumps only the content of section sect_name (import, export, debug)"},
|
||||
@ -247,6 +247,29 @@ static void parse_options (char *argv[])
|
||||
fatal ("Options -v and -q are mutually exclusive");
|
||||
}
|
||||
|
||||
static void set_module_name(unsigned setUC)
|
||||
{
|
||||
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);
|
||||
memcpy(buf, (void*)ptr, len);
|
||||
buf[len] = 0;
|
||||
globals.input_module = buf;
|
||||
OUTPUT_UC_DLL_NAME = (setUC) ? str_toupper( strdup (OUTPUT_DLL_NAME)) : "";
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* main
|
||||
@ -274,6 +297,7 @@ int main (int argc, char *argv[])
|
||||
VERBOSE = 1;
|
||||
|
||||
symbol_init (&symbol, globals.input_name);
|
||||
globals.input_module = "";
|
||||
if (symbol_demangle (&symbol) == -1)
|
||||
fatal( "Symbol hasn't got a mangled name\n");
|
||||
if (symbol.flags & SYM_DATA)
|
||||
@ -285,6 +309,7 @@ int main (int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case SPEC:
|
||||
set_module_name(1);
|
||||
dll_open (globals.input_name);
|
||||
|
||||
output_spec_preamble ();
|
||||
@ -335,7 +360,7 @@ int main (int argc, char *argv[])
|
||||
do_usage();
|
||||
break;
|
||||
case DUMP:
|
||||
globals.uc_dll_name = "";
|
||||
set_module_name(0);
|
||||
dump_file(globals.input_name);
|
||||
break;
|
||||
}
|
||||
|
@ -487,15 +487,43 @@ static char *demangle_datatype (char **str, compound_type *ct,
|
||||
/* FIXME: P6 = Function pointer, others who knows.. */
|
||||
if (isdigit (*iter))
|
||||
{
|
||||
if (*iter == '6') printf("Function pointer in argument list is not handled yet\n");
|
||||
return NULL;
|
||||
if (*iter == '6')
|
||||
{
|
||||
/* FIXME: there are a tons of memory leaks here */
|
||||
/* FIXME: this is still broken in some cases and it has to be
|
||||
* merged with the function prototype parsing above...
|
||||
*/
|
||||
iter += 3; /* FIXME */
|
||||
if (!demangle_datatype (&iter, &sub_ct, sym))
|
||||
return NULL;
|
||||
ct->expression = str_create(2, sub_ct.expression, " (*)(");
|
||||
if (*iter != '@')
|
||||
{
|
||||
while (*iter != 'Z')
|
||||
{
|
||||
FREE_CT (sub_ct);
|
||||
INIT_CT (sub_ct);
|
||||
if (!demangle_datatype (&iter, &sub_ct, sym))
|
||||
return NULL;
|
||||
ct->expression = str_create(3, ct->expression, ", ", sub_ct.expression);
|
||||
while (*iter == '@') iter++;
|
||||
}
|
||||
} else while (*iter == '@') iter++;
|
||||
iter++;
|
||||
ct->expression = str_create(2, ct->expression, ")");
|
||||
FREE_CT (sub_ct);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Recurse to get the pointed-to type */
|
||||
if (!demangle_datatype (&iter, &sub_ct, sym))
|
||||
return NULL;
|
||||
|
||||
/* Recurse to get the pointed-to type */
|
||||
if (!demangle_datatype (&iter, &sub_ct, sym))
|
||||
return NULL;
|
||||
|
||||
ct->expression = get_pointer_type_string (ct, sub_ct.expression);
|
||||
ct->expression = get_pointer_type_string (ct, sub_ct.expression);
|
||||
}
|
||||
|
||||
FREE_CT (sub_ct);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ void output_spec_preamble (void)
|
||||
puts ("Creating .spec preamble");
|
||||
|
||||
fprintf (specfile,
|
||||
"# Generated from %s.dll by winedump\nname %s\n"
|
||||
"# Generated from %s by winedump\nname %s\n"
|
||||
"type win32\ninit %s_Init\n\nimport kernel32.dll\n"
|
||||
"import ntdll.dll\n", globals.input_name, OUTPUT_DLL_NAME,
|
||||
OUTPUT_UC_DLL_NAME);
|
||||
@ -199,7 +199,7 @@ void output_c_preamble (void)
|
||||
atexit (output_c_postamble);
|
||||
|
||||
fprintf (cfile,
|
||||
"/*\n * %s.dll\n *\n * Generated from %s.dll by winedump.\n *\n"
|
||||
"/*\n * %s.dll\n *\n * Generated from %s by winedump.\n *\n"
|
||||
" * DO NOT SUBMIT GENERATED DLLS FOR INCLUSION INTO WINE!\n * \n */"
|
||||
"\n\n#include \"%s_dll.h\"\n\nDEFAULT_DEBUG_CHANNEL(%s);\n\n",
|
||||
OUTPUT_DLL_NAME, globals.input_name, OUTPUT_DLL_NAME,
|
||||
@ -419,7 +419,7 @@ void output_makefile (void)
|
||||
puts ("Creating makefile");
|
||||
|
||||
fprintf (makefile,
|
||||
"# Generated from %s.dll by winedump.\nTOPSRCDIR = @top_srcdir@\n"
|
||||
"# Generated from %s by winedump.\nTOPSRCDIR = @top_srcdir@\n"
|
||||
"TOPOBJDIR = ../..\nSRCDIR = @srcdir@\nVPATH = @srcdir@\n"
|
||||
"MODULE = %s\nEXTRALIBS = $(LIBUNICODE)\n\n"
|
||||
"LDDLLFLAGS = @LDDLLFLAGS@\nSYMBOLFILE = $(MODULE).tmp.o\n\n"
|
||||
|
@ -653,20 +653,13 @@ static enum FileSig check_headers(void)
|
||||
int pe_analysis(const char* name, void (*fn)(void), enum FileSig wanted_sig)
|
||||
{
|
||||
int fd;
|
||||
int len;
|
||||
enum FileSig effective_sig;
|
||||
int ret = 1;
|
||||
struct stat s;
|
||||
char *name_suffix;
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
len = strlen(name) + 5;
|
||||
name_suffix = malloc(len);
|
||||
strcpy(name_suffix, name);
|
||||
strcat(name_suffix, ".dll");
|
||||
|
||||
fd = open(name_suffix, O_RDONLY);
|
||||
fd = open(name, O_RDONLY);
|
||||
if (fd == -1) fatal("Can't open file");
|
||||
|
||||
if (fstat(fd, &s) < 0) fatal("Can't get size");
|
||||
@ -798,11 +791,6 @@ static void do_grab_sym(void)
|
||||
pFunc = RVA(exportDir->AddressOfFunctions, exportDir->NumberOfFunctions * sizeof(DWORD));
|
||||
if (!pFunc) {printf("Can't grab functions' address table\n"); return;}
|
||||
|
||||
/* Set DLL output names */
|
||||
if ((ptr = strrchr (globals.input_name, '/')))
|
||||
globals.input_name = ptr + 1; /* Strip path */
|
||||
OUTPUT_UC_DLL_NAME = str_toupper( strdup (OUTPUT_DLL_NAME));
|
||||
|
||||
for (i = 0; i < exportDir->NumberOfFunctions; i++)
|
||||
{
|
||||
if (pFunc[i] && !(map[i / 32] & (1 << (i % 32))))
|
||||
|
@ -88,6 +88,7 @@ typedef struct __globals
|
||||
|
||||
/* Option arguments: generic */
|
||||
const char *input_name; /* */
|
||||
const char *input_module; /* input module name generated after input_name according mode */
|
||||
|
||||
/* Options: spec mode */
|
||||
int do_code; /* -c, -t, -f */
|
||||
@ -118,7 +119,7 @@ extern _globals globals;
|
||||
|
||||
/* Names to use for output DLL */
|
||||
#define OUTPUT_DLL_NAME \
|
||||
(globals.dll_name ? globals.dll_name : globals.input_name)
|
||||
(globals.dll_name ? globals.dll_name : (globals.input_module ? globals.input_module : globals.input_name))
|
||||
#define OUTPUT_UC_DLL_NAME globals.uc_dll_name
|
||||
|
||||
/* Verbosity levels */
|
||||
|
Loading…
Reference in New Issue
Block a user