Commit d786a12d authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Added PE dump capabilities to specmaker and renamed specmaker into

winedump.
parent f876b5df
...@@ -7155,10 +7155,9 @@ relay32/Makefile ...@@ -7155,10 +7155,9 @@ relay32/Makefile
scheduler/Makefile scheduler/Makefile
server/Makefile server/Makefile
tools/Makefile tools/Makefile
tools/cvdump/Makefile
tools/specmaker/Makefile
tools/winapi/Makefile tools/winapi/Makefile
tools/winebuild/Makefile tools/winebuild/Makefile
tools/winedump/Makefile
tools/winelauncher tools/winelauncher
tools/wmc/Makefile tools/wmc/Makefile
tools/wrc/Makefile tools/wrc/Makefile
...@@ -7410,10 +7409,9 @@ relay32/Makefile ...@@ -7410,10 +7409,9 @@ relay32/Makefile
scheduler/Makefile scheduler/Makefile
server/Makefile server/Makefile
tools/Makefile tools/Makefile
tools/cvdump/Makefile
tools/specmaker/Makefile
tools/winapi/Makefile tools/winapi/Makefile
tools/winebuild/Makefile tools/winebuild/Makefile
tools/winedump/Makefile
tools/winelauncher tools/winelauncher
tools/wmc/Makefile tools/wmc/Makefile
tools/wrc/Makefile tools/wrc/Makefile
......
...@@ -1350,10 +1350,9 @@ relay32/Makefile ...@@ -1350,10 +1350,9 @@ relay32/Makefile
scheduler/Makefile scheduler/Makefile
server/Makefile server/Makefile
tools/Makefile tools/Makefile
tools/cvdump/Makefile
tools/specmaker/Makefile
tools/winapi/Makefile tools/winapi/Makefile
tools/winebuild/Makefile tools/winebuild/Makefile
tools/winedump/Makefile
tools/winelauncher tools/winelauncher
tools/wmc/Makefile tools/wmc/Makefile
tools/wrc/Makefile tools/wrc/Makefile
......
...@@ -10,15 +10,14 @@ MODULE = none ...@@ -10,15 +10,14 @@ MODULE = none
C_SRCS = makedep.c fnt2bdf.c bin2res.c C_SRCS = makedep.c fnt2bdf.c bin2res.c
SUBDIRS = \ SUBDIRS = \
cvdump \
specmaker \
winebuild \ winebuild \
winedump \
wmc \ wmc \
wrc wrc
INSTALLSUBDIRS = \ INSTALLSUBDIRS = \
specmaker \
winebuild \ winebuild \
winedump \
wmc \ wmc \
wrc wrc
...@@ -28,7 +27,7 @@ EXTRASUBDIRS = \ ...@@ -28,7 +27,7 @@ EXTRASUBDIRS = \
winapi_check/win32 \ winapi_check/win32 \
wineconf.libs wineconf.libs
all: $(PROGRAMS) specmaker winebuild wmc wrc all: $(PROGRAMS) winebuild winedump wmc wrc
@MAKE_RULES@ @MAKE_RULES@
......
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
PROGRAMS = cvdump
MODULE = none
C_SRCS = cvcrunch.c cvdump.c cvload.c
all: $(PROGRAMS)
@MAKE_RULES@
cvdump: $(OBJS)
$(CC) $(CFLAGS) -o cvdump $(OBJS)
### Dependencies:
/*
* Functions to process in-memory arrays of CodeView data sections
* (currently only contains sstSrcModule).
*
* Copyright 2000 John R. Sheets
*/
/* FIXME - Change to cvprint.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include "cvinclude.h"
/************************ sstSrcModule ************************/
/* Print out stuff in OMFSourceModule block. Rather than using the supplied
* OMFSourceModule struct, we'll extract each piece of data separately from
* the block of memory (rawdata). This struct (and the others used in
* sstSrcModule sections) is pretty useless. We can't use sizeof() on it
* because it contains the first element of the file offset array (i.e. baseSrcFile),
* which we need to parse separately anyway. See below for problems with the
* other structs.
*
* The contents of this section look like this (the first two fields are
* extracted and passed back out):
*
* unsigned short cFile
* unsigned short cSeg
* unsigned long baseSrcFile[cFile]
* unsigned long segarray[cSeg * 2]
* unsigned short segindexarray[cSeg]
*/
int PrintSrcModuleInfo (BYTE* rawdata, short *filecount, short *segcount)
{
int i;
int datalen;
unsigned short cFile;
unsigned short cSeg;
unsigned long *baseSrcFile;
unsigned long *segarray;
unsigned short *segindexarray;
/* Get all our pointers straightened out
*/
cFile = *(short*)rawdata;
cSeg = *(short*)(rawdata + 2);
baseSrcFile = (long*)(rawdata + 4);
segarray = &baseSrcFile[cFile];
segindexarray = (short*)(&segarray[cSeg * 2]);
/* Pass # of segments and files back to calling function
*/
*filecount = cFile;
*segcount = cSeg;
printf ("\n Module table: Found %d file(s) and %d segment(s)\n", cFile, cSeg);
for (i = 0; i < cFile; i++)
{
printf (" File #%d begins at an offset of 0x%lx in this section\n",
i + 1, baseSrcFile[i]);
}
for (i = 0; i < cSeg; i++)
{
printf (" Segment #%d start = 0x%lx, end = 0x%lx, seg index = %d\n",
i + 1, segarray[i * 2], segarray[(i * 2) + 1], segindexarray[i]);
}
/* Return the total length of the data (in bytes) that we used, so
* we'll know how far to jump ahead for the next part of the sstSrcModule.
*/
datalen = ((BYTE*)(&segindexarray[cSeg]) - rawdata);
/* printf ("datalen before padding = %d\n", datalen); */
if (datalen % 4)
datalen += 4 - (datalen % 4);
/* printf ("datalen after padding = %d\n", datalen); */
return datalen;
}
/* Print out the contents of a OMFSourceFile block. Unfortunately, the official
* version of this struct (probably quite outdated) claims that the 'cFName' field
* is a short. Based on experimentation with MSVC 5.0 .DBG files, this field is
* quite clearly only a single byte. Yet another reason to do it all by hand
* and avoid the "official" structs.
*
* The contents of this section look like this (the first field is
* pre-extracted, and 'pad' is ignored):
*
* unsigned short cSeg
* unsigned short pad
* unsigned long baseSrcLn[cSeg]
* unsigned long segarray[cSeg * 2]
* char cFName
* char Name[cFName]
*/
int PrintSrcModuleFileInfo (BYTE* rawdata)
{
int i;
int datalen;
unsigned short cSeg;
unsigned long *baseSrcLn;
unsigned long *segarray;
unsigned char cFName;
char Name[256];
/* Get all our pointers straightened out
*/
cSeg = *(short*)(rawdata);
/* Skip the 'pad' field */
baseSrcLn = (long*)(rawdata + 4);
segarray = &baseSrcLn[cSeg];
cFName = *((char*)&segarray[cSeg * 2]);
snprintf (Name, cFName + 1, "%s", (char*)&segarray[cSeg * 2] + 1);
/* printf ("cSeg = %d\n", cSeg); */
printf ("\n File table: '%s'\n", Name);
for (i = 0; i < cSeg; i++)
{
printf (" Segment #%d start = 0x%lx, end = 0x%lx, offset = 0x%lx\n",
i + 1, segarray[i * 2], segarray[(i * 2) + 1], baseSrcLn[i]);
}
/* Return the total length of the data (in bytes) that we used, so
* we'll know how far to jump ahead for the next part of the sstSrcModule.
*/
datalen = ((BYTE*)(&segarray[cSeg * 2]) + cFName + 1 - rawdata);
/* printf ("datalen before padding = %d\n", datalen); */
if (datalen % 4)
datalen += 4 - (datalen % 4);
/* printf ("datalen after padding = %d\n", datalen); */
return datalen;
}
/* Print out the contents of a OMFSourceLine block. The contents of this section
* look like this:
*
* unsigned short Seg
* unsigned short cPair
* unsigned long offset[cPair]
* unsigned long linenumber[cPair]
*/
int PrintSrcModuleLineInfo (BYTE* rawdata, int tablecount)
{
int i;
int datalen;
unsigned short Seg;
unsigned short cPair;
unsigned long *offset;
unsigned short *linenumber;
Seg = *(short*)rawdata;
cPair = *(short*)(rawdata + 2);
offset = (long*)(rawdata + 4);
linenumber = (short*)&offset[cPair];
printf ("\n Line table #%d: Found %d line numbers for segment index %d\n",
tablecount, cPair, Seg);
for (i = 0; i < cPair; i++)
{
printf (" Pair #%2d: offset = [0x%8lx], linenumber = %d\n",
i + 1, offset[i], linenumber[i]);
}
/* Return the total length of the data (in bytes) that we used, so
* we'll know how far to jump ahead for the next part of the sstSrcModule.
*/
datalen = ((BYTE*)(&linenumber[cPair]) - rawdata);
/* printf ("datalen before padding = %d\n", datalen); */
if (datalen % 4)
datalen += 4 - (datalen % 4);
/* printf ("datalen after padding = %d\n", datalen); */
return datalen;
}
/*
* Includes for cvdump tool.
*
* Copyright 2000 John R. Sheets
*/
/* #define VERBOSE */
#include "cvinclude.h"
typedef enum { CV_NONE, CV_DOS, CV_NT, CV_DBG } CVHeaderType;
/*
* Function Prototypes
*/
/* From cvload.c */
CVHeaderType GetHeaderType (FILE *debugfile);
int ReadDOSFileHeader (FILE *debugfile, IMAGE_DOS_HEADER *doshdr);
int ReadPEFileHeader (FILE *debugfile, IMAGE_NT_HEADERS *nthdr);
int ReadDBGFileHeader (FILE *debugfile, IMAGE_SEPARATE_DEBUG_HEADER *dbghdr);
int ReadSectionHeaders (FILE *debugfile, int numsects, IMAGE_SECTION_HEADER **secthdrs);
int ReadDebugDir (FILE *debugfile, int numdirs, IMAGE_DEBUG_DIRECTORY **debugdirs);
int ReadCodeViewHeader (FILE *debugfile, OMFSignature *sig, OMFDirHeader *dirhdr);
int ReadCodeViewDirectory (FILE *debugfile, int entrynum, OMFDirEntry **entries);
int ReadModuleData (FILE *debugfile, int entrynum, OMFDirEntry *entries,
int *module_count, OMFModuleFull **modules);
int ReadChunk (FILE *debugfile, void *dest, int length, int fileoffset);
/* From cvprint.c */
int PrintSrcModuleInfo (BYTE* rawdata, short *filecount, short *segcount);
int PrintSrcModuleFileInfo (BYTE* rawdata);
int PrintSrcModuleLineInfo (BYTE* rawdata, int tablecount);
/*
* DLL symbol extraction
*
* Copyright 2000 Jon Griffiths
*/
#include "specmaker.h"
/* DOS/PE Header details */
#define DOS_HEADER_LEN 64
#define DOS_MAGIC 0x5a4d
#define DOS_PE_OFFSET 60
#define PE_HEADER_LEN 248
#define PE_MAGIC 0x4550
#define PE_COUNT_OFFSET 6
#define PE_EXPORTS_OFFSET 120
#define PE_EXPORTS_SIZE PE_EXPORTS_OFFSET + 4
#define SECTION_HEADER_LEN 40
#define SECTION_ADDR_OFFSET 12
#define SECTION_ADDR_SIZE SECTION_ADDR_OFFSET + 4
#define SECTION_POS_OFFSET SECTION_ADDR_SIZE + 4
#define ORDINAL_BASE_OFFSET 16
#define ORDINAL_COUNT_OFFSET 20
#define ORDINAL_NAME_OFFSET ORDINAL_COUNT_OFFSET + 16
#define EXPORT_COUNT_OFFSET 24
#define EXPORT_NAME_OFFSET EXPORT_COUNT_OFFSET + 8
/* Minimum memory needed to read both headers into a buffer */
#define MIN_HEADER_LEN (PE_HEADER_LEN * sizeof (unsigned char))
/* Normalise a pointer in the exports section */
#define REBASE(x) ((x) - exports)
/* Module globals */
typedef struct _dll_symbol {
size_t ordinal;
char *symbol;
} dll_symbol;
static FILE *dll_file = NULL;
static dll_symbol *dll_symbols = NULL;
static size_t dll_num_exports = 0;
static size_t dll_num_ordinals = 0;
static int dll_ordinal_base = 0;
static dll_symbol *dll_current_symbol = NULL;
static unsigned int dll_current_export = 0;
/* Get a short from a memory block */
static inline size_t get_short (const char *mem)
{
return *((const unsigned char *)mem) +
(*((const unsigned char *)mem + 1) << 8);
}
/* Get an integer from a memory block */
static inline size_t get_int (const char *mem)
{
assert (sizeof (char) == (size_t)1);
return get_short (mem) + (get_short (mem + 2) << 16);
}
/* Compare symbols by ordinal for qsort */
static int symbol_cmp(const void *left, const void *right)
{
return ((dll_symbol *)left)->ordinal > ((dll_symbol *)right)->ordinal;
}
static void dll_close (void);
/*******************************************************************
* dll_open
*
* Open a DLL and read in exported symbols
*/
void dll_open (const char *dll_name)
{
size_t code = 0, code_len = 0, exports, exports_len, count, symbol_data;
size_t ordinal_data;
char *buff = NULL;
dll_file = open_file (dll_name, ".dll", "r");
atexit (dll_close);
/* Read in the required DOS and PE Headers */
if (!(buff = (char *) malloc (MIN_HEADER_LEN)))
fatal ("Out of memory");
if (fread (buff, DOS_HEADER_LEN, 1, dll_file) != 1 ||
get_short (buff) != DOS_MAGIC)
fatal ("Error reading DOS header");
if (fseek (dll_file, get_int (buff + DOS_PE_OFFSET), SEEK_SET) == -1)
fatal ("Error seeking PE header");
if (fread (buff, PE_HEADER_LEN, 1, dll_file) != 1 ||
get_int (buff) != PE_MAGIC)
fatal ("Error reading PE header");
exports = get_int (buff + PE_EXPORTS_OFFSET);
exports_len = get_int (buff + PE_EXPORTS_SIZE);
if (!exports || !exports_len)
fatal ("No exports in DLL");
if (!(count = get_short (buff + PE_COUNT_OFFSET)))
fatal ("No sections in DLL");
if (VERBOSE)
printf ("DLL has %d sections\n", count);
/* Iterate through sections until we find exports */
while (count--)
{
if (fread (buff, SECTION_HEADER_LEN, 1, dll_file) != 1)
fatal ("Section read error");
code = get_int (buff + SECTION_ADDR_OFFSET);
code_len = get_int (buff + SECTION_ADDR_SIZE);
if (code <= exports && code + code_len > exports)
break;
}
if (!count)
fatal ("No export section");
code_len -= (exports - code);
if (code_len < exports_len)
fatal ("Corrupt exports");
/* Load exports section */
if (fseek (dll_file, get_int (buff + SECTION_POS_OFFSET)
+ exports - code, SEEK_SET) == -1)
fatal ("Export section seek error");
if (VERBOSE)
printf ("Export data size = %d bytes\n", code_len);
if (!(buff = (char *) realloc (buff, code_len)))
fatal ("Out of memory");
if (fread (buff, code_len, 1, dll_file) != 1)
fatal ("Read error");
dll_close();
/* Locate symbol names/ordinals */
symbol_data = REBASE( get_int (buff + EXPORT_NAME_OFFSET));
ordinal_data = REBASE( get_int (buff + ORDINAL_NAME_OFFSET));
if (symbol_data > code_len)
fatal ("Corrupt exports section");
if (!(dll_num_ordinals = get_int (buff + ORDINAL_COUNT_OFFSET)))
fatal ("No ordinal count");
if (!(dll_num_exports = get_int (buff + EXPORT_COUNT_OFFSET)))
fatal ("No export count");
if (!(dll_symbols = (dll_symbol *) malloc ((dll_num_exports + 1) * sizeof (dll_symbol))))
fatal ("Out of memory");
dll_ordinal_base = get_int (buff + ORDINAL_BASE_OFFSET);
if (dll_num_exports != dll_num_ordinals || dll_ordinal_base > 1)
globals.do_ordinals = 1;
/* Read symbol names into 'dll_symbols' */
count = 0;
while (count < dll_num_exports)
{
const int symbol_offset = get_int (buff + symbol_data + count * 4);
const char *symbol_name_ptr = REBASE (buff + symbol_offset);
const int ordinal_offset = get_short (buff + ordinal_data + count * 2);
assert(symbol_name_ptr);
dll_symbols[count].symbol = strdup (symbol_name_ptr);
assert(dll_symbols[count].symbol);
dll_symbols[count].ordinal = ordinal_offset + dll_ordinal_base;
count++;
}
if (NORMAL)
printf ("%d named symbols in DLL, %d total\n", dll_num_exports, dll_num_ordinals);
free (buff);
qsort( dll_symbols, dll_num_exports, sizeof(dll_symbol), symbol_cmp );
dll_symbols[dll_num_exports].symbol = NULL;
dll_current_symbol = dll_symbols;
dll_current_export = dll_ordinal_base;
/* Set DLL output names */
if ((buff = strrchr (globals.input_name, '/')))
globals.input_name = buff + 1; /* Strip path */
OUTPUT_UC_DLL_NAME = str_toupper( strdup (OUTPUT_DLL_NAME));
}
/*******************************************************************
* dll_next_symbol
*
* Get next exported symbol from dll
*/
int dll_next_symbol (parsed_symbol * sym)
{
char ordinal_text[256];
if (dll_current_export > dll_num_ordinals)
return 1;
assert (dll_symbols);
if (!dll_current_symbol->symbol || dll_current_export < dll_current_symbol->ordinal)
{
assert(globals.do_ordinals);
/* Ordinal only entry */
snprintf (ordinal_text, sizeof(ordinal_text), "%s_%d",
globals.forward_dll ? globals.forward_dll : OUTPUT_UC_DLL_NAME,
dll_current_export);
str_toupper(ordinal_text);
sym->symbol = strdup (ordinal_text);
}
else
{
sym->symbol = strdup (dll_current_symbol->symbol);
dll_current_symbol++;
}
sym->ordinal = dll_current_export;
dll_current_export++;
return 0;
}
/*******************************************************************
* dll_close
*
* Free resources used by DLL
*/
static void dll_close (void)
{
size_t i;
if (dll_file)
{
fclose (dll_file);
dll_file = NULL;
}
if (dll_symbols)
{
for (i = 0; i < dll_num_exports; i++)
if (dll_symbols [i].symbol)
free (dll_symbols [i].symbol);
free (dll_symbols);
dll_symbols = NULL;
}
}
...@@ -4,15 +4,16 @@ TOPOBJDIR = ../.. ...@@ -4,15 +4,16 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
PROGRAMS = specmaker PROGRAMS = winedump
MODULE = none MODULE = none
C_SRCS = \ C_SRCS = \
dll.c \ debug.c \
main.c \ main.c \
misc.c \ misc.c \
msmangle.c \ msmangle.c \
output.c \ output.c \
pe.c \
search.c \ search.c \
symbol.c symbol.c
...@@ -20,16 +21,16 @@ all: $(PROGRAMS) ...@@ -20,16 +21,16 @@ all: $(PROGRAMS)
@MAKE_RULES@ @MAKE_RULES@
specmaker: $(OBJS) winedump: $(OBJS)
$(CC) $(CFLAGS) -o specmaker $(OBJS) $(LDFLAGS) $(CC) $(CFLAGS) -o winedump $(OBJS) $(LDFLAGS)
install:: $(PROGRAMS) install:: $(PROGRAMS)
[ -d $(bindir) ] || $(MKDIR) $(bindir) [ -d $(bindir) ] || $(MKDIR) $(bindir)
$(INSTALL_PROGRAM) specmaker $(bindir)/specmaker $(INSTALL_PROGRAM) winedump $(bindir)/winedump
$(INSTALL_SCRIPT) $(SRCDIR)/function_grep.pl $(bindir)/function_grep.pl $(INSTALL_SCRIPT) $(SRCDIR)/function_grep.pl $(bindir)/function_grep.pl
uninstall:: uninstall::
$(RM) $(bindir)/specmaker $(RM) $(bindir)/winedump
$(RM) $(bindir)/function_grep.pl $(RM) $(bindir)/function_grep.pl
### Dependencies: ### Dependencies:
...@@ -24,16 +24,6 @@ ...@@ -24,16 +24,6 @@
#include "pshpack1.h" #include "pshpack1.h"
/* FIXME: no idea if this is correct */
typedef struct
{
DWORD unknown1;
DWORD SizeOfData;
WORD unknown2;
WORD unknown3;
char Name[MAX_PATH];
} IMAGE_DEBUG_DIRECTORY_MISC;
/* /*
* CodeView headers * CodeView headers
*/ */
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 Jon Griffiths * Copyright 2000 Jon Griffiths
*/ */
#include "specmaker.h" #include "winedump.h"
/******************************************************************* /*******************************************************************
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 Jon Griffiths * Copyright 2000 Jon Griffiths
*/ */
#include "specmaker.h" #include "winedump.h"
/* Type for parsing mangled types */ /* Type for parsing mangled types */
typedef struct _compound_type typedef struct _compound_type
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 Jon Griffiths * Copyright 2000 Jon Griffiths
*/ */
#include "specmaker.h" #include "winedump.h"
/* Output files */ /* Output files */
static FILE *specfile = NULL; static FILE *specfile = NULL;
...@@ -33,7 +33,7 @@ void output_spec_preamble (void) ...@@ -33,7 +33,7 @@ void output_spec_preamble (void)
puts ("Creating .spec preamble"); puts ("Creating .spec preamble");
fprintf (specfile, fprintf (specfile,
"# Generated from %s.dll by specmaker\nname %s\n" "# Generated from %s.dll by winedump\nname %s\n"
"type win32\ninit %s_Init\n\nimport kernel32.dll\n" "type win32\ninit %s_Init\n\nimport kernel32.dll\n"
"import ntdll.dll\n", globals.input_name, OUTPUT_DLL_NAME, "import ntdll.dll\n", globals.input_name, OUTPUT_DLL_NAME,
OUTPUT_UC_DLL_NAME); OUTPUT_UC_DLL_NAME);
...@@ -133,7 +133,7 @@ void output_header_preamble (void) ...@@ -133,7 +133,7 @@ void output_header_preamble (void)
atexit (output_header_postamble); atexit (output_header_postamble);
fprintf (hfile, fprintf (hfile,
"/*\n * %s.dll\n *\n * Generated from %s.dll by specmaker.\n *\n" "/*\n * %s.dll\n *\n * Generated from %s.dll by winedump.\n *\n"
" * DO NOT SEND GENERATED DLLS FOR INCLUSION INTO WINE !\n * \n */" " * DO NOT SEND GENERATED DLLS FOR INCLUSION INTO WINE !\n * \n */"
"\n#ifndef __WINE_%s_DLL_H\n#define __WINE_%s_DLL_H\n\n#include " "\n#ifndef __WINE_%s_DLL_H\n#define __WINE_%s_DLL_H\n\n#include "
"\"config.h\"\n#include \"windef.h\"\n#include \"debugtools.h\"\n" "\"config.h\"\n#include \"windef.h\"\n#include \"debugtools.h\"\n"
...@@ -199,7 +199,7 @@ void output_c_preamble (void) ...@@ -199,7 +199,7 @@ void output_c_preamble (void)
atexit (output_c_postamble); atexit (output_c_postamble);
fprintf (cfile, fprintf (cfile,
"/*\n * %s.dll\n *\n * Generated from %s.dll by specmaker.\n *\n" "/*\n * %s.dll\n *\n * Generated from %s.dll by winedump.\n *\n"
" * DO NOT SUBMIT GENERATED DLLS FOR INCLUSION INTO WINE!\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", "\n\n#include \"%s_dll.h\"\n\nDEFAULT_DEBUG_CHANNEL(%s);\n\n",
OUTPUT_DLL_NAME, globals.input_name, OUTPUT_DLL_NAME, OUTPUT_DLL_NAME, globals.input_name, OUTPUT_DLL_NAME,
...@@ -419,7 +419,7 @@ void output_makefile (void) ...@@ -419,7 +419,7 @@ void output_makefile (void)
puts ("Creating makefile"); puts ("Creating makefile");
fprintf (makefile, fprintf (makefile,
"# Generated from %s.dll by specmaker.\nTOPSRCDIR = @top_srcdir@\n" "# Generated from %s.dll by winedump.\nTOPSRCDIR = @top_srcdir@\n"
"TOPOBJDIR = ../..\nSRCDIR = @srcdir@\nVPATH = @srcdir@\n" "TOPOBJDIR = ../..\nSRCDIR = @srcdir@\nVPATH = @srcdir@\n"
"MODULE = %s\nEXTRALIBS = $(LIBUNICODE)\n\n" "MODULE = %s\nEXTRALIBS = $(LIBUNICODE)\n\n"
"LDDLLFLAGS = @LDDLLFLAGS@\nSYMBOLFILE = $(MODULE).tmp.o\n\n" "LDDLLFLAGS = @LDDLLFLAGS@\nSYMBOLFILE = $(MODULE).tmp.o\n\n"
...@@ -447,7 +447,7 @@ void output_install_script (void) ...@@ -447,7 +447,7 @@ void output_install_script (void)
puts ("Creating install script"); puts ("Creating install script");
fprintf (install_file, fprintf (install_file,
"#!/bin/bash\n# Generated from %s.dll by specmaker.\n\n" "#!/bin/bash\n# Generated from %s.dll by winedump.\n\n"
"if [ $# -ne 1 ] || [ ! -d $1 ] || [ ! -f" "if [ $# -ne 1 ] || [ ! -d $1 ] || [ ! -f"
" $1/AUTHORS ]; then\n\t[ $# -eq 1 ] && echo \"Invalid path\"\n" " $1/AUTHORS ]; then\n\t[ $# -eq 1 ] && echo \"Invalid path\"\n"
"\techo \"Usage: $0 wine-base-dir\"\n\texit 1\nfi\n\n" "\techo \"Usage: $0 wine-base-dir\"\n\texit 1\nfi\n\n"
......
extern void dump_codeview(unsigned long ptr, unsigned long len);
extern void* PRD(unsigned long prd, unsigned long len);
extern unsigned long Offset(void* ptr);
extern char* get_time_str(DWORD _t);
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 Jon Griffiths * Copyright 2000 Jon Griffiths
*/ */
#include "specmaker.h" #include "winedump.h"
static char *grep_buff = NULL; static char *grep_buff = NULL;
static char *fgrep_buff = NULL; static char *fgrep_buff = NULL;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 Jon Griffiths * Copyright 2000 Jon Griffiths
*/ */
#include "specmaker.h" #include "winedump.h"
/* Items that are swapped in arguments after the symbol structure /* Items that are swapped in arguments after the symbol structure
......
/* /*
* Specmaker - A Wine DLL tool * Winedump - A Wine DLL tool
* *
* Copyright 2000 Jon Griffiths * Copyright 2000 Jon Griffiths
* *
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
* mistakes and some incorrect assumptions, but the lists of types * mistakes and some incorrect assumptions, but the lists of types
* are pure gold. * are pure gold.
*/ */
#ifndef __WINE_SPECMAKER_H #ifndef __WINE_WINEDUMP_H
#define __WINE_SPECMAKER_H #define __WINE_WINEDUMP_H
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
...@@ -58,6 +58,8 @@ ...@@ -58,6 +58,8 @@
#define SYM_THISCALL 0x4 #define SYM_THISCALL 0x4
#define SYM_DATA 0x8 /* Data, not a function */ #define SYM_DATA 0x8 /* Data, not a function */
typedef enum {NONE, DMGL, SPEC, DUMP} Mode;
/* Structure holding a parsed symbol */ /* Structure holding a parsed symbol */
typedef struct __parsed_symbol typedef struct __parsed_symbol
{ {
...@@ -78,23 +80,37 @@ typedef struct __parsed_symbol ...@@ -78,23 +80,37 @@ typedef struct __parsed_symbol
/* All globals */ /* All globals */
typedef struct __globals typedef struct __globals
{ {
/* Options */ Mode mode; /* SPEC, DEMANGLE or DUMP */
/* Options: generic */
int do_quiet; /* -q */
int do_verbose; /* -v */
/* Option arguments: generic */
const char *input_name; /* */
/* Options: spec mode */
int do_code; /* -c, -t, -f */ int do_code; /* -c, -t, -f */
int do_trace; /* -t, -f */ int do_trace; /* -t, -f */
int do_cdecl; /* -C */ int do_cdecl; /* -C */
int do_quiet; /* -q */
int do_verbose; /* -v */
int do_documentation; /* -D */ int do_documentation; /* -D */
int do_demangle; /* -S */
/* Option arguments */ /* Options: dump mode */
int do_demangle; /* -d */
int do_dumpheader; /* -f */
/* Option arguments: spec mode */
int start_ordinal; /* -s */ int start_ordinal; /* -s */
int end_ordinal; /* -e */ int end_ordinal; /* -e */
const char *directory; /* -I */ const char *directory; /* -I */
const char *input_name; /* -d */
const char *forward_dll; /* -f */ const char *forward_dll; /* -f */
const char *dll_name; /* -o */ const char *dll_name; /* -o */
char *uc_dll_name; /* -o */ char *uc_dll_name; /* -o */
/* Option arguments: dump mode */
const char *dumpsect; /* -j */
/* internal options */
int do_ordinals; int do_ordinals;
} _globals; } _globals;
...@@ -113,6 +129,8 @@ extern _globals globals; ...@@ -113,6 +129,8 @@ extern _globals globals;
/* Default calling convention */ /* Default calling convention */
#define CALLING_CONVENTION (globals.do_cdecl ? SYM_CDECL : SYM_STDCALL) #define CALLING_CONVENTION (globals.do_cdecl ? SYM_CDECL : SYM_STDCALL)
/* Image functions */
void dump_file(const char* name);
/* DLL functions */ /* DLL functions */
void dll_open (const char *dll_name); void dll_open (const char *dll_name);
...@@ -174,11 +192,12 @@ FILE *open_file (const char *name, const char *ext, const char *mode); ...@@ -174,11 +192,12 @@ FILE *open_file (const char *name, const char *ext, const char *mode);
#ifdef __GNUC__ #ifdef __GNUC__
void do_usage (void) __attribute__ ((noreturn)); void do_usage (void) __attribute__ ((noreturn));
void fatal (const char *message) __attribute__ ((noreturn));
#else #else
void do_usage (void); void do_usage (void);
void fatal (const char *message);
#endif #endif
void fatal (const char *message);
#endif /* __WINE_SPECMAKER_H */ #endif /* __WINE_WINEDUMP_H */
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