Skip to content

Toy project to demangle the symbol names generated by VC.

Notifications You must be signed in to change notification settings

fefe982/DeMangleVC

Repository files navigation

DeMangleVC Project

Toy project to demangle the symbol names generated by VC.

This is a project I started years ago, as toy to know something about both C# and C++. It main purpose is to get the undecorated names from the mangled symbol names generated by VC.

I started the project before I even know about UndecorateSymbolName in dbghelp.dll. But after I know it, I believes this project can do better than UndecoratedSymbolName.

You can refer to the REFINE__ macro in the code. Without it, the project tries to generate exact the same output as UndecorateSymbolName; with REFINE__, the project will do some of its own refinement.

One example would be, in UndecorateSymbolName, there is no blank between operater?? and the following template parameter list. So you can see things like operator<<int>(...) in the output. The project with refine will insert a blank: operator< <int>(...).

Also, there are a lot of symbols that UndecorateSymbolName cannot handle.

I noticed sometimes UndecoratedSymbolName can generator wrong result. For example with type ?pointer__v_p_c__c@@3RBDB(char const * volatile pointer__v_p_c__c), it outputs char const * const pointer__v_p_c__c. Another example is the compiler generated symbol ?$S1@?1??dynamic_init_dtor@@YAXXZ@4IA, which should be unsigned int `void __cdecl dynamic_init_dtor(void)'::`2'::$S1, but it generates S1<`template-parameter-2',ynamic_init_dtor,unsigned int, ?? &>. Currently the code without REFINE__ is not mantained. These code may be removed in the future. (Maybe I need to get a higher version of dbghelp.dll.)

The results from UndecoratedSymbolName is still used as reference, and the project use it to demangle the names is still included in this project.

The project now works with VS2019. You can get a community version for free.

Feedback is welcome!! You can provide me with any symbol that cannot be handled by this program. It will be very helpful if you can also provide the (partial) undecorated version (in case UndecorateSymbolName cannot handle it either), or the program that can generate such a symbol.

Introduction to the sub-projects

DeMangleVC

Main project. Written in C# Accepts file with decorated symbols, and output the undecorated ones.

The input file contains one symbol per line. Only the symbol before the first blank will be handled, anything else would be deleted. So you can put whatever you like after the symbol, like comments.

UnDecorateSymbolName

Simple project that uses UndecorateSymolName to do the job. You must obtain your own version of dbghelp.

GetAsmName

Get decorated symbol names from VS generated ASM files. It will aslo retrieve the 'partial' undecorated version in the comments if they exist, and put it in the output for reference.

GenNames

This is a project I used to generated various symbols.

This project is not expected to pass link or do anything useful. It will just output an ASM for the input cpp files, possibly with bunch of symbols. You can try to see how symbols are decorated.

It now include cpp files that would let the compiler generate various kind of special symbol. The compiler used in Visual Studio 2019 Community. Different versions of compiler may generate different result.

About

Toy project to demangle the symbol names generated by VC.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published