diff --git a/tools/winedump/dump.c b/tools/winedump/dump.c index 0aeb47468ac..f8b149d2e8a 100644 --- a/tools/winedump/dump.c +++ b/tools/winedump/dump.c @@ -159,6 +159,7 @@ dumpers[] = {SIG_COFFLIB, get_kind_lib, lib_dump}, {SIG_MDMP, get_kind_mdmp, mdmp_dump}, {SIG_LNK, get_kind_lnk, lnk_dump}, + {SIG_EMF, get_kind_emf, emf_dump}, {SIG_UNKNOWN, NULL, NULL} /* sentinel */ }; diff --git a/tools/winedump/emf.c b/tools/winedump/emf.c index df92e1d3ab9..f5375d03df3 100644 --- a/tools/winedump/emf.c +++ b/tools/winedump/emf.c @@ -36,7 +36,7 @@ #include "winbase.h" #include "wingdi.h" -static unsigned int read_int(unsigned char *buffer) +static unsigned int read_int(const unsigned char *buffer) { return buffer[0] + (buffer[1]<<8) @@ -46,18 +46,18 @@ static unsigned int read_int(unsigned char *buffer) #define EMRCASE(x) case x: printf("%-20s %08x\n", #x, length); break -static int dump_emfrecord(int fd) +static unsigned offset = 0; + +static int dump_emfrecord(void) { - unsigned char buffer[8]; - int r; + const unsigned char* ptr; unsigned int type, length, i; - r = read(fd, buffer, 8); - if(r!=8) - return -1; + ptr = PRD(offset, 8); + if (!ptr) return -1; - type = read_int(buffer); - length = read_int(buffer+4); + type = read_int(ptr); + length = read_int(ptr + 4); switch(type) { @@ -96,36 +96,34 @@ static int dump_emfrecord(int fd) length -= 8; + offset += 8; + for(i=0; iiType == EMR_HEADER && hdr->dSignature == ENHMETA_SIGNATURE) + return SIG_EMF; + return SIG_UNKNOWN; } -int dump_emf(const char *emf) +void emf_dump(void) { - int fd; - - fd = open(emf,O_RDONLY); - if (fd<0) return -1; - dump_emf_records(fd); - close(fd); - return 0; + offset = 0; + while (!dump_emfrecord()); } diff --git a/tools/winedump/main.c b/tools/winedump/main.c index 22c321051b0..193fb745535 100644 --- a/tools/winedump/main.c +++ b/tools/winedump/main.c @@ -80,13 +80,6 @@ static void do_dump (const char *arg) } -static void do_dumpemf(void) -{ - if (globals.mode != NONE) fatal("Only one mode can be specified\n"); - globals.mode = EMF; -} - - static void do_code (void) { globals.do_code = 1; @@ -223,20 +216,19 @@ static const struct my_option option_table[] = { {"-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 contents of the file (dll, exe, lib...)"}, + {"dump", DUMP, 0, do_dump, "dump Dumps the contents of a file (dll, exe, lib...)"}, {"-C", DUMP, 0, do_symdmngl, "-C Turns on symbol demangling"}, {"-f", DUMP, 0, do_dumphead, "-f Dumps file header information"}, {"-G", DUMP, 0, do_rawdebug, "-G Dumps raw debug information"}, {"-j", DUMP, 1, do_dumpsect, "-j sect_name Dumps only the content of section sect_name (import, export, debug, resource, tls)"}, {"-x", DUMP, 0, do_dumpall, "-x Dumps everything"}, - {"emf", EMF, 0, do_dumpemf, "emf Dumps an Enhanced Meta File"}, {NULL, NONE, 0, NULL, NULL} }; void do_usage (void) { const struct my_option *opt; - printf ("Usage: winedump [-h | sym | spec | dump | emf ]\n"); + printf ("Usage: winedump [-h | sym | spec | dump ]\n"); printf ("Mode options (can be put as the mode (sym/spec/dump...) is declared):\n"); printf ("\tWhen used in --help mode\n"); for (opt = option_table; opt->name; opt++) @@ -254,10 +246,6 @@ void do_usage (void) for (opt = option_table; opt->name; opt++) if (opt->mode == DUMP) printf ("\t %s\n", opt->usage); - printf ("\tWhen used in emf mode\n"); - for (opt = option_table; opt->name; opt++) - if (opt->mode == EMF) - printf ("\t %s\n", opt->usage); puts (""); exit (1); @@ -489,11 +477,6 @@ int main (int argc, char *argv[]) set_module_name(0); dump_file(globals.input_name); break; - case EMF: - if (globals.input_name == NULL) - fatal("No file name has been given\n"); - dump_emf(globals.input_name); - break; } return 0; diff --git a/tools/winedump/winedump.h b/tools/winedump/winedump.h index 37d905633d5..4c97fd06d5c 100644 --- a/tools/winedump/winedump.h +++ b/tools/winedump/winedump.h @@ -72,7 +72,7 @@ #define SYM_THISCALL 0x4 #define SYM_DATA 0x8 /* Data, not a function */ -typedef enum {NONE, DMGL, SPEC, DUMP, EMF} Mode; +typedef enum {NONE, DMGL, SPEC, DUMP} Mode; /* Structure holding a parsed symbol */ typedef struct __parsed_symbol @@ -156,9 +156,6 @@ extern _globals globals; /* Default calling convention */ #define CALLING_CONVENTION (globals.do_cdecl ? SYM_CDECL : SYM_STDCALL) -/* EMF functions */ -int dump_emf (const char *emf); - /* Image functions */ void dump_file(const char* name); @@ -221,7 +218,7 @@ char *str_toupper (char *str); const char *get_machine_str(int mach); /* file dumping functions */ -enum FileSig {SIG_UNKNOWN, SIG_DOS, SIG_PE, SIG_DBG, SIG_NE, SIG_LE, SIG_MDMP, SIG_COFFLIB, SIG_LNK}; +enum FileSig {SIG_UNKNOWN, SIG_DOS, SIG_PE, SIG_DBG, SIG_NE, SIG_LE, SIG_MDMP, SIG_COFFLIB, SIG_LNK, SIG_EMF}; const void* PRD(unsigned long prd, unsigned long len); unsigned long Offset(const void* ptr); @@ -246,6 +243,9 @@ enum FileSig get_kind_dbg(void); void dbg_dump( void ); enum FileSig get_kind_lnk(void); void lnk_dump( void ); +enum FileSig get_kind_emf(void); +void emf_dump( void ); + void dump_stabs(const void* pv_stabs, unsigned szstabs, const char* stabstr, unsigned szstr); void dump_codeview(unsigned long ptr, unsigned long len);