Updated 2015-03-16 07:02:22 by pooryorick

EB: In need of demangling a C++ symbol under windows, and failed to googled such tool, I have successfully ffidled UnDecorateSymbolName() function.

The signature of this function, found in imagehlp.dll, is:
DWORD UnDecorateSymbolName(
  IN  LPSTR DecoratedName,
  OUT LPSTR UnDecoratedName,
  IN  DWORD UndecoratedLength,
  IN  DWORD Flags

The function take a string buffer for the undecorated name in output. I don't know if this is the good way to do this. I reserve a string of 1024 chars for it.
load ffidl05.dll

ffidl::callout \
    dll_UnDecorateSymbolName {pointer-utf8 pointer-utf8 int int} int \
    [ffidl::symbol "imagehlp.dll" UnDecorateSymbolName]

proc demangle {symbol} {
    set ret [string repeat { } 1024]
    dll_UnDecorateSymbolName $symbol $ret 1024 0
    set ret