I'm trying to improve SymbolSort library, which reads PDB files with DIA SDK. I need to match the symbols read from object files with the symbols read from PDB.
The question is: given an IDiaSymbol
variable, how can I obtain its real name? I'm not interesting in the undecorated or human-readable name, I need the mangled name, exactly as it appears in the object file, exactly as linker sees it.
The undecorated name can be easily obtained via IDiaSymbol::get_undecoratedName
(ref). For decorated name, I use the following code:
string rawName;
IDiaSymbolUndecoratedNameExFlags flags = Flags.UNDNAME_32_BIT_DECODE | Flags.UNDNAME_TYPE_ONLY;
diaSymbol.get_undecoratedNameEx((uint)flags, out rawName);
It was found empirically that this hack seems to work well in most cases (for no reason). But sometimes it gives some trash as result, e.g.:
diaSymbol.undecoratedName:
"private: bool __cdecl idPhysics_Player::SlideMove(bool,bool,bool,bool) __ptr64"
rawSymbol:
" ?? :: ?? ::Z::_N_N000 & __ptr64 volatile "