zed.0xff.me

demangle MSVC, Delphi & C++Builder mangled function names with pure Ruby

Ever wanted to convert @afunc$qxzcupi or ??3@YAXPAX@Z to something more human-readable?

(ofcourse you wanted, and you know about tdump.exe and undname.exe :)

And now you can do it using pure ruby, thanks to unmangler gem:

Unmangling Borland mangled names

1
2
3
4
5
6
7
8
require 'unmangler'

puts Unmangler.unmangle "@afunc$qxzcupi"
puts Unmangler.unmangle "@Forms@TApplication@SetTitle$qqrx17System@AnsiString"

# output:
# afunc(const signed char, int *)
# __fastcall Forms::TApplication::SetTitle(const System::AnsiString)

Unmangling MSVC mangled names

1
2
3
4
5
6
7
8
require 'unmangler'

puts Unmangler.unmangle "??3@YAXPAX@Z"
puts Unmangler.unmangle "?AFXSetTopLevelFrame@@YAXPAVCFrameWnd@@@Z"

# output:
# void __cdecl operator delete(void *)
# void __cdecl AFXSetTopLevelFrame(class CFrameWnd *)

And now w/o arguments

1
2
3
4
5
6
7
8
9
require 'unmangler'

puts Unmangler.unmangle "@Forms@TApplication@SetTitle$qqrx17System@AnsiString", :args => false

# outputs "Forms::TApplication::SetTitle"

puts Unmangler.unmangle "?AFXSetTopLevelFrame@@YAXPAVCFrameWnd@@@Z", :args => false

# outputs "AFXSetTopLevelFrame"

Links

  1. unmangler gem on rubygems.org
  2. unmangler sources on github.com

TBD: GCC support