Demangler : problems with templates and others (VS17)
- Dominant language
- C++
- Stars
- 8.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Dear RetDec #enthusiasts,
The name mangling listed for the reconstructed classes (C++ class reconstruction, in the "classes" comment section of the C file output by detrec-decompiler.sh) does not correspond to any of the 3 name mangling schemes.
The demangler-tool provided with RetDec is not able to identified the name mangling to any of the available 3.
My experiment is on a DLL, with classes apparently correctly exported (if vftable creation is triggered ...), in debug (dllexp seems to be able to read correctly the method names).
It can be reproduced with the classes from the files MereFille.h and DllTest_for_retdec.cpp (yes, names do not match), see ZIP file attached.
The setup is Microsoft Visual Community 2017, with a project "Visual C++ / Windows Desktop / Dynamic Link Library (DLL)" with name "DllTest_for_retdec".
To compile, it has to be added the preprocessor setting, by right click on the project, going to "Properties", "C/C++" → "Preprocessor" :
"Prepocessor definitions" : add "COMPILINGDLL=1;" at the beginning
The so-produced DLL is then fed to RetDec for decompilation (no option, or aggressive option).
This results in a class identification with the following names :
// ------------------------- Classes --------------------------
// .?AV?$OutOfBlob@W4penum@@@@
// Blobinou
// Blobinounours (base classes: Blobinou, .?AV?$OutOfBlob@W4penum@@@@)
// Fille (base classes: Mere, Pere)
// Mere
// MonoFille (base classes: MonoMere)
// MonoMere
// Pere
// .?AVbad_alloc@std@@ (base classes: .?AVexception@std@@)
// .?AVbad_array_new_length@std@@ (base classes: .?AVexception@std@@, .?AVbad_alloc@std@@)
// .?AVexception@std@@
// type_info
It seems to me there is a problem with name demangling of template classes, and exceptions (or their namespace ?).
Best regards,
Thierry
[DllTest_for_retdec.zip](https://github.com/avast-tl/retdec/files/1814490/DllTest_for_retdec.zip)
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the report using the attached DllTest_for_retdec.zip, specifically MereFille.h and DllTest_for_retdec.cpp, compiled as the described Visual C++ Windows DLL. Run the resulting DLL through demangler-tool and retdec-decompiler.sh, then inspect the reconstructed classes section. Done means template and exception names are identified using the supported mangling schemes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- reverse-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100