TOOLS: extend winedump to allow dumping enhanced meta files
Mike McCormack
mike at codeweavers.com
Mon Jan 3 11:30:36 CST 2005
ChangeLog:
* extend winedump to allow dumping enhanced meta files
-------------- next part --------------
? tools/winedump/emf.c
Index: tools/winedump/Makefile.in
===================================================================
RCS file: /home/wine/wine/tools/winedump/Makefile.in,v
retrieving revision 1.10
diff -u -r1.10 Makefile.in
--- tools/winedump/Makefile.in 3 Jan 2005 14:48:49 -0000 1.10
+++ tools/winedump/Makefile.in 3 Jan 2005 17:28:53 -0000
@@ -10,6 +10,7 @@
C_SRCS = \
debug.c \
+ emf.c \
le.c \
main.c \
misc.c \
Index: tools/winedump/main.c
===================================================================
RCS file: /home/wine/wine/tools/winedump/main.c,v
retrieving revision 1.16
diff -u -r1.16 main.c
--- tools/winedump/main.c 20 Dec 2004 16:52:26 -0000 1.16
+++ tools/winedump/main.c 3 Jan 2005 17:28:54 -0000
@@ -79,6 +79,13 @@
}
+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;
@@ -213,6 +220,7 @@
{"-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, 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}
};
@@ -237,6 +245,10 @@
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 ("\n");
exit (1);
@@ -469,6 +481,11 @@
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;
Index: tools/winedump/winedump.h
===================================================================
RCS file: /home/wine/wine/tools/winedump/winedump.h,v
retrieving revision 1.10
diff -u -r1.10 winedump.h
--- tools/winedump/winedump.h 20 Dec 2004 16:52:26 -0000 1.10
+++ tools/winedump/winedump.h 3 Jan 2005 17:28:54 -0000
@@ -72,7 +72,7 @@
#define SYM_THISCALL 0x4
#define SYM_DATA 0x8 /* Data, not a function */
-typedef enum {NONE, DMGL, SPEC, DUMP} Mode;
+typedef enum {NONE, DMGL, SPEC, DUMP, EMF} Mode;
/* Structure holding a parsed symbol */
typedef struct __parsed_symbol
@@ -152,6 +152,9 @@
/* 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);
--- /dev/null 2004-12-26 03:00:47.000000000 +0900
+++ tools/winedump/emf.c 2005-01-04 02:28:40.000000000 +0900
@@ -0,0 +1,124 @@
+/*
+ * Dump and Enhanced Meta File
+ *
+ * Copyright 2005 Mike McCormack
+ *
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+
+static unsigned int read_int(unsigned char *buffer)
+{
+ return buffer[0]
+ + (buffer[1]<<8)
+ + (buffer[2]<<16)
+ + (buffer[3]<<24);
+}
+
+#define EMRCASE(x) case x: printf("%-20s %08x\n", #x, length); break
+
+static int dump_emfrecord(int fd)
+{
+ unsigned char buffer[8];
+ int r,i;
+ unsigned int type, length;
+
+ r = read(fd, buffer, 8);
+ if(r!=8)
+ return -1;
+
+ type = read_int(buffer);
+ length = read_int(buffer+4);
+
+ switch(type)
+ {
+ EMRCASE(EMR_HEADER);
+ EMRCASE(EMR_POLYGON);
+ EMRCASE(EMR_POLYLINE);
+ EMRCASE(EMR_SETWINDOWEXTEX);
+ EMRCASE(EMR_SETWINDOWORGEX);
+ EMRCASE(EMR_SETVIEWPORTEXTEX);
+ EMRCASE(EMR_EOF);
+ EMRCASE(EMR_SETMAPMODE);
+ EMRCASE(EMR_SETPOLYFILLMODE);
+ EMRCASE(EMR_SETROP2);
+ EMRCASE(EMR_SCALEWINDOWEXTEX);
+ EMRCASE(EMR_SAVEDC);
+ EMRCASE(EMR_SELECTOBJECT);
+ EMRCASE(EMR_CREATEPEN);
+ EMRCASE(EMR_CREATEBRUSHINDIRECT);
+ EMRCASE(EMR_DELETEOBJECT);
+ EMRCASE(EMR_RECTANGLE);
+ EMRCASE(EMR_SELECTPALETTE);
+ EMRCASE(EMR_GDICOMMENT);
+ EMRCASE(EMR_EXTSELECTCLIPRGN);
+ EMRCASE(EMR_EXTCREATEFONTINDIRECTW);
+ EMRCASE(EMR_EXTTEXTOUTW);
+ EMRCASE(EMR_POLYGON16);
+ EMRCASE(EMR_POLYLINE16);
+
+ default:
+ printf("%08x %08x\n",type,length);
+ break;
+ }
+
+ if ( (length < 8) || (length % 4) )
+ return -1;
+
+ length -= 8;
+
+ for(i=0; i<length; i+=4)
+ {
+ if (i%16 == 0)
+ printf(" ");
+ memset(buffer,0,sizeof buffer);
+ r = read(fd,buffer,4);
+ if(r!=4)
+ return -1;
+ printf("%08x ", read_int(buffer));
+ if ( (i%16 == 12) || ((i+4)==length) )
+ printf("\n");
+ }
+
+ return 0;
+}
+
+static int dump_emf_records(int fd)
+{
+ while(!dump_emfrecord(fd))
+ ;
+ return 0;
+}
+
+int dump_emf(const char *emf)
+{
+ int fd;
+
+ fd = open(emf,O_RDONLY);
+ if (fd<0) return -1;
+ dump_emf_records(fd);
+ close(fd);
+ return 0;
+}
More information about the wine-patches
mailing list