avast / retdec

RetDec is a retargetable machine-code decompiler based on LLVM.
https://retdec.com/
MIT License
8k stars 946 forks source link

MSVC symbol demangler fails to demangle most templated names #400

Open palant opened 6 years ago

palant commented 6 years ago

The way I read https://github.com/avast-tl/retdec/blob/7cad5076c06bbe99f410c98a9af8f08d73eb3175/src/demangler/extgrammars/gramatika-ms, the demangler will only expect template arguments in names starting with ??. This doesn't match the description on https://en.wikiversity.org/wiki/Visual_C%2B%2B_name_mangling and won't demangle names like ?xyz@?$abc@V?$def@H@@PAX@@ which the undname command line tool demangles just fine.

s3rvac commented 6 years ago

Thank you for the report. We lead a student who has been working on a completely new version of the demangler as his bachelor's thesis (milestone). This new version will hopefully have a better support for templates.

palant commented 6 years ago

Sounds good, I'll watch the progress. The DLL I am analyzing also contains mangled names like ".?Foo?$Bar@UStruct1@abc@@U12@@abc@@" (note: no @ after Foo). While these have definitely been created by MSVC, they don't make sense if you look at https://en.wikiversity.org/wiki/Visual_C%2B%2B_name_mangling and undname doesn't recognize them either.

PeterMatula commented 5 years ago

These examples does not get demangled even with the new demangler #95. But the new demangler uses LLVM demangler, so if the support is added there, we should get it too.