VC++ demangling tool

Michael Stefaniuc mstefani at redhat.de
Mon Feb 6 18:20:00 CST 2006


Hello!

winedump has a VC++ symbol demangling function but that is bitrotting as
it is a copy of the msvcrt.__unDname . As i wanted to use the newer
msvcrt.__unDname funtion i have written a quick and dirty program that
is basicaly only a wrapper around UnDecorateSymbolName(). Most importand
feature is that it runs on the command line.
I'm not expecting it to go into Wine but others might find it usefull.
After applying the patch configure needs to be regenerated.

bye
	michael
-- 
Michael Stefaniuc               Tel.: +49-711-96437-199
Sr. Network Engineer            Fax.: +49-711-96437-111
Red Hat GmbH                    Email: mstefani at redhat.com
Hauptstaetterstr. 58            http://www.redhat.de/
D-70178 Stuttgart
-------------- next part --------------
Add small tool demangle that uses UnDecorateSymbolName() to undecorate
a VC++ symbol.

---

 configure.ac                  |    1 +
 programs/Makefile.in          |    7 ++++++
 programs/demangle/.gitignore  |    2 ++
 programs/demangle/Makefile.in |   13 +++++++++++
 programs/demangle/demangle.c  |   49 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 programs/demangle/.gitignore
 create mode 100644 programs/demangle/Makefile.in
 create mode 100644 programs/demangle/demangle.c

811257bfb405e3a50616c6e5757168eaaacf32ce
diff --git a/configure.ac b/configure.ac
index 17caf2f..e47cce2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1742,6 +1742,7 @@ programs/avitools/Makefile
 programs/clock/Makefile
 programs/cmdlgtst/Makefile
 programs/control/Makefile
+programs/demangle/Makefile
 programs/eject/Makefile
 programs/expand/Makefile
 programs/explorer/Makefile
diff --git a/programs/Makefile.in b/programs/Makefile.in
index a02a1ef..cead883 100644
--- a/programs/Makefile.in
+++ b/programs/Makefile.in
@@ -10,6 +10,7 @@ SUBDIRS = \
 	clock \
 	cmdlgtst \
 	control \
+	demangle \
 	eject \
 	expand \
 	explorer \
@@ -45,6 +46,7 @@ INSTALLSUBDIRS = \
 	avitools \
 	clock \
 	control \
+	demangle \
 	eject \
 	expand \
 	explorer \
@@ -100,6 +102,7 @@ SYMLINKS = \
 	clock.exe$(DLLEXT) \
 	cmdlgtst.exe$(DLLEXT) \
 	control.exe$(DLLEXT) \
+	demangle.exe$(DLLEXT) \
 	eject.exe$(DLLEXT) \
 	expand.exe$(DLLEXT) \
 	explorer.exe$(DLLEXT) \
@@ -189,6 +192,9 @@ cmdlgtst.exe$(DLLEXT): cmdlgtst/cmdlgtst
 control.exe$(DLLEXT): control/control.exe$(DLLEXT)
 	$(RM) $@ && $(LN_S) control/control.exe$(DLLEXT) $@
 
+demangle.exe$(DLLEXT): demangle/demangle.exe$(DLLEXT)
+	$(RM) $@ && $(LN_S) demangle/demangle.exe$(DLLEXT) $@
+
 eject.exe$(DLLEXT): eject/eject.exe$(DLLEXT)
 	$(RM) $@ && $(LN_S) eject/eject.exe$(DLLEXT) $@
 
@@ -284,6 +290,7 @@ avitools/aviplay.exe$(DLLEXT): avitools
 clock/clock.exe$(DLLEXT): clock
 cmdlgtst/cmdlgtst.exe$(DLLEXT): cmdlgtst
 control/control.exe$(DLLEXT): control
+demangle/demangle.exe$(DLLEXT): demangle
 eject/eject.exe$(DLLEXT): eject
 expand/expand.exe$(DLLEXT): expand
 explorer/explorer.exe$(DLLEXT): explorer
diff --git a/programs/demangle/.gitignore b/programs/demangle/.gitignore
new file mode 100644
index 0000000..e66578d
--- /dev/null
+++ b/programs/demangle/.gitignore
@@ -0,0 +1,2 @@
+Makefile
+demangle
diff --git a/programs/demangle/Makefile.in b/programs/demangle/Makefile.in
new file mode 100644
index 0000000..a9a32c7
--- /dev/null
+++ b/programs/demangle/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = demangle.exe
+APPMODE   = -mconsole
+IMPORTS   = dbghelp kernel32
+
+C_SRCS = demangle.c
+
+ at MAKE_PROG_RULES@
+
+### Dependencies:
diff --git a/programs/demangle/demangle.c b/programs/demangle/demangle.c
new file mode 100644
index 0000000..a0947d6
--- /dev/null
+++ b/programs/demangle/demangle.c
@@ -0,0 +1,49 @@
+/*
+ * Demangle VC++ symbols
+ *
+ * Copyright 2006 Michael Stefaniuc
+ *
+ * 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
+ */
+
+#define WIN32_LEAN_AND_MEAN
+
+#include <windows.h>
+#include <dbghelp.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+int main(int argc, char *argv[])
+{
+    int i;
+    DWORD ret;
+    CHAR buf[1024];
+    
+    if (argc < 2) {
+        fputs("Usage: demangle.exe symbol ...\n", stderr);
+        exit (1);
+    }
+
+    for (i = 1; i < argc; i++) {
+        ret = UnDecorateSymbolName(argv[i], buf, sizeof(buf), UNDNAME_COMPLETE);
+        if (ret)
+            puts(buf);
+        else
+            printf("Failed to demangle %s. Error code %ld\n", argv[i], ret);
+    }
+
+    exit (0);
+}
-- 
1.1.4


More information about the wine-patches mailing list